From patchwork Tue Apr 2 07:33:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nick Desaulniers X-Patchwork-Id: 161622 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp1413983jan; Tue, 2 Apr 2019 00:33:32 -0700 (PDT) X-Google-Smtp-Source: APXvYqx+6DCX53+N/HhmgQzX2PwQVYZqJWQr2DPT3MZrQCI3GNKODdwBBXued9IRW0BdEkXBug9+ X-Received: by 2002:aa7:938b:: with SMTP id t11mr59770182pfe.67.1554190412279; Tue, 02 Apr 2019 00:33:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554190412; cv=none; d=google.com; s=arc-20160816; b=FiwkAGkKBclRnqBwhPQrlDLghnhZSwOFNrAi8LI4ZdisaaHnHkQeQLWBbjXPAW+lXF 8T2kAovzOjT9oov8rXHeX/6DSFkeAFDse9+CZVimZZgjmC+lbzpXYkevhRwnSWI+U3WD kWFdzbaDCyHI8PakCHxr8aoJiWpGGl6MiOWmO7MsrQOPXZRGQSDSo1ra++hQ/burtGyF wGh2cQwa22tCWrh25rlJJv5eWYfvTTPghcZvsZzbmqBopIUtK0GYoZEDEiXf/JVzByQR ZFHOeoDBSgsgSdDTyNX4pipkX+1Vrz4jtdpKb1y1P7Gqe91NNBD2Ji8HMLDW68zLjgo1 sg4g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:from:subject:references :mime-version:message-id:in-reply-to:date:dkim-signature; bh=q6AEs42Yptqy+iLpgSDIlp7Uvrf/sOqm7YVBDoal0w8=; b=lgU4pEaYZPh0rRmqwAYNNLoa+1kisKVLOShXq8SFCDzBTQecEw8D4AGemVlFqrdEC6 OyRUFNpFsrvj7bXX9A8kPv/sy/SAM6R4LrMx9DXYAKClHPY0BWqC7k7r9B5YP2SdGB2J 58TRVeJc+CqeiGEGw3XLjwGKOLydiuGN69K6/3AuEUm6VzBDQ+U/90jAeP2EBuPW/EKJ E3vvnSpgRL9Ptkj08efXwIVB3IXCZlDLEbvrJ4uAyNSe3aHveAI+OtLO5W2F/Lhf3UyK Om0MI+spIzqVN+zcWMIxNDkdjGjLSCZWgTZC1hz8SE7wyrc1Tj9YNS2WJt2QJkMAEQlk tAwg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=OVk42bkF; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k72si10785177pgc.362.2019.04.02.00.33.32; Tue, 02 Apr 2019 00:33:32 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=OVk42bkF; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729174AbfDBHd0 (ORCPT + 31 others); Tue, 2 Apr 2019 03:33:26 -0400 Received: from mail-io1-f73.google.com ([209.85.166.73]:42247 "EHLO mail-io1-f73.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728968AbfDBHd0 (ORCPT ); Tue, 2 Apr 2019 03:33:26 -0400 Received: by mail-io1-f73.google.com with SMTP id i1so10274519ioq.9 for ; Tue, 02 Apr 2019 00:33:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=q6AEs42Yptqy+iLpgSDIlp7Uvrf/sOqm7YVBDoal0w8=; b=OVk42bkFWAzTse1R7qCna/cXD/YEW+pcJNSgHWLAbCuvXR5ruo+sAq2OxXNqIOpwiD Ya2gQ+b6TTqPBnAfuWXSYFFePyVNION9J0/1yLUqRs49n2mPD3jKa/3HlPWzYjRvveeD 5JuYZdLFNOoLeKhRvAy84oYIheVHHsF+mwXl3/ek4IcYM9mp1i2EbhEOQt5hnBXePQAu r1oxPVrlVPk3eFTyBGlwcCcLqBkI6MKAuPQOF3lPfeL1/Z5tbZzOA9iqDgKQHYm96+Uv 5WVT/P37j1F/4nfuTJeON1/fR7KylQ1rdSvOx30ageVIaZL/Ts1tv5OOL7Lw1H20ZTMq QcdA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=q6AEs42Yptqy+iLpgSDIlp7Uvrf/sOqm7YVBDoal0w8=; b=nr9dpu3aLqEMu1vjSsHyxM2VRhEMz9L1q+OTbFve36ayiTXTJvH2SRS9EtfVNEgNTe XfmqOhX7ussSpcEj/8Nkh00xhpxQPvSjZFDJotirc2XQ/XH+9gsE537+xdzQoLMhaJ29 8RlirInOC2j3pCGa2ffphEa7KlkWOy+amdJKmAqbevRpAdxlx3guMwDOsz9c9i/Vj6zg 5g/mDVXKgPBoIeQsf7ocpi5YBle6pOlqWfLJIjLt7Aw7Sj9QzYM0UIcoCJuUNFOoQr/t fUWX59QIcon39yeugbTx/40uM6/DKb7stc2zfbL0plLH6I7m0lxmP8qLKZW7KMFuT89F 7pRg== X-Gm-Message-State: APjAAAWRmzkZoOQjSoTeboFXMhvRVphCaU2w85ls/uh6A8cenC5KWn/M iN/0QnVzpHfSytIypqWOmDKhLdcG/PYBuUZlxBI= X-Received: by 2002:a05:660c:a45:: with SMTP id j5mr7272933itl.20.1554190405733; Tue, 02 Apr 2019 00:33:25 -0700 (PDT) Date: Tue, 2 Apr 2019 00:33:17 -0700 In-Reply-To: <20190402072726.GA16650@archlinux-ryzen> Message-Id: <20190402073317.56529-1-ndesaulniers@google.com> Mime-Version: 1.0 References: <20190402072726.GA16650@archlinux-ryzen> X-Mailer: git-send-email 2.21.0.392.gf8f6787159e-goog Subject: [PATCH v4] Makefile: lld: tell clang to use lld From: Nick Desaulniers To: yamada.masahiro@socionext.com Cc: keescook@chromium.org, clang-built-linux@googlegroups.com, Nick Desaulniers , Nathan Chancellor , Michal Marek , linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This is needed because clang doesn't select which linker to use based on $LD but rather -fuse-ld={bfd,gold,lld,}. This is problematic especially for cc-ldoption, which checks for linker flag support via invoking the compiler, rather than the linker. Select the linker via absolute path from $PATH via `which`. This allows you to build with: $ make LD=ld.lld $ make LD=ld.lld-8 $ make LD=/path/to/ld.lld Add -Qunused-arguments to KBUILD_CPPFLAGS sooner, as otherwise Clang likes to complain about -fuse-lld= being unused when compiling but not linking (-c) such as when cc-option is used. There's no need to guard with cc-option. Link: https://github.com/ClangBuiltLinux/linux/issues/342 Link: https://github.com/ClangBuiltLinux/linux/issues/366 Link: https://github.com/ClangBuiltLinux/linux/issues/357 Suggested-by: Nathan Chancellor Suggested-by: Masahiro Yamada Signed-off-by: Nick Desaulniers --- Changes V3->V4: * Unconditionally add -Qunused-arguments sooners, as per Nathan. * Slight modification to commit message for that point. Changes V2->V3: * Use absolute path based on `which $LD` as per Masahiro. * Add -Qunused-arguments. * Drop tested-by/reviewed-by tags, since this patched has changed enough to warrant re-testing/re-review, IMO. * Add more info to the commit message. Changes V1->V2: * add reviewed and tested by tags. * move this addition up 2 statments so that it's properly added to KBUILD_*FLAGS as per Nathan. Makefile | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) -- 2.21.0.392.gf8f6787159e-goog Reviewed-by: Nathan Chancellor Tested-by: Nathan Chancellor diff --git a/Makefile b/Makefile index 026fbc450906..b290e76e1ca5 100644 --- a/Makefile +++ b/Makefile @@ -514,6 +514,10 @@ ifneq ($(GCC_TOOLCHAIN),) CLANG_FLAGS += --gcc-toolchain=$(GCC_TOOLCHAIN) endif CLANG_FLAGS += -no-integrated-as +ifneq ($(shell $(LD) --version 2>&1 | head -n 1 | grep LLD),) +CLANG_FLAGS += -fuse-ld=$(shell which $(LD)) +endif +KBUILD_CPPFLAGS += -Qunused-arguments KBUILD_CFLAGS += $(CLANG_FLAGS) KBUILD_AFLAGS += $(CLANG_FLAGS) export CLANG_FLAGS @@ -716,7 +720,6 @@ stackp-flags-$(CONFIG_STACKPROTECTOR_STRONG) := -fstack-protector-strong KBUILD_CFLAGS += $(stackp-flags-y) ifdef CONFIG_CC_IS_CLANG -KBUILD_CPPFLAGS += $(call cc-option,-Qunused-arguments,) KBUILD_CFLAGS += $(call cc-disable-warning, format-invalid-specifier) KBUILD_CFLAGS += $(call cc-disable-warning, gnu) KBUILD_CFLAGS += $(call cc-disable-warning, address-of-packed-member)