Re: [PATCH 4/4] powerpc/Makefile: Auto detect cross compiler
Segher Boessenkool writes: > On Wed, Dec 06, 2023 at 10:55:48PM +1100, Michael Ellerman wrote: >> Look for various combinations, matching: >> powerpc(64(le)?)?(-unknown)?-linux(-gnu)?- >> >> There are more possibilities, but the above is known to find a compiler >> on Fedora and Ubuntu (which use linux-gnu-), and also detects the >> kernel.org cross compilers (which use linux-). > > $ sh ../config.sub powerpc64-linux > powerpc64-unknown-linux-gnu > > I am very very lazy, so buildall uses short names everywhere :-) I used to use just ppc64-gcc :) I can add more variants but didn't want to add too many unless someone is actually using them. > Btw, can you build the kernel for a config that differs in 32/64 or > BE/LE with the default your compiler uses? There is no reason this > shouldn't work (you don't use any system libraries), but you need to > use the correct compiler command-line flags for that always. Yes it should work. I've tested at least ppc64le/ppc64/ppc defconfigs. There have been bugs in the past but AFAIK we have fixed all of them, though there's probably some still lurking for more obscure configs. > Acked-by: Segher Boessenkool Thanks. cheers
Re: [PATCH 4/4] powerpc/Makefile: Auto detect cross compiler
On Wed, Dec 06, 2023 at 10:55:48PM +1100, Michael Ellerman wrote: > Look for various combinations, matching: > powerpc(64(le)?)?(-unknown)?-linux(-gnu)?- > > There are more possibilities, but the above is known to find a compiler > on Fedora and Ubuntu (which use linux-gnu-), and also detects the > kernel.org cross compilers (which use linux-). $ sh ../config.sub powerpc64-linux powerpc64-unknown-linux-gnu I am very very lazy, so buildall uses short names everywhere :-) Btw, can you build the kernel for a config that differs in 32/64 or BE/LE with the default your compiler uses? There is no reason this shouldn't work (you don't use any system libraries), but you need to use the correct compiler command-line flags for that always. Acked-by: Segher Boessenkool Segher
[PATCH 4/4] powerpc/Makefile: Auto detect cross compiler
If no cross compiler is specified, try to auto detect one. Look for various combinations, matching: powerpc(64(le)?)?(-unknown)?-linux(-gnu)?- There are more possibilities, but the above is known to find a compiler on Fedora and Ubuntu (which use linux-gnu-), and also detects the kernel.org cross compilers (which use linux-). This allows cross compiling with simply: # Ubuntu $ sudo apt install gcc-powerpc-linux-gnu # Fedora $ sudo dnf install gcc-powerpc64-linux-gnu $ make ARCH=powerpc defconfig $ make ARCH=powerpc -j 4 Inspired by arch/parisc/Makefile. Signed-off-by: Michael Ellerman --- arch/powerpc/Makefile | 11 +++ 1 file changed, 11 insertions(+) diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile index 48c06f5a0dc1..051247027da0 100644 --- a/arch/powerpc/Makefile +++ b/arch/powerpc/Makefile @@ -10,6 +10,17 @@ # Rewritten by Cort Dougan and Paul Mackerras # +ifdef cross_compiling + ifeq ($(CROSS_COMPILE),) +# Auto detect cross compiler prefix. +# Look for: (powerpc(64(le)?)?)(-unknown)?-linux(-gnu)?- +CC_ARCHES := powerpc powerpc64 powerpc64le +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 + HAS_BIARCH := $(call cc-option-yn, -m32) # Set default 32 bits cross compilers for vdso and boot wrapper -- 2.43.0