diff mbox

PATCH: Add x32 support to config.guess

Message ID 20120816172648.GA7120@intel.com
State New
Headers show

Commit Message

H.J. Lu Aug. 16, 2012, 5:26 p.m. UTC
Hi,

GCC on Linux/x86-64 may be configured for x32:

https://sites.google.com/site/x32abi/

by default and the Linux/x32 target should be x86_64-VENDOR-linux-gnux32.
This patch adds x32 support to config.guess.  OK to install?

Thanks.


H.J.
---
2012-08-16  H.J. Lu  <hongjiu.lu@intel.com>

	* config.guess (x86_64:Linux:*:*): Append x32 if compiler is
	configured for 32-bit  objects.

Comments

Ben Elliston Aug. 18, 2012, 12:49 p.m. UTC | #1
On Thu, Aug 16, 2012 at 10:26:48AM -0700, H.J. Lu wrote:

> GCC on Linux/x86-64 may be configured for x32:
> https://sites.google.com/site/x32abi/
> by default and the Linux/x32 target should be x86_64-VENDOR-linux-gnux32.
> This patch adds x32 support to config.guess.  OK to install?

> +	eval $set_cc_for_build

I am working to eliminate the use of $set_cc_for_build and am not
really willing to accept any new patches which make this further
entrenched.  Can you please find another way?

Thanks,
Ben
H.J. Lu Aug. 18, 2012, 1:52 p.m. UTC | #2
On Sat, Aug 18, 2012 at 5:49 AM, Ben Elliston <bje@air.net.au> wrote:
> On Thu, Aug 16, 2012 at 10:26:48AM -0700, H.J. Lu wrote:
>
>> GCC on Linux/x86-64 may be configured for x32:
>> https://sites.google.com/site/x32abi/
>> by default and the Linux/x32 target should be x86_64-VENDOR-linux-gnux32.
>> This patch adds x32 support to config.guess.  OK to install?
>
>> +     eval $set_cc_for_build
>
> I am working to eliminate the use of $set_cc_for_build and am not
> really willing to accept any new patches which make this further
> entrenched.  Can you please find another way?
>

In case of x32, the only difference between x32 and x86-64 is
the default output of CC.  What do you recommend how to
detect x32?

Thanks.
Mike Stump Aug. 18, 2012, 5:32 p.m. UTC | #3
On Aug 18, 2012, at 6:52 AM, "H.J. Lu" <hjl.tools@gmail.com> wrote:
> In case of x32, the only difference between x32 and x86-64 is
> the default output of CC.  What do you recommend how to
> detect x32?

So, is there a cpp symbol that is defined for code-gen?  If so, something like

  If [ $(gcc -x c /dev/null -dM -E | grep x32) = x32 ]; then fi

Would do it.
Mike Frysinger Aug. 18, 2012, 5:40 p.m. UTC | #4
On Saturday 18 August 2012 13:32:59 Mike Stump wrote:
> On Aug 18, 2012, at 6:52 AM, "H.J. Lu" <hjl.tools@gmail.com> wrote:
> > In case of x32, the only difference between x32 and x86-64 is
> > the default output of CC.  What do you recommend how to
> > detect x32?
> 
> So, is there a cpp symbol that is defined for code-gen?  If so, something
> like
> 
>   If [ $(gcc -x c /dev/null -dM -E | grep x32) = x32 ]; then fi
> 
> Would do it.

how is executing `gcc` any better than $CC_FOR_BUILD ?

your code suggestion here is pretty much what H.J. Lu is already doing.
-mike
H.J. Lu Aug. 18, 2012, 6:01 p.m. UTC | #5
On Sat, Aug 18, 2012 at 10:40 AM, Mike Frysinger <vapier@gentoo.org> wrote:
> On Saturday 18 August 2012 13:32:59 Mike Stump wrote:
>> On Aug 18, 2012, at 6:52 AM, "H.J. Lu" <hjl.tools@gmail.com> wrote:
>> > In case of x32, the only difference between x32 and x86-64 is
>> > the default output of CC.  What do you recommend how to
>> > detect x32?
>>
>> So, is there a cpp symbol that is defined for code-gen?  If so, something
>> like
>>
>>   If [ $(gcc -x c /dev/null -dM -E | grep x32) = x32 ]; then fi
>>
>> Would do it.
>
> how is executing `gcc` any better than $CC_FOR_BUILD ?
>
> your code suggestion here is pretty much what H.J. Lu is already doing.
> -mike

There are 12 existing set_cc_for_build usages in config.guess.
I don't think it is reasonable to require x32 not to use it without
providing an alternative.  If you want to remove set_cc_for_build,
one extra usage doesn't make it much harder to do.
Mike Frysinger Aug. 18, 2012, 6:53 p.m. UTC | #6
On Saturday 18 August 2012 14:01:57 H.J. Lu wrote:
> On Sat, Aug 18, 2012 at 10:40 AM, Mike Frysinger wrote:
> > On Saturday 18 August 2012 13:32:59 Mike Stump wrote:
> >> On Aug 18, 2012, at 6:52 AM, "H.J. Lu" <hjl.tools@gmail.com> wrote:
> >> > In case of x32, the only difference between x32 and x86-64 is
> >> > the default output of CC.  What do you recommend how to
> >> > detect x32?
> >> 
> >> So, is there a cpp symbol that is defined for code-gen?  If so,
> >> something like
> >> 
> >>   If [ $(gcc -x c /dev/null -dM -E | grep x32) = x32 ]; then fi
> >> 
> >> Would do it.
> > 
> > how is executing `gcc` any better than $CC_FOR_BUILD ?
> > 
> > your code suggestion here is pretty much what H.J. Lu is already doing.
> 
> There are 12 existing set_cc_for_build usages in config.guess.
> I don't think it is reasonable to require x32 not to use it without
> providing an alternative.  If you want to remove set_cc_for_build,
> one extra usage doesn't make it much harder to do.

(in case it wasn't clear, i'm in favor of H.J. Lu's patch)
-mike
diff mbox

Patch

diff --git a/config.guess b/config.guess
index b02565c..4b0f7c2 100755
--- a/config.guess
+++ b/config.guess
@@ -984,7 +984,18 @@  EOF
 	echo ${UNAME_MACHINE}-dec-linux-gnu
 	exit ;;
     x86_64:Linux:*:*)
-	echo x86_64-unknown-linux-gnu
+	eval $set_cc_for_build
+	X86_64_ABI=
+	# If there is a compiler, see if it is configured for 32-bit objects.
+	if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then
+	    if (echo '#ifdef __ILP32__'; echo IS_X32; echo '#endif') | \
+		(CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \
+		grep IS_X32 >/dev/null
+	    then
+		X86_64_ABI=x32
+	    fi
+	fi
+	echo x86_64-unknown-linux-gnu${X86_64_ABI}
 	exit ;;
     xtensa*:Linux:*:*)
 	echo ${UNAME_MACHINE}-unknown-linux-gnu