public inbox for linux-parisc@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] parisc: make default cross compiler search more robust
@ 2013-05-09  5:08 Mike Frysinger
  2013-05-09 12:28 ` Jeroen Roovers
  0 siblings, 1 reply; 7+ messages in thread
From: Mike Frysinger @ 2013-05-09  5:08 UTC (permalink / raw)
  To: linux-parisc, Helge Deller, James E.J. Bottomley; +Cc: John David Anglin

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

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
---
 arch/parisc/Makefile | 20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/arch/parisc/Makefile b/arch/parisc/Makefile
index 2f967cc..523ae34 100644
--- a/arch/parisc/Makefile
+++ b/arch/parisc/Makefile
@@ -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
-- 
1.8.2.1


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

* Re: [PATCH] parisc: make default cross compiler search more robust
  2013-05-09  5:08 [PATCH] parisc: make default cross compiler search more robust Mike Frysinger
@ 2013-05-09 12:28 ` Jeroen Roovers
  2013-05-09 13:14   ` Helge Deller
  0 siblings, 1 reply; 7+ messages in thread
From: Jeroen Roovers @ 2013-05-09 12:28 UTC (permalink / raw)
  To: linux-parisc
  Cc: Mike Frysinger, Helge Deller, James E.J. Bottomley,
	John David Anglin

On Thu,  9 May 2013 01:08:35 -0400
Mike Frysinger <vapier@gentoo.org> 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_COMPILE isn't
> explicitly set.

Several architectures appear to use a scriptlet called 
cc-cross-prefix for this. See scripts/Kbuild.include.


     jer

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

* Re: [PATCH] parisc: make default cross compiler search more robust
  2013-05-09 12:28 ` Jeroen Roovers
@ 2013-05-09 13:14   ` Helge Deller
  2013-05-09 19:24     ` Mike Frysinger
  0 siblings, 1 reply; 7+ messages in thread
From: Helge Deller @ 2013-05-09 13:14 UTC (permalink / raw)
  To: Jeroen Roovers
  Cc: linux-parisc, Mike Frysinger, James E.J. Bottomley,
	John David Anglin

On 05/09/2013 02:28 PM, Jeroen Roovers wrote:
> On Thu,  9 May 2013 01:08:35 -0400
> Mike Frysinger <vapier@gentoo.org> 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_COMPILE isn'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

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

* Re: [PATCH] parisc: make default cross compiler search more robust
  2013-05-09 13:14   ` Helge Deller
@ 2013-05-09 19:24     ` Mike Frysinger
  0 siblings, 0 replies; 7+ messages in thread
From: Mike Frysinger @ 2013-05-09 19:24 UTC (permalink / raw)
  To: Helge Deller
  Cc: Jeroen Roovers, linux-parisc, James E.J. Bottomley,
	John David Anglin

[-- Attachment #1: Type: Text/Plain, Size: 1906 bytes --]

On Thursday 09 May 2013 09:14:51 Helge Deller wrote:
> On 05/09/2013 02:28 PM, Jeroen Roovers wrote:
> > 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_COMPILE isn'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?

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.0
CC_SUFFIXES = linux linux-gnu unknown-linux-gnu
CROSS_COMPILE := $(call cc-cross-prefix, \
	$(foreach a,$(CC_ARCHES),$(foreach s,$(CC_SUFFIXES),$(a)-$(s)-)))
-mike

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

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

* [PATCH] parisc: make default cross compiler search more robust
@ 2013-05-16 19:32 Helge Deller
  2013-05-17 18:25 ` Greg KH
  0 siblings, 1 reply; 7+ messages in thread
From: Helge Deller @ 2013-05-16 19:32 UTC (permalink / raw)
  To: stable, linux-parisc

please add to stable kernel v3.9
this patch is a merge of upstream commits 
	93782eba49e23c3f311a6b05a19ba15927ec4e8b
and
	6880b0150a7c25fd75c5ece80abc49ebf53c38c1


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.

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
	hppa2.0-unknown-linux-gnu
	hppa2.0-linux-gnu
	hppa2.0-linux
	hppa1.1-unknown-linux-gnu
	hppa1.1-linux-gnu
	hppa1.1-linux

This patch was initiated by Mike Frysinger, with feedback from Jeroen
Roovers, John David Anglin and Helge Deller.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Jeroen Roovers <jer@gentoo.org>
Signed-off-by: John David Anglin <dave.anglin@bell.net>
Signed-off-by: Helge Deller <deller@gmx.de>

diff --git a/arch/parisc/Makefile b/arch/parisc/Makefile
index 113e282..1976900 100644
--- a/arch/parisc/Makefile
+++ b/arch/parisc/Makefile
@@ -23,26 +23,21 @@ NM		= sh $(srctree)/arch/parisc/nm
 CHECKFLAGS	+= -D__hppa__=1
 LIBGCC		= $(shell $(CC) $(KBUILD_CFLAGS) -print-libgcc-file-name)
 
-MACHINE		:= $(shell uname -m)
-ifeq ($(MACHINE),parisc*)
-NATIVE		:= 1
-endif
-
 ifdef CONFIG_64BIT
 UTS_MACHINE	:= parisc64
 CHECKFLAGS	+= -D__LP64__=1 -m64
-WIDTH		:= 64
+CC_ARCHES	= hppa64
 else # 32-bit
-WIDTH		:=
+CC_ARCHES	= hppa hppa2.0 hppa1.1
 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
+ifneq ($(SUBARCH),$(UTS_MACHINE))
+	ifeq ($(CROSS_COMPILE),)
+		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
 
 OBJCOPY_FLAGS =-O binary -R .note -R .comment -S

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

* Re: [PATCH] parisc: make default cross compiler search more robust
  2013-05-16 19:32 Helge Deller
@ 2013-05-17 18:25 ` Greg KH
  2013-05-17 20:06   ` Helge Deller
  0 siblings, 1 reply; 7+ messages in thread
From: Greg KH @ 2013-05-17 18:25 UTC (permalink / raw)
  To: Helge Deller; +Cc: stable, linux-parisc

On Thu, May 16, 2013 at 09:32:20PM +0200, Helge Deller wrote:
> please add to stable kernel v3.9
> this patch is a merge of upstream commits 
> 	93782eba49e23c3f311a6b05a19ba15927ec4e8b
> and
> 	6880b0150a7c25fd75c5ece80abc49ebf53c38c1

I prefer to take the original upstream patches, so I've just applied
both of these, instead of your merge.

thanks,

greg k-h

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

* Re: [PATCH] parisc: make default cross compiler search more robust
  2013-05-17 18:25 ` Greg KH
@ 2013-05-17 20:06   ` Helge Deller
  0 siblings, 0 replies; 7+ messages in thread
From: Helge Deller @ 2013-05-17 20:06 UTC (permalink / raw)
  To: Greg KH; +Cc: stable, linux-parisc

On 05/17/2013 08:25 PM, Greg KH wrote:
> On Thu, May 16, 2013 at 09:32:20PM +0200, Helge Deller wrote:
>> please add to stable kernel v3.9
>> this patch is a merge of upstream commits 
>> 	93782eba49e23c3f311a6b05a19ba15927ec4e8b
>> and
>> 	6880b0150a7c25fd75c5ece80abc49ebf53c38c1
> 
> I prefer to take the original upstream patches, so I've just applied
> both of these, instead of your merge.

That's absolutely fine.
Thanks!

Helge

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

end of thread, other threads:[~2013-05-17 20:06 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-05-09  5:08 [PATCH] parisc: make default cross compiler search more robust Mike Frysinger
2013-05-09 12:28 ` Jeroen Roovers
2013-05-09 13:14   ` Helge Deller
2013-05-09 19:24     ` Mike Frysinger
  -- strict thread matches above, loose matches on Subject: below --
2013-05-16 19:32 Helge Deller
2013-05-17 18:25 ` Greg KH
2013-05-17 20:06   ` Helge Deller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox