Help building a 32bit GCC that can generate 32/64bit (x86)
Paul Smith
paul@mad-scientist.net
Wed Apr 27 17:50:00 GMT 2011
Hi Ian; thanks for the reply!
On Wed, 2011-04-27 at 08:20 -0700, Ian Lance Taylor wrote:
> Paul Smith <paul@mad-scientist.net> writes:
>
> > I'd like to create a 32bit version of GCC (+ binutils) that can compile
> > for both 32bit and 64bit output.
>
> Do you mean that you want a gcc which is itself a 32-bit binary? Or do
> you mean that you want the default to be -m32?
What I'm trying to get is a GCC which is a 32bit app (so I can run it on
a 32bit version of Linux, and "file gcc" says it's i686 or similar).
But I want to be able to run both "gcc -m32" and "gcc -m64" and get the
appropriate outputs. Obviously if I run this gcc on a 32bit system and
use -m64 I won't be able to run that output on that system (it would
basically be a cross-compiler).
When I run this compiler, I'll be using --sysroot to point to an
appropriate multilib sysroot.
I don't much care whether the default is 32bit or 64bit although a
default of 32bit would be slightly preferable (but only very, very
slightly).
> I think the simplest way to do this would be to configure as usual on a
> 64-bit system, and build it using something like
> make BOOT_CFLAGS="-m32 -g -O2"
I tried to build on a 64bit system setting CC="gcc -m32" and CXX="g++
-m32" when running configure. But this failed. I'll look up
BOOT_CFLAGS and see what I can find out.
If I can get advice on the best way to proceed I'll go off and whack at
it for a while and come back with more specific issues. The main
options seem to me to be:
One, build on a 32bit host and use --target=x86_64-pc-linux-gnu (or
something) to get a 64bit cross compiler (I assume(?) the resulting
compiler will also be able to build 32bit targets).
Two, build on a 64bit host and figure out a way to force the resulting
compiler to be a 32bit application. Would the best way of doing that be
using configure with CC="gcc -m32"? Or setting --host=i686-pc-linux-gnu
(or similar)? Or...?
Or is there a third, better method?
> > I am using --enable-targets=all to configure.
>
> That only affects the binutils.
It's listed in the GCC install.info file... is it relevant only for
binutils?
More information about the Gcc-help
mailing list