Installing bootstrap glibc headers so you can build gcc-3.3. Not for the faint-hearted...

Dan Kegel
Sun Jun 22 05:22:00 GMT 2003

When building gcc-3.3/glibc-2.3.2 cross toolchains,
you have to do a bootstrap install of glibc headers,
then build a bootstrap compiler,
then build the real glibc,
then build the real gcc.

That first step (a bootstrap install of glibc headers)
is new as of gcc-3.3, and it's not quite clear yet
what the best way to approach it is (or why it's needed,
or if there's a way to avoid it totally, hope hope).
I've been doing essentially

CC=gcc \
  ${GLIBC_DIR}/configure --host=$TARGET --prefix=/usr \
   --without-cvs --disable-sanity-checks --with-headers=${PREFIX}/${TARGET}/include
if grep -q GLIBC_2.3 ${GLIBC_DIR}/ChangeLog; then
         make sysdeps/gnu/errlist.c
         mkdir -p stdio-common
         touch stdio-common/errlist-compat.c
make cross-compiling=yes install_root=${PREFIX}/${TARGET} prefix="" install-headers
mkdir -p ${PREFIX}/${TARGET}/include/gnu
touch ${PREFIX}/${TARGET}/include/gnu/stubs.h
cp ${GLIBC_DIR}/include/features.h ${PREFIX}/${TARGET}/include/features.h

There are five kludges there:
1. CC=gcc
Unless you do this, configure tries to use $TARGET-gcc or something like that,
which fails miserably, since you haven't built that yet.
2. if glibc_2.3 ...
This hackery prevents glibc-2.3.x from generating errlist-compat.c,
which would fail because it passes real target options to $(CC),
which would fail because we haven't built a cc for the target yet.
3. cross-compiling=yes
Can't recall why this is needed, but something nasty happens if you leave it out.
4. --disable-sanity-checks
I guess building a cross-compiler is a bit on the insane side...
5. Manual install of stubs.h and features.h.  Bleah.

Well, that wasn't complicated enough for the hppa guys, so they added
another hoop to jump through.  The above fails for hppa with
  checking for assembler line separator... *** You need a newer assembler to compile glibc
This was discussed briefly at and
without real resolution.  It turns out there's a cheezy workaround; just
pass --enable-hacker-mode to the bootstrap glibc configure.  This
disables the particular sanity check causing the problem
(which, oddly, wasn't disabled by --disable-sanity-checks).
It's reasonable for glibc to require this for the moment, since
glibc doesn't officially support hppa yet, but it'd
be nice if it wasn't needed someday.

I'm looking forward to the day when building a cross toolchain isn't
such a Rube Goldberg process.
- Dan



For completeness, here's the actual script fragment I am trying now
to conditionally build and install bootstrap glibc headers.
This should be up at tomorrow sometime.

if grep -q gcc-3 ${GCC_DIR}/ChangeLog && test '!' -f ${PREFIX}/${TARGET}/include/features.h; then
     mkdir -p build-glibc-headers; cd build-glibc-headers

     if test '!' -f Makefile; then
         # The following three things have to be done to build glibc-2.3.x, but they don't hurt older versions.
         # 1. override CC to keep glibc's configure from using $TARGET-gcc.
         # 2. disable linuxthreads, which needs a real cross-compiler to generate tcb-offsets.h properly
         # 3. build with gcc 3.2 or later
         # Compare these options with the ones used when building glibc for real below - they're different.
         # As of glibc-2.3.2, to get this step to work for hppa-linux, you need --enable-hacker-mode
         # so when configure checks to make sure gcc has access to the assembler you just built...
         # Alternately, we could put ${PREFIX}/${TARGET}/bin on the path.
         CC=gcc \
             ${GLIBC_DIR}/configure --host=$TARGET --prefix=/usr \
             --without-cvs --disable-sanity-checks --with-headers=${PREFIX}/${TARGET}/include \

     if grep -q GLIBC_2.3 ${GLIBC_DIR}/ChangeLog; then
         # glibc-2.3.x passes cross options to $(CC) when generating errlist-compat.c, which fails without a real cross-compiler.
         # Fortunately, we don't need errlist-compat.c, since we just need .h files,
         # so work around this by creating a fake errlist-compat.c and satisfying its dependencies.
         # Another workaround might be to tell configure to not use any cross options to $(CC).
         # The real fix would be to get install-headers to not generate errlist-compat.c.
         make sysdeps/gnu/errlist.c
         mkdir -p stdio-common
         touch stdio-common/errlist-compat.c
     make cross-compiling=yes install_root=${PREFIX}/${TARGET} prefix="" install-headers

     # Two headers -- stubs.h and features.h -- aren't installed by install-headers,
     # so do them by hand.  We can tolerate an empty stubs.h for the moment.
     # See e.g.

     mkdir -p ${PREFIX}/${TARGET}/include/gnu
     touch ${PREFIX}/${TARGET}/include/gnu/stubs.h
     cp ${GLIBC_DIR}/include/features.h ${PREFIX}/${TARGET}/include/features.h

     cd ..
Dan Kegel

Want more information?  See the CrossGCC FAQ,
Want to unsubscribe? Send a note to

More information about the crossgcc mailing list