# HG changeset patch # User Johannes Stezenbach # Date 1280425636 -7200 # Node ID fdaa6c7f6dea27928e87fdea11a87e5a04d5f68a # Parent 20dd8cef1c8adff0aa3e78ae6d7acfbc45ed5a83 cc/gcc: add option to compile against static libstdc++, for gcc-4.4 and newer Idea and know-how taken from CodeSourcery build script. Normal build: $ ldd arm-unknown-linux-uclibcgnueabi-gcc linux-gate.so.1 => (0xb77f3000) libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0xb76e8000) libc.so.6 => /lib/i686/cmov/libc.so.6 (0xb75a1000) libm.so.6 => /lib/i686/cmov/libm.so.6 (0xb757a000) /lib/ld-linux.so.2 (0xb77f4000) libgcc_s.so.1 => /lib/libgcc_s.so.1 (0xb755c000) CC_STATIC_LIBSTDCXX=y: $ ldd arm-unknown-linux-uclibcgnueabi-gcc linux-gate.so.1 => (0xb7843000) libc.so.6 => /lib/i686/cmov/libc.so.6 (0xb76e6000) /lib/ld-linux.so.2 (0xb7844000) I made CC_STATIC_LIBSTDCXX default=y since I think it is always desirable. Signed-off-by: Johannes Stezenbach diff -r 20dd8cef1c8a -r fdaa6c7f6dea config/cc/gcc.in.2 --- a/config/cc/gcc.in.2 Thu Jul 29 19:30:37 2010 +0200 +++ b/config/cc/gcc.in.2 Thu Jul 29 19:47:16 2010 +0200 @@ -7,6 +7,18 @@ This will compile crossgcc's libs with -Os. +config CC_STATIC_LIBSTDCXX + bool + prompt "Link libstdc++ statically into the gcc binary" + default y + depends on CC_GCC_4_4_or_later + help + Newer gcc versions use the PPL library which is C++ code. Statically + linking libstdc++ increases the likeliness that the gcc binary will + run on machines other than the one which it was built on, without + having to worry about distributing the matching version of libstdc++ + along with it. + comment "Misc. obscure options." config CC_CXA_ATEXIT diff -r 20dd8cef1c8a -r fdaa6c7f6dea scripts/build/cc/gcc.sh --- a/scripts/build/cc/gcc.sh Thu Jul 29 19:30:37 2010 +0200 +++ b/scripts/build/cc/gcc.sh Thu Jul 29 19:47:16 2010 +0200 @@ -347,10 +347,16 @@ extra_config+=(--disable-libmudflap) fi - # When companion libraries are build static (eg !shared), - # the libstdc++ is not pulled automatically, although it - # is needed. Shoe-horn it in our LDFLAGS - if [ "${CT_COMPLIBS_SHARED}" != "y" ]; then + if [ "${CT_CC_STATIC_LIBSTDCXX}" = "y" ]; then + # this is from CodeSourcery arm-2010q1-202-arm-none-linux-gnueabi.src.tar.bz2 + # build script + # FIXME: if the host gcc is gcc-4.5 then presumably we could use -static-libstdc++, + # see http://gcc.gnu.org/ml/gcc-patches/2009-06/msg01635.html + extra_config+=("--with-host-libstdcxx=-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic -lm") + elif [ "${CT_COMPLIBS_SHARED}" != "y" ]; then + # When companion libraries are build static (eg !shared), + # the libstdc++ is not pulled automatically, although it + # is needed. Shoe-horn it in our LDFLAGS final_LDFLAGS='-lstdc++' fi if [ "${CT_CC_GCC_USE_GMP_MPFR}" = "y" ]; then