kbuild: remove TMPO from try-run
Subsystems (10)
PATCH 1/2 kbuild: remove TMPO from try-run
TMPO is only used by arch/x86/Makefile.
Change arch/x86/Makefile to use $$TMPO.o and remove TMPO from scripts/Makefile.compiler.
---
arch/x86/Makefile | 4 ++-- scripts/Makefile.compiler | 1 - 2 files changed, 2 insertions(+), 3 deletions(-)
arch/x86/Makefile +2 -2
@@ -129,8 +129,8 @@ ifdef CONFIG_X86_X32 x32_ld_ok := $(call try-run,\ /bin/echo -e '1: .quad 1b' | \ $(CC) $(KBUILD_AFLAGS) -c -x assembler -o "$$TMP" - && \ - $(OBJCOPY) -O elf32-x86-64 "$$TMP" "$$TMPO" && \ - $(LD) -m elf32_x86_64 "$$TMPO" -o "$$TMP",y,n) + $(OBJCOPY) -O elf32-x86-64 "$$TMP" "$$TMP.o" && \ + $(LD) -m elf32_x86_64 "$$TMP.o" -o "$$TMP",y,n) ifeq ($(x32_ld_ok),y) CONFIG_X86_X32_ABI := y KBUILD_AFLAGS += -DCONFIG_X86_X32_ABI
scripts/Makefile.compiler +0 -1
@@ -21,7 +21,6 @@ TMPOUT = $(if $(KBUILD_EXTMOD),$(firstword $(KBUILD_EXTMOD))/).tmp_$$$$ # automatically cleaned up. try-run = $(shell set -e; \ TMP=$(TMPOUT)/tmp; \ - TMPO=$(TMPOUT)/tmp.o; \ mkdir -p $(TMPOUT); \ trap "rm -rf $(TMPOUT)" EXIT; \ if ($(1)) >/dev/null 2>&1; \
Signature · 1 line
2.27.0
PATCH 2/2 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 to do 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 want there, and stop including scripts/Kbuild.include from the tool Makefiles.
---
tools/testing/selftests/bpf/Makefile | 3 ++- tools/testing/selftests/kvm/Makefile | 12 +++++++++++- .../selftests/powerpc/pmu/ebb/Makefile | 11 ++++++++++- tools/thermal/tmon/Makefile | 19 +++++++++++++++++-- 4 files changed, 40 insertions(+), 5 deletions(-)
tools/testing/selftests/bpf/Makefile +2 -1
@@ -1,5 +1,4 @@ # SPDX-License-Identifier: GPL-2.0 -include ../../../../scripts/Kbuild.include include ../../../scripts/Makefile.arch include ../../../scripts/Makefile.include
@@ -476,3 +475,5 @@ EXTRA_CLEAN := $(TEST_CUSTOM_PROGS) $(SCRATCH_DIR) $(HOST_SCRATCH_DIR) \ prog_tests/tests.h map_tests/tests.h verifier/tests.h \ feature \ $(addprefix $(OUTPUT)/,*.o *.skel.h no_alu32 bpf_gcc bpf_testmod.ko) + +.DELETE_ON_ERROR:
tools/testing/selftests/kvm/Makefile +11 -1
@@ -1,5 +1,15 @@ # SPDX-License-Identifier: GPL-2.0-only -include ../../../../scripts/Kbuild.include + +TMPOUT = .tmp_$$$$ + +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) all:
tools/testing/selftests/powerpc/pmu/ebb/Makefile +10 -1
@@ -1,5 +1,4 @@ # SPDX-License-Identifier: GPL-2.0 -include ../../../../../../scripts/Kbuild.include noarg: $(MAKE) -C ../../
@@ -8,6 +7,16 @@ noarg: CFLAGS += -m64 TMPOUT = $(OUTPUT)/TMPDIR/ + +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) + # Toolchains may build PIE by default which breaks the assembly no-pie-option := $(call try-run, echo 'int main() { return 0; }' | \ $(CC) -Werror $(KBUILD_CPPFLAGS) $(CC_OPTION_CFLAGS) -no-pie -x c - -o "$$TMP", -no-pie)
tools/thermal/tmon/Makefile +17 -2
@@ -1,6 +1,21 @@ # SPDX-License-Identifier: GPL-2.0 -# We need this for the "cc-option" macro. -include ../../../scripts/Kbuild.include + +TMPOUT = .tmp_$$$$ + +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 = $(call try-run,\ + $(1) -Werror $(2) $(3) -c -x c /dev/null -o "$$TMP",$(3),$(4)) + +cc-option = $(call __cc-option, $(CC),\ + $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS),$(1),$(2)) VERSION = 1.0
Signature · 1 line
2.27.0
Paolo Bonzini
maintainerRe: [PATCH 2/2] tools: do not include scripts/Kbuild.include
Quoted 24 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 to do 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.
Quoted 7 lines
- Commit
0695f8bca93e("selftests/powerpc: HandleMakefilefor unrecognized option") includedscripts/Kbuild.includefromtools/testing/selftests/powerpc/pmu/ebb/Makefileto import the try-run macro.Copy what they want there, and stop including
scripts/Kbuild.includefrom the tool Makefiles.
I think it would make sense to add try-run, cc-option and .DELETE_ON_ERROR to tools/build/Build.include?
Paolo
Quoted 106 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]>---
tools/testing/selftests/bpf/Makefile | 3 ++- tools/testing/selftests/kvm/Makefile | 12 +++++++++++- .../selftests/powerpc/pmu/ebb/Makefile | 11 ++++++++++- tools/thermal/tmon/Makefile | 19 +++++++++++++++++-- 4 files changed, 40 insertions(+), 5 deletions(-)tools/testing/selftests/bpf/Makefile +2
-1@@ -1,5 +1,4 @@ # SPDX-License-Identifier: GPL-2.0 -include ../../../../scripts/Kbuild.include include ../../../scripts/Makefile.arch include ../../../scripts/Makefile.include@@ -476,3 +475,5 @@ EXTRA_CLEAN := $(TEST_CUSTOM_PROGS) $(SCRATCH_DIR) $(HOST_SCRATCH_DIR) \ prog_tests/tests.h map_tests/tests.h verifier/tests.h \ feature \ $(addprefix $(OUTPUT)/,*.o *.skel.h no_alu32 bpf_gcc bpf_testmod.ko) + +.DELETE_ON_ERROR:tools/testing/selftests/kvm/Makefile +11
-1@@ -1,5 +1,15 @@ # SPDX-License-Identifier: GPL-2.0-only -include ../../../../scripts/Kbuild.include + +TMPOUT = .tmp_$$$$ + +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) all:tools/testing/selftests/powerpc/pmu/ebb/Makefile +10
-1@@ -1,5 +1,4 @@ # SPDX-License-Identifier: GPL-2.0 -include ../../../../../../scripts/Kbuild.include noarg: $(MAKE) -C ../../@@ -8,6 +7,16 @@ noarg: CFLAGS += -m64 TMPOUT = $(OUTPUT)/TMPDIR/ + +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) + # Toolchains may build PIE by default which breaks the assembly no-pie-option := $(call try-run, echo 'int main() { return 0; }' | \ $(CC) -Werror $(KBUILD_CPPFLAGS) $(CC_OPTION_CFLAGS) -no-pie -x c - -o "$$TMP", -no-pie)tools/thermal/tmon/Makefile +17
-2@@ -1,6 +1,21 @@ # SPDX-License-Identifier: GPL-2.0 -# We need this for the "cc-option" macro. -include ../../../scripts/Kbuild.include + +TMPOUT = .tmp_$$$$ + +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 = $(call try-run,\ + $(1) -Werror $(2) $(3) -c -x c /dev/null -o "$$TMP",$(3),$(4)) + +cc-option = $(call __cc-option, $(CC),\ + $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS),$(1),$(2)) VERSION = 1.0
Re: [PATCH 2/2] tools: do not include scripts/Kbuild.include
Quoted 31 lines · Paolo Bonzini
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 to do 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 5 lines
Quoted 2 lines
Copy what they want there, and stop including
scripts/Kbuild.includefrom the tool Makefiles.I think it would make sense to add try-run, cc-option and .DELETE_ON_ERROR to
tools/build/Build.include?
To be safe, I just copy-pasted what the makefiles need. If someone wants to refactor the tool build system, that is fine, but, to me, I do not see consistent rules or policy under tools/.
Signature · 2 lines
Best Regards Masahiro Yamada
Paolo Bonzini
maintainerRe: [PATCH 2/2] tools: do not include scripts/Kbuild.include
Quoted 7 lines · Masahiro Yamada
Quoted 2 lines · Paolo Bonzini
I think it would make sense to add try-run, cc-option and .DELETE_ON_ERROR to
tools/build/Build.include?To be safe, I just copy-pasted what the makefiles need. If someone wants to refactor the tool build system, that is fine, but, to me, I do not see consistent rules or policy under
tools/.
"Please put this in a common file instead of introducing duplication" is not asking for wholesale refactoring.
Paolo
Re: [PATCH 2/2] tools: do not include scripts/Kbuild.include
In reply to Masahiro YamadaQuoted 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 to do 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 want there, and stop including
scripts/Kbuild.includefrom the tool Makefiles.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]>
When applying this on top of d9f4ff50d2aa ("kbuild: spilt cc-option and friends to scripts/Makefile.compiler")
I still do get
# ==== Test Assertion Failure ====
# lib/kvm_util.c:142: vm->fd >= 0
# pid=315635 tid=315635 - Invalid argument
# 1 0x0000000001002f4b: vm_open at kvm_util.c:142 # 2 (inlined by) vm_create at kvm_util.c:258 # 3 0x00000000010015ef: test_add_max_memory_regions at set_memory_region_test.c:351 # 4 (inlined by) main at set_memory_region_test.c:397 # 5 0x000003ff971abb89: ?? ??:0 # 6 0x00000000010017ad: .annobin_abi_note.c.hot at crt1.o:?
# KVM_CREATE_VM ioctl failed, rc: -1 errno: 22
not ok 7 selftests: kvm: set_memory_region_test # exit=254
and the testcase compilation does not pickup the pgste option.
Re: [PATCH 2/2] tools: do not include scripts/Kbuild.include
Quoted 56 lines · Christian Borntraeger
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 to do 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 want there, and stop including
scripts/Kbuild.includefrom the tool Makefiles.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]>When applying this on top of
d9f4ff50d2aa("kbuild: spilt cc-option and friends toscripts/Makefile.compiler")I still do get
# ==== Test Assertion Failure ====
#lib/kvm_util.c:142:vm->fd>= 0
# pid=315635 tid=315635 - Invalid argument
# 10x0000000001002f4b:vm_openat kvm_util.c:142
# 2 (inlined by)vm_createat kvm_util.c:258
# 30x00000000010015ef:test_add_max_memory_regionsat set_memory_region_test.c:351 # 4 (inlined by) main at set_memory_region_test.c:397
# 50x000003ff971abb89: ?? ??:0
# 60x00000000010017ad: .annobin_abi_note.c.hot at crt1.o:?
#KVM_CREATE_VMioctl failed, rc: -1 errno: 22
not ok 7 selftests: kvm:set_memory_region_test# exit=254
Quoted 1 line
and the testcase compilation does not pickup the pgste option.
What does work is the following:
tools/testing/selftests/kvm/Makefile +1 -0
@@ -1,5 +1,6 @@ # SPDX-License-Identifier: GPL-2.0-only include ../../../../scripts/Kbuild.include +include ../../../../scripts/Makefile.compiler all:
as it does pickup the linker option handling.
Re: [PATCH 2/2] tools: do not include scripts/Kbuild.include
Quoted 74 lines · Christian Borntraeger
Quoted 53 lines · Christian Borntraeger
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 to do 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 want there, and stop including
scripts/Kbuild.includefrom the tool Makefiles.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]>When applying this on top of
d9f4ff50d2aa("kbuild: spilt cc-option and friends toscripts/Makefile.compiler")I still do get
# ==== Test Assertion Failure ====
#lib/kvm_util.c:142:vm->fd>= 0
# pid=315635 tid=315635 - Invalid argument# 1 0x0000000001002f4b: vm_open at kvm_util.c:142 # 2 (inlined by) vm_create at kvm_util.c:258 # 3 0x00000000010015ef: test_add_max_memory_regions at set_memory_region_test.c:351 # 4 (inlined by) main at set_memory_region_test.c:397 # 5 0x000003ff971abb89: ?? ??:0 # 6 0x00000000010017ad: .annobin_abi_note.c.hot at crt1.o:?Quoted 4 lines
#
KVM_CREATE_VMioctl failed, rc: -1 errno: 22
not ok 7 selftests: kvm:set_memory_region_test# exit=254and the testcase compilation does not pickup the pgste option.
What does work is the following:
tools/testing/selftests/kvm/Makefile +1
-0@@ -1,5 +1,6 @@ # SPDX-License-Identifier: GPL-2.0-only include ../../../../scripts/Kbuild.include +include ../../../../scripts/Makefile.compiler all:
Quoted 1 line
as it does pickup the linker option handling.
Kbuild and the tools are divorced.
They cannot be married unless the tools/ build system is largely refactored. That will be a tons of works (and I am not sure if it is welcome).
The Kbuild refactoring should not be bothered by the tools.
For now, I want them separated from each other.
--
Best Regards
Masahiro Yamada