cc/gcc: add option to compile against static libstdc++, for gcc-4.4 and newer
authorJohannes Stezenbach <js@sig21.net>
Thu Jul 29 19:47:16 2010 +0200 (2010-07-29)
changeset 2045fdaa6c7f6dea
parent 2044 20dd8cef1c8a
child 2051 57cda75fd174
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 <js@sig21.net>
config/cc/gcc.in.2
scripts/build/cc/gcc.sh
     1.1 --- a/config/cc/gcc.in.2	Thu Jul 29 19:30:37 2010 +0200
     1.2 +++ b/config/cc/gcc.in.2	Thu Jul 29 19:47:16 2010 +0200
     1.3 @@ -7,6 +7,18 @@
     1.4        
     1.5        This will compile crossgcc's libs with -Os.
     1.6  
     1.7 +config CC_STATIC_LIBSTDCXX
     1.8 +    bool
     1.9 +    prompt "Link libstdc++ statically into the gcc binary"
    1.10 +    default y
    1.11 +    depends on CC_GCC_4_4_or_later
    1.12 +    help
    1.13 +      Newer gcc versions use the PPL library which is C++ code.  Statically
    1.14 +      linking libstdc++ increases the likeliness that the gcc binary will
    1.15 +      run on machines other than the one which it was built on, without
    1.16 +      having to worry about distributing the matching version of libstdc++
    1.17 +      along with it.
    1.18 +
    1.19  comment "Misc. obscure options."
    1.20  
    1.21  config CC_CXA_ATEXIT
     2.1 --- a/scripts/build/cc/gcc.sh	Thu Jul 29 19:30:37 2010 +0200
     2.2 +++ b/scripts/build/cc/gcc.sh	Thu Jul 29 19:47:16 2010 +0200
     2.3 @@ -347,10 +347,16 @@
     2.4          extra_config+=(--disable-libmudflap)
     2.5      fi
     2.6  
     2.7 -    # When companion libraries are build static (eg !shared),
     2.8 -    # the libstdc++ is not pulled automatically, although it
     2.9 -    # is needed. Shoe-horn it in our LDFLAGS
    2.10 -    if [ "${CT_COMPLIBS_SHARED}" != "y" ]; then
    2.11 +    if [ "${CT_CC_STATIC_LIBSTDCXX}" = "y" ]; then
    2.12 +        # this is from CodeSourcery arm-2010q1-202-arm-none-linux-gnueabi.src.tar.bz2
    2.13 +        # build script
    2.14 +        # FIXME: if the host gcc is gcc-4.5 then presumably we could use -static-libstdc++,
    2.15 +        # see http://gcc.gnu.org/ml/gcc-patches/2009-06/msg01635.html
    2.16 +        extra_config+=("--with-host-libstdcxx=-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic -lm")
    2.17 +    elif [ "${CT_COMPLIBS_SHARED}" != "y" ]; then
    2.18 +        # When companion libraries are build static (eg !shared),
    2.19 +        # the libstdc++ is not pulled automatically, although it
    2.20 +        # is needed. Shoe-horn it in our LDFLAGS
    2.21          final_LDFLAGS='-lstdc++'
    2.22      fi
    2.23      if [ "${CT_CC_GCC_USE_GMP_MPFR}" = "y" ]; then