From patchwork Tue Apr 2 07:08:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nick Desaulniers X-Patchwork-Id: 161614 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp1395445jan; Tue, 2 Apr 2019 00:09:18 -0700 (PDT) X-Google-Smtp-Source: APXvYqwCu7qcCmIHCPjgcPMecpe1NBEz8SuTyW337imexbXBpF4PE18EBBCVghif3bfWz4OMJzv9 X-Received: by 2002:a65:5303:: with SMTP id m3mr64431679pgq.292.1554188958465; Tue, 02 Apr 2019 00:09:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554188958; cv=none; d=google.com; s=arc-20160816; b=rdX7MyjFEx8MY4cqaOXxndhWubuTaPb91uvckPsQoSMzVlXhuD3ChQTMu/oCZ0ch8B L5KNSgMzBSEv9wURNyIC4c382VqPgh7F6XBq/aonVRUxGUSFI+mqkt9oo42BJ8qMgeHR rdNAVJ5IwSsgKuRrQcSMmTVJN+bFDN7NwNHW2taeCCa0flyAxyD/2dXAs4UKpTQpy/SZ KNuVhnxlgX0uksxZTReBIZWOxLZs5dwr4YP9w8+yfLdyom904w3K6fBwMy34JcYoZhoZ 3ihUBJs/eS6AE165c65s4RqLZ/cKtcdBSqMVemmhEAedBiQZDnnEjt70xQWxh7wUuDeR tb3Q== 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=6fjJy8yswnbkmtbxTFEZ/Qrr257jfY2BDV+aITklo40=; b=T7iWsk9DLskI3277dqs5irNk9IUYWVDhhUvLMnew1hoBBEEsmXqHZUXxKnMHB0lBbM GPv49x+Pb4NacTOSffAa5DuXiiWXu6Zy2ETfL+UybuJ6BTFm84j1MIq3JT2ERoBZJFsI 1qLK70MNvhYSmoW8PgsGJo2EYywo8XTEgMvgz+IhyN9BWA0l7MkNmHzfCoZOQyEoxCBS dDHGletJ+9CEvKFJqeoJ+flEs3IdKPVExm88ZEVH2g8waVvVbQH3J/97n9U0yZPwBmNl 3xZZCioLbRgIPr4v2r1xznGE1IIXHuFDg+EooCwJjBIBHUCKUHcDkkI1+z6BZm4lYyL+ ZXPA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=IOEx5Mmr; 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 f63si4244705pff.107.2019.04.02.00.09.18; Tue, 02 Apr 2019 00:09:18 -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=IOEx5Mmr; 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 S1729409AbfDBHJQ (ORCPT + 31 others); Tue, 2 Apr 2019 03:09:16 -0400 Received: from mail-io1-f73.google.com ([209.85.166.73]:44714 "EHLO mail-io1-f73.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725889AbfDBHJQ (ORCPT ); Tue, 2 Apr 2019 03:09:16 -0400 Received: by mail-io1-f73.google.com with SMTP id c2so10056964ioh.11 for ; Tue, 02 Apr 2019 00:09:15 -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=6fjJy8yswnbkmtbxTFEZ/Qrr257jfY2BDV+aITklo40=; b=IOEx5MmrzBQW2a1Uik6PO/3VBDmNvgmOUIZgRpn2ByOjilXHh0sULLQE3eVnKsxLAN cEzdanotzIFZE4Omm1LpNIYJnnmSgsd2wsTXjbO1y0cz89L4ZPL5SIhZLU2zbzLHvC3c hqqLPpSLAcEhUCxg8SdyETezh17JC5YPPJpomqFLfaVKHjBxo44WXDdOU8hV27Pueccb UGonDZWw5675DRCB41bPERZnuZlgI1huUqNCYcrju3IRxGgXVM1/UbfnZ2BWFVKH+15G IW+wAuwfRc4E/ZuUZn3Vx7QQRkOVGJB7UkUnajGvwM5jX/Yfi8jEj2gDWVloual4oEwj lDrw== 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=6fjJy8yswnbkmtbxTFEZ/Qrr257jfY2BDV+aITklo40=; b=tm6h+RnVjQt9Je7p/XXOKjhsfkbr0ixODoQMmo5GbtbLocaGAHYXurKTutmmFXdXu5 ssAoUsNe3fQHznQM6LzSvElS+YicV5NSMzVWYfVrsyvA99U7tw2WKYox1VUca9wBg9W9 LbYov6Ti6KqaKzws7mVVKhvd9XfCoOQnOoO7Q3hXSvjrop5IkvUfvTuQHMawKjkOan3E urVfuDdHJufScOcfN99g018l2HCQgo7ohCoI55FA1U35NwmObQGmJBhdwp6ayLtpI8Za w5K75klpwFyJOzvmXQlwLrFy3ThCz9qqAcKutT0tYiMwk7Gu3GBd5eRZanQTUpN769JT Cc7g== X-Gm-Message-State: APjAAAVjfG47GOmIO1uLoWNo3G8ZNmPSZQB1xx/f1hSY+FmGU4+XxoFf AeQTW7zIsBAq77MdoWlsGjdovcCYef410DS0ztQ= X-Received: by 2002:a24:455b:: with SMTP id y88mr7235585ita.14.1554188955497; Tue, 02 Apr 2019 00:09:15 -0700 (PDT) Date: Tue, 2 Apr 2019 00:08:58 -0700 In-Reply-To: Message-Id: <20190402070858.49597-1-ndesaulniers@google.com> Mime-Version: 1.0 References: X-Mailer: git-send-email 2.21.0.392.gf8f6787159e-goog Subject: [PATCH v3] 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 when using LLD, as otherwise Clang likes to complain about -fuse-lld= being unused when compiling but not linking (-c) such as when cc-option is used. 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 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 | 4 ++++ 1 file changed, 4 insertions(+) -- 2.21.0.392.gf8f6787159e-goog Reviewed-by: Nathan Chancellor Tested-by: Nathan Chancellor Reviewed-by: Sedat Dilek diff --git a/Makefile b/Makefile index 026fbc450906..895c076b6305 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)) +KBUILD_CPPFLAGS += -Qunused-arguments +endif KBUILD_CFLAGS += $(CLANG_FLAGS) KBUILD_AFLAGS += $(CLANG_FLAGS) export CLANG_FLAGS