Page 1 of 1

Cross compiling the libgcc libaries, especially libgo

Posted: Mon Apr 08, 2013 9:36 am
by iansmith
I'm trying to build a cross-compiling version of gcc 4.6.3 including support for gccgo. My host system is OSX (x86_64-apple-darwin) and my target is 32bit linux (i686-pc-linux-gnu).

Using the guide, I successfully built binutils and installed them for use by my cross-compiling gcc.
Using the guide, I successfully built gcc 4.6.3 as a cross compiler.

I'm failing to build libgcc, which in my case includes libgo.

I have tried a number of things, but the seem to all boil down to the same two root problems. Here's the clue on the first problem that comes when I am trying build libgcc.

Code: Select all

/Users/iansmith/oder/build-gcc/./gcc/xgcc -B/Users/iansmith/oder/build-gcc/./gcc/ -B/Users/iansmith/oder/gocross/i686-pc-linux-gnu/bin/ -B/Users/iansmith/oder/gocross/i686-pc-linux-gnu/lib/ -isystem /Users/iansmith/oder/gocross/i686-pc-linux-gnu/include -isystem /Users/iansmith/oder/gocross/i686-pc-linux-gnu/sys-include    -g -O2 -O2  -g -O2 -DIN_GCC -DCROSS_DIRECTORY_STRUCTURE  -W -Wall -Wwrite-strings -Wcast-qual -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition  -isystem ./include  -fPIC -g -DHAVE_GTHR_DEFAULT -DIN_LIBGCC2 -D__GCC_FLOAT_NOT_NEEDED -fno-stack-protector -Dinhibit_libc  -I. -I. -I../.././gcc -I../../../gcc_4_6_3_release/libgcc -I../../../gcc_4_6_3_release/libgcc/. -I../../../gcc_4_6_3_release/libgcc/../gcc -I../../../gcc_4_6_3_release/libgcc/../include -I../../../gcc_4_6_3_release/libgcc/config/libbid -DENABLE_DECIMAL_BID_FORMAT -DHAVE_CC_TLS  -DUSE_TLS -o bid_decimal_globals.o -MT bid_decimal_globals.o -MD -MP -MF bid_decimal_globals.dep -c ../../../gcc_4_6_3_release/libgcc/config/libbid/bid_decimal_globals.c

Code: Select all

../../../gcc_4_6_3_release/libgcc/config/libbid/bid_decimal_globals.c:47:18: fatal error: fenv.h: No such file or directory
fenv.h is part of the c++ standard library and is present in the distribution.

Code: Select all

$ find ../gcc_4_6_3_release/ -name fenv.h
../gcc_4_6_3_release//libstdc++-v3/include/c_compatibility/fenv.h
../gcc_4_6_3_release//libstdc++-v3/include/tr1/fenv.h

I have tried to change the CXXFLAGS that are set at the time of ./configure but that seems to have no effect.

Problem #2 has a workaround, but something seems broken and maybe it is a symptom of something I am doing wrong:

When I build gcc I get the cross compiler as gcc/xgcc in my build directory. However, the assembler in gcc/as seems to have a problem in it's script. If I go in and check the environment variables at the top:

Code: Select all

ORIGINAL_AS_FOR_TARGET="/Users/iansmith/oder/gocross/i686-pc-linux-gnu/bin/as"
ORIGINAL_LD_FOR_TARGET="/Users/iansmith/oder/gocross/i686-pc-linux-gnu/bin/ld"
ORIGINAL_PLUGIN_LD_FOR_TARGET="/Users/iansmith/oder/gocross/i686-pc-linux-gnu/bin/ld"
ORIGINAL_NM_FOR_TARGET="/Users/iansmith/oder/gocross/i686-pc-linux-gnu/bin/nm"
These are my "workaround" values that point to the values built by the compile of gcc step. They are initially "" (empty) which causes the gcc/as script to fail out. I was careful to try to make sure that my PATH was set properly to includes this directory at the time I did configure of the gcc source.

Any thoughts on either of these?

thanks
ian smith

Re: Cross compiling the libgcc libaries, especially libgo

Posted: Fri Apr 12, 2013 6:17 am
by sortie
Hi,

The <fenv.h> header is normally part of the target system libm. Such a header does not come with the GNU compiler collection - you can normally find it with your target system libc if it isn't a separate project, in this case probably amongst GNU libc. Note, however, that the files that you claim satisfies the need for a <fenv.h> actually isn't <fenv.h> implementations, but rather C++ compatibility wrapper headers that contain statements such as #include_next <fenv.h>. That is, these headers fix or extend the C <fenv.h> header with some C++ stuff. However, they still rely on the presence of a compatible <fenv.h> somewhere else. It would seem that your cross-compiler is failing to find such a header when it builds the auxiliary support libraries (libm, libgo, ...).

The solution is that you should create a system root for the target system whose location you pass to gcc's configure using --with-sysroot=$SYSROOT_PATH. In this system root, you should install all the headers of your target system libc and libm (into a location such as /usr/include or where your cross-compiler will look for the headers). You should be sure that a fenv.h is properly installed into this directory, noting that this header depends on the system architecture and might be inside a /usr/include/i386-linux-gnu directory on multiarch Linux distributions - in that case, your should verify that your cross-compiler is looking inside that directory. You can pass --verbose to your cross gcc to see in which directories it searches for headers (doesn't list non-existent directories it tries to search).

For further help, please include the exact configure line you used as well as giving the exact failed command executed by make and the error it gave, without separating the two - this way we know exactly what happened.

You are using an older gcc, you may wish to use a newer release such as gcc 4.8.0.

I don't understand your second question. As a random guess, have you added the directories with your cross binutils to PATH before running gcc configure? Trying hack the makefile and override the defaults should never be needed.