kbuild: use ?= to assign CROSS_COMPILE by arch-Makefile
Subsystems (6)
PATCH 1/1 kbuild: use ?= to assign CROSS_COMPILE by arch-Makefile
Use ?= operator to let arch/*/Makefile to assign CROSS_COMPILE only when CROSS_COMPILE is undefined.
This allows arch-Makefiles to drop the ifeq ($(CROSS_COMPILE),) conditional.
This slightly changes the behavior; the arch-Makefile previously overrode CROSS_COMPILE when CROSS_COMPILE has already been made empty via an environment variable as in 'export CROSS_COMPILE='.
With this commit, arch-Makefle will respect the user's environment set-up, which seems to be a more correct behavior.
---
arch/arc/Makefile | 4 +--- arch/h8300/Makefile | 4 +--- arch/m68k/Makefile | 4 +--- arch/mips/Makefile | 4 +--- arch/parisc/Makefile | 6 ++---- arch/sh/Makefile | 4 +--- 6 files changed, 7 insertions(+), 19 deletions(-)
arch/arc/Makefile +1 -3
@@ -5,9 +5,7 @@ KBUILD_DEFCONFIG := haps_hs_smp_defconfig -ifeq ($(CROSS_COMPILE),) -CROSS_COMPILE := $(call cc-cross-prefix, arc-linux- arceb-linux-) -endif +CROSS_COMPILE ?= $(call cc-cross-prefix, arc-linux- arceb-linux-) cflags-y += -fno-common -pipe -fno-builtin -mmedium-calls -D__linux__
arch/h8300/Makefile +1 -3
@@ -26,9 +26,7 @@ KBUILD_LDFLAGS += $(ldflags-y) CHECKFLAGS += -msize-long -ifeq ($(CROSS_COMPILE),) -CROSS_COMPILE := $(call cc-cross-prefix, h8300-unknown-linux- h8300-linux-) -endif +CROSS_COMPILE ?= $(call cc-cross-prefix, h8300-unknown-linux- h8300-linux-) core-y += arch/$(ARCH)/kernel/ arch/$(ARCH)/mm/ core-y += arch/$(ARCH)/boot/dts/
arch/m68k/Makefile +1 -3
@@ -17,10 +17,8 @@ KBUILD_DEFCONFIG := multi_defconfig ifneq ($(SUBARCH),$(ARCH)) - ifeq ($(CROSS_COMPILE),) - CROSS_COMPILE := $(call cc-cross-prefix, \ + CROSS_COMPILE ?= $(call cc-cross-prefix, \ m68k-linux-gnu- m68k-linux- m68k-unknown-linux-gnu-) - endif endif #
arch/mips/Makefile +1 -3
@@ -51,9 +51,7 @@ UTS_MACHINE := mips64 endif ifneq ($(SUBARCH),$(ARCH)) - ifeq ($(CROSS_COMPILE),) - CROSS_COMPILE := $(call cc-cross-prefix, $(tool-archpref)-linux- $(tool-archpref)-linux-gnu- $(tool-archpref)-unknown-linux-gnu-) - endif + CROSS_COMPILE ?= $(call cc-cross-prefix, $(tool-archpref)-linux- $(tool-archpref)-linux-gnu- $(tool-archpref)-unknown-linux-gnu-) endif ifdef CONFIG_FUNCTION_GRAPH_TRACER
arch/parisc/Makefile +2 -4
@@ -42,12 +42,10 @@ endif export LD_BFD ifneq ($(SUBARCH),$(UTS_MACHINE)) - ifeq ($(CROSS_COMPILE),) - CC_SUFFIXES = linux linux-gnu unknown-linux-gnu - CROSS_COMPILE := $(call cc-cross-prefix, \ + CC_SUFFIXES = linux linux-gnu unknown-linux-gnu + CROSS_COMPILE ?= $(call cc-cross-prefix, \ $(foreach a,$(CC_ARCHES), \ $(foreach s,$(CC_SUFFIXES),$(a)-$(s)-))) - endif endif ifdef CONFIG_DYNAMIC_FTRACE
arch/sh/Makefile +1 -3
@@ -10,9 +10,7 @@ # for more details. # ifneq ($(SUBARCH),$(ARCH)) - ifeq ($(CROSS_COMPILE),) - CROSS_COMPILE := $(call cc-cross-prefix, sh-linux- sh-linux-gnu- sh-unknown-linux-gnu-) - endif + CROSS_COMPILE ?= $(call cc-cross-prefix, sh-linux- sh-linux-gnu- sh-unknown-linux-gnu-) endif KBUILD_DEFCONFIG := shx3_defconfig
Signature · 7 lines
2.27.0 _______________________________________________ linux-snps-arc mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-snps-arc
Geert Uytterhoeven
maintainerHi Yamada-san,
Quoted 6 lines · Masahiro Yamada
Use ?= operator to let
arch/*/Makefileto assignCROSS_COMPILEonly whenCROSS_COMPILEis undefined.This allows arch-Makefiles to drop the ifeq ($(CROSS_COMPILE),) conditional.
Quoted 8 lines
This slightly changes the behavior; the arch-Makefile previously overrode
CROSS_COMPILEwhenCROSS_COMPILEhas already been made empty via an environment variable as in 'export CROSS_COMPILE='.With this commit, arch-Makefle will respect the user's environment set-up, which seems to be a more correct behavior.
Signed-off-by Masahiro Yamada <[email protected]>
Thanks for your patch!
Quoted 8 lines
---
arch/arc/Makefile | 4 +--- arch/h8300/Makefile | 4 +--- arch/m68k/Makefile | 4 +--- arch/mips/Makefile | 4 +--- arch/parisc/Makefile | 6 ++---- arch/sh/Makefile | 4 +---
What about arch/xtensa/Makefile?
arch/m68k/Makefile line 22
Quoted 12 lines
arch/m68k/Makefile +1
-3@@ -17,10 +17,8 @@ KBUILD_DEFCONFIG := multi_defconfig ifneq ($(SUBARCH),$(ARCH)) - ifeq ($(CROSS_COMPILE),) - CROSS_COMPILE := $(call cc-cross-prefix, \ + CROSS_COMPILE ?= $(call cc-cross-prefix, \ m68k-linux-gnu- m68k-linux- m68k-unknown-linux-gnu-) - endif endif
This does not seem to work as expected: my standard build scripts (using "make ARCH=m68k") no longer pick up the cross-compiler, but fall back to the native compiler, thus breaking the build.
Gr{oetje,eeting}s,
Geert
Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected] In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds
Quoted 37 lines · Geert Uytterhoeven
Hi Yamada-san,
Quoted 6 lines · Masahiro Yamada
Use ?= operator to let
arch/*/Makefileto assignCROSS_COMPILEonly whenCROSS_COMPILEis undefined.This allows arch-Makefiles to drop the ifeq ($(CROSS_COMPILE),) conditional.
Quoted 8 lines
This slightly changes the behavior; the arch-Makefile previously overrode
CROSS_COMPILEwhenCROSS_COMPILEhas already been made empty via an environment variable as in 'export CROSS_COMPILE='.With this commit, arch-Makefle will respect the user's environment set-up, which seems to be a more correct behavior.
Signed-off-by Masahiro Yamada <[email protected]>Thanks for your patch!
Quoted 8 lines
---
arch/arc/Makefile | 4 +--- arch/h8300/Makefile | 4 +--- arch/m68k/Makefile | 4 +--- arch/mips/Makefile | 4 +--- arch/parisc/Makefile | 6 ++---- arch/sh/Makefile | 4 +---What about
arch/xtensa/Makefile?Quoted 5 lines
arch/m68k/Makefile +0
-0@@ -17,10 +17,8 @@ KBUILD_DEFCONFIG := multi_defconfig
Quoted 11 lines
arch/m68k/Makefile line 22
Quoted 7 lines
arch/m68k/Makefile +1
-3ifneq ($(SUBARCH),$(ARCH)) - ifeq ($(CROSS_COMPILE),) - CROSS_COMPILE := $(call cc-cross-prefix, \ + CROSS_COMPILE ?= $(call cc-cross-prefix, \ m68k-linux-gnu- m68k-linux- m68k-unknown-linux-gnu-) - endif endifThis does not seem to work as expected: my standard build scripts (using "make ARCH=m68k") no longer pick up the cross-compiler, but fall back to the native compiler, thus breaking the build.
Agh, sorry, this patch does not work
because the top Makefile exports CROSS_COMPILE.
export ARCH SRCARCH CONFIG_SHELL BASH HOSTCC KBUILD_HOSTCFLAGS CROSS_COMPILE LD CC
Removing CROSS_COMPILE from that makes ?= work,
but it would break other parts.
Please ignore this patch.
Quoted 10 lines
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
Signature · 2 lines
Best Regards Masahiro Yamada
Quoted 60 lines · Masahiro Yamada
Quoted 37 lines · Geert Uytterhoeven
Hi Yamada-san,
Quoted 6 lines · Masahiro Yamada
Use ?= operator to let
arch/*/Makefileto assignCROSS_COMPILEonly whenCROSS_COMPILEis undefined.This allows arch-Makefiles to drop the ifeq ($(CROSS_COMPILE),) conditional.
Quoted 8 lines
This slightly changes the behavior; the arch-Makefile previously overrode
CROSS_COMPILEwhenCROSS_COMPILEhas already been made empty via an environment variable as in 'export CROSS_COMPILE='.With this commit, arch-Makefle will respect the user's environment set-up, which seems to be a more correct behavior.
Signed-off-by Masahiro Yamada <[email protected]>Thanks for your patch!
Quoted 8 lines
---
arch/arc/Makefile | 4 +--- arch/h8300/Makefile | 4 +--- arch/m68k/Makefile | 4 +--- arch/mips/Makefile | 4 +--- arch/parisc/Makefile | 6 ++---- arch/sh/Makefile | 4 +---What about
arch/xtensa/Makefile?Quoted 5 lines
arch/m68k/Makefile +0
-0@@ -17,10 +17,8 @@ KBUILD_DEFCONFIG := multi_defconfigQuoted 11 lines
arch/m68k/Makefile line 22
Quoted 7 lines
arch/m68k/Makefile +1
-3ifneq ($(SUBARCH),$(ARCH)) - ifeq ($(CROSS_COMPILE),) - CROSS_COMPILE := $(call cc-cross-prefix, \ + CROSS_COMPILE ?= $(call cc-cross-prefix, \ m68k-linux-gnu- m68k-linux- m68k-unknown-linux-gnu-) - endif endifThis does not seem to work as expected: my standard build scripts (using "make ARCH=m68k") no longer pick up the cross-compiler, but fall back to the native compiler, thus breaking the build.
Agh, sorry, this patch does not work
because the topMakefileexportsCROSS_COMPILE.export ARCH SRCARCH
CONFIG_SHELLBASH HOSTCCKBUILD_HOSTCFLAGSCROSS_COMPILELD CC
Quoted 20 lines
Removing
CROSS_COMPILEfrom that makes ?= work,
but it would break other parts.Please ignore this patch.
Quoted 10 lines
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
The following will make this patch work, but probably it is better to not do this...
Makefile +0 -1
@@ -506,7 +506,7 @@ KBUILD_LDFLAGS_MODULE := KBUILD_LDFLAGS := CLANG_FLAGS := -export ARCH SRCARCH CONFIG_SHELL BASH HOSTCC KBUILD_HOSTCFLAGS
CROSS_COMPILE LD CC
+export ARCH SRCARCH CONFIG_SHELL BASH HOSTCC KBUILD_HOSTCFLAGS LD CC
export CPP AR NM STRIP OBJCOPY OBJDUMP READELF PAHOLE RESOLVE_BTFIDS
LEX YACC AWK INSTALLKERNEL
export PERL PYTHON3 CHECK CHECKFLAGS MAKE UTS_MACHINE HOSTCXX export KGZIP KBZIP2 KLZOP LZMA LZ4 XZ ZSTD
@@ -681,6 +681,8 @@ export RETPOLINE_VDSO_CFLAGS
include arch/$(SRCARCH)/Makefile
+export CROSS_COMPILE
+
ifdef need-config
ifdef may-sync-config
# Read in dependencies to all Kconfig* files, make sure to run syncconfig if
Signature · 2 lines
Best Regards Masahiro Yamada