linux-m68k.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] kbuild: use ?= to assign CROSS_COMPILE by arch-Makefile
@ 2021-04-11 13:55 Masahiro Yamada
  2021-04-12  7:44 ` Geert Uytterhoeven
  0 siblings, 1 reply; 4+ messages in thread
From: Masahiro Yamada @ 2021-04-11 13:55 UTC (permalink / raw)
  To: linux-kbuild
  Cc: Masahiro Yamada, Geert Uytterhoeven, Helge Deller,
	James E.J. Bottomley, Rich Felker, Thomas Bogendoerfer,
	Vineet Gupta, Yoshinori Sato, linux-kernel, linux-m68k,
	linux-mips, linux-parisc, linux-sh, linux-snps-arc,
	uclinux-h8-devel

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.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---

 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(-)

diff --git a/arch/arc/Makefile b/arch/arc/Makefile
index 4392c9c189c4..bd5a9daa3461 100644
--- a/arch/arc/Makefile
+++ b/arch/arc/Makefile
@@ -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__
 
diff --git a/arch/h8300/Makefile b/arch/h8300/Makefile
index ba0f26cfad61..d6e466dbfc00 100644
--- a/arch/h8300/Makefile
+++ b/arch/h8300/Makefile
@@ -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/
diff --git a/arch/m68k/Makefile b/arch/m68k/Makefile
index ea14f2046fb4..79208ad7a355 100644
--- a/arch/m68k/Makefile
+++ b/arch/m68k/Makefile
@@ -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
 
 #
diff --git a/arch/mips/Makefile b/arch/mips/Makefile
index e71d587af49c..75e4e46532a4 100644
--- a/arch/mips/Makefile
+++ b/arch/mips/Makefile
@@ -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
diff --git a/arch/parisc/Makefile b/arch/parisc/Makefile
index 7d9f71aa829a..62272cb3513c 100644
--- a/arch/parisc/Makefile
+++ b/arch/parisc/Makefile
@@ -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
diff --git a/arch/sh/Makefile b/arch/sh/Makefile
index 3bcbf52fb30e..0e8277be362e 100644
--- a/arch/sh/Makefile
+++ b/arch/sh/Makefile
@@ -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
-- 
2.27.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] kbuild: use ?= to assign CROSS_COMPILE by arch-Makefile
  2021-04-11 13:55 [PATCH] kbuild: use ?= to assign CROSS_COMPILE by arch-Makefile Masahiro Yamada
@ 2021-04-12  7:44 ` Geert Uytterhoeven
  2021-04-12  8:15   ` Masahiro Yamada
  0 siblings, 1 reply; 4+ messages in thread
From: Geert Uytterhoeven @ 2021-04-12  7:44 UTC (permalink / raw)
  To: Masahiro Yamada
  Cc: linux-kbuild, Helge Deller, James E.J. Bottomley, Rich Felker,
	Thomas Bogendoerfer, Vineet Gupta, Yoshinori Sato,
	Linux Kernel Mailing List, linux-m68k,
	open list:BROADCOM NVRAM DRIVER, Parisc List, Linux-sh list,
	arcml, moderated list:H8/300 ARCHITECTURE

Hi Yamada-san,

On Sun, Apr 11, 2021 at 3:56 PM Masahiro Yamada <masahiroy@kernel.org> wrote:
> 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.
>
> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>

Thanks for your patch!

> ---
>
>  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?

> --- a/arch/m68k/Makefile
> +++ b/arch/m68k/Makefile
> @@ -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

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] kbuild: use ?= to assign CROSS_COMPILE by arch-Makefile
  2021-04-12  7:44 ` Geert Uytterhoeven
@ 2021-04-12  8:15   ` Masahiro Yamada
  2021-04-12  8:27     ` Masahiro Yamada
  0 siblings, 1 reply; 4+ messages in thread
From: Masahiro Yamada @ 2021-04-12  8:15 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: linux-kbuild, Helge Deller, James E.J. Bottomley, Rich Felker,
	Thomas Bogendoerfer, Vineet Gupta, Yoshinori Sato,
	Linux Kernel Mailing List, linux-m68k,
	open list:BROADCOM NVRAM DRIVER, Parisc List, Linux-sh list,
	arcml, moderated list:H8/300 ARCHITECTURE

On Mon, Apr 12, 2021 at 4:44 PM Geert Uytterhoeven <geert@linux-m68k.org> wrote:
>
> Hi Yamada-san,
>
> On Sun, Apr 11, 2021 at 3:56 PM Masahiro Yamada <masahiroy@kernel.org> wrote:
> > 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.
> >
> > Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
>
> Thanks for your patch!
>
> > ---
> >
> >  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?
>
> > --- a/arch/m68k/Makefile
> > +++ b/arch/m68k/Makefile
> > @@ -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.


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.




> Gr{oetje,eeting}s,
>
>                         Geert
>
> --
> Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
>
> 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



-- 
Best Regards
Masahiro Yamada

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] kbuild: use ?= to assign CROSS_COMPILE by arch-Makefile
  2021-04-12  8:15   ` Masahiro Yamada
@ 2021-04-12  8:27     ` Masahiro Yamada
  0 siblings, 0 replies; 4+ messages in thread
From: Masahiro Yamada @ 2021-04-12  8:27 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: linux-kbuild, Helge Deller, James E.J. Bottomley, Rich Felker,
	Thomas Bogendoerfer, Vineet Gupta, Yoshinori Sato,
	Linux Kernel Mailing List, linux-m68k,
	open list:BROADCOM NVRAM DRIVER, Parisc List, Linux-sh list,
	arcml, moderated list:H8/300 ARCHITECTURE

On Mon, Apr 12, 2021 at 5:15 PM Masahiro Yamada <masahiroy@kernel.org> wrote:
>
> On Mon, Apr 12, 2021 at 4:44 PM Geert Uytterhoeven <geert@linux-m68k.org> wrote:
> >
> > Hi Yamada-san,
> >
> > On Sun, Apr 11, 2021 at 3:56 PM Masahiro Yamada <masahiroy@kernel.org> wrote:
> > > 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.
> > >
> > > Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
> >
> > Thanks for your patch!
> >
> > > ---
> > >
> > >  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?
> >
> > > --- a/arch/m68k/Makefile
> > > +++ b/arch/m68k/Makefile
> > > @@ -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.
>
>
> 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.
>
>
>
>
> > Gr{oetje,eeting}s,
> >
> >                         Geert
> >
> > --
> > Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
> >
> > 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...




diff --git a/Makefile b/Makefile
index cc77fd45ca64..26bf482f0d88 100644
--- a/Makefile
+++ b/Makefile
@@ -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






-- 
Best Regards
Masahiro Yamada

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-04-12  8:28 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-11 13:55 [PATCH] kbuild: use ?= to assign CROSS_COMPILE by arch-Makefile Masahiro Yamada
2021-04-12  7:44 ` Geert Uytterhoeven
2021-04-12  8:15   ` Masahiro Yamada
2021-04-12  8:27     ` Masahiro Yamada

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).