Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp297753pxb; Fri, 16 Apr 2021 06:05:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwjQO/yhTahSriHv4KV+LIu/McK5U2atMHQZKOX87MDd9QtV+lnY4Vg08WvASg8MowYc19g X-Received: by 2002:aa7:824e:0:b029:20a:3a1:eeda with SMTP id e14-20020aa7824e0000b029020a03a1eedamr7749770pfn.71.1618578325145; Fri, 16 Apr 2021 06:05:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618578325; cv=none; d=google.com; s=arc-20160816; b=NM0qP/v0ftAv4rbXgVOZvKRORr1df50PKhZvad/dUdf0ozHaDBAUN6l7LAIvUwd7Vc a//d2Z9XWOko/8xR82Qv3RzWtk2dyIcDNfJP5MypAOKFqx0Kzw2VAyJ8r22WtxkY6KRe HoKREN+9rdCFIPLN40HLmvqXPgt+C/yOmnhGMh+2Lpsoh+b8q5TRMT1iFy3VYlcNa/ot py67WuTncy9DdzrzmqbWjqGoc5hukXag5U6lqpjECfEyTurwTTWu7VxUzjMcMh7YtGwf m6X+m3RTVbOIndl2r14m8lNMihaPQp2I2y1MxoFNtXR+dl0Kf1lZEWhpiJqSYuoZY6KF Wuxw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature:dkim-filter; bh=Bj3vmQYuw6AVeyGMQICNThf6rcoOcN89RQenb/sBZqc=; b=06kfZf9SYhRi08jCLLM9XgDw5ZlbXEXi4M7AyaFgLqFXcAjHncBHKodTEMTQ+NdlNf AcLJRwoMuSndeSZJAj4E2roZ98mi0pH2ZN5OVd6ZPFZntRnwOmuuWoU9//CjpuwoFvct w9Io6eXgiIGgoTzCTjR6FenbsaUK1o8eqjznpCXv/eRdBhqzuqRenbo41sRIIybVNg/j RF/gj9phgXu18UfJixe2kqYEtj6KRGxfkKF52yufEpPKWKs5ECqOmlWvxtSVMABlLOZb nSnZadOe550TNkaLSeqejYWURLuek8TBqQUAUuFxJ8VbB7Kk7CLtgACfKnyA4hyuPyJl UW7A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=cohJ7HYO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u10si2168878plz.247.2021.04.16.06.05.11; Fri, 16 Apr 2021 06:05:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=cohJ7HYO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235599AbhDPNET (ORCPT + 99 others); Fri, 16 Apr 2021 09:04:19 -0400 Received: from conuserg-10.nifty.com ([210.131.2.77]:62731 "EHLO conuserg-10.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234291AbhDPNEG (ORCPT ); Fri, 16 Apr 2021 09:04:06 -0400 Received: from localhost.localdomain (133-32-232-101.west.xps.vectant.ne.jp [133.32.232.101]) (authenticated) by conuserg-10.nifty.com with ESMTP id 13GD0vCC002141; Fri, 16 Apr 2021 22:00:57 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-10.nifty.com 13GD0vCC002141 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1618578059; bh=Bj3vmQYuw6AVeyGMQICNThf6rcoOcN89RQenb/sBZqc=; h=From:To:Cc:Subject:Date:From; b=cohJ7HYOsMdZ1GxI+GPzxKdV6N29fjrZk2jG+NGNstD314tHgEbG1QBPeqxMrUsyr 7++2XZI+7lWdwgeNa4be4MW81jDO6eWRJk3EhPU7BoQ2Q9u4UoAU1Na4K+ouH8aBwq r3bvf4X+WQ10oGdloNZbFLbtpcbX6iHUXuvbbfcH6til8Qc1zsKomaY8HoWwPcfR4o bDrOpsyGuwxcIwnHtNyaiZKvlc7CU1DMChm0gv/vpRVwRclMie2D0YSh3JvTEEg6rp muPa6be/33bZI1soC0khkf0soRvW3ohefQLjYRjiDLNIkcMn8UCpEPn6Z507ju6Ys7 mMSBmrcjdC8Tw== X-Nifty-SrcIP: [133.32.232.101] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Janosch Frank , Christian Borntraeger , Masahiro Yamada , Alexei Starovoitov , Andrii Nakryiko , Benjamin Herrenschmidt , Daniel Borkmann , John Fastabend , KP Singh , Martin KaFai Lau , Michael Ellerman , Nathan Chancellor , Nick Desaulniers , Paolo Bonzini , Paul Mackerras , Shuah Khan , Song Liu , Yonghong Song , bpf@vger.kernel.org, clang-built-linux@googlegroups.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, netdev@vger.kernel.org Subject: [PATCH v2] tools: do not include scripts/Kbuild.include Date: Fri, 16 Apr 2021 22:00:51 +0900 Message-Id: <20210416130051.239782-1-masahiroy@kernel.org> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Since commit d9f4ff50d2aa ("kbuild: spilt cc-option and friends to scripts/Makefile.compiler"), some kselftests fail to build. The tools/ directory opted out Kbuild, and went in a different direction. They copy any kind of files to the tools/ directory in order to do whatever they want in their world. tools/build/Build.include mimics scripts/Kbuild.include, but some tool Makefiles included the Kbuild one to import a feature that is missing in tools/build/Build.include: - Commit ec04aa3ae87b ("tools/thermal: tmon: use "-fstack-protector" only if supported") included scripts/Kbuild.include from tools/thermal/tmon/Makefile to import the cc-option macro. - Commit c2390f16fc5b ("selftests: kvm: fix for compilers that do not support -no-pie") included scripts/Kbuild.include from tools/testing/selftests/kvm/Makefile to import the try-run macro. - Commit 9cae4ace80ef ("selftests/bpf: do not ignore clang failures") included scripts/Kbuild.include from tools/testing/selftests/bpf/Makefile to import the .DELETE_ON_ERROR target. - Commit 0695f8bca93e ("selftests/powerpc: Handle Makefile for unrecognized option") included scripts/Kbuild.include from tools/testing/selftests/powerpc/pmu/ebb/Makefile to import the try-run macro. Copy what they need into tools/build/Build.include, and make them include it instead of scripts/Kbuild.include. Link: https://lore.kernel.org/lkml/86dadf33-70f7-a5ac-cb8c-64966d2f45a1@linux.ibm.com/ Fixes: d9f4ff50d2aa ("kbuild: spilt cc-option and friends to scripts/Makefile.compiler") Reported-by: Janosch Frank Reported-by: Christian Borntraeger Signed-off-by: Masahiro Yamada --- Changes in v2: - copy macros to tools/build/BUild.include tools/build/Build.include | 24 +++++++++++++++++++ tools/testing/selftests/bpf/Makefile | 2 +- tools/testing/selftests/kvm/Makefile | 2 +- .../selftests/powerpc/pmu/ebb/Makefile | 2 +- tools/thermal/tmon/Makefile | 2 +- 5 files changed, 28 insertions(+), 4 deletions(-) diff --git a/tools/build/Build.include b/tools/build/Build.include index 585486e40995..2cf3b1bde86e 100644 --- a/tools/build/Build.include +++ b/tools/build/Build.include @@ -100,3 +100,27 @@ cxx_flags = -Wp,-MD,$(depfile) -Wp,-MT,$@ $(CXXFLAGS) -D"BUILD_STR(s)=\#s" $(CXX ## HOSTCC C flags host_c_flags = -Wp,-MD,$(depfile) -Wp,-MT,$@ $(KBUILD_HOSTCFLAGS) -D"BUILD_STR(s)=\#s" $(HOSTCFLAGS_$(basetarget).o) $(HOSTCFLAGS_$(obj)) + +# output directory for tests below +TMPOUT = .tmp_$$$$ + +# try-run +# Usage: option = $(call try-run, $(CC)...-o "$$TMP",option-ok,otherwise) +# Exit code chooses option. "$$TMP" serves as a temporary file and is +# automatically cleaned up. +try-run = $(shell set -e; \ + TMP=$(TMPOUT)/tmp; \ + mkdir -p $(TMPOUT); \ + trap "rm -rf $(TMPOUT)" EXIT; \ + if ($(1)) >/dev/null 2>&1; \ + then echo "$(2)"; \ + else echo "$(3)"; \ + fi) + +# cc-option +# Usage: cflags-y += $(call cc-option,-march=winchip-c6,-march=i586) +cc-option = $(call try-run, \ + $(CC) -Werror $(1) -c -x c /dev/null -o "$$TMP",$(1),$(2)) + +# delete partially updated (i.e. corrupted) files on error +.DELETE_ON_ERROR: diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile index 044bfdcf5b74..17a5cdf48d37 100644 --- a/tools/testing/selftests/bpf/Makefile +++ b/tools/testing/selftests/bpf/Makefile @@ -1,5 +1,5 @@ # SPDX-License-Identifier: GPL-2.0 -include ../../../../scripts/Kbuild.include +include ../../../build/Build.include include ../../../scripts/Makefile.arch include ../../../scripts/Makefile.include diff --git a/tools/testing/selftests/kvm/Makefile b/tools/testing/selftests/kvm/Makefile index a6d61f451f88..5ef141f265bd 100644 --- a/tools/testing/selftests/kvm/Makefile +++ b/tools/testing/selftests/kvm/Makefile @@ -1,5 +1,5 @@ # SPDX-License-Identifier: GPL-2.0-only -include ../../../../scripts/Kbuild.include +include ../../../build/Build.include all: diff --git a/tools/testing/selftests/powerpc/pmu/ebb/Makefile b/tools/testing/selftests/powerpc/pmu/ebb/Makefile index af3df79d8163..c5ecb4634094 100644 --- a/tools/testing/selftests/powerpc/pmu/ebb/Makefile +++ b/tools/testing/selftests/powerpc/pmu/ebb/Makefile @@ -1,5 +1,5 @@ # SPDX-License-Identifier: GPL-2.0 -include ../../../../../../scripts/Kbuild.include +include ../../../../../build/Build.include noarg: $(MAKE) -C ../../ diff --git a/tools/thermal/tmon/Makefile b/tools/thermal/tmon/Makefile index 59e417ec3e13..9db867df7679 100644 --- a/tools/thermal/tmon/Makefile +++ b/tools/thermal/tmon/Makefile @@ -1,6 +1,6 @@ # SPDX-License-Identifier: GPL-2.0 # We need this for the "cc-option" macro. -include ../../../scripts/Kbuild.include +include ../../build/Build.include VERSION = 1.0 -- 2.27.0