Building an x86_64-linux-gnux32 (x32) gcc

In order to get an x32 environment, I have followed the instructions at https://wiki.debian.org/X32Port to set up a Debian system in a chroot environment. Note that you do not need to be running Debian, it was very easy to do it under openSUSE 13.2 too, even without passing any special options at boot. Moreover, the debootstrap tool is pre-packaged for many Linux distributions. You just need to be running Linux kernel with compiled-in x32 support, which you can verify by grepping the corresponding config file, e.g.:

$ grep -i x32 /boot/config-3.16.7-7-desktop 
CONFIG_X86_X32=y

After you set up the chroot system, mount /proc and /sys filesystems as described at the end of the man pages of debootstrap and chroot into it. Then set up your environment as you prefer and use aptitude to install all GCC prerequisites.

After you check out the sources of trunk or the branch you want to build, create and enter a build directory and pass the following options to configure, in addition to those you wanted anyway:

Strictly speaking, only the first option is really necessary and compilation will keep failing in moderately mysterious ways if you omit it. ---build, --host and --target will make your built compiler report the correct triplet. I needed --disable-multilib to make configure succeed, but you can of course build a multilib gcc if you have the required libraries. To give an example, this is how I have configured and then successfully built an x32 trunk gcc to debug PR 65028:

/home/jamborm/gcc/trunk/src/configure --prefix=/home/jamborm/gcc/trunk/inst --enable-languages=c,c++ --enable-checking=yes --disable-bootstrap --disable-libsanitizer --disable-libcilkrts --build=x86_64-linux-gnux32 --host=x86_64-linux-gnux32 --target=x86_64-linux-gnux32 --with-abi=mx32 --disable-multilib

After configuring, run make and make install as usual.

None: SettingUpX32GCC (last edited 2015-02-20 13:42:14 by MartinJambor)