This is the mail archive of the gcc-help@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]

building a biarch x86_64/i686 toolchain


I've been reading around for a while now trying to figure out how to build
a biarch toolchain for use on my amd64 system. Currently everything on the
system is 32bit, including the kernel; the end goal is a compiler set that
will generate i686 compatible code when invoked as
'gcc -m32 file.c'
and x86_64 compatible/optimized code when invoked as
'gcc -m64 file.c' or 'gcc file.c'

this is a linux machine.

>From what I gather, I need to build a biarch binutils first, then configure
and install the headers from glibc, build a 'basic' gcc that only includes
the c compiler, and then rebuild gcc and glibc.
The tricky part seems to be in search paths; I'll need a /lib and a /lib64
or similar setup for each different copy of crt*, libc, and other paths
with objects that ld searches for, right?

binutils appears to build fine. I build it as follows
../binutils-2.14/configure --target=x86_64-linux --host=i686-pc-linux-gnu
  --prefix=/usr/nsys
  --with-sysroot=/usr/nsys
  --disable-nls
make
make install

I'm putting things in /usr/nsys for the time being because I want to be sure
I don't overwrite existing tools and break my existing toolchain.
The glibc headers also configure/'build' fine:
../glibc-2.3.2/configure --target=x86_64-linux \
  --disable-nls --with-elf --without-cvs \
  --prefix=/usr/nsys --enable-add-ons=linuxthreads
make cross-compiling=yes install-headers

The glibc build process seems to need some kernel include files too, so I
copy /usr/include{linux,asm,gnu,bits} over to /usr/nsys/include, and then
build as follows:
../gcc-3.4.0/configure --disable-nls --target=x86_64-linux \
   --enable-languages="c" \
   --enable-version-specific-runtime-libs \
   --disable-shared --disable-threads \
   --without-headers --without-libiberty \
   --prefix=/usr/nsys --with-sysroot=/usr/nsys
make all-gcc
make install-gcc

but the build fails during 'all-gcc' in 'unwind-dw2.c'. The error messages
I get seem to indicate that the compiler is trying to use registers which
my configured kernel doesn't know about? Just a guess..

if [ -f stmp-dirs ]; then true; else touch stmp-dirs; fi
/home/tfogal/tarballs/gcc1/gcc/xgcc -B/home/tfogal/tarballs/gcc1/gcc/ -B/usr/nsys/x86_64-linux/bin/ -B/usr/nsys/x86_64-linux/lib/ -isystem /usr/nsys/x86_64-linux/include -isystem /usr/nsys/x86_64-linux/sys-include -O2  -DIN_GCC -DCROSS_COMPILE -DNATIVE_CROSS   -W -Wall -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition  -isystem ./include  -fPIC -g  -DIN_LIBGCC2 -D__GCC_FLOAT_NOT_NEEDED  -I. -I -I../../gcc-3.4.0/gcc -I../../gcc-3.4.0/gcc/ -I../../gcc-3.4.0/gcc/../include  -fexceptions -c ../../gcc-3.4.0/gcc/unwind-dw2.c -o libgcc/./unwind-dw2.o
../../gcc-3.4.0/gcc/unwind-dw2.c: In function `uw_frame_state_for':
../../gcc-3.4.0/gcc/unwind-dw2.c:1022: error: structure has no member named `rsp'
../../gcc-3.4.0/gcc/unwind-dw2.c:1022: error: structure has no member named `rax'
../../gcc-3.4.0/gcc/unwind-dw2.c:1022: error: structure has no member named `rdx'
../../gcc-3.4.0/gcc/unwind-dw2.c:1022: error: structure has no member named `rcx'
../../gcc-3.4.0/gcc/unwind-dw2.c:1022: error: structure has no member named `rbx'
../../gcc-3.4.0/gcc/unwind-dw2.c:1022: error: structure has no member named `rsi'
../../gcc-3.4.0/gcc/unwind-dw2.c:1022: error: structure has no member named `rdi'
../../gcc-3.4.0/gcc/unwind-dw2.c:1022: error: structure has no member named `rbp'
../../gcc-3.4.0/gcc/unwind-dw2.c:1022: error: structure has no member named `r8'
../../gcc-3.4.0/gcc/unwind-dw2.c:1022: error: structure has no member named `r9'
../../gcc-3.4.0/gcc/unwind-dw2.c:1022: error: structure has no member named `r10'
../../gcc-3.4.0/gcc/unwind-dw2.c:1022: error: structure has no member named `r11'
../../gcc-3.4.0/gcc/unwind-dw2.c:1022: error: structure has no member named `r12'
../../gcc-3.4.0/gcc/unwind-dw2.c:1022: error: structure has no member named `r13'
../../gcc-3.4.0/gcc/unwind-dw2.c:1022: error: structure has no member named `r14'
../../gcc-3.4.0/gcc/unwind-dw2.c:1022: error: structure has no member named `r15'
../../gcc-3.4.0/gcc/unwind-dw2.c:1022: error: structure has no member named `rip'
make[2]: *** [libgcc/./unwind-dw2.o] Error 1
make[2]: Leaving directory `/home/tfogal/tarballs/gcc1/gcc'
make[1]: *** [stmp-multilib] Error 2
make[1]: Leaving directory `/home/tfogal/tarballs/gcc1/gcc'
make: *** [install-gcc] Error 2

For some context, heres whats around line 1022:

      /* Couldn't find frame unwind info for this function.  Try a
    target-specific fallback mechanism.  This will necessarily
    not provide a personality routine or LSDA.  */
#ifdef MD_FALLBACK_FRAME_STATE_FOR
----------
>>>>      MD_FALLBACK_FRAME_STATE_FOR (context, fs, success);
----------
      return _URC_END_OF_STACK;

with the emphasized line being 1022.

Any ideas on how to get by this? Do I need kernel includes appropriate for a
64bit kernel? If so, is there any way to get these without building a 64bit
kernel? I can't even 'make dep' currently because some of the dependency
tools are compiled and then run, and I can't seem to get the kernel to use
one compiler for things it will use in the build process and another for
building the actual kernel...

Thanks for any tips/pointers/ideas,

-tom


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