1.1 --- a/scripts/build/cc/gcc.sh Thu Dec 09 18:55:42 2010 +0100
1.2 +++ b/scripts/build/cc/gcc.sh Thu Dec 09 18:55:59 2010 +0100
1.3 @@ -63,12 +63,19 @@
1.4 # In any other case, build the static core gcc and, if using gcc-4.3+,
1.5 # also build the target libgcc.
1.6 case "${CT_BARE_METAL},${CT_CANADIAN},${CT_THREADS}" in
1.7 - y,*,*) do_cc_core mode=baremetal build_libgcc=yes build_libstdcxx=yes;;
1.8 + y,*,*)
1.9 + if [ "${CT_STATIC_TOOLCHAIN}" = "y" ]; then
1.10 + do_cc_core mode=baremetal build_libgcc=yes build_libstdcxx=yes build_staticlinked=yes
1.11 + else
1.12 + do_cc_core mode=baremetal build_libgcc=yes build_libstdcxx=yes
1.13 + fi
1.14 + ;;
1.15 ,y,*) ;;
1.16 ,,nptl)
1.17 do_cc_core mode=shared build_libgcc=yes
1.18 ;;
1.19 - ,,win32) do_cc_core mode=static build_libgcc=yes
1.20 + ,,win32)
1.21 + do_cc_core mode=static build_libgcc=yes
1.22 ;;
1.23 *) if [ "${CT_CC_GCC_4_3_or_later}" = "y" ]; then
1.24 do_cc_core mode=static build_libgcc=yes
1.25 @@ -84,18 +91,20 @@
1.26 # This function is used to build both the static and the shared core C conpiler,
1.27 # with or without the target libgcc. We need to know wether:
1.28 # - we're building static, shared or bare metal: mode=[static|shared|baremetal]
1.29 -# - we need to build libgcc or not : build_libgcc=[yes|no] (default: no)
1.30 -# - we need to build libstdc++ or not : build_libstdcxx=[yes|no] (default: no)
1.31 -# Usage: do_cc_core_static mode=[static|shared|baremetal] build_libgcc=[yes|no]
1.32 +# - we need to build libgcc or not : build_libgcc=[yes|no] (default: no)
1.33 +# - we need to build libstdc++ or not : build_libstdcxx=[yes|no] (default: no)
1.34 +# - we need to build statically linked or not : build_staticlinked=[yes|no] (default: no)
1.35 +# Usage: do_cc_core mode=[static|shared|baremetal] build_libgcc=[yes|no] build_staticlinked=[yes|no]
1.36 do_cc_core() {
1.37 local mode
1.38 local build_libgcc=no
1.39 local build_libstdcxx=no
1.40 + local build_staticlinked=no
1.41 local core_prefix_dir
1.42 local lang_opt
1.43 local tmp
1.44 local -a extra_config
1.45 - local core_LDFLAGS
1.46 + local -a core_LDFLAGS
1.47 local -a core_targets
1.48
1.49 while [ $# -ne 0 ]; do
1.50 @@ -158,13 +167,35 @@
1.51 extra_config+=("--disable-__cxa_atexit")
1.52 fi
1.53
1.54 - # When companion libraries are build static (eg !shared),
1.55 - # the libstdc++ is not pulled automatically, although it
1.56 - # is needed. Shoe-horn it in our LDFLAGS
1.57 - # Ditto libm on some Fedora boxen
1.58 - if [ "${CT_COMPLIBS_SHARED}" != "y" ]; then
1.59 - core_LDFLAGS='-lstdc++ -lm'
1.60 + # *** WARNING ! ***
1.61 + # Keep this full if-else-if-elif-fi-fi block in sync
1.62 + # with the same block in do_cc, below.
1.63 + if [ "${build_staticlinked}" = "yes" ]; then
1.64 + core_LDFLAGS+=("-static")
1.65 + extra_config+=("--with-host-libstdcxx=-static-libgcc -Wl,-Bstatic,-lstdc++ -lm")
1.66 + # Companion libraries are build static (eg !shared), so
1.67 + # the libstdc++ is not pulled automatically, although it
1.68 + # is needed. Shoe-horn it in our LDFLAGS
1.69 + # Ditto libm on some Fedora boxen
1.70 + final_LDFLAGS+=("-lstdc++")
1.71 + final_LDFLAGS+=("-lm")
1.72 + else
1.73 + if [ "${CT_CC_STATIC_LIBSTDCXX}" = "y" ]; then
1.74 + # this is from CodeSourcery arm-2010q1-202-arm-none-linux-gnueabi.src.tar.bz2
1.75 + # build script
1.76 + # FIXME: if the host gcc is gcc-4.5 then presumably we could use -static-libstdc++,
1.77 + # see http://gcc.gnu.org/ml/gcc-patches/2009-06/msg01635.html
1.78 + extra_config+=("--with-host-libstdcxx=-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic -lm")
1.79 + elif [ "${CT_COMPLIBS_SHARED}" != "y" ]; then
1.80 + # When companion libraries are build static (eg !shared),
1.81 + # the libstdc++ is not pulled automatically, although it
1.82 + # is needed. Shoe-horn it in our LDFLAGS
1.83 + # Ditto libm on some Fedora boxen
1.84 + core_LDFLAGS+=("-lstdc++")
1.85 + core_LDFLAGS+=("-lm")
1.86 + fi
1.87 fi
1.88 +
1.89 if [ "${CT_CC_GCC_USE_GMP_MPFR}" = "y" ]; then
1.90 extra_config+=("--with-gmp=${CT_COMPLIBS_DIR}")
1.91 extra_config+=("--with-mpfr=${CT_COMPLIBS_DIR}")
1.92 @@ -202,7 +233,7 @@
1.93 # Use --with-local-prefix so older gccs don't look in /usr/local (http://gcc.gnu.org/PR10532)
1.94 CC_FOR_BUILD="${CT_BUILD}-gcc" \
1.95 CFLAGS="${CT_CFLAGS_FOR_HOST}" \
1.96 - LDFLAGS="${core_LDFLAGS}" \
1.97 + LDFLAGS="${core_LDFLAGS[*]}" \
1.98 CT_DoExecLog CFG \
1.99 "${CT_SRC_DIR}/gcc-${CT_CC_VERSION}/configure" \
1.100 --build=${CT_BUILD} \
1.101 @@ -373,6 +404,9 @@
1.102 extra_config+=(--disable-libssp)
1.103 fi
1.104
1.105 + # *** WARNING ! ***
1.106 + # Keep this full if-else-if-elif-fi-fi block in sync
1.107 + # with the same block in do_cc_core, above.
1.108 if [ "${CT_STATIC_TOOLCHAIN}" = "y" ]; then
1.109 final_LDFLAGS+=("-static")
1.110 extra_config+=("--with-host-libstdcxx=-static-libgcc -Wl,-Bstatic,-lstdc++ -lm")