2004-11-24 22:47:19

by H. Peter Anvin

[permalink] [raw]
Subject: [PATCH] Allow compiling i386 with an x86-64 compiler

This patch adds -m32 if gcc supports it, thus making it easier to
compile the i386 architecture with an x86-64 compiler.

Note that it adds the option to CC, since it also affects assembly code
and linking. The extra level of indirection is because $(call
cc-option) itself uses $(CC), so just doing CC += ... would cause $(CC)
to be recursively defined.

-hpa


Signed-Off-By: H. Peter Anvin <[email protected]>


Attachments:
build_on_x86_64.diff (602.00 B)

2004-11-29 18:50:10

by Tom Rini

[permalink] [raw]
Subject: Re: [PATCH] Allow compiling i386 with an x86-64 compiler

On Wed, Nov 24, 2004 at 08:22:05AM -0800, H. Peter Anvin wrote:

> This patch adds -m32 if gcc supports it, thus making it easier to
> compile the i386 architecture with an x86-64 compiler.
>
> Note that it adds the option to CC, since it also affects assembly code
> and linking. The extra level of indirection is because $(call
> cc-option) itself uses $(CC), so just doing CC += ... would cause $(CC)
> to be recursively defined.

Just so 'bi-arch' arches look the same, I'd like to suggest (and stolen
from ppc32) something like:
HAS_BIARCH := $(call cc-option-yn, -m32)
ifeq ($(HAS_BIARCH),y)
CC := $(CC) -m32
endif

Up near the top...

--
Tom Rini
http://gate.crashing.org/~trini/

2004-11-29 19:40:29

by H. Peter Anvin

[permalink] [raw]
Subject: Re: [PATCH] Allow compiling i386 with an x86-64 compiler

Tom Rini wrote:
> On Wed, Nov 24, 2004 at 08:22:05AM -0800, H. Peter Anvin wrote:
>
>
>>This patch adds -m32 if gcc supports it, thus making it easier to
>>compile the i386 architecture with an x86-64 compiler.
>>
>>Note that it adds the option to CC, since it also affects assembly code
>>and linking. The extra level of indirection is because $(call
>>cc-option) itself uses $(CC), so just doing CC += ... would cause $(CC)
>>to be recursively defined.
>
>
> Just so 'bi-arch' arches look the same, I'd like to suggest (and stolen
> from ppc32) something like:
> HAS_BIARCH := $(call cc-option-yn, -m32)
> ifeq ($(HAS_BIARCH),y)
> CC := $(CC) -m32
> endif
>
> Up near the top...
>

I'm not really happy with it, because it's misleading; it implies it
tests for a working x86-64 devel environment, which it doesn't. It's
not a strong opinion, though.

-hpa