From patchwork Fri Feb 23 04:56:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 129329 Delivered-To: patch@linaro.org Received: by 10.46.66.2 with SMTP id p2csp189542lja; Thu, 22 Feb 2018 20:58:47 -0800 (PST) X-Google-Smtp-Source: AH8x224yV2EOX68lFhcteqwxyfXm7evgiYIv2JhzhJhniEHjqDKx9bDiQbGVEDS4+PhA6/sAhxa0 X-Received: by 10.98.155.93 with SMTP id r90mr487541pfd.132.1519361927654; Thu, 22 Feb 2018 20:58:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519361927; cv=none; d=google.com; s=arc-20160816; b=nRd2BLwSE6hAjn8ArUc8BDBJEcvRcZGnTlcQ9rdLdJ5BAJARPD9QUojRj4Ma6YnjG8 QKah97R2i6b/nlVXTVtz59a+MQ+c1MbHBA9HnFKLj7KFVKNQo+6WjLAsZKmaPdbQ5OUD 8vJe6YXu5RtWwOkBIQjYzaybS34jltaojBIsJC7Zdq69x2R9lpd9ilx/p0b7BKwxOAhG JhXuwjf2jjeVh3GrvJYp0uoI4z2WXUtfeMn0LNCwgcNuzmWuHARrRA8FdB1uYZ1v/+sy EYcAvqHWGipEHZbiAvgqEN4BI8W30eU69VZQffFZSHqcPpC+cPh+bG39ifIVtmET+ti4 nhng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:dkim-filter:arc-authentication-results; bh=5YlP5jLnIeyIU+Oj4e0c6QE5BnNR+rJxhBajjL2ftfE=; b=tlUUf3VT4x+OqpODF/0N9hpm+8yf+DofYKyIVMOUVnk6eLbnr6TOCruci8w8THPkeO v52xUGO4wB1Dg/ggkDjkUrTaFxm2cGkJ3zXaTqddZaVNeZzGXcmX5qErT2njEUVQkQ75 cz2jSdCQppBVFy4rbjdUBt8doueDUkv/Hx2L42slTOTeoURhWgRfCEKWZjfCedCPgsGA C/ddw0fzln0nUYIHz/CFU1rj3wnHl6YeOhkYWmaQZnuJJJudSuvyZfXOTf0mO4QGBwkN GRgfhwu2z8qIhCj0+WfihRdGvlEHg7N8nYgOosSUF96LJDUQNlI97MXNdaThew+VREAc gn3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=Je3idMz4; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r11si1018529pgn.147.2018.02.22.20.58.46; Thu, 22 Feb 2018 20:58:47 -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=@nifty.com header.s=dec2015msa header.b=Je3idMz4; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751447AbeBWE63 (ORCPT + 28 others); Thu, 22 Feb 2018 23:58:29 -0500 Received: from conuserg-12.nifty.com ([210.131.2.79]:26215 "EHLO conuserg-12.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751296AbeBWE61 (ORCPT ); Thu, 22 Feb 2018 23:58:27 -0500 Received: from pug.e01.socionext.com (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-12.nifty.com with ESMTP id w1N4uwWA024939; Fri, 23 Feb 2018 13:56:59 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-12.nifty.com w1N4uwWA024939 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1519361819; bh=5YlP5jLnIeyIU+Oj4e0c6QE5BnNR+rJxhBajjL2ftfE=; h=From:To:Cc:Subject:Date:From; b=Je3idMz4Mk5WBe4iKQ6sQaQw1snLAfBFZdGq/aKdLPxvZGSw4MEk1FI2SpbdnzFtq 0F5SFvLhzEaZGY/vnksmteXQX8Dx9py3F3D0LbPGld7pf82eymRIRfeAGq20OapB8O 2NUBPyTUlFLlhlX2X5vUOLdzpFcBVMwKlTZuN12QJalzRFkEYXOQO8AX7kp52u+BV4 mkeNz+0ALRsLSN35LXlnlKarUxr6h6e9KDDEaRllPxTjTFLqra4fHSdq69hHlG9PFj VZgSiyfQFR9xx5BZjXiIIEw04wJazSmYlZ0/KGq7KrSjqNaDfhTa6U3XWLVSzg1DzT GxTiNy3NYHqnA== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Arnd Bergmann , Sam Ravnborg , Nick Desaulniers , Matthias Kaehlcke , Masahiro Yamada , Michal Marek , linux-kernel@vger.kernel.org Subject: [PATCH 1/2] kbuild: test --build-id linker flag by ld-option instead of cc-ldoption Date: Fri, 23 Feb 2018 13:56:52 +0900 Message-Id: <1519361813-8553-1-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org '--build-id' is passed to $(LD), so it should be tested by 'ld-option'. This seems a kind of misconversion when ld-option was renamed to cc-ldoption. Commit f86fd3066052 ("kbuild: rename ld-option to cc-ldoption") renamed all instances of 'ld-option' to 'cc-ldoption'. Then, commit 691ef3e7fdc1 ("kbuild: introduce ld-option") re-added 'ld-option' as a new implementation. Signed-off-by: Masahiro Yamada --- Makefile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) -- 2.7.4 diff --git a/Makefile b/Makefile index 4f295a2..1ed2a15 100644 --- a/Makefile +++ b/Makefile @@ -866,8 +866,7 @@ KBUILD_AFLAGS += $(ARCH_AFLAGS) $(KAFLAGS) KBUILD_CFLAGS += $(ARCH_CFLAGS) $(KCFLAGS) # Use --build-id when available. -LDFLAGS_BUILD_ID := $(patsubst -Wl$(comma)%,%,\ - $(call cc-ldoption, -Wl$(comma)--build-id,)) +LDFLAGS_BUILD_ID := $(call ld-option, --build-id) KBUILD_LDFLAGS_MODULE += $(LDFLAGS_BUILD_ID) LDFLAGS_vmlinux += $(LDFLAGS_BUILD_ID) From patchwork Fri Feb 23 04:56:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 129330 Delivered-To: patch@linaro.org Received: by 10.46.66.2 with SMTP id p2csp189691lja; Thu, 22 Feb 2018 20:59:00 -0800 (PST) X-Google-Smtp-Source: AH8x226xobn70ErMWjFGPircgGozAGfnlkyDAW4VejOcxMQJeJHnJGUdX+VEAupDvOIEDZ0mv5J8 X-Received: by 10.99.116.25 with SMTP id p25mr411858pgc.109.1519361940693; Thu, 22 Feb 2018 20:59:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519361940; cv=none; d=google.com; s=arc-20160816; b=hLPwv4ovWPNftB7/+7Sx5jpn7UOMurobujG4n+gNoHYxIPH/OTMXVYPaNyeWtMFOpG 84ixTHLtBbehW1i7KkWZU9hPNeTP585L+qUf0vu9okwh3g/E93nuTdV7xpMFiioRFSN3 r06cdbibPQltkcre6xQTbAv7lxnEIhiVdV7dQFy7rVzaFVrAHLJc7SD++rrjp5JJtDfO D45jdr78i/s2Vupt7dZ4sbZqHjB7RSYpUfXqc/yRCE//YrwrkvN7V73DG/90V7OtQLem 2Ba8ehLvfbrSOL7huUX+7XrjKgdnMOvRapt1sT9eqi0xAxen5v2LLvYMiwdjvW/5tziq 1Acw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:dkim-filter :arc-authentication-results; bh=c94CzZXaICBETuLbyrkOPLALL6MwXImEuVsXqRc+Yns=; b=idD4cOIJRcGjlEbNqN96sY8kyiBj6rG8QCxclS/Q/SbsIHD510Ljd6RLo8A6gWIKHz TlXdOjbhEizAC/KzsKDZmmW1ySviT/Dq3PLhCWl5dqAAov07LMZlU8QOn8KWYZvYyoKi 8nBzOhtQjK5kCQexh5oq3SZ8GEXdg09TF1LAomvWIL8ggdT/pvyxueg/Fokste1nmDQN 8ok2cbm8dXxcSKqkCZPwjA8EaF9/JtkFayeaUBs7uMJkVUQhLrHZJY1SFahHRAAMvQnf 3C9m3K8X6eyc0+xvpSyOjG2NQAhjBDtxvzGLQvpyFeBA7xOo21vjuLVEjOvthtF/sYvu iKuA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=TWcBGWXT; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b59-v6si1191682plb.354.2018.02.22.20.59.00; Thu, 22 Feb 2018 20:59:00 -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=@nifty.com header.s=dec2015msa header.b=TWcBGWXT; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751507AbeBWE6t (ORCPT + 28 others); Thu, 22 Feb 2018 23:58:49 -0500 Received: from conuserg-12.nifty.com ([210.131.2.79]:26797 "EHLO conuserg-12.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751296AbeBWE6r (ORCPT ); Thu, 22 Feb 2018 23:58:47 -0500 Received: from pug.e01.socionext.com (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-12.nifty.com with ESMTP id w1N4uwWB024939; Fri, 23 Feb 2018 13:57:00 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-12.nifty.com w1N4uwWB024939 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1519361820; bh=c94CzZXaICBETuLbyrkOPLALL6MwXImEuVsXqRc+Yns=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TWcBGWXT4wmYUliJIw1PJSgdsuAoy90TwyidLp6STTp1tsQWE2M/fR8HtyprJoc+l 7B1JPoOzQPbHbLWQX1WBICJovv04i0Q3UcesRGfJmjsA4Ittzp4C1N0vwpsJPn73yw be3W29n1Z4x5W9LhvjhckyEXwI3Xvv37rwod8rcowqhia313DlB2Pc9qxkwwlp+Sb2 dJ3Twmvjsn+HiFFVJ8s9adaX7sao0LTVTwiEi7QvYR8yA5DNLA/6Mg7rPn/4uQH8nq gFG0clOl74Tm/8QXi3w5im8YTG68RDXU8/VuoQO6ncClzZx9hImvp8/cydsTvpImSA /mZE9hqwvy8Cw== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Arnd Bergmann , Sam Ravnborg , Nick Desaulniers , Matthias Kaehlcke , Masahiro Yamada , Cao jin , Mark Charlebois , Michael Forney , linux-kernel@vger.kernel.org, Douglas Anderson , Josh Poimboeuf , Ingo Molnar Subject: [PATCH 2/2] kbuild: simplify ld-option implementation Date: Fri, 23 Feb 2018 13:56:53 +0900 Message-Id: <1519361813-8553-2-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1519361813-8553-1-git-send-email-yamada.masahiro@socionext.com> References: <1519361813-8553-1-git-send-email-yamada.masahiro@socionext.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Currently, linker options are tested by the coordination of $(CC) and $(LD) because LD needs some object to link. As commit 86a9df597cdd ("kbuild: fix linker feature test macros when cross compiling with Clang") addressed, we need to make sure $(CC) and $(LD) agree the underlying architecture of the passed object. This could be a bit complex when we combine tools from different groups. For example, we can use clang for $(CC), but we still need to rely on GCC toolchain for $(LD). So, I was searching a way for standalone testing of linker options. A trick I found is to use '-v'. This prints the version string, but also tests if the given option is recognized. If a given option is supported, $ aarch64-linux-gnu-ld -v --fix-cortex-a53-843419 GNU ld (Linaro_Binutils-2017.11) 2.28.2.20170706 $ echo $? 0 If unsupported, $ aarch64-linux-gnu-ld -v --fix-cortex-a53-843419 GNU ld (crosstool-NG linaro-1.13.1-4.7-2013.04-20130415 - Linaro GCC 2013.04) 2.23.1 aarch64-linux-gnu-ld: unrecognized option '--fix-cortex-a53-843419' aarch64-linux-gnu-ld: use the --help option for usage information $ echo $? 1 Gold works likewise. $ aarch64-linux-gnu-ld.gold -v --fix-cortex-a53-843419 GNU gold (Linaro_Binutils-2017.11 2.28.2.20170706) 1.14 masahiro@pug:~/ref/linux$ echo $? 0 $ aarch64-linux-gnu-ld.gold -v --fix-cortex-a53-999999 GNU gold (Linaro_Binutils-2017.11 2.28.2.20170706) 1.14 aarch64-linux-gnu-ld.gold: --fix-cortex-a53-999999: unknown option aarch64-linux-gnu-ld.gold: use the --help option for usage information $ echo $? 1 LLD too. $ ld.lld -v --gc-sections LLD 7.0.0 (http://llvm.org/git/lld.git 4a0e4190e74cea19f8a8dc625ccaebdf8b5d1585) (compatible with GNU linkers) $ echo $? 0 $ ld.lld -v --fix-cortex-a53-843419 LLD 7.0.0 (http://llvm.org/git/lld.git 4a0e4190e74cea19f8a8dc625ccaebdf8b5d1585) (compatible with GNU linkers) $ echo $? 0 $ ld.lld -v --fix-cortex-a53-999999 ld.lld: error: unknown argument: --fix-cortex-a53-999999 LLD 7.0.0 (http://llvm.org/git/lld.git 4a0e4190e74cea19f8a8dc625ccaebdf8b5d1585) (compatible with GNU linkers) $ echo $? 1 Signed-off-by: Masahiro Yamada --- scripts/Kbuild.include | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) -- 2.7.4 Signed-off-by: Nick Desaulniers Tested-by: Nick Desaulniers diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include index 34cbd81..f9c2f07 100644 --- a/scripts/Kbuild.include +++ b/scripts/Kbuild.include @@ -237,9 +237,7 @@ cc-ldoption = $(call try-run-cached,\ # ld-option # Usage: LDFLAGS += $(call ld-option, -X) -ld-option = $(call try-run-cached,\ - $(CC) $(KBUILD_CPPFLAGS) $(CC_OPTION_CFLAGS) -x c /dev/null -c -o "$$TMPO"; \ - $(LD) $(LDFLAGS) $(1) "$$TMPO" -o "$$TMP",$(1),$(2)) +ld-option = $(call try-run-cached, $(LD) $(LDFLAGS) $(1) -v,$(1),$(2)) # ar-option # Usage: KBUILD_ARFLAGS := $(call ar-option,D)