This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Building an x86_64-linux-gnux32 (x32) gcc wiki page


On Fri, Feb 20, 2015 at 5:51 AM, Martin Jambor <mjambor@suse.cz> wrote:
> Hi,
>
> I have spent quite some time trying to build an x32 gcc to debug a PR
> this week before I finally found the configure switch that made
> everything work.  In order to share this possibly valuable knowledge,
> I have created a wiki mini-page detailing how I managed to get it
> finally working:
>
> https://gcc.gnu.org/wiki/SettingUpX32GCC
>
> I've linked it from the "Tutorials, HOWTOs" section of the
> GettingStarted page because I did not find a better place.  Of course,
> feel free to correct any mistakes I might have made.
>

Thanks for doing this.

X32 codegen is always enabled for Linux/x86-64 targets.  You just need
to compile x32 run-time to compile programs in x32.  There are 2 ways to
enable x32 run-time:

1.  Configure GCC with --with-multilib-list=m32,m64,mx32.  It will enable
x32 multilib:

[hjl@gnu-tools-1 gcc-x32]$ file build-x86_64-linux/gcc/cc1plus
build-x86_64-linux/gcc/cc1plus: ELF 64-bit LSB executable, x86-64,
version 1 (GNU/Linux), dynamically linked, interpreter
/lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.32,
BuildID[sha1]=7fb3d0574eda3475dfb2247640524bb1099c9751, not stripped
[hjl@gnu-tools-1 gcc-x32]$ ./build-x86_64-linux/gcc/xgcc -v
Using built-in specs.
COLLECT_GCC=./build-x86_64-linux/gcc/xgcc
Target: x86_64-unknown-linux-gnu
Configured with: /export/gnu/import/git/gcc/configure
--enable-clocale=gnu --with-system-zlib --with-demangler-in-ld
--enable-languages=c,c++,fortran,java,lto,objc,obj-c++,go
--prefix=/usr/gcc-5.0.0-x32 --with-local-prefix=/usr/local
--enable-gnu-indirect-function --with-multilib-list=m32,m64,mx32
--enable-linker-build-id --enable-gnu-unique-object --with-fpmath=sse
Thread model: posix
gcc version 5.0.0 20141231 (experimental) (GCC)

[hjl@gnu-tools-1 gcc-x32]$

2.  Configure GCC with --with-abi=mx32.  It will bootstrap GCC into
x32 format with x32 run-time enabled:

[hjl@gnu-tools-1 gcc-x32-mx32]$ file build-x86_64-linux/gcc/cc1plus
build-x86_64-linux/gcc/cc1plus: ELF 32-bit LSB executable, x86-64,
version 1 (GNU/Linux), dynamically linked, interpreter
/libx32/ld-linux-x32.so.2, for GNU/Linux 3.4.0,
BuildID[sha1]=b44082efbfec9ec5e7309445110f266d6f43cbfe, not stripped
[hjl@gnu-tools-1 gcc-x32-mx32]$ ./build-x86_64-linux/gcc/xgcc -v
Using built-in specs.
COLLECT_GCC=./build-x86_64-linux/gcc/xgcc
Target: x86_64-unknown-linux-gnu
Configured with: /export/gnu/import/git/sources/gcc/configure
--enable-languages=c,c++ --disable-bootstrap
--prefix=/usr/gcc-5.0.0-mx32 --with-local-prefix=/usr/local
--enable-gnu-indirect-function --with-multilib-list=m32,m64,mx32
--enable-linker-build-id --enable-gnu-unique-object --with-abi=mx32
--with-fpmath=sse
Thread model: posix
gcc version 5.0.0 20150122 (experimental) (GCC)
[hjl@gnu-tools-1 gcc-x32-mx32]$

Either will produce GCC which support -mx32. x86_64-linux-gnux32 isn't
required to configure
GCC.


-- 
H.J.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]