scripts/build/cc/gcc.sh
changeset 2211 2f67667ee385
parent 2162 3cec1d170ba4
child 2212 a2f4986779bf
     1.1 --- a/scripts/build/cc/gcc.sh	Sun Oct 24 22:03:53 2010 +0200
     1.2 +++ b/scripts/build/cc/gcc.sh	Thu Dec 09 18:55:42 2010 +0100
     1.3 @@ -305,8 +305,8 @@
     1.4  # Build final gcc
     1.5  do_cc() {
     1.6      local -a extra_config
     1.7 +    local -a final_LDFLAGS
     1.8      local tmp
     1.9 -    local final_LDFLAGS
    1.10  
    1.11      # If building for bare metal, nothing to be done here, the static core conpiler is enough!
    1.12      [ "${CT_BARE_METAL}" = "y" ] && return 0
    1.13 @@ -373,19 +373,32 @@
    1.14          extra_config+=(--disable-libssp)
    1.15      fi
    1.16  
    1.17 -    if [ "${CT_CC_STATIC_LIBSTDCXX}" = "y" ]; then
    1.18 -        # this is from CodeSourcery arm-2010q1-202-arm-none-linux-gnueabi.src.tar.bz2
    1.19 -        # build script
    1.20 -        # FIXME: if the host gcc is gcc-4.5 then presumably we could use -static-libstdc++,
    1.21 -        # see http://gcc.gnu.org/ml/gcc-patches/2009-06/msg01635.html
    1.22 -        extra_config+=("--with-host-libstdcxx=-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic -lm")
    1.23 -    elif [ "${CT_COMPLIBS_SHARED}" != "y" ]; then
    1.24 -        # When companion libraries are build static (eg !shared),
    1.25 +    if [ "${CT_STATIC_TOOLCHAIN}" = "y" ]; then
    1.26 +        final_LDFLAGS+=("-static")
    1.27 +        extra_config+=("--with-host-libstdcxx=-static-libgcc -Wl,-Bstatic,-lstdc++ -lm")
    1.28 +        # Companion libraries are build static (eg !shared), so
    1.29          # the libstdc++ is not pulled automatically, although it
    1.30          # is needed. Shoe-horn it in our LDFLAGS
    1.31          # Ditto libm on some Fedora boxen
    1.32 -        final_LDFLAGS='-lstdc++ -lm'
    1.33 +        final_LDFLAGS+=("-lstdc++")
    1.34 +        final_LDFLAGS+=("-lm")
    1.35 +    else
    1.36 +        if [ "${CT_CC_STATIC_LIBSTDCXX}" = "y" ]; then
    1.37 +            # this is from CodeSourcery arm-2010q1-202-arm-none-linux-gnueabi.src.tar.bz2
    1.38 +            # build script
    1.39 +            # FIXME: if the host gcc is gcc-4.5 then presumably we could use -static-libstdc++,
    1.40 +            # see http://gcc.gnu.org/ml/gcc-patches/2009-06/msg01635.html
    1.41 +            extra_config+=("--with-host-libstdcxx=-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic -lm")
    1.42 +        elif [ "${CT_COMPLIBS_SHARED}" != "y" ]; then
    1.43 +            # When companion libraries are build static (eg !shared),
    1.44 +            # the libstdc++ is not pulled automatically, although it
    1.45 +            # is needed. Shoe-horn it in our LDFLAGS
    1.46 +            # Ditto libm on some Fedora boxen
    1.47 +            final_LDFLAGS+=("-lstdc++")
    1.48 +            final_LDFLAGS+=("-lm")
    1.49 +        fi
    1.50      fi
    1.51 +
    1.52      if [ "${CT_CC_GCC_USE_GMP_MPFR}" = "y" ]; then
    1.53          extra_config+=("--with-gmp=${CT_COMPLIBS_DIR}")
    1.54          extra_config+=("--with-mpfr=${CT_COMPLIBS_DIR}")
    1.55 @@ -442,7 +455,7 @@
    1.56      # embedded systems don't really need message catalogs...
    1.57      CC_FOR_BUILD="${CT_BUILD}-gcc"                  \
    1.58      CFLAGS="${CT_CFLAGS_FOR_HOST}"                  \
    1.59 -    LDFLAGS="${final_LDFLAGS}"                      \
    1.60 +    LDFLAGS="${final_LDFLAGS[*]}"                   \
    1.61      CFLAGS_FOR_TARGET="${CT_TARGET_CFLAGS}"         \
    1.62      CXXFLAGS_FOR_TARGET="${CT_TARGET_CFLAGS}"       \
    1.63      LDFLAGS_FOR_TARGET="${CT_TARGET_LDFLAGS}"       \