building gcc 4.4.5 from source on Fedora 13

Mr Dash Four
Fri Nov 26 19:23:00 GMT 2010

Apologies if this is the wrong mailing list, but I could not find a 
Fedora-specific one for gcc (as my problem seems to be specific to the 
Fedora build of gcc 4.4.5 - at least that is what I think anyway)!

The reason I'd like to build gcc from source is so that I could enable 
multilib allowing me to compile code for both i686 and x86_64 
architectures (my machine is x86_64). The 'standard' Fedora distribution 
rpm does not allow me to do that - when I try "gcc -o hello -m32 
hello.c" or "gcc -o hello -march=i686 hello.c" I get the following errors:

/usr/bin/ld: skipping incompatible 
/usr/lib/gcc/x86_64-redhat-linux/4.4.5/ when searching for 
/usr/bin/ld: skipping incompatible 
/usr/lib/gcc/x86_64-redhat-linux/4.4.5/ when searching for 
/usr/bin/ld: cannot find -lgcc_s
collect2: ld returned 1 exit status


hello.c:1: error: CPU you selected does not support x86-64 instruction set

So I downloaded the source rpm and tried to build a binary rpm by 
running "rpmbuild -bb gcc.spec".

I've got a lot of errors and had to hack into this VERY POORLY designed 
file to disable the languages I do not need (gcc-java, fortran to name a 
few), but still no go!

I've passed (and fixed) the dreaded GCC No executable error, and then 
after all this (wasted about a day with this!) at my latest attempt 
after about an hour of compiling I've got this:

Executing(%install): /bin/sh -e /var/tmp/rpm-tmp.oz4CGW
+ umask 022
+ cd /home/zeek/rpmbuild/BUILD
+ '[' /home/zeek/rpmbuild/BUILDROOT/gcc-4.4.5-2.fc13.x86_64 '!=' / ']'
+ rm -rf /home/zeek/rpmbuild/BUILDROOT/gcc-4.4.5-2.fc13.x86_64
++ dirname /home/zeek/rpmbuild/BUILDROOT/gcc-4.4.5-2.fc13.x86_64
+ mkdir -p /home/zeek/rpmbuild/BUILDROOT
+ mkdir /home/zeek/rpmbuild/BUILDROOT/gcc-4.4.5-2.fc13.x86_64
+ cd gcc-4.4.5-20101113
+ export LANG
+ unset DISPLAY
+ rm -fr /home/zeek/rpmbuild/BUILDROOT/gcc-4.4.5-2.fc13.x86_64
+ cd obj-x86_64-redhat-linux
+ TARGET_PLATFORM=x86_64-redhat-linux
+ make -C x86_64-redhat-linux/libstdc++-v3
make: *** x86_64-redhat-linux/libstdc++-v3: No such file or directory.  
error: Bad exit status from /var/tmp/rpm-tmp.oz4CGW (%install)

Close examination of the gcc.spec file reveals that the last 3 
statements above (marked with '+') are executed from the gcc.spec file 
and they refer to an environment variable called gcc_target_platform, 
which is set at the very top of gcc.spec for my host architecture 
(x86_64) to the (presumably internal) value of __target_platform. Its 
value is "x86_64-redhat-linux" as evident from the above 3 statements, 
but the actual directory name is "x86_64-unknown-linux-gnu" in reality 
and that is why this fails.

I then tried to force the issue and set the --host and --build targets 
of ./configure to "x86_64-redhat-linux", but it then ./configure assumes 
the taget directory to be "x86_64-redhat-linux-gnu", which again fails 
at the above point simply because there is no subdirectory named 
"x86_64-redhat-linux" in the "obj-x86_64-redhat-linux" directory either!

I do not wish to change the value of either the gcc_target_platform or 
__target_platform variables because they are later used to install the 
32-bit libraries under the 64 architecture and create the symlinks, 
which are used with ld and gcc itself so I am not certain that gcc/ld 
will work after that.

Any idea how can I get out of this mess?

More information about the Gcc-help mailing list