Skip to contentSkip to conversation

kbuild: add image_name to no-sync-config-targets

PATCH In review Masahiro Yamada 4 participants 11 messages Feb 28, 2021 – Apr 15, 2021

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/4 kbuild: add image_name to no-sync-config-targets

'make image_name' needs include/config/auto.conf to show the correct output because KBUILD_IMAGE depends on CONFIG options, but should not attempt to resync the configuration.

---

 Makefile | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
Makefile +2 -1
index 633d2769b6ec..c84a9311df29 100644
@@ -263,7 +263,8 @@ no-dot-config-targets := $(clean-targets) \
 			 $(version_h) headers headers_% archheaders archscripts \
 			 %asm-generic kernelversion %src-pkg dt_binding_check \
 			 outputmakefile
-no-sync-config-targets := $(no-dot-config-targets) %install kernelrelease
+no-sync-config-targets := $(no-dot-config-targets) %install kernelrelease \
+			  image_name
 single-targets := %.a %.i %.ko %.lds %.ll %.lst %.mod %.o %.s %.symtypes %/
 
 config-build	:=
Signature · 1 line
2.27.0
#1 lore raw

PATCH 2/4 kbuild: prefix $(srctree)/ to some included Makefiles

VPATH is used in Kbuild to make pattern rules to search for prerequisites in both $(objtree) and $(srctree). Some source files may not be real sources, but generated by tools such as flex, bison, perl.

In contrast, I doubt the benefit of --include-dir=$(abs_srctree) because it is always clear which Makefiles are real sources, and which are not.

So, my hope is to add $(srctree)/ prefix to all check-in Makefiles, then remove --include-dir=$(abs_srctree) flag in the future.

I am touching only some Kbuild core parts for now. Treewide fixes will be needed to achieve this goal.

---

 Makefile                     | 8 ++++----
 scripts/Makefile.asm-generic | 4 ++--
 scripts/Makefile.build       | 8 ++++----
 scripts/Makefile.clean       | 2 +-
 scripts/Makefile.dtbinst     | 2 +-
 scripts/Makefile.headersinst | 2 +-
 scripts/Makefile.modinst     | 2 +-
 scripts/Makefile.modpost     | 4 ++--
 scripts/Makefile.modsign     | 2 +-
 9 files changed, 17 insertions(+), 17 deletions(-)
Makefile +4 -4
index c84a9311df29..2253e31a6bcf 100644
@@ -338,14 +338,14 @@ __build_one_by_one:
 
 else # !mixed-build
 
-include scripts/Kbuild.include
+include $(srctree)/scripts/Kbuild.include
 
 # Read KERNELRELEASE from include/config/kernel.release (if it exists)
 KERNELRELEASE = $(shell cat include/config/kernel.release 2> /dev/null)
 KERNELVERSION = $(VERSION)$(if $(PATCHLEVEL),.$(PATCHLEVEL)$(if $(SUBLEVEL),.$(SUBLEVEL)))$(EXTRAVERSION)
 export VERSION PATCHLEVEL SUBLEVEL KERNELRELEASE KERNELVERSION
 
-include scripts/subarch.include
+include $(srctree)/scripts/subarch.include
 
 # Cross compiling and selecting different set of gcc/bin-utils
 # ---------------------------------------------------------------------------
@@ -590,7 +590,7 @@ ifdef config-build
 # Read arch specific Makefile to set KBUILD_DEFCONFIG as needed.
 # KBUILD_DEFCONFIG may point out an alternative default configuration
 # used for 'make defconfig'
-include arch/$(SRCARCH)/Makefile
+include $(srctree)/arch/$(SRCARCH)/Makefile
 export KBUILD_DEFCONFIG KBUILD_KCONFIG CC_VERSION_TEXT
 
 config: outputmakefile scripts_basic FORCE
@@ -677,7 +677,7 @@ RETPOLINE_VDSO_CFLAGS := $(call cc-option,$(RETPOLINE_VDSO_CFLAGS_GCC),$(call cc
 export RETPOLINE_CFLAGS
 export RETPOLINE_VDSO_CFLAGS
 
-include arch/$(SRCARCH)/Makefile
+include $(srctree)/arch/$(SRCARCH)/Makefile
 
 ifdef need-config
 ifdef may-sync-config
scripts/Makefile.asm-generic +2 -2
index 82ad63dcd62b..1d501c57f9ef 100644
@@ -14,10 +14,10 @@ src := $(subst /generated,,$(obj))
 
 # $(generic)/Kbuild lists mandatory-y. Exclude um since it is a special case.
 ifneq ($(SRCARCH),um)
-include $(generic)/Kbuild
+include $(srctree)/$(generic)/Kbuild
 endif
 
-include scripts/Kbuild.include
+include $(srctree)/scripts/Kbuild.include
 
 redundant := $(filter $(mandatory-y) $(generated-y), $(generic-y))
 redundant += $(foreach f, $(generic-y), $(if $(wildcard $(srctree)/$(src)/$(f)),$(f)))
scripts/Makefile.build +4 -4
index 1b6094a13034..750d6d5225af 100644
@@ -35,27 +35,27 @@ subdir-ccflags-y :=
 # Read auto.conf if it exists, otherwise ignore
 -include include/config/auto.conf
 
-include scripts/Kbuild.include
+include $(srctree)/scripts/Kbuild.include
 
 # The filename Kbuild has precedence over Makefile
 kbuild-dir := $(if $(filter /%,$(src)),$(src),$(srctree)/$(src))
 kbuild-file := $(if $(wildcard $(kbuild-dir)/Kbuild),$(kbuild-dir)/Kbuild,$(kbuild-dir)/Makefile)
 include $(kbuild-file)
 
-include scripts/Makefile.lib
+include $(srctree)/scripts/Makefile.lib
 
 # Do not include hostprogs rules unless needed.
 # $(sort ...) is used here to remove duplicated words and excessive spaces.
 hostprogs := $(sort $(hostprogs))
 ifneq ($(hostprogs),)
-include scripts/Makefile.host
+include $(srctree)/scripts/Makefile.host
 endif
 
 # Do not include userprogs rules unless needed.
 # $(sort ...) is used here to remove duplicated words and excessive spaces.
 userprogs := $(sort $(userprogs))
 ifneq ($(userprogs),)
-include scripts/Makefile.userprogs
+include $(srctree)/scripts/Makefile.userprogs
 endif
 
 ifndef obj
scripts/Makefile.clean +1 -1
index 22a8172bce1f..fd6175322470 100644
@@ -8,7 +8,7 @@ src := $(obj)
 PHONY := __clean
 __clean:
 
-include scripts/Kbuild.include
+include $(srctree)/scripts/Kbuild.include
 
 # The filename Kbuild has precedence over Makefile
 kbuild-dir := $(if $(filter /%,$(src)),$(src),$(srctree)/$(src))
scripts/Makefile.dtbinst +1 -1
index ba01f5ba2517..190d781e84f4 100644
@@ -14,7 +14,7 @@ PHONY := __dtbs_install
 __dtbs_install:
 
 include include/config/auto.conf
-include scripts/Kbuild.include
+include $(srctree)/scripts/Kbuild.include
 include $(src)/Makefile
 
 dtbs    := $(addprefix $(dst)/, $(dtb-y) $(if $(CONFIG_OF_ALL_DTBS),$(dtb-)))
scripts/Makefile.headersinst +1 -1
index 708fbd08a2c5..029d85bb0b23 100644
@@ -12,7 +12,7 @@
 PHONY := __headers
 __headers:
 
-include scripts/Kbuild.include
+include $(srctree)/scripts/Kbuild.include
 
 src := $(srctree)/$(obj)
 gen := $(objtree)/$(subst include/,include/generated/,$(obj))
scripts/Makefile.modinst +1 -1
index 5a4579e76485..ad1981233d0b 100644
@@ -6,7 +6,7 @@
 PHONY := __modinst
 __modinst:
 
-include scripts/Kbuild.include
+include $(srctree)/scripts/Kbuild.include
 
 modules := $(sort $(shell cat $(if $(KBUILD_EXTMOD),$(KBUILD_EXTMOD)/)modules.order))
 
scripts/Makefile.modpost +2 -2
index 066beffca09a..df57e259fac3 100644
@@ -41,10 +41,10 @@ PHONY := __modpost
 __modpost:
 
 include include/config/auto.conf
-include scripts/Kbuild.include
+include $(srctree)/scripts/Kbuild.include
 
 # for ld_flags
-include scripts/Makefile.lib
+include $(srctree)/scripts/Makefile.lib
 
 MODPOST = scripts/mod/modpost								\
 	$(if $(CONFIG_MODVERSIONS),-m)							\
scripts/Makefile.modsign +1 -1
index d7325cefe709..ddf9b5ca77d7 100644
@@ -6,7 +6,7 @@
 PHONY := __modsign
 __modsign:
 
-include scripts/Kbuild.include
+include $(srctree)/scripts/Kbuild.include
 
 modules := $(sort $(shell cat modules.order))
 
Signature · 1 line
2.27.0
#2 lore raw

PATCH 3/4 kbuild: spilt cc-option and friends to scripts/Makefile.compiler

In reply to Masahiro Yamada

scripts/Kbuild.include is included everywhere, but macros such as cc-option are needed by build targets only.

For example, when 'make clean' traverses the tree, it does not need to evaluate $(call cc-option,).

Split cc-option, ld-option, etc. to scripts/Makefile.compiler, which is only included from the top Makefile and scripts/Makefile.build.

---

 Makefile                  |  4 ++
 scripts/Kbuild.include    | 80 ---------------------------------------
 scripts/Makefile.build    |  1 +
 scripts/Makefile.compiler | 77 +++++++++++++++++++++++++++++++++++++
 4 files changed, 82 insertions(+), 80 deletions(-)
 create mode 100644 scripts/Makefile.compiler
Makefile +4 -0
index 2253e31a6bcf..eec7a94f5c33 100644
@@ -582,6 +582,10 @@ KBUILD_AFLAGS	+= $(CLANG_FLAGS)
 export CLANG_FLAGS
 endif
 
+# Include this also for config targets because some architectures need
+# cc-cross-prefix to determine CROSS_COMPILE.
+include $(srctree)/scripts/Makefile.compiler
+
 ifdef config-build
 # ===========================================================================
 # *config targets only - make sure prerequisites are updated, and descend
scripts/Kbuild.include +0 -80

86 lines not on this page · raw message

scripts/Makefile.build +1 -0
index 750d6d5225af..d74d3383666e 100644
@@ -36,6 +36,7 @@ subdir-ccflags-y :=
 -include include/config/auto.conf
 
 include $(srctree)/scripts/Kbuild.include
+include $(srctree)/scripts/Makefile.compiler
 
 # The filename Kbuild has precedence over Makefile
 kbuild-dir := $(if $(filter /%,$(src)),$(src),$(srctree)/$(src))
scripts/Makefile.compiler new file +77 -0

77 lines not on this page · raw message

Signature · 1 line
2.27.0
#6 lore raw

PATCH 4/4 kbuild: include Makefile.compiler only when compiler is required

In reply to Masahiro Yamada

Since commit f2f02ebd8f38 ("kbuild: improve cc-option to clean up all temporary files"), running 'make kernelversion' in a read-only source tree emits a bunch of warnings:

mkdir: cannot create directory '.tmp_12345': Permission denied

Non-build targets such as kernelversion, clean, help, etc. do not need to evaluate $(call cc-option,) and friends. Do not include Makefile.compiler so $(call cc-option,) becomes no-op.

This not only fix the warnings, but also runs non-build targets much faster.

Basically, all installation targets should also be non-build targets. Unfortunately, vdso_install requires the compiler because it builds vdso before installtion. This is a problem that must be fixed by a separate patch.

---

I am not adding Reported-by for now because a reporter sent me an email privately.

If he allows me to add Reported-by, I will add it to record the credit.

(Perhaps, another person might have reported a similar issue somewhere, but my memory is obsure. I cannot recall it.)

 Makefile | 13 +++++++++++++
 1 file changed, 13 insertions(+)
Makefile +13 -0
index eec7a94f5c33..20724711dc71 100644
@@ -263,6 +263,10 @@ no-dot-config-targets := $(clean-targets) \
 			 $(version_h) headers headers_% archheaders archscripts \
 			 %asm-generic kernelversion %src-pkg dt_binding_check \
 			 outputmakefile
+# Installation targets should not require compiler. Unfortunately, vdso_install
+# is an exception where build artifacts may be updated. This must be fixed.
+no-compiler-targets := $(no-dot-config-targets) install dtbs_install \
+			headers_install modules_install kernelrelease image_name
 no-sync-config-targets := $(no-dot-config-targets) %install kernelrelease \
 			  image_name
 single-targets := %.a %.i %.ko %.lds %.ll %.lst %.mod %.o %.s %.symtypes %/
@@ -270,6 +274,7 @@ single-targets := %.a %.i %.ko %.lds %.ll %.lst %.mod %.o %.s %.symtypes %/
 config-build	:=
 mixed-build	:=
 need-config	:= 1
+need-compiler	:= 1
 may-sync-config	:= 1
 single-build	:=
 
@@ -279,6 +284,12 @@ ifneq ($(filter $(no-dot-config-targets), $(MAKECMDGOALS)),)
 	endif
 endif
 
+ifneq ($(filter $(no-compiler-targets), $(MAKECMDGOALS)),)
+	ifeq ($(filter-out $(no-compiler-targets), $(MAKECMDGOALS)),)
+		need-compiler :=
+	endif
+endif
+
 ifneq ($(filter $(no-sync-config-targets), $(MAKECMDGOALS)),)
 	ifeq ($(filter-out $(no-sync-config-targets), $(MAKECMDGOALS)),)
 		may-sync-config :=
@@ -584,7 +595,9 @@ endif
 
 # Include this also for config targets because some architectures need
 # cc-cross-prefix to determine CROSS_COMPILE.
+ifdef need-compiler
 include $(srctree)/scripts/Makefile.compiler
+endif
 
 ifdef config-build
 # ===========================================================================
Signature · 1 line
2.27.0
#7 lore raw

Re: [PATCH 4/4] kbuild: include Makefile.compiler only when compiler is required

Quoted 22 lines · Masahiro Yamada

Since commit f2f02ebd8f38 ("kbuild: improve cc-option to clean up all temporary files"), running 'make kernelversion' in a read-only source tree emits a bunch of warnings:

mkdir: cannot create directory '.tmp_12345': Permission denied

Non-build targets such as kernelversion, clean, help, etc. do not need to evaluate $(call cc-option,) and friends. Do not include Makefile.compiler so $(call cc-option,) becomes no-op.

This not only fix the warnings, but also runs non-build targets much faster.

Basically, all installation targets should also be non-build targets. Unfortunately, vdso_install requires the compiler because it builds vdso before installtion. This is a problem that must be fixed by a separate patch.

---

Quoted 9 lines

I am not adding Reported-by for now because a reporter sent me an email privately.

If he allows me to add Reported-by, I will add it to record the credit.

(Perhaps, another person might have reported a similar issue somewhere, but my memory is obsure. I cannot recall it.)

Now, I got acknowledge to add this:

Quoted 52 lines
 Makefile | 13 +++++++++++++
 1 file changed, 13 insertions(+)
Makefile +13 -1
index eec7a94f5c33..20724711dc71 100644
@@ -263,6 +263,10 @@ no-dot-config-targets := $(clean-targets) \
                         $(version_h) headers headers_% archheaders archscripts \
                         %asm-generic kernelversion %src-pkg dt_binding_check \
                         outputmakefile
+# Installation targets should not require compiler. Unfortunately, vdso_install
+# is an exception where build artifacts may be updated. This must be fixed.
+no-compiler-targets := $(no-dot-config-targets) install dtbs_install \
+                       headers_install modules_install kernelrelease image_name
 no-sync-config-targets := $(no-dot-config-targets) %install kernelrelease \
                          image_name
 single-targets := %.a %.i %.ko %.lds %.ll %.lst %.mod %.o %.s %.symtypes %/
@@ -270,6 +274,7 @@ single-targets := %.a %.i %.ko %.lds %.ll %.lst %.mod %.o %.s %.symtypes %/
 config-build   :=
 mixed-build    :=
 need-config    := 1
+need-compiler  := 1
 may-sync-config        := 1
 single-build   :=
 
@@ -279,6 +284,12 @@ ifneq ($(filter $(no-dot-config-targets), $(MAKECMDGOALS)),)
        endif
 endif
 
+ifneq ($(filter $(no-compiler-targets), $(MAKECMDGOALS)),)
+       ifeq ($(filter-out $(no-compiler-targets), $(MAKECMDGOALS)),)
+               need-compiler :=
+       endif
+endif
+
 ifneq ($(filter $(no-sync-config-targets), $(MAKECMDGOALS)),)
        ifeq ($(filter-out $(no-sync-config-targets), $(MAKECMDGOALS)),)
                may-sync-config :=
@@ -584,7 +595,9 @@ endif
 
 # Include this also for config targets because some architectures need
 # cc-cross-prefix to determine CROSS_COMPILE.
+ifdef need-compiler
 include $(srctree)/scripts/Makefile.compiler
+endif
 
 ifdef config-build
 # ===========================================================================
--

2.27.0

Signature · 2 lines
Best Regards
Masahiro Yamada
#10 lore raw
In reply to Masahiro Yamada
Quoted 7 lines · Masahiro Yamada

'make image_name' needs include/config/auto.conf to show the correct output because KBUILD_IMAGE depends on CONFIG options, but should not attempt to resync the configuration.

---

All applied to linux-kbuild.

Quoted 20 lines
 Makefile | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
Makefile +2 -2
index 633d2769b6ec..c84a9311df29 100644
@@ -263,7 +263,8 @@ no-dot-config-targets := $(clean-targets) \
                         $(version_h) headers headers_% archheaders archscripts \
                         %asm-generic kernelversion %src-pkg dt_binding_check \
                         outputmakefile
-no-sync-config-targets := $(no-dot-config-targets) %install kernelrelease
+no-sync-config-targets := $(no-dot-config-targets) %install kernelrelease \
+                         image_name
 single-targets := %.a %.i %.ko %.lds %.ll %.lst %.mod %.o %.s %.symtypes %/
 
 config-build   :=
--

2.27.0

Signature · 2 lines
Best Regards
Masahiro Yamada
#8 lore raw

Re: [PATCH 4/4] kbuild: include Makefile.compiler only when compiler is required

In reply to Masahiro Yamada
Quoted 83 lines · Masahiro Yamada

Since commit f2f02ebd8f38 ("kbuild: improve cc-option to clean up all temporary files"), running 'make kernelversion' in a read-only source tree emits a bunch of warnings:

mkdir: cannot create directory '.tmp_12345': Permission denied

Non-build targets such as kernelversion, clean, help, etc. do not need to evaluate $(call cc-option,) and friends. Do not include Makefile.compiler so $(call cc-option,) becomes no-op.

This not only fix the warnings, but also runs non-build targets much faster.

Basically, all installation targets should also be non-build targets. Unfortunately, vdso_install requires the compiler because it builds vdso before installtion. This is a problem that must be fixed by a separate patch.

---

I am not adding Reported-by for now because a reporter sent me an email privately.

If he allows me to add Reported-by, I will add it to record the credit.

(Perhaps, another person might have reported a similar issue somewhere, but my memory is obsure. I cannot recall it.)

 Makefile | 13 +++++++++++++
 1 file changed, 13 insertions(+)
Makefile +13 -0
index eec7a94f5c33..20724711dc71 100644
@@ -263,6 +263,10 @@ no-dot-config-targets := $(clean-targets) \
 			 $(version_h) headers headers_% archheaders archscripts \
 			 %asm-generic kernelversion %src-pkg dt_binding_check \
 			 outputmakefile
+# Installation targets should not require compiler. Unfortunately, vdso_install
+# is an exception where build artifacts may be updated. This must be fixed.
+no-compiler-targets := $(no-dot-config-targets) install dtbs_install \
+			headers_install modules_install kernelrelease image_name
 no-sync-config-targets := $(no-dot-config-targets) %install kernelrelease \
 			  image_name
 single-targets := %.a %.i %.ko %.lds %.ll %.lst %.mod %.o %.s %.symtypes %/
@@ -270,6 +274,7 @@ single-targets := %.a %.i %.ko %.lds %.ll %.lst %.mod %.o %.s %.symtypes %/
 config-build	:=
 mixed-build	:=
 need-config	:= 1
+need-compiler	:= 1
 may-sync-config	:= 1
 single-build	:=
 
@@ -279,6 +284,12 @@ ifneq ($(filter $(no-dot-config-targets), $(MAKECMDGOALS)),)
 	endif
 endif
 
+ifneq ($(filter $(no-compiler-targets), $(MAKECMDGOALS)),)
+	ifeq ($(filter-out $(no-compiler-targets), $(MAKECMDGOALS)),)
+		need-compiler :=
+	endif
+endif
+
 ifneq ($(filter $(no-sync-config-targets), $(MAKECMDGOALS)),)
 	ifeq ($(filter-out $(no-sync-config-targets), $(MAKECMDGOALS)),)
 		may-sync-config :=
@@ -584,7 +595,9 @@ endif
 
 # Include this also for config targets because some architectures need
 # cc-cross-prefix to determine CROSS_COMPILE.
+ifdef need-compiler
 include $(srctree)/scripts/Makefile.compiler
+endif
 
 ifdef config-build
 # ===========================================================================
Signature · 1 line
2.27.0

Hi Masahiro,

I see a new warning in my builds on arm64 now when running 'modules_install' or 'dtbs_install' because ld-option evaluates to nothing, which triggers the warning in arch/arm64/Makefile:

$ make -skj"$(nproc)" \
ARCH=arm64 \
CROSS_COMPILE=aarch64-linux- \
INSTALL_DTBS_PATH=rootfs \
INSTALL_MOD_PATH=rootfs \
O=build/arm64 \
distclean defconfig all modules_install dtbs_install
...
/home/nathan/cbl/src/linux-next/arch/arm64/Makefile:25: ld does not support --fix-cortex-a53-843419; kernel may be susceptible to erratum
/home/nathan/cbl/src/linux-next/arch/arm64/Makefile:25: ld does not support --fix-cortex-a53-843419; kernel may be susceptible to erratum
$ sed -n '23,29p' arch/arm64/Makefile
ifeq ($(CONFIG_ARM64_ERRATUM_843419),y)
  ifeq ($(call ld-option, --fix-cortex-a53-843419),)
$(warning ld does not support --fix-cortex-a53-843419; kernel may be susceptible to erratum)
  else
LDFLAGS_vmlinux += --fix-cortex-a53-843419
  endif
endif

I am not sure how this should be resolved, hence just the report.

Cheers,
Nathan

#9 lore raw

Re: [PATCH 4/4] kbuild: include Makefile.compiler only when compiler is required

(CC: Will and ARM ML)

Quoted 112 lines · Nathan Chancellor
Quoted 81 lines · Masahiro Yamada

Since commit f2f02ebd8f38 ("kbuild: improve cc-option to clean up all temporary files"), running 'make kernelversion' in a read-only source tree emits a bunch of warnings:

mkdir: cannot create directory '.tmp_12345': Permission denied

Non-build targets such as kernelversion, clean, help, etc. do not need to evaluate $(call cc-option,) and friends. Do not include Makefile.compiler so $(call cc-option,) becomes no-op.

This not only fix the warnings, but also runs non-build targets much faster.

Basically, all installation targets should also be non-build targets. Unfortunately, vdso_install requires the compiler because it builds vdso before installtion. This is a problem that must be fixed by a separate patch.

---

I am not adding Reported-by for now because a reporter sent me an email privately.

If he allows me to add Reported-by, I will add it to record the credit.

(Perhaps, another person might have reported a similar issue somewhere, but my memory is obsure. I cannot recall it.)

 Makefile | 13 +++++++++++++
 1 file changed, 13 insertions(+)
Makefile +13 -1
index eec7a94f5c33..20724711dc71 100644
@@ -263,6 +263,10 @@ no-dot-config-targets := $(clean-targets) \
                       $(version_h) headers headers_% archheaders archscripts \
                       %asm-generic kernelversion %src-pkg dt_binding_check \
                       outputmakefile
+# Installation targets should not require compiler. Unfortunately, vdso_install
+# is an exception where build artifacts may be updated. This must be fixed.
+no-compiler-targets := $(no-dot-config-targets) install dtbs_install \
+                     headers_install modules_install kernelrelease image_name
 no-sync-config-targets := $(no-dot-config-targets) %install kernelrelease \
                        image_name
 single-targets := %.a %.i %.ko %.lds %.ll %.lst %.mod %.o %.s %.symtypes %/
@@ -270,6 +274,7 @@ single-targets := %.a %.i %.ko %.lds %.ll %.lst %.mod %.o %.s %.symtypes %/
 config-build :=
 mixed-build  :=
 need-config  := 1
+need-compiler        := 1
 may-sync-config      := 1
 single-build :=
 
@@ -279,6 +284,12 @@ ifneq ($(filter $(no-dot-config-targets), $(MAKECMDGOALS)),)
      endif
 endif
 
+ifneq ($(filter $(no-compiler-targets), $(MAKECMDGOALS)),)
+     ifeq ($(filter-out $(no-compiler-targets), $(MAKECMDGOALS)),)
+             need-compiler :=
+     endif
+endif
+
 ifneq ($(filter $(no-sync-config-targets), $(MAKECMDGOALS)),)
      ifeq ($(filter-out $(no-sync-config-targets), $(MAKECMDGOALS)),)
              may-sync-config :=
@@ -584,7 +595,9 @@ endif
 
 # Include this also for config targets because some architectures need
 # cc-cross-prefix to determine CROSS_COMPILE.
+ifdef need-compiler
 include $(srctree)/scripts/Makefile.compiler
+endif
 
 ifdef config-build
 # ===========================================================================
--
Quoted 2 lines

2.27.0

Hi Masahiro,

I see a new warning in my builds on arm64 now when running 'modules_install' or 'dtbs_install' because ld-option evaluates to nothing, which triggers the warning in arch/arm64/Makefile:

$ make -skj"$(nproc)" \
ARCH=arm64 \
CROSS_COMPILE=aarch64-linux- \
INSTALL_DTBS_PATH=rootfs \
INSTALL_MOD_PATH=rootfs \
O=build/arm64 \
distclean defconfig all modules_install dtbs_install
...
/home/nathan/cbl/src/linux-next/arch/arm64/Makefile:25: ld does not support --fix-cortex-a53-843419; kernel may be susceptible to erratum
/home/nathan/cbl/src/linux-next/arch/arm64/Makefile:25: ld does not support --fix-cortex-a53-843419; kernel may be susceptible to erratum
$ sed -n '23,29p' arch/arm64/Makefile
ifeq ($(CONFIG_ARM64_ERRATUM_843419),y)
  ifeq ($(call ld-option, --fix-cortex-a53-843419),)
$(warning ld does not support --fix-cortex-a53-843419; kernel may be susceptible to erratum)
  else
LDFLAGS_vmlinux += --fix-cortex-a53-843419
  endif
endif
Quoted 4 lines

I am not sure how this should be resolved, hence just the report.

Cheers,
Nathan

I see this a few lines below:

ifeq ($(CONFIG_ARM64_USE_LSE_ATOMICS), y)
ifneq ($(CONFIG_ARM64_LSE_ATOMICS), y)
$(warning LSE atomics not supported by binutils)
endif
endif

We can move ld-option evaluation to Kconfig.

ifeq ($(CONFIG_ARM64_ERRATUM_843419),y)
ifneq ($(CONFIG_ARM64_LD_HAS_FIX_ERRATUM_843419,y))
$(warning ld does not support --fix-cortex-a53-843419; kernel may be susceptible to erratum)
else
LDFLAGS_vmlinux += --fix-cortex-a53-843419
endif
endif

I do not know what CONFIG name is preferred.

Signature · 2 lines
Best Regards
Masahiro Yamada
#3 lore raw

Re: [PATCH 3/4] kbuild: spilt cc-option and friends to scripts/Makefile.compiler

In reply to Masahiro Yamada
Quoted 10 lines · Masahiro Yamada

scripts/Kbuild.include is included everywhere, but macros such as cc-option are needed by build targets only.

For example, when 'make clean' traverses the tree, it does not need to evaluate $(call cc-option,).

Split cc-option, ld-option, etc. to scripts/Makefile.compiler, which is only included from the top Makefile and scripts/Makefile.build.

This commit broke the KVM selftest compilation under s390 in linux-next for me. Funny enough the compilation is only broken on Ubuntu, under Fedora the test fails with an assertion.

FEDORA:
[root@fedora kvm]# ./set_memory_region_test
Allowed number of memory slots: 32767
==== Test Assertion Failure ====
lib/kvm_util.c:142: vm->fd >= 0
pid=1541645 tid=1541645 - 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	0x000003ffa3d2bb89: ?? ??:0
     6	0x00000000010017ad: .annobin_abi_note.c.hot at crt1.o:?

KVM_CREATE_VM ioctl failed, rc: -1 errno: 22

Ubuntu:
make[1]: Leaving directory '/mnt/dev/linux'
gcc -Wall -Wstrict-prototypes -Wuninitialized -O2 -g -std=gnu99 -fno-stack-protector -fno-PIE -I../../../../tools/include -I../../../../tools/arch/s390/include -I../../../../usr/include/
-Iinclude -Ilib -Iinclude/s390x -I.. -c lib/sparsebit.c -o
/mnt/dev/linux/tools/testing/selftests/kvm/lib/sparsebit.o
gcc -Wall -Wstrict-prototypes -Wuninitialized -O2 -g -std=gnu99 -fno-stack-protector -fno-PIE -I../../../../tools/include -I../../../../tools/arch/s390/include -I../../../../usr/include/
-Iinclude -Ilib -Iinclude/s390x -I.. -c lib/kvm_util.c -o
/mnt/dev/linux/tools/testing/selftests/kvm/lib/kvm_util.o
gcc -Wall -Wstrict-prototypes -Wuninitialized -O2 -g -std=gnu99 -fno-stack-protector -fno-PIE -I../../../../tools/include -I../../../../tools/arch/s390/include -I../../../../usr/include/
-Iinclude -Ilib/s390x -Iinclude/s390x -I.. -c
lib/s390x/diag318_test_handler.c -o /mnt/dev/linux/tools/testing/selftests/kvm/lib/s390x/diag318_test_handler.o ar crs /mnt/dev/linux/tools/testing/selftests/kvm/libkvm.a /mnt/dev/linux/tools/testing/selftests/kvm/lib/assert.o /mnt/dev/linux/tools/testing/selftests/kvm/lib/elf.o /mnt/dev/linux/tools/testing/selftests/kvm/lib/io.o /mnt/dev/linux/tools/testing/selftests/kvm/lib/kvm_util.o /mnt/dev/linux/tools/testing/selftests/kvm/lib/sparsebit.o /mnt/dev/linux/tools/testing/selftests/kvm/lib/test_util.o /mnt/dev/linux/tools/testing/selftests/kvm/lib/guest_modes.o /mnt/dev/linux/tools/testing/selftests/kvm/lib/perf_test_util.o /mnt/dev/linux/tools/testing/selftests/kvm/lib/s390x/processor.o /mnt/dev/linux/tools/testing/selftests/kvm/lib/s390x/ucall.o /mnt/dev/linux/tools/testing/selftests/kvm/lib/s390x/diag318_test_handler.o gcc -Wall -Wstrict-prototypes -Wuninitialized -O2 -g -std=gnu99 -fno-stack-protector -fno-PIE -I../../../../tools/include -I../../../../tools/arch/s390/include -I../../../../usr/include/
-Iinclude -Is390x -Iinclude/s390x -I.. -pthread s390x/memop.c
/mnt/dev/linux/tools/testing/selftests/kvm/libkvm.a -o /mnt/dev/linux/tools/testing/selftests/kvm/s390x/memop /usr/bin/ld: /tmp/ccFU8WYF.o: `stdout@@GLIBC_2.2' non-PLT reloc for symbol defined in shared library and accessed from executable (rebuild file with -fPIC ?)
/usr/bin/ld: final link failed: bad value
collect2: error: ld returned 1 exit status
make: *** [../lib.mk:139:
/mnt/dev/linux/tools/testing/selftests/kvm/s390x/memop] Error 1

Quoted 211 lines

---

 Makefile                  |  4 ++
 scripts/Kbuild.include    | 80 ---------------------------------------
 scripts/Makefile.build    |  1 +
 scripts/Makefile.compiler | 77 +++++++++++++++++++++++++++++++++++++
 4 files changed, 82 insertions(+), 80 deletions(-)
 create mode 100644 scripts/Makefile.compiler
Makefile +4 -0
index 2253e31a6bcf..eec7a94f5c33 100644
@@ -582,6 +582,10 @@ KBUILD_AFLAGS	+= $(CLANG_FLAGS)
 export CLANG_FLAGS
 endif
 
+# Include this also for config targets because some architectures need
+# cc-cross-prefix to determine CROSS_COMPILE.
+include $(srctree)/scripts/Makefile.compiler
+
 ifdef config-build
 # ===========================================================================
 # *config targets only - make sure prerequisites are updated, and descend
scripts/Kbuild.include +0 -80
index 509e0856d653..82dd1b65b7a8 100644
@@ -67,86 +67,6 @@ define filechk
 	fi
 endef
 
-######
-# gcc support functions
-# See documentation in Documentation/kbuild/makefiles.rst
-
-# cc-cross-prefix
-# Usage: CROSS_COMPILE := $(call cc-cross-prefix, m68k-linux-gnu- m68k-linux-)
-# Return first <prefix> where a <prefix>gcc is found in PATH.
-# If no gcc found in PATH with listed prefixes return nothing
-#
-# Note: '2>/dev/null' is here to force Make to invoke a shell. Otherwise, it
-# would try to directly execute the shell builtin 'command'. This workaround
-# should be kept for a long time since this issue was fixed only after the
-# GNU Make 4.2.1 release.
-cc-cross-prefix = $(firstword $(foreach c, $(1), \
-			$(if $(shell command -v -- $(c)gcc 2>/dev/null), $(c))))
-
-# output directory for tests below
-TMPOUT = $(if $(KBUILD_EXTMOD),$(firstword $(KBUILD_EXTMOD))/).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;		\
-	TMPO=$(TMPOUT)/tmp.o;		\
-	mkdir -p $(TMPOUT);		\
-	trap "rm -rf $(TMPOUT)" EXIT;	\
-	if ($(1)) >/dev/null 2>&1;	\
-	then echo "$(2)";		\
-	else echo "$(3)";		\
-	fi)
-
-# as-option
-# Usage: cflags-y += $(call as-option,-Wa$(comma)-isa=foo,)
-
-as-option = $(call try-run,\
-	$(CC) $(KBUILD_CFLAGS) $(1) -c -x assembler /dev/null -o "$$TMP",$(1),$(2))
-
-# as-instr
-# Usage: cflags-y += $(call as-instr,instr,option1,option2)
-
-as-instr = $(call try-run,\
-	printf "%b\n" "$(1)" | $(CC) $(KBUILD_AFLAGS) -c -x assembler -o "$$TMP" -,$(2),$(3))
-
-# __cc-option
-# Usage: MY_CFLAGS += $(call __cc-option,$(CC),$(MY_CFLAGS),-march=winchip-c6,-march=i586)
-__cc-option = $(call try-run,\
-	$(1) -Werror $(2) $(3) -c -x c /dev/null -o "$$TMP",$(3),$(4))
-
-# cc-option
-# Usage: cflags-y += $(call cc-option,-march=winchip-c6,-march=i586)
-
-cc-option = $(call __cc-option, $(CC),\
-	$(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS),$(1),$(2))
-
-# cc-option-yn
-# Usage: flag := $(call cc-option-yn,-march=winchip-c6)
-cc-option-yn = $(call try-run,\
-	$(CC) -Werror $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) $(1) -c -x c /dev/null -o "$$TMP",y,n)
-
-# cc-disable-warning
-# Usage: cflags-y += $(call cc-disable-warning,unused-but-set-variable)
-cc-disable-warning = $(call try-run,\
-	$(CC) -Werror $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) -W$(strip $(1)) -c -x c /dev/null -o "$$TMP",-Wno-$(strip $(1)))
-
-# cc-ifversion
-# Usage:  EXTRA_CFLAGS += $(call cc-ifversion, -lt, 0402, -O1)
-cc-ifversion = $(shell [ $(CONFIG_GCC_VERSION)0 $(1) $(2)000 ] && echo $(3) || echo $(4))
-
-# ld-option
-# Usage: KBUILD_LDFLAGS += $(call ld-option, -X, -Y)
-ld-option = $(call try-run, $(LD) $(KBUILD_LDFLAGS) $(1) -v,$(1),$(2),$(3))
-
-# ld-ifversion
-# Usage:  $(call ld-ifversion, -ge, 22252, y)
-ld-ifversion = $(shell [ $(CONFIG_LD_VERSION)0 $(1) $(2)0 ] && echo $(3) || echo $(4))
-
-######
-
 ###
 # Shorthand for $(Q)$(MAKE) -f scripts/Makefile.build obj=
 # Usage:
scripts/Makefile.build +1 -0
index 750d6d5225af..d74d3383666e 100644
@@ -36,6 +36,7 @@ subdir-ccflags-y :=
 -include include/config/auto.conf
 
 include $(srctree)/scripts/Kbuild.include
+include $(srctree)/scripts/Makefile.compiler
 
 # The filename Kbuild has precedence over Makefile
 kbuild-dir := $(if $(filter /%,$(src)),$(src),$(srctree)/$(src))
scripts/Makefile.compiler new file +77 -0
new file mode 100644
index 000000000000..5f759ecc4f04
@@ -0,0 +1,77 @@
+######
+# gcc support functions
+# See documentation in Documentation/kbuild/makefiles.rst
+
+# cc-cross-prefix
+# Usage: CROSS_COMPILE := $(call cc-cross-prefix, m68k-linux-gnu- m68k-linux-)
+# Return first <prefix> where a <prefix>gcc is found in PATH.
+# If no gcc found in PATH with listed prefixes return nothing
+#
+# Note: '2>/dev/null' is here to force Make to invoke a shell. Otherwise, it
+# would try to directly execute the shell builtin 'command'. This workaround
+# should be kept for a long time since this issue was fixed only after the
+# GNU Make 4.2.1 release.
+cc-cross-prefix = $(firstword $(foreach c, $(1), \
+			$(if $(shell command -v -- $(c)gcc 2>/dev/null), $(c))))
+
+# output directory for tests below
+TMPOUT = $(if $(KBUILD_EXTMOD),$(firstword $(KBUILD_EXTMOD))/).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;		\
+	TMPO=$(TMPOUT)/tmp.o;		\
+	mkdir -p $(TMPOUT);		\
+	trap "rm -rf $(TMPOUT)" EXIT;	\
+	if ($(1)) >/dev/null 2>&1;	\
+	then echo "$(2)";		\
+	else echo "$(3)";		\
+	fi)
+
+# as-option
+# Usage: cflags-y += $(call as-option,-Wa$(comma)-isa=foo,)
+
+as-option = $(call try-run,\
+	$(CC) $(KBUILD_CFLAGS) $(1) -c -x assembler /dev/null -o "$$TMP",$(1),$(2))
+
+# as-instr
+# Usage: cflags-y += $(call as-instr,instr,option1,option2)
+
+as-instr = $(call try-run,\
+	printf "%b\n" "$(1)" | $(CC) $(KBUILD_AFLAGS) -c -x assembler -o "$$TMP" -,$(2),$(3))
+
+# __cc-option
+# Usage: MY_CFLAGS += $(call __cc-option,$(CC),$(MY_CFLAGS),-march=winchip-c6,-march=i586)
+__cc-option = $(call try-run,\
+	$(1) -Werror $(2) $(3) -c -x c /dev/null -o "$$TMP",$(3),$(4))
+
+# cc-option
+# Usage: cflags-y += $(call cc-option,-march=winchip-c6,-march=i586)
+
+cc-option = $(call __cc-option, $(CC),\
+	$(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS),$(1),$(2))
+
+# cc-option-yn
+# Usage: flag := $(call cc-option-yn,-march=winchip-c6)
+cc-option-yn = $(call try-run,\
+	$(CC) -Werror $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) $(1) -c -x c /dev/null -o "$$TMP",y,n)
+
+# cc-disable-warning
+# Usage: cflags-y += $(call cc-disable-warning,unused-but-set-variable)
+cc-disable-warning = $(call try-run,\
+	$(CC) -Werror $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) -W$(strip $(1)) -c -x c /dev/null -o "$$TMP",-Wno-$(strip $(1)))
+
+# cc-ifversion
+# Usage:  EXTRA_CFLAGS += $(call cc-ifversion, -lt, 0402, -O1)
+cc-ifversion = $(shell [ $(CONFIG_GCC_VERSION)0 $(1) $(2)000 ] && echo $(3) || echo $(4))
+
+# ld-option
+# Usage: KBUILD_LDFLAGS += $(call ld-option, -X, -Y)
+ld-option = $(call try-run, $(LD) $(KBUILD_LDFLAGS) $(1) -v,$(1),$(2),$(3))
+
+# ld-ifversion
+# Usage:  $(call ld-ifversion, -ge, 22252, y)
+ld-ifversion = $(shell [ $(CONFIG_LD_VERSION)0 $(1) $(2)0 ] && echo $(3) || echo $(4))
#4 lore raw

Re: [PATCH 3/4] kbuild: spilt cc-option and friends to scripts/Makefile.compiler

Quoted 67 lines · Janosch Frank
Quoted 10 lines · Masahiro Yamada

scripts/Kbuild.include is included everywhere, but macros such as cc-option are needed by build targets only.

For example, when 'make clean' traverses the tree, it does not need to evaluate $(call cc-option,).

Split cc-option, ld-option, etc. to scripts/Makefile.compiler, which is only included from the top Makefile and scripts/Makefile.build.

This commit broke the KVM selftest compilation under s390 in linux-next for me. Funny enough the compilation is only broken on Ubuntu, under Fedora the test fails with an assertion.

FEDORA:
[root@fedora kvm]# ./set_memory_region_test
Allowed number of memory slots: 32767
==== Test Assertion Failure ====
lib/kvm_util.c:142: vm->fd >= 0
pid=1541645 tid=1541645 - 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	0x000003ffa3d2bb89: ?? ??:0
      6	0x00000000010017ad: .annobin_abi_note.c.hot at crt1.o:?

KVM_CREATE_VM ioctl failed, rc: -1 errno: 22

Ubuntu:
make[1]: Leaving directory '/mnt/dev/linux'
gcc -Wall -Wstrict-prototypes -Wuninitialized -O2 -g -std=gnu99

(quoted diff) +0 -3
-fno-stack-protector -fno-PIE -I../../../../tools/include
-I../../../../tools/arch/s390/include -I../../../../usr/include/
-Iinclude -Ilib -Iinclude/s390x -I..   -c lib/sparsebit.c -o

/mnt/dev/linux/tools/testing/selftests/kvm/lib/sparsebit.o gcc -Wall -Wstrict-prototypes -Wuninitialized -O2 -g -std=gnu99

(quoted diff) +0 -3
-fno-stack-protector -fno-PIE -I../../../../tools/include
-I../../../../tools/arch/s390/include -I../../../../usr/include/
-Iinclude -Ilib -Iinclude/s390x -I..   -c lib/kvm_util.c -o

/mnt/dev/linux/tools/testing/selftests/kvm/lib/kvm_util.o gcc -Wall -Wstrict-prototypes -Wuninitialized -O2 -g -std=gnu99

(quoted diff) +0 -3
-fno-stack-protector -fno-PIE -I../../../../tools/include
-I../../../../tools/arch/s390/include -I../../../../usr/include/
-Iinclude -Ilib/s390x -Iinclude/s390x -I..   -c

lib/s390x/diag318_test_handler.c -o /mnt/dev/linux/tools/testing/selftests/kvm/lib/s390x/diag318_test_handler.o ar crs /mnt/dev/linux/tools/testing/selftests/kvm/libkvm.a /mnt/dev/linux/tools/testing/selftests/kvm/lib/assert.o /mnt/dev/linux/tools/testing/selftests/kvm/lib/elf.o /mnt/dev/linux/tools/testing/selftests/kvm/lib/io.o /mnt/dev/linux/tools/testing/selftests/kvm/lib/kvm_util.o /mnt/dev/linux/tools/testing/selftests/kvm/lib/sparsebit.o /mnt/dev/linux/tools/testing/selftests/kvm/lib/test_util.o /mnt/dev/linux/tools/testing/selftests/kvm/lib/guest_modes.o /mnt/dev/linux/tools/testing/selftests/kvm/lib/perf_test_util.o /mnt/dev/linux/tools/testing/selftests/kvm/lib/s390x/processor.o /mnt/dev/linux/tools/testing/selftests/kvm/lib/s390x/ucall.o /mnt/dev/linux/tools/testing/selftests/kvm/lib/s390x/diag318_test_handler.o gcc -Wall -Wstrict-prototypes -Wuninitialized -O2 -g -std=gnu99

(quoted diff) +0 -3
-fno-stack-protector -fno-PIE -I../../../../tools/include
-I../../../../tools/arch/s390/include -I../../../../usr/include/
-Iinclude -Is390x -Iinclude/s390x -I..  -pthread    s390x/memop.c

/mnt/dev/linux/tools/testing/selftests/kvm/libkvm.a -o

Quoted 9 lines

/mnt/dev/linux/tools/testing/selftests/kvm/s390x/memop /usr/bin/ld: /tmp/ccFU8WYF.o: `stdout@@GLIBC_2.2' non-PLT reloc for symbol defined in shared library and accessed from executable (rebuild file with -fPIC ?)
/usr/bin/ld: final link failed: bad value
collect2: error: ld returned 1 exit status
make: *** [../lib.mk:139:
/mnt/dev/linux/tools/testing/selftests/kvm/s390x/memop] Error 1

It looks like that from tools/testing/selftests/kvm/Makefile additional linker flags are being ignored with this patch.

no-pie-option := $(call try-run, echo 'int main() { return 0; }' | \
        $(CC) -Werror -no-pie -x c - -o "$$TMP", -no-pie)

# On s390, build the testcases KVM-enabled

pgste-option = $(call try-run, echo 'int main() { return 0; }' | \
        $(CC) -Werror -Wl$(comma)--s390-pgste -x c - -o "$$TMP",-Wl$(comma)--s390-pgste)

LDFLAGS += -pthread $(no-pie-option) $(pgste-option)

#5 lore raw

Re: [PATCH 3/4] kbuild: spilt cc-option and friends to scripts/Makefile.compiler

Quoted 89 lines · Christian Borntraeger
Quoted 67 lines · Janosch Frank
Quoted 10 lines · Masahiro Yamada

scripts/Kbuild.include is included everywhere, but macros such as cc-option are needed by build targets only.

For example, when 'make clean' traverses the tree, it does not need to evaluate $(call cc-option,).

Split cc-option, ld-option, etc. to scripts/Makefile.compiler, which is only included from the top Makefile and scripts/Makefile.build.

This commit broke the KVM selftest compilation under s390 in linux-next for me. Funny enough the compilation is only broken on Ubuntu, under Fedora the test fails with an assertion.

FEDORA:
[root@fedora kvm]# ./set_memory_region_test
Allowed number of memory slots: 32767
==== Test Assertion Failure ====
lib/kvm_util.c:142: vm->fd >= 0
pid=1541645 tid=1541645 - 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       0x000003ffa3d2bb89: ?? ??:0
      6       0x00000000010017ad: .annobin_abi_note.c.hot at crt1.o:?

KVM_CREATE_VM ioctl failed, rc: -1 errno: 22

Ubuntu:
make[1]: Leaving directory '/mnt/dev/linux'
gcc -Wall -Wstrict-prototypes -Wuninitialized -O2 -g -std=gnu99

(quoted diff) +0 -3
-fno-stack-protector -fno-PIE -I../../../../tools/include
-I../../../../tools/arch/s390/include -I../../../../usr/include/
-Iinclude -Ilib -Iinclude/s390x -I..   -c lib/sparsebit.c -o

/mnt/dev/linux/tools/testing/selftests/kvm/lib/sparsebit.o gcc -Wall -Wstrict-prototypes -Wuninitialized -O2 -g -std=gnu99

(quoted diff) +0 -3
-fno-stack-protector -fno-PIE -I../../../../tools/include
-I../../../../tools/arch/s390/include -I../../../../usr/include/
-Iinclude -Ilib -Iinclude/s390x -I..   -c lib/kvm_util.c -o

/mnt/dev/linux/tools/testing/selftests/kvm/lib/kvm_util.o gcc -Wall -Wstrict-prototypes -Wuninitialized -O2 -g -std=gnu99

(quoted diff) +0 -3
-fno-stack-protector -fno-PIE -I../../../../tools/include
-I../../../../tools/arch/s390/include -I../../../../usr/include/
-Iinclude -Ilib/s390x -Iinclude/s390x -I..   -c

lib/s390x/diag318_test_handler.c -o /mnt/dev/linux/tools/testing/selftests/kvm/lib/s390x/diag318_test_handler.o ar crs /mnt/dev/linux/tools/testing/selftests/kvm/libkvm.a /mnt/dev/linux/tools/testing/selftests/kvm/lib/assert.o /mnt/dev/linux/tools/testing/selftests/kvm/lib/elf.o /mnt/dev/linux/tools/testing/selftests/kvm/lib/io.o /mnt/dev/linux/tools/testing/selftests/kvm/lib/kvm_util.o /mnt/dev/linux/tools/testing/selftests/kvm/lib/sparsebit.o /mnt/dev/linux/tools/testing/selftests/kvm/lib/test_util.o /mnt/dev/linux/tools/testing/selftests/kvm/lib/guest_modes.o /mnt/dev/linux/tools/testing/selftests/kvm/lib/perf_test_util.o /mnt/dev/linux/tools/testing/selftests/kvm/lib/s390x/processor.o /mnt/dev/linux/tools/testing/selftests/kvm/lib/s390x/ucall.o /mnt/dev/linux/tools/testing/selftests/kvm/lib/s390x/diag318_test_handler.o gcc -Wall -Wstrict-prototypes -Wuninitialized -O2 -g -std=gnu99

(quoted diff) +0 -3
-fno-stack-protector -fno-PIE -I../../../../tools/include
-I../../../../tools/arch/s390/include -I../../../../usr/include/
-Iinclude -Is390x -Iinclude/s390x -I..  -pthread    s390x/memop.c

/mnt/dev/linux/tools/testing/selftests/kvm/libkvm.a -o

Quoted 9 lines

/mnt/dev/linux/tools/testing/selftests/kvm/s390x/memop /usr/bin/ld: /tmp/ccFU8WYF.o: `stdout@@GLIBC_2.2' non-PLT reloc for symbol defined in shared library and accessed from executable (rebuild file with -fPIC ?)
/usr/bin/ld: final link failed: bad value
collect2: error: ld returned 1 exit status
make: *** [../lib.mk:139:
/mnt/dev/linux/tools/testing/selftests/kvm/s390x/memop] Error 1

It looks like that from tools/testing/selftests/kvm/Makefile additional linker flags are being ignored with this patch.

no-pie-option := $(call try-run, echo 'int main() { return 0; }' | \
         $(CC) -Werror -no-pie -x c - -o "$$TMP", -no-pie)
Quoted 7 lines

# On s390, build the testcases KVM-enabled

pgste-option = $(call try-run, echo 'int main() { return 0; }' | \
         $(CC) -Werror -Wl$(comma)--s390-pgste -x c - -o "$$TMP",-Wl$(comma)--s390-pgste)

LDFLAGS += -pthread $(no-pie-option) $(pgste-option)

Thanks.

I will separate Kbuild and the tool build system.
https://patchwork.kernel.org/project/linux-kbuild/patch/[email protected]/

I do not want to be bothered by the can of worms.

Signature · 2 lines
Best Regards
Masahiro Yamada