parisc: make default cross compiler search more robust
PATCH 1/1 parisc: make default cross compiler search more robust
People/distros vary how they prefix the toolchain name for 64bit builds. Rather than enforce one convention over another, add a for loop which does a search for all the general prefixes. This code will run for both native and cross builds when CROSS_COMPILE isn't explicitly set.
For 64bit builds, we now search for (in order):
hppa64-unknown-linux-gnu
hppa64-linux-gnu
hppa64-linux
For 32bit builds, we look for:
hppa-unknown-linux-gnu hppa-linux-gnu hppa-linux hppa1.1-unknown-linux-gnu hppa1.1-linux-gnu hppa1.1-linux hppa2.0-unknown-linux-gnu hppa2.0-linux-gnu hppa2.0-linux
--- arch/parisc/Makefile | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-)
arch/parisc/Makefile +11 -9
@@ -23,9 +23,6 @@ NM = sh $(srctree)/arch/parisc/nm CHECKFLAGS += -D__hppa__=1 LIBGCC = $(shell $(CC) $(KBUILD_CFLAGS) -print-libgcc-file-name) -MACHINE := $(shell uname -m) -NATIVE := $(if $(filter parisc%,$(MACHINE)),1,0) - ifdef CONFIG_64BIT UTS_MACHINE := parisc64 CHECKFLAGS += -D__LP64__=1 -m64
@@ -35,12 +32,17 @@ WIDTH := endif # attempt to help out folks who are cross-compiling -ifeq ($(NATIVE),1) -CROSS_COMPILE := hppa$(WIDTH)-linux- -else - ifeq ($(CROSS_COMPILE),) - CROSS_COMPILE := hppa$(WIDTH)-linux-gnu- - endif +ifeq ($(CROSS_COMPILE),) +CROSS_COMPILE := $(shell \ + arches="hppa$(WIDTH)"; \ + [ -z "$(WIDTH)" ] && arches="$$a hppa1.1 hppa2.0"; \ + for a in $$arches; do \ + for p in unknown-linux-gnu linux-gnu linux; do \ + c="$$a-$$p-"; \ + command -v $${c}gcc >/dev/null 2>&1 && echo $$c && break 2; \ + done; \ + done \ +) endif OBJCOPY_FLAGS =-O binary -R .note -R .comment -S
Signature · 1 line
1.8.2.1
Quoted 5 lines · On Thu, 9 May 2013 01:08:35 -0400 Mike Frysinger <[email protected]> wrote:
People/distros vary how they prefix the toolchain name for 64bit builds. Rather than enforce one convention over another, add a for loop which does a search for all the general prefixes. This code will run for both native and cross builds when
CROSS_COMPILEisn't explicitly set.
Several architectures appear to use a scriptlet called cc-cross-prefix for this. See scripts/Kbuild.include.
jer
Helge Deller
maintainerQuoted 11 lines · Jeroen Roovers
Quoted 5 lines · On Thu, 9 May 2013 01:08:35 -0400 Mike Frysinger <[email protected]> wrote:
People/distros vary how they prefix the toolchain name for 64bit builds. Rather than enforce one convention over another, add a for loop which does a search for all the general prefixes. This code will run for both native and cross builds when
CROSS_COMPILEisn't explicitly set.Several architectures appear to use a scriptlet called cc-cross-prefix for this. See
scripts/Kbuild.include.
That's cool :-)
Basically this
+ifneq ($(SUBARCH),$(ARCH))
+ ifeq ($(CROSS_COMPILE),)
+ CROSS_COMPILE := $(call cc-cross-prefix, hppa$(WIDTH)-linux- hppa$(WIDTH)-linux-gnu-)
+ endif
endif
should then be enough.
Do we really need to search for:
hppa1.1-unknown-linux-gnu hppa1.1-linux-gnu hppa1.1-linux hppa2.0-unknown-linux-gnu hppa2.0-linux-gnu hppa2.0-linux
on 32bit?
Helge
Quoted 24 lines · On Thursday 09 May 2013 09:14:51 Helge Deller wrote:
Quoted 9 lines · Jeroen Roovers
Quoted 5 lines · On Thu, 9 May 2013 01:08:35 -0400 Mike Frysinger wrote:
People/distros vary how they prefix the toolchain name for 64bit builds. Rather than enforce one convention over another, add a for loop which does a search for all the general prefixes. This code will run for both native and cross builds when
CROSS_COMPILEisn't explicitly set.Several architectures appear to use a scriptlet called cc-cross-prefix for this. See
scripts/Kbuild.include.That's cool :-)
Basically this
(quoted diff) +3
-0+ifneq ($(SUBARCH),$(ARCH)) + ifeq ($(CROSS_COMPILE),) + CROSS_COMPILE := $(call cc-cross-prefix,hppa$(WIDTH)-linux- hppa$(WIDTH)-linux-gnu-)
+ endif
endifshould then be enough.
Quoted 8 lines
Do we really need to search for:
hppa1.1-unknown-linux-gnu hppa1.1-linux-gnu hppa1.1-linux hppa2.0-unknown-linux-gnu hppa2.0-linux-gnu hppa2.0-linuxon 32bit?
Gentoo actively uses hppa1.1 and hppa2.0 (i'm not sure we have any systems that don't use those). we've seen some projects key off of those tuples (like gmp) to change code selection.
similarly, the reason i included -unknown- is that is the tuple we use in Gentoo for our native toolchain. for 64bit ones, we've been using ${ARCH}64- linux as it was only good for building the kernel ... it didn't include a C lib itself.
along that last line, hppa is the only target anymore where we have a dedicated 64bit compiler for the kernel. all the other ports have biarch support in gcc/binutils :/.
CC_ARCHES = hppa$(WIDTH) hppa1.1 hppa2.0CC_SUFFIXES = linux linux-gnu unknown-linux-gnu
CROSS_COMPILE := $(call cc-cross-prefix, \ $(foreach a,$(CC_ARCHES),$(foreach s,$(CC_SUFFIXES),$(a)-$(s)-)))
-mike