tools: do not include scripts/Kbuild.include
Subsystems (9)
PATCH v2 1/1 tools: do not include scripts/Kbuild.include
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.
---
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(-)
tools/build/Build.include +24 -0
@@ -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:
tools/testing/selftests/bpf/Makefile +1 -1
@@ -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
tools/testing/selftests/kvm/Makefile +1 -1
@@ -1,5 +1,5 @@ # SPDX-License-Identifier: GPL-2.0-only -include ../../../../scripts/Kbuild.include +include ../../../build/Build.include all:
tools/testing/selftests/powerpc/pmu/ebb/Makefile +1 -1
@@ -1,5 +1,5 @@ # SPDX-License-Identifier: GPL-2.0 -include ../../../../../../scripts/Kbuild.include +include ../../../../../build/Build.include noarg: $(MAKE) -C ../../
tools/thermal/tmon/Makefile +1 -1
@@ -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
Signature · 1 line
2.27.0
Quoted 29 lines · Masahiro Yamada
Since commit
d9f4ff50d2aa("kbuild: spilt cc-option and friends toscripts/Makefile.compiler"), some kselftests fail to build.The
tools/directory opted outKbuild, and went in a different direction. They copy any kind of files to thetools/directory in order to do whatever they want in their world.
tools/build/Build.includemimicsscripts/Kbuild.include, but some tool Makefiles included theKbuildone to import a feature that is missing intools/build/Build.include:- Commit
ec04aa3ae87b("tools/thermal: tmon: use "-fstack-protector" only if supported") includedscripts/Kbuild.includefromtools/thermal/tmon/Makefileto import the cc-option macro.- Commit
c2390f16fc5b("selftests: kvm: fix for compilers that do not support -no-pie") includedscripts/Kbuild.includefromtools/testing/selftests/kvm/Makefileto import the try-run macro.- Commit
9cae4ace80ef("selftests/bpf: do not ignore clang failures") includedscripts/Kbuild.includefromtools/testing/selftests/bpf/Makefileto import the .DELETE_ON_ERROR target.- Commit
0695f8bca93e("selftests/powerpc: HandleMakefilefor unrecognized option") includedscripts/Kbuild.includefromtools/testing/selftests/powerpc/pmu/ebb/Makefileto import the try-run macro.
Quoted 8 lines
Copy what they need into
tools/build/Build.include, and make them include it instead ofscripts/Kbuild.include.Fixes d9f4ff50d2aa ("kbuild: spilt cc-option and friends to scripts/Makefile.compiler")Reported-by Janosch Frank <[email protected]>Reported-by Christian Borntraeger <[email protected]>Signed-off-by Masahiro Yamada <[email protected]>
looks better.
Paolo Bonzini
maintainerQuoted 37 lines · Christian Borntraeger
Quoted 34 lines · Masahiro Yamada
Since commit
d9f4ff50d2aa("kbuild: spilt cc-option and friends toscripts/Makefile.compiler"), some kselftests fail to build.The
tools/directory opted outKbuild, and went in a different direction. They copy any kind of files to thetools/directory in order to do whatever they want in their world.
tools/build/Build.includemimicsscripts/Kbuild.include, but some tool Makefiles included theKbuildone to import a feature that is missing intools/build/Build.include:- Commit
ec04aa3ae87b("tools/thermal: tmon: use "-fstack-protector" only if supported") includedscripts/Kbuild.includefromtools/thermal/tmon/Makefileto import the cc-option macro.- Commit
c2390f16fc5b("selftests: kvm: fix for compilers that do not support -no-pie") includedscripts/Kbuild.includefromtools/testing/selftests/kvm/Makefileto import the try-run macro.- Commit
9cae4ace80ef("selftests/bpf: do not ignore clang failures") includedscripts/Kbuild.includefromtools/testing/selftests/bpf/Makefileto import the .DELETE_ON_ERROR target.- Commit
0695f8bca93e("selftests/powerpc: HandleMakefilefor unrecognized option") includedscripts/Kbuild.includefromtools/testing/selftests/powerpc/pmu/ebb/Makefileto import the try-run macro.Copy what they need into
tools/build/Build.include, and make them include it instead ofscripts/Kbuild.include.
Quoted 8 lines
Quoted 4 lines
Fixes d9f4ff50d2aa ("kbuild: spilt cc-option and friends to scripts/Makefile.compiler")Reported-by Janosch Frank <[email protected]>Reported-by Christian Borntraeger <[email protected]>Signed-off-by Masahiro Yamada <[email protected]>looks better.
Thank you very much Masahiro, this look great.
Paolo
Quoted 29 lines · Masahiro Yamada
Since commit
d9f4ff50d2aa("kbuild: spilt cc-option and friends toscripts/Makefile.compiler"), some kselftests fail to build.The
tools/directory opted outKbuild, and went in a different direction. They copy any kind of files to thetools/directory in order to do whatever they want in their world.
tools/build/Build.includemimicsscripts/Kbuild.include, but some tool Makefiles included theKbuildone to import a feature that is missing intools/build/Build.include:- Commit
ec04aa3ae87b("tools/thermal: tmon: use "-fstack-protector" only if supported") includedscripts/Kbuild.includefromtools/thermal/tmon/Makefileto import the cc-option macro.- Commit
c2390f16fc5b("selftests: kvm: fix for compilers that do not support -no-pie") includedscripts/Kbuild.includefromtools/testing/selftests/kvm/Makefileto import the try-run macro.- Commit
9cae4ace80ef("selftests/bpf: do not ignore clang failures") includedscripts/Kbuild.includefromtools/testing/selftests/bpf/Makefileto import the .DELETE_ON_ERROR target.- Commit
0695f8bca93e("selftests/powerpc: HandleMakefilefor unrecognized option") includedscripts/Kbuild.includefromtools/testing/selftests/powerpc/pmu/ebb/Makefileto import the try-run macro.
Quoted 8 lines
Copy what they need into
tools/build/Build.include, and make them include it instead ofscripts/Kbuild.include.Fixes d9f4ff50d2aa ("kbuild: spilt cc-option and friends to scripts/Makefile.compiler")Reported-by Janosch Frank <[email protected]>Reported-by Christian Borntraeger <[email protected]>Signed-off-by Masahiro Yamada <[email protected]>
LGTM although I see some tools Makefile directly added ".DELETE_ON_ERROR:" in their Makefile.
Quoted 30 lines · Masahiro Yamada
Since commit
d9f4ff50d2aa("kbuild: spilt cc-option and friends toscripts/Makefile.compiler"), some kselftests fail to build.The
tools/directory opted outKbuild, and went in a different direction. They copy any kind of files to thetools/directory in order to do whatever they want in their world.
tools/build/Build.includemimicsscripts/Kbuild.include, but some tool Makefiles included theKbuildone to import a feature that is missing intools/build/Build.include:- Commit
ec04aa3ae87b("tools/thermal: tmon: use "-fstack-protector" only if supported") includedscripts/Kbuild.includefromtools/thermal/tmon/Makefileto import the cc-option macro.- Commit
c2390f16fc5b("selftests: kvm: fix for compilers that do not support -no-pie") includedscripts/Kbuild.includefromtools/testing/selftests/kvm/Makefileto import the try-run macro.- Commit
9cae4ace80ef("selftests/bpf: do not ignore clang failures") includedscripts/Kbuild.includefromtools/testing/selftests/bpf/Makefileto import the .DELETE_ON_ERROR target.- Commit
0695f8bca93e("selftests/powerpc: HandleMakefilefor unrecognized option") includedscripts/Kbuild.includefromtools/testing/selftests/powerpc/pmu/ebb/Makefileto import the try-run macro.
Quoted 8 lines
Copy what they need into
tools/build/Build.include, and make them include it instead ofscripts/Kbuild.include.Fixes d9f4ff50d2aa ("kbuild: spilt cc-option and friends to scripts/Makefile.compiler")Reported-by Janosch Frank <[email protected]>Reported-by Christian Borntraeger <[email protected]>Signed-off-by Masahiro Yamada <[email protected]>
Applied to linux-kbuild.
Quoted 96 lines
---
Changes in v2:
- copy macros totools/build/BUild.includetools/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(-)tools/build/Build.include +24
-0@@ -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:tools/testing/selftests/bpf/Makefile +1
-1@@ -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.includetools/testing/selftests/kvm/Makefile +1
-1@@ -1,5 +1,5 @@ # SPDX-License-Identifier: GPL-2.0-only -include ../../../../scripts/Kbuild.include +include ../../../build/Build.include all:tools/testing/selftests/powerpc/pmu/ebb/Makefile +1
-1@@ -1,5 +1,5 @@ # SPDX-License-Identifier: GPL-2.0 -include ../../../../../../scripts/Kbuild.include +include ../../../../../build/Build.include noarg: $(MAKE) -C ../../tools/thermal/tmon/Makefile +1
-2@@ -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
--
You received this message because you are subscribed to the Google Groups "Clang Built Linux" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/clang-built-linux/20210416130051.239782-1-masahiroy%40kernel.org.
Signature · 2 lines
Best Regards Masahiro Yamada