1.1 --- a/config/cc/gcc.in.2 Thu Dec 09 18:55:33 2010 +0100
1.2 +++ b/config/cc/gcc.in.2 Thu Dec 09 18:55:42 2010 +0100
1.3 @@ -36,6 +36,9 @@
1.4 This will require the libelf companion library, and it
1.5 wil be build automatically for you.
1.6
1.7 +config STATIC_TOOLCHAIN
1.8 + select CC_STATIC_LIBSTDCXX if CC_GCC_4_4_or_later
1.9 +
1.10 config CC_STATIC_LIBSTDCXX
1.11 bool
1.12 prompt "Link libstdc++ statically into the gcc binary"
2.1 --- a/scripts/build/cc/gcc.sh Thu Dec 09 18:55:33 2010 +0100
2.2 +++ b/scripts/build/cc/gcc.sh Thu Dec 09 18:55:42 2010 +0100
2.3 @@ -305,8 +305,8 @@
2.4 # Build final gcc
2.5 do_cc() {
2.6 local -a extra_config
2.7 + local -a final_LDFLAGS
2.8 local tmp
2.9 - local final_LDFLAGS
2.10
2.11 # If building for bare metal, nothing to be done here, the static core conpiler is enough!
2.12 [ "${CT_BARE_METAL}" = "y" ] && return 0
2.13 @@ -373,19 +373,32 @@
2.14 extra_config+=(--disable-libssp)
2.15 fi
2.16
2.17 - if [ "${CT_CC_STATIC_LIBSTDCXX}" = "y" ]; then
2.18 - # this is from CodeSourcery arm-2010q1-202-arm-none-linux-gnueabi.src.tar.bz2
2.19 - # build script
2.20 - # FIXME: if the host gcc is gcc-4.5 then presumably we could use -static-libstdc++,
2.21 - # see http://gcc.gnu.org/ml/gcc-patches/2009-06/msg01635.html
2.22 - extra_config+=("--with-host-libstdcxx=-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic -lm")
2.23 - elif [ "${CT_COMPLIBS_SHARED}" != "y" ]; then
2.24 - # When companion libraries are build static (eg !shared),
2.25 + if [ "${CT_STATIC_TOOLCHAIN}" = "y" ]; then
2.26 + final_LDFLAGS+=("-static")
2.27 + extra_config+=("--with-host-libstdcxx=-static-libgcc -Wl,-Bstatic,-lstdc++ -lm")
2.28 + # Companion libraries are build static (eg !shared), so
2.29 # the libstdc++ is not pulled automatically, although it
2.30 # is needed. Shoe-horn it in our LDFLAGS
2.31 # Ditto libm on some Fedora boxen
2.32 - final_LDFLAGS='-lstdc++ -lm'
2.33 + final_LDFLAGS+=("-lstdc++")
2.34 + final_LDFLAGS+=("-lm")
2.35 + else
2.36 + if [ "${CT_CC_STATIC_LIBSTDCXX}" = "y" ]; then
2.37 + # this is from CodeSourcery arm-2010q1-202-arm-none-linux-gnueabi.src.tar.bz2
2.38 + # build script
2.39 + # FIXME: if the host gcc is gcc-4.5 then presumably we could use -static-libstdc++,
2.40 + # see http://gcc.gnu.org/ml/gcc-patches/2009-06/msg01635.html
2.41 + extra_config+=("--with-host-libstdcxx=-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic -lm")
2.42 + elif [ "${CT_COMPLIBS_SHARED}" != "y" ]; then
2.43 + # When companion libraries are build static (eg !shared),
2.44 + # the libstdc++ is not pulled automatically, although it
2.45 + # is needed. Shoe-horn it in our LDFLAGS
2.46 + # Ditto libm on some Fedora boxen
2.47 + final_LDFLAGS+=("-lstdc++")
2.48 + final_LDFLAGS+=("-lm")
2.49 + fi
2.50 fi
2.51 +
2.52 if [ "${CT_CC_GCC_USE_GMP_MPFR}" = "y" ]; then
2.53 extra_config+=("--with-gmp=${CT_COMPLIBS_DIR}")
2.54 extra_config+=("--with-mpfr=${CT_COMPLIBS_DIR}")
2.55 @@ -442,7 +455,7 @@
2.56 # embedded systems don't really need message catalogs...
2.57 CC_FOR_BUILD="${CT_BUILD}-gcc" \
2.58 CFLAGS="${CT_CFLAGS_FOR_HOST}" \
2.59 - LDFLAGS="${final_LDFLAGS}" \
2.60 + LDFLAGS="${final_LDFLAGS[*]}" \
2.61 CFLAGS_FOR_TARGET="${CT_TARGET_CFLAGS}" \
2.62 CXXFLAGS_FOR_TARGET="${CT_TARGET_CFLAGS}" \
2.63 LDFLAGS_FOR_TARGET="${CT_TARGET_LDFLAGS}" \