libc/glibc: fix building for seemingly native toolchains
author"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Fri Oct 02 22:10:38 2009 +0200 (2009-10-02)
changeset 15518c40b842e798
parent 1550 2e84b052ed5f
child 1552 6ee673ab382e
libc/glibc: fix building for seemingly native toolchains

Build glibc with -O2 as a fix/workaround to building
seemingly-native toolchains.

See:
- docs/overview.txt
- docs/known-issues.txt
- http://sourceware.org/ml/crossgcc/2009-09/msg00055.html
docs/known-issues.txt
docs/overview.txt
scripts/build/libc/glibc.sh
     1.1 --- a/docs/known-issues.txt	Thu Oct 01 22:14:45 2009 +0200
     1.2 +++ b/docs/known-issues.txt	Fri Oct 02 22:10:38 2009 +0200
     1.3 @@ -51,8 +51,10 @@
     1.4    None known.
     1.5  
     1.6  Workaround:
     1.7 -  If this happens for you, stick with glibc-2.6.1 for now.
     1.8 -  Or investigate! :-)
     1.9 +  It seems that using -O2 in the CFLAGS fixes the problem. It has been
    1.10 +  confirmed in the following threads:
    1.11 +    http://sourceware.org/ml/crossgcc/2009-09/msg00055.html (for glibc)
    1.12 +    http://sourceware.org/ml/crossgcc/2009-10/msg00001.html (for eglibc)
    1.13  
    1.14  --------------------------------
    1.15  Symptoms:
     2.1 --- a/docs/overview.txt	Thu Oct 01 22:14:45 2009 +0200
     2.2 +++ b/docs/overview.txt	Fri Oct 02 22:10:38 2009 +0200
     2.3 @@ -28,6 +28,7 @@
     2.4    Tools wrapper
     2.5  Using the toolchain
     2.6  Toolchain types
     2.7 +  Seemingly-native toolchains
     2.8  Internals
     2.9    Makefile front-end
    2.10    Kconfig parser
    2.11 @@ -590,6 +591,21 @@
    2.12      were all being hashed out, Canada had three national political parties.
    2.13      http://en.wikipedia.org/wiki/Cross_compiler
    2.14  
    2.15 +Seemingly-native toolchains |
    2.16 +----------------------------+
    2.17 +
    2.18 +Seemingly-native toolchains are toolchains that target the same architecture
    2.19 +as the one it is built on, and on which it will run, but the machine tuple
    2.20 +may be different (eg i686 vs. i386, or x86_64-unknown-linux-gnu vs.
    2.21 +x86_64-pc-linux-gnu). This also applies if the target architecture is of the
    2.22 +same kind (eg. x86 vs. x86_64, or ppc vs. ppc64).
    2.23 +
    2.24 +Such toolchain is tricky to build, as the configure scripts may incorrectly
    2.25 +assume that files (headers and libs) from the build (or host) machine can be
    2.26 +used by the cross-compiler it is going to build. The problem seems to arise
    2.27 +only with glibc (and eglibc?) starting with version 2.7.
    2.28 +
    2.29 +
    2.30  _____________
    2.31              /
    2.32  Internals  /
     3.1 --- a/scripts/build/libc/glibc.sh	Thu Oct 01 22:14:45 2009 +0200
     3.2 +++ b/scripts/build/libc/glibc.sh	Fri Oct 02 22:10:38 2009 +0200
     3.3 @@ -180,7 +180,7 @@
     3.4  
     3.5          libc_cv_ppc_machine=yes                         \
     3.6          CT_DoExecLog ALL                                \
     3.7 -        make CFLAGS="-O -DBOOTSTRAP_GCC"                \
     3.8 +        make CFLAGS="-O2 -DBOOTSTRAP_GCC"               \
     3.9               OBJDUMP_FOR_HOST="${CT_TARGET}-objdump"    \
    3.10               PARALLELMFLAGS="${PARALLELMFLAGS}"         \
    3.11               sysdeps/gnu/errlist.c
    3.12 @@ -197,7 +197,7 @@
    3.13      CT_DoExecLog ALL                                \
    3.14      make cross-compiling=yes                        \
    3.15           install_root=${CT_SYSROOT_DIR}             \
    3.16 -         CFLAGS="-O -DBOOTSTRAP_GCC"                \
    3.17 +         CFLAGS="-O2 -DBOOTSTRAP_GCC"               \
    3.18           ${LIBC_SYSROOT_ARG}                        \
    3.19           OBJDUMP_FOR_HOST="${CT_TARGET}-objdump"    \
    3.20           PARALLELMFLAGS="${PARALLELMFLAGS}"         \
    3.21 @@ -325,7 +325,7 @@
    3.22      # Please see the comment for the configure step in do_libc().
    3.23  
    3.24      BUILD_CC="${CT_BUILD}-gcc"                                      \
    3.25 -    CFLAGS="${CT_TARGET_CFLAGS} ${CT_LIBC_GLIBC_EXTRA_CFLAGS} -O "  \
    3.26 +    CFLAGS="${CT_TARGET_CFLAGS} ${CT_LIBC_GLIBC_EXTRA_CFLAGS} -O2"  \
    3.27      CC="${cross_cc} ${CT_LIBC_EXTRA_CC_ARGS} ${extra_cc_args}"      \
    3.28      AR=${CT_TARGET}-ar                                              \
    3.29      RANLIB=${CT_TARGET}-ranlib                                      \
    3.30 @@ -457,7 +457,7 @@
    3.31      # silly messages. GNU folks again, he?
    3.32  
    3.33      BUILD_CC="${CT_BUILD}-gcc"                                      \
    3.34 -    CFLAGS="${CT_TARGET_CFLAGS} ${CT_LIBC_GLIBC_EXTRA_CFLAGS} -O"   \
    3.35 +    CFLAGS="${CT_TARGET_CFLAGS} ${CT_LIBC_GLIBC_EXTRA_CFLAGS} -O2"  \
    3.36      CC="${CT_TARGET}-gcc ${CT_LIBC_EXTRA_CC_ARGS} ${extra_cc_args}" \
    3.37      AR=${CT_TARGET}-ar                                              \
    3.38      RANLIB=${CT_TARGET}-ranlib                                      \