From patchwork Mon Feb 11 19:30:03 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nick Desaulniers X-Patchwork-Id: 158028 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp2983803jaa; Mon, 11 Feb 2019 11:30:37 -0800 (PST) X-Google-Smtp-Source: AHgI3Iaw+Y13tL9stiAkIfIzmbiWQ7NX2rWssCPALRdTYOnL/lS0lla1lHehPJ7jvGa5kMf//55s X-Received: by 2002:a17:902:bd0a:: with SMTP id p10mr38005533pls.322.1549913437618; Mon, 11 Feb 2019 11:30:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549913437; cv=none; d=google.com; s=arc-20160816; b=LassWBcbCzAeXPqWy4Ne0ogLpOPbSvMLm19eVFw/inbZm/XTmSNTaWPPUK56WmUFiN 2N0cHL+Jvck/xaa5FFchaLnE7WV2j5/pFe3fOqtMJjvtvNNotYBlcvXELM20YST8MZz4 Kf/KxGMexU7P4DCaAa7RoPGER73eDe8NLCmlJy6cUwNpj6RXoJMnnW7C8JkTDa9mDElz 9OwCrGVS2yhOPSJFrtLhbyt4A6yqmVjZtO3CPOUxaG5n9p0gUjddTeKoKPQE19N6GDKr Rs2UIX0dHJu2BIeetonIYw9/Fqa/bckHqi1lZ9B3SI1ZD+884tQNJ/8QZ9a5h0xI/yuL On/w== 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:mime-version :message-id:date:dkim-signature; bh=yTmTM4lUWy38wNpJAAj82b5/JRtPQPUWiVhvkLc+GmU=; b=nBimBkuxuN4JCd38z8GsYMbDbury9+XfapT3PbZithsZBjjFVrdjof+q5+3XoPO8QN jNqRwbuYTBm0MuKHTGENQBYiHikxQeScfj9T/PTo4llRE3X7elKhVdA7eADZ2AhXgZAy rA7wOacJfpK3NfCKMtFeULFVazEqPH7vL6LdiBwKMIUiupNHrgsdLHsxknQ3X6wRx8xj 1PC5XxsSl5Ok9jyvumx7xJ5iYEsrO/2UIcbdeWMajeymECR3lbl4jcSNBBFWsj9fgfvo SZ+CAi2j0lmCkQ6RKsn2nITFE9j2n/TF0oBWd99n6Diu1rCByVEmXw84fsT2wTAqPmdk l2hA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=IgD0EQVv; 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 d10si9483622pgv.14.2019.02.11.11.30.37; Mon, 11 Feb 2019 11:30:37 -0800 (PST) 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=IgD0EQVv; 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 S2388235AbfBKTaf (ORCPT + 31 others); Mon, 11 Feb 2019 14:30:35 -0500 Received: from mail-vs1-f73.google.com ([209.85.217.73]:44277 "EHLO mail-vs1-f73.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731469AbfBKTae (ORCPT ); Mon, 11 Feb 2019 14:30:34 -0500 Received: by mail-vs1-f73.google.com with SMTP id o132so24536vsd.11 for ; Mon, 11 Feb 2019 11:30:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:message-id:mime-version:subject:from:to:cc; bh=yTmTM4lUWy38wNpJAAj82b5/JRtPQPUWiVhvkLc+GmU=; b=IgD0EQVvZuRTW8V34xCcsd5j+kuukE2iC4AfflnsyCWMauneJH9QQAwi3n3dFkIVl1 yQswrFqCX01hxOU9LOZO0jzflZSDdobLsqRH5CHZZS9fyZhRZN6ud1RvJO39OL8fdmbt yLJy++glVR3+LvhqrpbOMBvg79T3MIgcnDdm7OK9ePSvhksVKeSMnZwAsu1RJPhY8pVF UAUdVqmig6Bg1NRh1FsbaVldgBDaN9hsdr5ZXzn4pVerj9lk7g8t8xyKGo6LarW5hRMs Q3HUQFQaraxBEnLMlaCLxHCQs0YFbjOCOpL7Jt8ePKT/VScKQENAsWNu/THSYgipbRiR /zDQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=yTmTM4lUWy38wNpJAAj82b5/JRtPQPUWiVhvkLc+GmU=; b=Hij+j741/9dG4TJXNJ+M5xl/pORQm7UTUanNurKoqGLyE/5e7hAEsLVPaRvPql9OnW R2z8tkDgNdHfRG2FdJiAi003yiGjp5jtGQgMj1N+FNZ8sSBFCIzw/L1Ff3esRUsUtJma xsYyNhyVmnHZN4PcT2MiGnyvG3KIp6CRbTdexBAOL8YYtRaBlXH+yoxxXzb3ZHuhLbhS azg7LzrdeBX8wUsn3M4/qGwcva2/8Xbt8AZmlkOhu0+hZ87r9J7ZbjMB5duyjIRQhO/V bRAqRKEdC2Tu08rm42QA0h2LI5Xu9a6J6o4FJrI1zOV3ZE8FKutgU0tzJolvUywg6VbT coUw== X-Gm-Message-State: AHQUAubimfz/4whBWKOaxyDBCCNLDRESPpkWCxcjJM6hIEwgeuXhnEsI W6LGOzG4+vVoQXIbdfH3ftEPQ7oh+PlbtWEm8g4= X-Received: by 2002:ab0:4e23:: with SMTP id g35mr23818918uah.0.1549913433804; Mon, 11 Feb 2019 11:30:33 -0800 (PST) Date: Mon, 11 Feb 2019 11:30:03 -0800 Message-Id: <20190211193008.24101-1-ndesaulniers@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.20.1.791.gb4d0f1c61a-goog Subject: [PATCH v2 1/4] init/Kconfig: add config support for detecting linker From: ndesaulniers@google.com To: yamada.masahiro@socionext.com Cc: natechancellor@gmail.com, sedat.dilek@gmail.com, keescook@chromium.org, samitolvanen@google.com, michal.lkml@markovi.net, akpm@linux-foundation.org, hannes@cmpxchg.org, peterz@infradead.org, linux@dominikbrodowski.net, npiggin@gmail.com, mathieu.desnoyers@efficios.com, gor@linux.ibm.com, adrian@lisas.de, rgb@redhat.com, linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org, Nick Desaulniers Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Similar to how we differentiate between CONFIG_CC_IS_GCC and CONFIG_CC_IS_CLANG, add CONFIG_LD_IS_BFD, CONFIG_LD_IS_GOLD, and CONFIG_LD_IS_LLD. This simiplifies patches to Makefiles that need to do different things for different linkers. Cc: Sami Tolvanen Suggested-by: Sedat Dilek Reviewed-by: Kees Cook Reviewed-by: Nathan Chancellor Tested-by: Nathan Chancellor Signed-off-by: Nick Desaulniers --- Changes V1->V2: * Add suggested, reviewed, and tested by tags. init/Kconfig | 9 +++++++++ 1 file changed, 9 insertions(+) -- 2.20.1.791.gb4d0f1c61a-goog diff --git a/init/Kconfig b/init/Kconfig index c9386a365eea..b6046dcf7794 100644 --- a/init/Kconfig +++ b/init/Kconfig @@ -26,6 +26,15 @@ config CLANG_VERSION config CC_HAS_ASM_GOTO def_bool $(success,$(srctree)/scripts/gcc-goto.sh $(CC)) +config LD_IS_BFD + def_bool $(success,$(LD) --version | head -n 1 | grep -q 'GNU ld') + +config LD_IS_GOLD + def_bool $(success,$(LD) --version | head -n 1 | grep -q 'GNU gold') + +config LD_IS_LLD + def_bool $(success,$(LD) --version | head -n 1 | grep -q 'LLD') + config CONSTRUCTORS bool depends on !UML From patchwork Mon Feb 11 19:30:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nick Desaulniers X-Patchwork-Id: 158029 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp2983936jaa; Mon, 11 Feb 2019 11:30:42 -0800 (PST) X-Google-Smtp-Source: AHgI3IYheMUQl1gpv6xc0eP2nAnqm4FPd2Vuke2DhwQhtekfy+zwRU3bOjKVPD7zi8gNHW14oNn0 X-Received: by 2002:a17:902:ab8f:: with SMTP id f15mr25226523plr.218.1549913442676; Mon, 11 Feb 2019 11:30:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549913442; cv=none; d=google.com; s=arc-20160816; b=ARdVaREvnma227Pa9C5dInhEk7o0OxfB6v3c1DecOyY/tCSL8dz6NqdouNtWHbt/GD saifBASMmk2vGWbasQ6ooZiZbF4IIALOM1qMuH6jgxSdFvLZe6fvZgydxZ4cxmlPs1xX sM4jQBsuzcsTcFqqXGH1r/9X+B7EF+r34+OzukHJKQHd7t1GOU+Y/GfyF3F43dWB+wvQ rFwi0Nc/PKPJFffKAr60Han4klfau2NcEWAG0tTq+lcmsNT9V03UBKAPTvVuaGKyzQcB VCQwNuOauzGqxukRE30TsHiPsvZhX8dokbm7iX0F1bfdozN9HH8Q6qm1P52MBKH232Hw xvvA== 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=d5X1DHNjDUb5NLL3O4YMEIQYPjCFJAnKD/tNSL5RNTA=; b=uYL55qC4V76M3oIOkoR8vQZItAU/qdlclZqDijlHG3NvwdvOm3Qj949JmfbPQnxJ7+ b6q4Qf/QUwNZgZrMU4s2BwLJF/o7ceaB3pVJiGUMBlu1T1ixCxUMVQN20X0uYhEgmktU ekDUmBpRMWKkpNU/FCLGsocKOUy7dlGxyMzlBtXYImVT+feV5HzJFrSFjgIJwx6AuKTX P2ByB3PXNRIX4Qz4iI3ucqf/JLcaQ/GMVZY8cbHOPcunX9xb9cQa+QhP5n0gIYFxWwGw p/MrC+hCBaQeW8vZoo+AktpTOIUNPZh7RCb2PssCPRDWh8csOWSLj/ZviqojDYjl/RaT A7xQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=ZBVmQgwn; 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 d12si11046807pla.351.2019.02.11.11.30.42; Mon, 11 Feb 2019 11:30:42 -0800 (PST) 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=ZBVmQgwn; 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 S2388259AbfBKTal (ORCPT + 31 others); Mon, 11 Feb 2019 14:30:41 -0500 Received: from mail-pl1-f201.google.com ([209.85.214.201]:33427 "EHLO mail-pl1-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388240AbfBKTak (ORCPT ); Mon, 11 Feb 2019 14:30:40 -0500 Received: by mail-pl1-f201.google.com with SMTP id o23so69260pll.0 for ; Mon, 11 Feb 2019 11:30:39 -0800 (PST) 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=d5X1DHNjDUb5NLL3O4YMEIQYPjCFJAnKD/tNSL5RNTA=; b=ZBVmQgwn6wPvQ808Q2qhEWWaFjM6+9X1q8IZ4ZIKeyEJduZfSgRN2FFUZoJEnmFB61 2izQC8j/FEojBJj296AnNPhLv0IHe8E/75uimTQC+TQnX9aMXrNSlUNjZNg56yooRaO3 LiGHDs/lGY3lEEWv4ziLOkQSDdDXbM9uCuY/bJ1px4k5FfpKNqeLnjCcldjnuDEaeP1a +Z0PuNJIMAGlUG0CtpTgdrTQo/fErysoynGFb9yZi+Qk1oiC93I3p2jnrcTrBRflFBW9 Q5bvbEwRTjz3Rb5FX/HMP5FfhF7CmjZrBR8lM5fozm4sNYfqsPTTIpmougO9/NdQOWik vYVw== 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=d5X1DHNjDUb5NLL3O4YMEIQYPjCFJAnKD/tNSL5RNTA=; b=J2SaVCLX8+k0Wjt3Fbr2ay7w0ryA6/TapJZxxO3F2EAMAlYEwkXZX9CruPLcSthk9+ rTzC9cpBCyeS/f0MWhD8hVhJpZ4l56nC1ftAhYyzrPp5ujdqVSNmvAlz5a7yLs3yH/24 TUG5NB2iErWa/Z1LLTw6nkRR9VRYDnzxYlBtW8KGK6dskmwcBjoLSGRJW0yod43+om5v 6wF6c4bHowKqOSgdVEr8vscQvCkvQAit2FGvvvr/zqP7qYoUccv4vw138ctncnLm7f9+ nFD+7RCKapihZLXlko6upVmg3w6Evp1hD0uLBxXcCjDNFwDtweb2xEBiJeEoFTeC/Dtw OJXg== X-Gm-Message-State: AHQUAub8FmaVWXdDEPqG7eNGjupoGIUKG+gHuqYk/6Q9/u5P9r0T5895 F2FH6INgCEKpRZlFVeWwnxk6VVD0vzRiUpVqcuA= X-Received: by 2002:aa7:8acb:: with SMTP id b11mr1064903pfd.72.1549913438630; Mon, 11 Feb 2019 11:30:38 -0800 (PST) Date: Mon, 11 Feb 2019 11:30:04 -0800 In-Reply-To: <20190211193008.24101-1-ndesaulniers@google.com> Message-Id: <20190211193008.24101-2-ndesaulniers@google.com> Mime-Version: 1.0 References: <20190211193008.24101-1-ndesaulniers@google.com> X-Mailer: git-send-email 2.20.1.791.gb4d0f1c61a-goog Subject: [PATCH v2 2/4] Makefile: clang: choose GCC_TOOLCHAIN_DIR not on LD From: ndesaulniers@google.com To: yamada.masahiro@socionext.com Cc: natechancellor@gmail.com, sedat.dilek@gmail.com, keescook@chromium.org, samitolvanen@google.com, michal.lkml@markovi.net, akpm@linux-foundation.org, hannes@cmpxchg.org, peterz@infradead.org, linux@dominikbrodowski.net, npiggin@gmail.com, mathieu.desnoyers@efficios.com, gor@linux.ibm.com, adrian@lisas.de, rgb@redhat.com, linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org, Nick Desaulniers Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This causes an issue when trying to build with `make LD=ld.lld` if ld.lld and the rest of your cross tools aren't in the same directory (ex. /usr/local/bin) (as is the case for Android's build system), as the GCC_TOOLCHAIN_DIR then gets set based on `which $(LD)` which will point where LLVM tools are, not GCC/binutils tools are located. Instead, select the GCC_TOOLCHAIN_DIR based on another tool provided by binutils for which LLVM does not provide a substitute for, such as elfedit. Fixes commit 785f11aa595b ("kbuild: Add better clang cross build support") Link: https://github.com/ClangBuiltLinux/linux/issues/341 Suggested-by: Nathan Chancellor Reviewed-by: Nathan Chancellor Tested-by: Nathan Chancellor Signed-off-by: Nick Desaulniers --- Changes V1->V2: * add reviewed and tested tags. Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.20.1.791.gb4d0f1c61a-goog diff --git a/Makefile b/Makefile index 86cf35d1d79d..d3b65e96d183 100644 --- a/Makefile +++ b/Makefile @@ -492,7 +492,7 @@ endif ifneq ($(shell $(CC) --version 2>&1 | head -n 1 | grep clang),) ifneq ($(CROSS_COMPILE),) CLANG_FLAGS := --target=$(notdir $(CROSS_COMPILE:%-=%)) -GCC_TOOLCHAIN_DIR := $(dir $(shell which $(LD))) +GCC_TOOLCHAIN_DIR := $(dir $(shell which $(CROSS_COMPILE)elfedit)) CLANG_FLAGS += --prefix=$(GCC_TOOLCHAIN_DIR) GCC_TOOLCHAIN := $(realpath $(GCC_TOOLCHAIN_DIR)/..) endif From patchwork Mon Feb 11 19:30:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nick Desaulniers X-Patchwork-Id: 158030 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp2984060jaa; Mon, 11 Feb 2019 11:30:49 -0800 (PST) X-Google-Smtp-Source: AHgI3IZjwHV4RQ0rfCusBR3fcq7sqMTXta+en2hd44HYQ/dSPx6dkWwoZrEXSDlUEKLACpFiTEo/ X-Received: by 2002:a17:902:8641:: with SMTP id y1mr38984616plt.159.1549913449055; Mon, 11 Feb 2019 11:30:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549913449; cv=none; d=google.com; s=arc-20160816; b=tSJZKisytAiuaVq+ruHkmilErDbMutdT3jWN6dxuI0XYFxZQMvJ9UKcB3ILuApyDXf wNbgMbpo0h1+Zec9JZM/fsc0qWXLdBpzDaT+fzSAgI83GUMruiThOnQQuhPfq5arms6K 8s+af0nBgGzGxwL4L2FWjqqtjf1Qm3MonyrKjKmLHi5uDZUzwyNS1zxMJCy+UyMzraqb nSm1ch0p4pGBfRKZztmFkOZZb+Sqd/1V9gHPtfxA0Q3ONxgPEyueoRK0AZtMMSgZIPBf KtwXDD3QV2YqWkiA+Su76NQYTa5pLGwrrFUPnNnh+iXl9m8+KysKBPoCvpJUUQhBrKQf 1voQ== 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=A+p5CcPbc67CNJ+HtkbKBMLEqE5iK/BxBkcy0srR2f4=; b=oFQ8T6iVuax/j62B2XdbesJwJSy6cHp9QHwMJNUJJYIuXGifu8IrHokw8fiFubL4f7 RJN162QO8GSNySGI0rFoez2/QVDlkJJhX2C3YqSagNfrWh+Br8BIpU0OVYVuLzOhl88R fNaHkl8u9Jt97XxfxZbZG1o/2H1ZVv0CNf7oRFv7tnHEWgRc6NH6cdeNabjg/xkQVXb+ DwRkdl6TJRiJwAC4aKwqMcQrYQRafgrd9EgyV5RdlkWkp40oEGu+IQW6kFY+fQjsH6dw NSayroA8DDd5ArfCA5I8g10GMVAI7sxFQlJVhO5h2E7ZwiIId5F+wRj9KHs9aGq65Ojx maUQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=EUfDjdob; 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 y22si9026562pll.284.2019.02.11.11.30.48; Mon, 11 Feb 2019 11:30:49 -0800 (PST) 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=EUfDjdob; 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 S2388285AbfBKTar (ORCPT + 31 others); Mon, 11 Feb 2019 14:30:47 -0500 Received: from mail-it1-f201.google.com ([209.85.166.201]:39705 "EHLO mail-it1-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388241AbfBKTaq (ORCPT ); Mon, 11 Feb 2019 14:30:46 -0500 Received: by mail-it1-f201.google.com with SMTP id k133so16344ite.4 for ; Mon, 11 Feb 2019 11:30:45 -0800 (PST) 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=A+p5CcPbc67CNJ+HtkbKBMLEqE5iK/BxBkcy0srR2f4=; b=EUfDjdobRLMV2Tk3lGBtNvj9QujsHoJi9ZqtEcH+YVtBCw0t/FCOOKOLjYPLz2olUE +TKRIo6Qkhd4/yl5EoeB93P6IDHZzfNjrzFK7iELdrQbe/FgB6/rqt0ScvP0xuzVt8hB z3fEBdPiKZndqh/aWqmvhVbI4J2B7eYEVxxuxU9Axu+akFPva/9Qj60M9PMrdYG72vSq Gubv63+gi2EzkY3wnIv2NYmvI/aEm0HnzTlhgrrxsVzTrjldQ24LgR14yr2G4DK4e8hr yPFkN2CogT0A25zsQf9ZCs9OjpRlwz3HR/KZ4hDpMclFW4EC5h+L1Va45mhPLcZKJY2J lLGw== 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=A+p5CcPbc67CNJ+HtkbKBMLEqE5iK/BxBkcy0srR2f4=; b=TfYv2Iel5R29UNe5jfMHAEhuu3XDISufMYE3miPc22kAmC/MOX1rU6Cv/q4o6wPhQv gAh+aWF/9JapQxJSlUkUf3TObRculUmt0z+/zYupSwqtSVCnofdIVWjDVU3vKPWEymkt jfWoFd+H3BQ0i0RULfxmIpIW4v8NckFXU4JPc2kTx59os/HQMgklodZctuRLvRzrWg71 zfi8lQjRKV+i5/F37rLh+jy/8reuTVPiwL+1O+0hMMpCSIvcBo64YrCDL1mgbSbGxWIv fjO6pwhIAg3EDTxmV0lv7anHJ8CwQboyL1NwIFagEVigjq9H2hIF7IvgUpi3UAO7g87E vXYg== X-Gm-Message-State: AHQUAubHMbdwMGw4mdTcjvnsT0j+FacqmoWxTPCt8cUzJfVRau9/NYbO ciWiWHP4LKFUn6q2UBHKNPc+Sq3FovsqcZzjCZU= X-Received: by 2002:a24:d82:: with SMTP id 124mr794567itx.10.1549913443054; Mon, 11 Feb 2019 11:30:43 -0800 (PST) Date: Mon, 11 Feb 2019 11:30:05 -0800 In-Reply-To: <20190211193008.24101-1-ndesaulniers@google.com> Message-Id: <20190211193008.24101-3-ndesaulniers@google.com> Mime-Version: 1.0 References: <20190211193008.24101-1-ndesaulniers@google.com> X-Mailer: git-send-email 2.20.1.791.gb4d0f1c61a-goog Subject: [PATCH v2 3/4] Makefile: lld: tell clang to use lld From: ndesaulniers@google.com To: yamada.masahiro@socionext.com Cc: natechancellor@gmail.com, sedat.dilek@gmail.com, keescook@chromium.org, samitolvanen@google.com, michal.lkml@markovi.net, akpm@linux-foundation.org, hannes@cmpxchg.org, peterz@infradead.org, linux@dominikbrodowski.net, npiggin@gmail.com, mathieu.desnoyers@efficios.com, gor@linux.ibm.com, adrian@lisas.de, rgb@redhat.com, linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org, Nick Desaulniers 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=lld. This is problematic especially for cc-ldoption, which checks for linker flag support via invoking the compiler, rather than the linker. Link: https://github.com/ClangBuiltLinux/linux/issues/342 Suggested-by: Nathan Chancellor Reviewed-by: Nathan Chancellor Tested-by: Nathan Chancellor Signed-off-by: Nick Desaulniers --- 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 | 3 +++ 1 file changed, 3 insertions(+) -- 2.20.1.791.gb4d0f1c61a-goog diff --git a/Makefile b/Makefile index d3b65e96d183..00e8e01d23fc 100644 --- a/Makefile +++ b/Makefile @@ -500,6 +500,9 @@ 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=lld +endif KBUILD_CFLAGS += $(CLANG_FLAGS) KBUILD_AFLAGS += $(CLANG_FLAGS) export CLANG_FLAGS From patchwork Mon Feb 11 19:30:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nick Desaulniers X-Patchwork-Id: 158031 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp2984111jaa; Mon, 11 Feb 2019 11:30:52 -0800 (PST) X-Google-Smtp-Source: AHgI3IbDqBx/L1DS2iYNjdI7iyX8mQQFHB26NPpQguva+esAGCkN0L6Uh/SrOUJmSVuIhpdu46De X-Received: by 2002:a63:a80c:: with SMTP id o12mr17346480pgf.185.1549913452232; Mon, 11 Feb 2019 11:30:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549913452; cv=none; d=google.com; s=arc-20160816; b=K88bZ0xvwLa4qlSg9WV00aIWgEehNvvILeQ2VF2kOjD/ZkJdXzFYdpXC+NnDStzs5Y u8JCiyDO8grXPEGY5DQAA45/3d6U6ypjPFieFBhxCYNU1J8ouE3XzkHQbo1QLcI57ssk CzPgsZ95t1jDSDWVveyfjaz1yDk7mR1CI1r8k3D4zpdqVGmKYCfPPtR9MPwZ3c/RgIVu qFCtREAuNJtcqucSHT3MRjNMUPaNOmVYwbH7vNet1QeGVhyDyBPXdGrpmJk6aqNls9rl QOS7olneiW9FIMT64RjLvpDjJ5e85GsoZDh9pKqcvYQqlqGvOLKc0rqBA9skv8kfa7bZ jQ0g== 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=fgo15CY3NgYRpF97TzDUfVV2bSFDYAqgksNtaJxXuEA=; b=BSgia76kXQQn+uVt4OQnCRMeLORS2/R4sKDUn9RZr5IXV2pvC4kMm8EpzFSIdyJR2d QAPQQfO/+8VzCX2RpFxLlQ+inAU1rkFz2jL9G6cf6rtCX9Uw8flrtilhov86CSHYeq0o votXvWqX6jn+r+/4XfLxuPXu9lzRcVgcmXOTrnYJCqjfzB6q6N3TNG5PqA7ardN5Mq1q EZ0eI1xfpwHyKr/noigTu8gv94kWxEGBjiqoEqFlvNNbLutZoHw5Fe+tsbDbsciDMY4N zFd0xCGf/GRFR8wJ56YF7cbI8DfDMlt4FEYlxWqIV95d/2DVBx2cSMArTLKkihu2vFNC cnhw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=P33ZEVn9; 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 y22si9026562pll.284.2019.02.11.11.30.51; Mon, 11 Feb 2019 11:30:52 -0800 (PST) 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=P33ZEVn9; 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 S2388318AbfBKTau (ORCPT + 31 others); Mon, 11 Feb 2019 14:30:50 -0500 Received: from mail-qk1-f201.google.com ([209.85.222.201]:42865 "EHLO mail-qk1-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388241AbfBKTat (ORCPT ); Mon, 11 Feb 2019 14:30:49 -0500 Received: by mail-qk1-f201.google.com with SMTP id 207so5175451qkf.9 for ; Mon, 11 Feb 2019 11:30:48 -0800 (PST) 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=fgo15CY3NgYRpF97TzDUfVV2bSFDYAqgksNtaJxXuEA=; b=P33ZEVn9lWw4ExXF0pVb2kRhsMzsHIZnSCIoTjgHA67m1TBvJkvTccmmchHplJnzYi tK2h0WoALbgU2nZkZBJ2SxgLYpjlLfwsyM0qPDqW+WBGaVbVrCsDmIH6NfN+z6JfOa8G T+CWOFyTf+3H6TpEGTUvVR3EWZKAFrVXa/1HeoxRLcFre021WqnSEaB0okT2cdrUH/Zp j6/LfS6vWUOX8eAWpEshZ9EdhfKAPlTBxfbG9fyzxahFURQCfQqWoyJvynTy4bLNZmAd Fru81lvlu6FIits75GNMSWZETZYzfa/xtYGwkz6eLWKT5EO6vuFx7ZpACi8+YI0l12y3 10LQ== 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=fgo15CY3NgYRpF97TzDUfVV2bSFDYAqgksNtaJxXuEA=; b=U2F65+YXMKudz+1Yr7Ch+CT4ZLPc0aERcASVopTdV12tIoJAtmTuJ9UTqUQgizm5nt GALwQcM1HsR+mh864NlNVshll8rbExrWVxwi21/ijrPeqqz2/sPPp9wgYuS3Hflc2xKo vOd+zcFvdztsxNTr1RKy6YA4GzjsRAyv3K6l3jxD5G8/J97Z+F2hYEtdiML2a+tpKfE3 yg6tX5Udpotb2Rxy8vkXlry2agsPafqhuQibWEiyyOZTQSuqHfR28r9nx1Bqn1kswR7s BGvlIxSzvHeNfiYSY1iGJx0THWIsvzJN3oQhjFXcpKfjUCDhD0bxaw/1dIa5SW2auIaY h2ow== X-Gm-Message-State: AHQUAuYjSKd+59Vyq7/SGE3xdHFZZwGgbrcH0jn1SX85U7sDwOmxdTGy Q4qEE+lnz4AleW+09jQWXFIiMJNtinGiHrLPO2E= X-Received: by 2002:a0c:add8:: with SMTP id x24mr21936434qvc.16.1549913448304; Mon, 11 Feb 2019 11:30:48 -0800 (PST) Date: Mon, 11 Feb 2019 11:30:06 -0800 In-Reply-To: <20190211193008.24101-1-ndesaulniers@google.com> Message-Id: <20190211193008.24101-4-ndesaulniers@google.com> Mime-Version: 1.0 References: <20190211193008.24101-1-ndesaulniers@google.com> X-Mailer: git-send-email 2.20.1.791.gb4d0f1c61a-goog Subject: [PATCH v2 4/4] Makefile: lld: set -O2 linker flag when linking with LLD From: ndesaulniers@google.com To: yamada.masahiro@socionext.com Cc: natechancellor@gmail.com, sedat.dilek@gmail.com, keescook@chromium.org, samitolvanen@google.com, michal.lkml@markovi.net, akpm@linux-foundation.org, hannes@cmpxchg.org, peterz@infradead.org, linux@dominikbrodowski.net, npiggin@gmail.com, mathieu.desnoyers@efficios.com, gor@linux.ibm.com, adrian@lisas.de, rgb@redhat.com, linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org, Nick Desaulniers , Rui Ueyama Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org For arm64: 0.34% size improvement with lld -O2 over lld for vmlinux. 3.3% size improvement with lld -O2 over lld for Image.lz4-dtb. Link: https://github.com/ClangBuiltLinux/linux/issues/343 Suggested-by: Rui Ueyama Suggested-by: Nathan Chancellor Reviewed-by: Nathan Chancellor Tested-by: Nathan Chancellor Signed-off-by: Nick Desaulniers --- Changes V1->V2: * add tested and reviewed by tags. Makefile | 4 ++++ 1 file changed, 4 insertions(+) -- 2.20.1.791.gb4d0f1c61a-goog diff --git a/Makefile b/Makefile index 00e8e01d23fc..8011555745aa 100644 --- a/Makefile +++ b/Makefile @@ -718,6 +718,10 @@ else KBUILD_CFLAGS += -Wno-unused-but-set-variable endif +ifdef CONFIG_LD_IS_LLD +KBUILD_LDFLAGS += -O2 +endif + KBUILD_CFLAGS += $(call cc-disable-warning, unused-const-variable) ifdef CONFIG_FRAME_POINTER KBUILD_CFLAGS += -fno-omit-frame-pointer -fno-optimize-sibling-calls