diff --git a/config/cc/gcc.in.2 b/config/cc/gcc.in.2 index d6827697..cfef3f1b 100644 --- a/config/cc/gcc.in.2 +++ b/config/cc/gcc.in.2 @@ -7,6 +7,18 @@ config CC_GCC_ENABLE_TARGET_OPTSPACE 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 --git a/scripts/build/cc/gcc.sh b/scripts/build/cc/gcc.sh index f11517c7..0b40d71d 100644 --- a/scripts/build/cc/gcc.sh +++ b/scripts/build/cc/gcc.sh @@ -347,10 +347,16 @@ do_cc() { 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