building native cross compiler
Michael Zintakis
michael.zintakis@googlemail.com
Sun Mar 13 14:23:00 GMT 2011
Ian,
I spent the whole day yesterday trying to build GCC2, though
unfortunately, I wasn't successful!
>> And my second (speculative) query - would it be wise to skip the first
>> step in this process (building GCC1) and build GCC2 instead and
>> continue the path from there? What would be the implications if such
>> path is to be followed (if at all possible that is)?
>>
>
> It would be neither wise nor unwise. It would save some time, and there
> would be a very small risk that the compiler you used instead of GCC1
> had a bug. (That has actually happened to me--a bug in the first
> compiler which subtly miscompiled the second compiler and caused
> problems in the code it generated--but not for many years.)
>
I did try this just as a 'test run', but hit a brick wall. Here is what
I did:
I've downloaded and unpacked gcc 4.5.2 (didn't want to use the new
version as 4.5.2 was already installed on my host system) in
~/gcc-test/gcc-4.5.2. I then created ~/gcc-test/gcc-build, jumped to it
and executed the following:
CC=gcc CFLAGS="-O2 -g -pipe -Wall -fexceptions -fstack-protector
--param=ssp-buffer-size=4" CXXFLAGS="-O2 -g -pipe -fexceptions
-fstack-protector --param=ssp-buffer-size=4" XCFLAGS="-O2 -g -pipe -Wall
-fexceptions -fstack-protector --param=ssp-buffer-size=4" TCFLAGS="-O2
-g -pipe -Wall -fexceptions -fstack-protector --param=ssp-buffer-size=4"
GCJFLAGS="-O2 -g -pipe -Wall -fexceptions -fstack-protector
--param=ssp-buffer-size=4" ../gcc-4.5.2/configure
--target=powerpc-redhat-linux --host=x86_64-redhat-linux
--build=x86_64-redhat-linux --prefix=/usr --disable-bootstrap
--enable-shared --enable-threads=posix --enable-checking=release
--with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions
--enable-gnu-unique-object --disable-nls
--enable-languages=c,c++,objc,obj-c++,fortran --disable-libgcj
--with-ppl --with-cloog --disable-multilib
That went well. I then executed the following:
GCJFLAGS="-O2 -g -pipe -Wall -fexceptions -fstack-protector
--param=ssp-buffer-size=4" make BOOT_CFLAGS="-O2 -g -pipe -Wall
-fexceptions -fstack-protector --param=ssp-buffer-size=4"
After a while I've got this error:
Configuring in powerpc-redhat-linux/libgcc
configure: creating cache ./config.cache
checking for --enable-version-specific-runtime-libs... no
checking for a BSD-compatible install... /usr/bin/install -c
checking for gawk... gawk
checking build system type... x86_64-redhat-linux-gnu
checking host system type... powerpc-redhat-linux-gnu
checking for powerpc-redhat-linux-ar... powerpc-redhat-linux-ar
checking for powerpc-redhat-linux-lipo... powerpc-redhat-linux-lipo
checking for powerpc-redhat-linux-nm... /home/mz/gcc-test/gcc-build/./gcc/nm
checking for powerpc-redhat-linux-ranlib... powerpc-redhat-linux-ranlib
checking for powerpc-redhat-linux-strip... powerpc-redhat-linux-strip
checking whether ln -s works... yes
checking for powerpc-redhat-linux-gcc...
/home/mz/gcc-test/gcc-build/./gcc/xgcc
-B/home/mz/gcc-test/gcc-build/./gcc/ -B/usr/powerpc-redhat-linux/bin/
-B/usr/powerpc-redhat-linux/lib/ -isystem
/usr/powerpc-redhat-linux/include -isystem
/usr/powerpc-redhat-linux/sys-include
checking for suffix of object files... configure: error: in
`/home/mz/gcc-test/gcc-build/powerpc-redhat-linux/libgcc':
configure: error: cannot compute suffix of object files: cannot compile
See `config.log' for more details.
make[1]: *** [configure-target-libgcc] Error 1
make[1]: Leaving directory `/home/mz/gcc-test/gcc-build'
make: *** [all] Error 2
Closer examination reveals that build-x86_64-redhat-linux is built,
though the above error happens when the build up of the ppc branch
starts. configure.log (which I have a copy of here and can attach, if
needed) shows this:
configure:2993: /home/mz/gcc-test/gcc-build/./gcc/xgcc
-B/home/mz/gcc-test/gcc-build/./gcc/ -B/usr/powerpc-redhat-linux/bin/
-B/usr/powerpc-redhat-linux/lib/ -isystem
/usr/powerpc-redhat-linux/include -isystem
/usr/powerpc-redhat-linux/sys-include -V >&5
xgcc: '-V' must come at the start of the command line
configure:3004: $? = 1
configure:2993: /home/mz/gcc-test/gcc-build/./gcc/xgcc
-B/home/mz/gcc-test/gcc-build/./gcc/ -B/usr/powerpc-redhat-linux/bin/
-B/usr/powerpc-redhat-linux/lib/ -isystem
/usr/powerpc-redhat-linux/include -isystem
/usr/powerpc-redhat-linux/sys-include -qversion >&5
xgcc: unrecognized option '-qversion'
xgcc: no input files
configure:3004: $? = 1
configure:3020: /home/mz/gcc-test/gcc-build/./gcc/xgcc
-B/home/mz/gcc-test/gcc-build/./gcc/ -B/usr/powerpc-redhat-linux/bin/
-B/usr/powerpc-redhat-linux/lib/ -isystem
/usr/powerpc-redhat-linux/include -isystem
/usr/powerpc-redhat-linux/sys-include -o conftest -O2 -g -pipe -Wall
-fexceptions -fstack-protector --param=ssp-buffer-size=4 conftest.c >&5
/home/mz/gcc-test/gcc-build/./gcc/as: line 83: exec: : not found
configure:3023: $? = 2
configure:3211: checking for suffix of object files
configure:3233: /home/mz/gcc-test/gcc-build/./gcc/xgcc
-B/home/mz/gcc-test/gcc-build/./gcc/ -B/usr/powerpc-redhat-linux/bin/
-B/usr/powerpc-redhat-linux/lib/ -isystem
/usr/powerpc-redhat-linux/include -isystem
/usr/powerpc-redhat-linux/sys-include -c -O2 -g -pipe -Wall
-fexceptions -fstack-protector --param=ssp-buffer-size=4 conftest.c >&5
/home/mz/gcc-test/gcc-build/./gcc/as: line 83: exec: : not found
configure:3237: $? = 2
configure: failed program was:
| /* confdefs.h */
| #define PACKAGE_NAME "GNU C Runtime Library"
| #define PACKAGE_TARNAME "libgcc"
| #define PACKAGE_VERSION "1.0"
| #define PACKAGE_STRING "GNU C Runtime Library 1.0"
| #define PACKAGE_BUGREPORT ""
| #define PACKAGE_URL "http://www.gnu.org/software/libgcc/"
| /* end confdefs.h. */
|
| int
| main ()
| {
|
| ;
| return 0;
| }
configure:3251: error: in
`/home/mz/gcc-test/gcc-build/powerpc-redhat-linux/libgcc':
configure:3254: error: cannot compute suffix of object files: cannot compile
See `config.log' for more details.
There is obviously something I am missing, but do not know what.
When I build gcc, but without cross compilation (i.e. multilib x86_64 ->
i586/i686) and execute this as a configure & make:
CC=gcc CFLAGS="-O2 -g -pipe -Wall -fexceptions -fstack-protector
--param=ssp-buffer-size=4 -mtune=core2" CXXFLAGS="-O2 -g -pipe
-fexceptions -fstack-protector --param=ssp-buffer-size=4 -mtune=core2"
XCFLAGS="-O2 -g -pipe -Wall -fexceptions -fstack-protector
--param=ssp-buffer-size=4 -mtune=core2" TCFLAGS="-O2 -g -pipe -Wall
-fexceptions -fstack-protector --param=ssp-buffer-size=4 -mtune=core2"
GCJFLAGS="-O2 -g -pipe -Wall -fexceptions -fstack-protector
--param=ssp-buffer-size=4 -mtune=core2" ../gcc-4.5.2/configure
--prefix=/usr --disable-bootstrap --enable-shared --enable-threads=posix
--enable-checking=release --with-system-zlib --enable-__cxa_atexit
--disable-libunwind-exceptions --enable-gnu-unique-object --disable-nls
--enable-languages=c,c++,objc,obj-c++,fortran --disable-libgcj
--with-ppl --with-cloog --with-tune-32=pentium4 --with-tune-64=core2
--with-cpu-32=pentium4 --with-cpu-64=core2 --with-arch-32=pentium4
--with-arch-64=core2 --enable-multilib
GCJFLAGS="-O2 -g -pipe -Wall -fexceptions -fstack-protector
--param=ssp-buffer-size=4 -mtune=core2" make BOOT_CFLAGS="-O2 -g -pipe
-Wall -fexceptions -fstack-protector --param=ssp-buffer-size=4 -mtune=core2"
I do not have the above error and everything is OK. I end up with
"build-x86_64-redhat-linux" as well as "x86_64-redhat-linux" directories
and they have their 32/ counterparts completely built as well. So, to me
it is something to do with the cross-compilation I am attempting.
There is another 'weird' problem I am getting - when I execute 'make
-j3' instead of just 'make' the build stops with the following error:
config.status: linking ../../gcc-4.5.2/gmp/mpn/generic/gmp-mparam.h to
gmp-mparam.h
config.status: executing libtool commands
make[1]: Leaving directory `/home/mz/gcc-test/gcc-build'
make: *** [all] Error 2
When I restart make again with the same command after that error (i.e.
execute the same 'make -j3' from that point) the build continues without
problems! Weird!
More information about the Gcc-help
mailing list