scripts: add BUILD/HOST extra cflags/ldflags
authorYann Diorcet <diorcet.yann@gmail.com>
Fri Nov 16 15:25:57 2012 +0100 (2012-11-16)
changeset 31191c56c03b7ed5
parent 3118 51160d293e1f
child 3120 f32c0f8ffaa3
scripts: add BUILD/HOST extra cflags/ldflags

On some hosts, and for certain toolchains (eg. toolchain targetting
the upcoming Darwin), it may be necessary to pass arbitrary CFLAGS
and/or LDFLAGS when building the components.

And necessary infrastructure:
- EXTRA_{CFLAGS,LDFLAGS}_FOR_{BUILD,HOST} as config options
- pass those extra flags to components

Fix-up a slight typo in elf2flt at the same time (misnamed cflags).

Signed-off-by: Yann Diorcet <diorcet.yann@gmail.com>
Message-Id: <d24043276c9243a35421.1353077450@macbook-smorlat.local>
Patchwork-Id: 199645
config/global/build-behave.in
scripts/build/binutils/binutils.sh
scripts/build/binutils/elf2flt.sh
scripts/build/cc/gcc.sh
scripts/build/companion_libs/100-gmp.sh
scripts/build/companion_libs/110-mpfr.sh
scripts/build/companion_libs/120-ppl.sh
scripts/build/companion_libs/130-cloog.sh
scripts/build/companion_libs/140-mpc.sh
scripts/build/companion_libs/200-libelf.sh
scripts/crosstool-NG.sh.in
     1.1 --- a/config/global/build-behave.in	Mon Nov 19 15:20:13 2012 -0800
     1.2 +++ b/config/global/build-behave.in	Fri Nov 16 15:25:57 2012 +0100
     1.3 @@ -41,7 +41,27 @@
     1.4        Use gcc's option -pipe to use pipes rather than temp files when building
     1.5        the toolchain.
     1.6  
     1.7 -config EXTRA_FLAGS_FOR_HOST
     1.8 +config EXTRA_CFLAGS_FOR_BUILD
     1.9 +    string
    1.10 +    prompt "Extra build compiler flags"
    1.11 +    default ""
    1.12 +    help
    1.13 +      Extra flags to pass to the build C and C++ compiler.
    1.14 +
    1.15 +      May be used to change the default features of the build
    1.16 +      compiler such as turning off the stack protector or fortify.
    1.17 +      
    1.18 +config EXTRA_LDFLAGS_FOR_BUILD
    1.19 +    string
    1.20 +    prompt "Extra build linker flags"
    1.21 +    default ""
    1.22 +    help
    1.23 +      Extra flags to pass to the build linker.
    1.24 +
    1.25 +      May be used to change the default features of the build
    1.26 +      linker.
    1.27 +      
    1.28 +config EXTRA_CFLAGS_FOR_HOST
    1.29      string
    1.30      prompt "Extra host compiler flags"
    1.31      default ""
    1.32 @@ -50,6 +70,16 @@
    1.33  
    1.34        May be used to change the default features of the host
    1.35        compiler such as turning off the stack protector or fortify.
    1.36 +      
    1.37 +config EXTRA_LDFLAGS_FOR_HOST
    1.38 +    string
    1.39 +    prompt "Extra host linker flags"
    1.40 +    default ""
    1.41 +    help
    1.42 +      Extra flags to pass to the host linker.
    1.43 +
    1.44 +      May be used to change the default features of the host
    1.45 +      linker.
    1.46  
    1.47  choice
    1.48      bool
     2.1 --- a/scripts/build/binutils/binutils.sh	Mon Nov 19 15:20:13 2012 -0800
     2.2 +++ b/scripts/build/binutils/binutils.sh	Fri Nov 16 15:25:57 2012 +0100
     2.3 @@ -39,6 +39,8 @@
     2.4  
     2.5      binutils_opts+=( "host=${CT_BUILD}" )
     2.6      binutils_opts+=( "prefix=${CT_BUILDTOOLS_PREFIX_DIR}" )
     2.7 +    binutils_opts+=( "cflags=${CT_CFLAGS_FOR_BUILD}" )
     2.8 +    binutils_opts+=( "ldflags=${CT_LDFLAGS_FOR_BUILD}" )
     2.9  
    2.10      do_binutils_backend "${binutils_opts[@]}"
    2.11  
    2.12 @@ -58,6 +60,7 @@
    2.13      binutils_opts+=( "prefix=${CT_PREFIX_DIR}" )
    2.14      binutils_opts+=( "static_build=${CT_STATIC_TOOLCHAIN}" )
    2.15      binutils_opts+=( "cflags=${CT_CFLAGS_FOR_HOST}" )
    2.16 +    binutils_opts+=( "ldflags=${CT_LDFLAGS_FOR_HOST}" )
    2.17      binutils_opts+=( "build_manuals=${CT_BUILD_MANUALS}" )
    2.18  
    2.19      do_binutils_backend "${binutils_opts[@]}"
    2.20 @@ -99,13 +102,15 @@
    2.21  #     host          : machine to run on         : tuple     : (none)
    2.22  #     prefix        : prefix to install into    : dir       : (none)
    2.23  #     static_build  : build statcially          : bool      : no
    2.24 -#     cflags        : host cflags to use        : string    : (empty)
    2.25 +#     cflags        : cflags to use             : string    : (empty)
    2.26 +#     ldflags       : ldflags to use            : string    : (empty)
    2.27  #     build_manuals : whether to build manuals  : bool      : no
    2.28  do_binutils_backend() {
    2.29      local host
    2.30      local prefix
    2.31      local static_build
    2.32      local cflags
    2.33 +    local ldflags
    2.34      local build_manuals=no
    2.35      local -a extra_config
    2.36      local -a extra_make_flags
    2.37 @@ -158,6 +163,7 @@
    2.38      CT_DoExecLog CFG                                            \
    2.39      CFLAGS="${cflags}"                                          \
    2.40      CXXFLAGS="${cflags}"                                        \
    2.41 +    LDFLAGS="${ldflags}"                                        \
    2.42      "${CT_SRC_DIR}/binutils-${CT_BINUTILS_VERSION}/configure"   \
    2.43          --build=${CT_BUILD}                                     \
    2.44          --host=${host}                                          \
     3.1 --- a/scripts/build/binutils/elf2flt.sh	Mon Nov 19 15:20:13 2012 -0800
     3.2 +++ b/scripts/build/binutils/elf2flt.sh	Fri Nov 16 15:25:57 2012 +0100
     3.3 @@ -49,6 +49,8 @@
     3.4  
     3.5      elf2flt_opts+=( "host=${CT_BUILD}" )
     3.6      elf2flt_opts+=( "prefix=${CT_BUILDTOOLS_PREFIX_DIR}" )
     3.7 +    elf2flt_opts+=( "cflags=${CT_CFLAGS_FOR_BUILD}" )
     3.8 +    elf2flt_opts+=( "ldflags=${CT_LDFLAGS_FOR_BUILD}" )
     3.9      elf2flt_opts+=( "binutils_bld=${CT_BUILD_DIR}/build-binutils-build-${CT_HOST}" )
    3.10  
    3.11      do_elf2flt_backend "${elf2flt_opts[@]}"
    3.12 @@ -68,6 +70,7 @@
    3.13      elf2flt_opts+=( "prefix=${CT_PREFIX_DIR}" )
    3.14      elf2flt_opts+=( "static_build=${CT_STATIC_TOOLCHAIN}" )
    3.15      elf2flt_opts+=( "cflags=${CT_CFLAGS_FOR_HOST}" )
    3.16 +    elf2flt_opts+=( "ldflags=${CT_LDFLAGS_FOR_HOST}" )
    3.17      elf2flt_opts+=( "binutils_bld=${CT_BUILD_DIR}/build-binutils-host-${CT_HOST}" )
    3.18  
    3.19      do_elf2flt_backend "${elf2flt_opts[@]}"
    3.20 @@ -102,12 +105,14 @@
    3.21  #     host          : machine to run on         : tuple     : (none)
    3.22  #     prefix        : prefix to install into    : dir       : (none)
    3.23  #     static_build  : build statcially          : bool      : no
    3.24 -#     cflags        : host cflags to use        : string    : (empty)
    3.25 +#     cflags        : cflags to use             : string    : (empty)
    3.26 +#     ldflags       : ldflags to use            : string    : (empty)
    3.27  do_elf2flt_backend() {
    3.28      local host
    3.29      local prefix
    3.30      local static_build
    3.31      local cflags
    3.32 +    local ldflags
    3.33      local binutils_bld
    3.34      local binutils_src
    3.35      local arg
    3.36 @@ -120,7 +125,8 @@
    3.37  
    3.38      CT_DoLog EXTRA "Configuring elf2flt"
    3.39      CT_DoExecLog CFG                                            \
    3.40 -    CFLAGS="${host_cflags}"                                     \
    3.41 +    CFLAGS="${cflags}"                                          \
    3.42 +    LDFLAGS="${ldflags}"                                        \
    3.43      "${CT_SRC_DIR}/elf2flt-${CT_ELF2FLT_VERSION}/configure"     \
    3.44          --build=${CT_BUILD}                                     \
    3.45          --host=${host}                                          \
     4.1 --- a/scripts/build/cc/gcc.sh	Mon Nov 19 15:20:13 2012 -0800
     4.2 +++ b/scripts/build/cc/gcc.sh	Fri Nov 16 15:25:57 2012 +0100
     4.3 @@ -88,6 +88,7 @@
     4.4      core_opts+=( "complibs=${CT_BUILDTOOLS_PREFIX_DIR}" )
     4.5      core_opts+=( "prefix=${CT_BUILDTOOLS_PREFIX_DIR}" )
     4.6      core_opts+=( "cflags=${CT_CFLAGS_FOR_HOST}" )
     4.7 +    core_opts+=( "ldflags=${CT_LDFLAGS_FOR_HOST}" )
     4.8      core_opts+=( "lang_list=c" )
     4.9  
    4.10      CT_DoStep INFO "Installing pass-1 core C compiler"
    4.11 @@ -108,6 +109,7 @@
    4.12      core_opts+=( "prefix=${CT_BUILDTOOLS_PREFIX_DIR}" )
    4.13      core_opts+=( "complibs=${CT_BUILDTOOLS_PREFIX_DIR}" )
    4.14      core_opts+=( "cflags=${CT_CFLAGS_FOR_HOST}" )
    4.15 +    core_opts+=( "ldflags=${CT_LDFLAGS_FOR_HOST}" )
    4.16      core_opts+=( "lang_list=c" )
    4.17  
    4.18      # Different conditions are at stake here:
    4.19 @@ -155,7 +157,8 @@
    4.20  #   build_libstdcxx     : build libstdc++ or not                    : bool      : no
    4.21  #   build_staticlinked  : build statically linked or not            : bool      : no
    4.22  #   build_manuals       : whether to build manuals or not           : bool      : no
    4.23 -#   cflags              : host CFLAGS to use                        : string    : (empty)
    4.24 +#   cflags              : cflags to use                             : string    : (empty)
    4.25 +#   ldflags             : ldflags to use                            : string    : (empty)
    4.26  # Usage: do_cc_core_backend mode=[static|shared|baremetal] build_libgcc=[yes|no] build_staticlinked=[yes|no]
    4.27  do_cc_core_backend() {
    4.28      local mode
    4.29 @@ -168,6 +171,7 @@
    4.30      local complibs
    4.31      local lang_list
    4.32      local cflags
    4.33 +    local ldflags
    4.34      local tmp
    4.35      local -a host_libstdcxx_flags
    4.36      local -a extra_config
    4.37 @@ -227,6 +231,8 @@
    4.38          extra_config+=("--disable-__cxa_atexit")
    4.39      fi
    4.40  
    4.41 +    core_LDFLAGS+=("${ldflags}")
    4.42 +
    4.43      # *** WARNING ! ***
    4.44      # Keep this full if-else-if-elif-fi-fi block in sync
    4.45      # with the same block in do_cc, below.
    4.46 @@ -521,6 +527,7 @@
    4.47      final_opts+=( "prefix=${CT_PREFIX_DIR}" )
    4.48      final_opts+=( "complibs=${CT_HOST_COMPLIBS_DIR}" )
    4.49      final_opts+=( "cflags=${CT_CFLAGS_FOR_HOST}" )
    4.50 +    final_opts+=( "ldflags=${CT_LDFLAGS_FOR_HOST}" )
    4.51      final_opts+=( "lang_list=$( cc_gcc_lang_list )" )
    4.52      if [ "${CT_BUILD_MANUALS}" = "y" ]; then
    4.53          final_opts+=( "build_manuals=yes" )
    4.54 @@ -553,7 +560,8 @@
    4.55  #   host          : the host we run onto                : tuple     : (none)
    4.56  #   prefix        : the runtime prefix                  : dir       : (none)
    4.57  #   complibs      : the companion libraries prefix      : dir       : (none)
    4.58 -#   cflags        : the host CFLAGS                     : string    : (empty)
    4.59 +#   cflags        : cflags to use                       : string    : (empty)
    4.60 +#   ldflags       : ldflags to use                      : string    : (empty)
    4.61  #   lang_list     : the list of languages to build      : string    : (empty)
    4.62  #   build_manuals : whether to build manuals or not     : bool      : no
    4.63  do_cc_backend() {
    4.64 @@ -561,6 +569,7 @@
    4.65      local prefix
    4.66      local complibs
    4.67      local cflags
    4.68 +    local ldflags
    4.69      local lang_list
    4.70      local build_manuals
    4.71      local -a host_libstdcxx_flags
    4.72 @@ -628,6 +637,8 @@
    4.73          fi
    4.74      fi
    4.75  
    4.76 +    final_LDFLAGS+=("${ldflags}")
    4.77 +
    4.78      # *** WARNING ! ***
    4.79      # Keep this full if-else-if-elif-fi-fi block in sync
    4.80      # with the same block in do_cc_core, above.
     5.1 --- a/scripts/build/companion_libs/100-gmp.sh	Mon Nov 19 15:20:13 2012 -0800
     5.2 +++ b/scripts/build/companion_libs/100-gmp.sh	Fri Nov 16 15:25:57 2012 +0100
     5.3 @@ -37,6 +37,8 @@
     5.4  
     5.5      gmp_opts+=( "host=${CT_BUILD}" )
     5.6      gmp_opts+=( "prefix=${CT_BUILDTOOLS_PREFIX_DIR}" )
     5.7 +    gmp_opts+=( "cflags=${CT_CFLAGS_FOR_BUILD}" )
     5.8 +    gmp_opts+=( "ldflags=${CT_LDFLAGS_FOR_BUILD}" )
     5.9      do_gmp_backend "${gmp_opts[@]}"
    5.10  
    5.11      CT_Popd
    5.12 @@ -53,6 +55,7 @@
    5.13      gmp_opts+=( "host=${CT_HOST}" )
    5.14      gmp_opts+=( "prefix=${CT_HOST_COMPLIBS_DIR}" )
    5.15      gmp_opts+=( "cflags=${CT_CFLAGS_FOR_HOST}" )
    5.16 +    gmp_opts+=( "ldflags=${CT_LDFLAGS_FOR_HOST}" )
    5.17      do_gmp_backend "${gmp_opts[@]}"
    5.18  
    5.19      CT_Popd
    5.20 @@ -63,11 +66,13 @@
    5.21  #     Parameter     : description               : type      : default
    5.22  #     host          : machine to run on         : tuple     : (none)
    5.23  #     prefix        : prefix to install into    : dir       : (none)
    5.24 -#     cflags        : host cflags to use        : string    : (empty)
    5.25 +#     cflags        : cflags to use             : string    : (empty)
    5.26 +#     ldflags       : ldflags to use            : string    : (empty)
    5.27  do_gmp_backend() {
    5.28      local host
    5.29      local prefix
    5.30      local cflags
    5.31 +    local ldflags
    5.32      local arg
    5.33  
    5.34      for arg in "$@"; do
    5.35 @@ -78,6 +83,7 @@
    5.36  
    5.37      CT_DoExecLog CFG                                \
    5.38      CFLAGS="${cflags} -fexceptions"                 \
    5.39 +    LDFLAGS="${ldflags}"                            \
    5.40      "${CT_SRC_DIR}/gmp-${CT_GMP_VERSION}/configure" \
    5.41          --build=${CT_BUILD}                         \
    5.42          --host=${host}                              \
     6.1 --- a/scripts/build/companion_libs/110-mpfr.sh	Mon Nov 19 15:20:13 2012 -0800
     6.2 +++ b/scripts/build/companion_libs/110-mpfr.sh	Fri Nov 16 15:25:57 2012 +0100
     6.3 @@ -80,6 +80,8 @@
     6.4  
     6.5      mpfr_opts+=( "host=${CT_BUILD}" )
     6.6      mpfr_opts+=( "prefix=${CT_BUILDTOOLS_PREFIX_DIR}" )
     6.7 +    mpfr_opts+=( "cflags=${CT_CFLAGS_FOR_BUILD}" )
     6.8 +    mpfr_opts+=( "ldflags=${CT_LDFLAGS_FOR_BUILD}" )
     6.9      do_mpfr_backend "${mpfr_opts[@]}"
    6.10  
    6.11      CT_Popd
    6.12 @@ -96,6 +98,7 @@
    6.13      mpfr_opts+=( "host=${CT_HOST}" )
    6.14      mpfr_opts+=( "prefix=${CT_HOST_COMPLIBS_DIR}" )
    6.15      mpfr_opts+=( "cflags=${CT_CFLAGS_FOR_HOST}" )
    6.16 +    mpfr_opts+=( "ldflags=${CT_LDFLAGS_FOR_HOST}" )
    6.17      do_mpfr_backend "${mpfr_opts[@]}"
    6.18  
    6.19      CT_Popd
    6.20 @@ -106,11 +109,13 @@
    6.21  #     Parameter     : description               : type      : default
    6.22  #     host          : machine to run on         : tuple     : (none)
    6.23  #     prefix        : prefix to install into    : dir       : (none)
    6.24 -#     cflags        : host cflags to use        : string    : (empty)
    6.25 +#     cflags        : cflags to use             : string    : (empty)
    6.26 +#     ldflags       : ldflags to use            : string    : (empty)
    6.27  do_mpfr_backend() {
    6.28      local host
    6.29      local prefix
    6.30      local cflags
    6.31 +    local ldflags
    6.32      local arg
    6.33  
    6.34      for arg in "$@"; do
    6.35 @@ -128,7 +133,8 @@
    6.36      CT_DoLog EXTRA "Configuring MPFR"
    6.37      CT_DoExecLog CFG                                    \
    6.38      CC="${host}-gcc"                                    \
    6.39 -    CFLAGS="${CT_CFLAGS_FOR_HOST}"                      \
    6.40 +    CFLAGS="${cflags}"                                  \
    6.41 +    LDFLAGS="${ldflags}"                                \
    6.42      "${CT_SRC_DIR}/mpfr-${CT_MPFR_VERSION}/configure"   \
    6.43          --build=${CT_BUILD}                             \
    6.44          --host=${host}                                  \
     7.1 --- a/scripts/build/companion_libs/120-ppl.sh	Mon Nov 19 15:20:13 2012 -0800
     7.2 +++ b/scripts/build/companion_libs/120-ppl.sh	Fri Nov 16 15:25:57 2012 +0100
     7.3 @@ -40,6 +40,8 @@
     7.4  
     7.5      ppl_opts+=( "host=${CT_BUILD}" )
     7.6      ppl_opts+=( "prefix=${CT_BUILDTOOLS_PREFIX_DIR}" )
     7.7 +    ppl_opts+=( "cflags=${CT_CFLAGS_FOR_BUILD}" )
     7.8 +    ppl_opts+=( "ldflags=${CT_LDFLAGS_FOR_BUILD}" )
     7.9      do_ppl_backend "${ppl_opts[@]}"
    7.10  
    7.11      CT_Popd
    7.12 @@ -56,6 +58,7 @@
    7.13      ppl_opts+=( "host=${CT_HOST}" )
    7.14      ppl_opts+=( "prefix=${CT_HOST_COMPLIBS_DIR}" )
    7.15      ppl_opts+=( "cflags=${CT_CFLAGS_FOR_HOST}" )
    7.16 +    ppl_opts+=( "ldflags=${CT_LDFLAGS_FOR_HOST}" )
    7.17      do_ppl_backend "${ppl_opts[@]}"
    7.18  
    7.19      CT_Popd
    7.20 @@ -66,11 +69,13 @@
    7.21  #     Parameter     : description               : type      : default
    7.22  #     host          : machine to run on         : tuple     : (none)
    7.23  #     prefix        : prefix to install into    : dir       : (none)
    7.24 -#     cflags        : host cflags to use        : string    : (empty)
    7.25 +#     cflags        : cflags to use             : string    : (empty)
    7.26 +#     ldflags       : ldflags to use            : string    : (empty)
    7.27  do_ppl_backend() {
    7.28      local host
    7.29      local prefix
    7.30      local cflags
    7.31 +    local ldflags
    7.32      local arg
    7.33  
    7.34      for arg in "$@"; do
    7.35 @@ -82,6 +87,7 @@
    7.36      CT_DoExecLog CFG                                \
    7.37      CFLAGS="${cflags}"                              \
    7.38      CXXFLAGS="${cflags}"                            \
    7.39 +    LDFLAGS="${ldflags}"                            \
    7.40      "${CT_SRC_DIR}/ppl-${CT_PPL_VERSION}/configure" \
    7.41          --build=${CT_BUILD}                         \
    7.42          --host=${host}                              \
     8.1 --- a/scripts/build/companion_libs/130-cloog.sh	Mon Nov 19 15:20:13 2012 -0800
     8.2 +++ b/scripts/build/companion_libs/130-cloog.sh	Fri Nov 16 15:25:57 2012 +0100
     8.3 @@ -53,6 +53,8 @@
     8.4  
     8.5      cloog_opts+=( "host=${CT_BUILD}" )
     8.6      cloog_opts+=( "prefix=${CT_BUILDTOOLS_PREFIX_DIR}" )
     8.7 +    cloog_opts+=( "cflags=${CT_CFLAGS_FOR_BUILD}" )
     8.8 +    cloog_opts+=( "ldflags=${CT_LDFLAGS_FOR_BUILD}" )
     8.9      do_cloog_backend "${cloog_opts[@]}"
    8.10  
    8.11      CT_Popd
    8.12 @@ -69,6 +71,7 @@
    8.13      cloog_opts+=( "host=${CT_HOST}" )
    8.14      cloog_opts+=( "prefix=${CT_HOST_COMPLIBS_DIR}" )
    8.15      cloog_opts+=( "cflags=${CT_CFLAGS_FOR_HOST}" )
    8.16 +    cloog_opts+=( "ldflags=${CT_LDFLAGS_FOR_HOST}" )
    8.17      do_cloog_backend "${cloog_opts[@]}"
    8.18  
    8.19      CT_Popd
    8.20 @@ -79,11 +82,13 @@
    8.21  #     Parameter     : description               : type      : default
    8.22  #     host          : machine to run on         : tuple     : (none)
    8.23  #     prefix        : prefix to install into    : dir       : (none)
    8.24 -#     cflags        : host cflags to use        : string    : (empty)
    8.25 +#     cflags        : cflags to use             : string    : (empty)
    8.26 +#     ldflags       : ldflags to use            : string    : (empty)
    8.27  do_cloog_backend() {
    8.28      local host
    8.29      local prefix
    8.30      local cflags
    8.31 +    local ldflags
    8.32      local cloog_src_dir="${CT_SRC_DIR}/cloog-ppl-${CT_CLOOG_VERSION}"
    8.33      local arg
    8.34  
    8.35 @@ -95,6 +100,7 @@
    8.36  
    8.37      CT_DoExecLog CFG                            \
    8.38      CFLAGS="${cflags}"                          \
    8.39 +    LDFLAGS="${ldflags}"                        \
    8.40      LIBS="-lm"                                  \
    8.41      "${cloog_src_dir}/configure"                \
    8.42          --build=${CT_BUILD}                     \
     9.1 --- a/scripts/build/companion_libs/140-mpc.sh	Mon Nov 19 15:20:13 2012 -0800
     9.2 +++ b/scripts/build/companion_libs/140-mpc.sh	Fri Nov 16 15:25:57 2012 +0100
     9.3 @@ -38,6 +38,8 @@
     9.4  
     9.5      mpc_opts+=( "host=${CT_BUILD}" )
     9.6      mpc_opts+=( "prefix=${CT_BUILDTOOLS_PREFIX_DIR}" )
     9.7 +    mpc_opts+=( "cflags=${CT_CFLAGS_FOR_BUILD}" )
     9.8 +    mpc_opts+=( "ldflags=${CT_LDFLAGS_FOR_BUILD}" )
     9.9      do_mpc_backend "${mpc_opts[@]}"
    9.10  
    9.11      CT_Popd
    9.12 @@ -54,6 +56,7 @@
    9.13      mpc_opts+=( "host=${CT_HOST}" )
    9.14      mpc_opts+=( "prefix=${CT_HOST_COMPLIBS_DIR}" )
    9.15      mpc_opts+=( "cflags=${CT_CFLAGS_FOR_HOST}" )
    9.16 +    mpc_opts+=( "ldflags=${CT_LDFLAGS_FOR_HOST}" )
    9.17      do_mpc_backend "${mpc_opts[@]}"
    9.18  
    9.19      CT_Popd
    9.20 @@ -64,11 +67,13 @@
    9.21  #     Parameter     : description               : type      : default
    9.22  #     host          : machine to run on         : tuple     : (none)
    9.23  #     prefix        : prefix to install into    : dir       : (none)
    9.24 -#     cflags        : host cflags to use        : string    : (empty)
    9.25 +#     cflags        : cflags to use             : string    : (empty)
    9.26 +#     ldflags       : ldflags to use            : string    : (empty)
    9.27  do_mpc_backend() {
    9.28      local host
    9.29      local prefix
    9.30      local cflags
    9.31 +    local ldflags
    9.32      local arg
    9.33  
    9.34      for arg in "$@"; do
    9.35 @@ -79,6 +84,7 @@
    9.36  
    9.37      CT_DoExecLog CFG                                \
    9.38      CFLAGS="${cflags}"                              \
    9.39 +    LDFLAGS="${ldflags}"                            \
    9.40      "${CT_SRC_DIR}/mpc-${CT_MPC_VERSION}/configure" \
    9.41          --build=${CT_BUILD}                         \
    9.42          --host=${host}                              \
    10.1 --- a/scripts/build/companion_libs/200-libelf.sh	Mon Nov 19 15:20:13 2012 -0800
    10.2 +++ b/scripts/build/companion_libs/200-libelf.sh	Fri Nov 16 15:25:57 2012 +0100
    10.3 @@ -38,6 +38,8 @@
    10.4  
    10.5      libelf_opts+=( "host=${CT_BUILD}" )
    10.6      libelf_opts+=( "prefix=${CT_BUILDTOOLS_PREFIX_DIR}" )
    10.7 +    libelf_opts+=( "cflags=${CT_CFLAGS_FOR_BUILD}" )
    10.8 +    libelf_opts+=( "ldflags=${CT_LDFLAGS_FOR_BUILD}" )
    10.9      do_libelf_backend "${libelf_opts[@]}"
   10.10  
   10.11      CT_Popd
   10.12 @@ -54,6 +56,7 @@
   10.13      libelf_opts+=( "host=${CT_HOST}" )
   10.14      libelf_opts+=( "prefix=${CT_HOST_COMPLIBS_DIR}" )
   10.15      libelf_opts+=( "cflags=${CT_CFLAGS_FOR_HOST}" )
   10.16 +    libelf_opts+=( "ldflags=${CT_LDFLAGS_FOR_HOST}" )
   10.17      do_libelf_backend "${libelf_opts[@]}"
   10.18  
   10.19      CT_Popd
   10.20 @@ -87,13 +90,15 @@
   10.21  #     destdir       : out-of-tree install dir   : string    : /
   10.22  #     host          : machine to run on         : tuple     : (none)
   10.23  #     prefix        : prefix to install into    : dir       : (none)
   10.24 -#     cflags        : host cflags to use        : string    : (empty)
   10.25 +#     cflags        : cflags to use             : string    : (empty)
   10.26 +#     ldflags       : ldflags to use            : string    : (empty)
   10.27  #     shared        : also buils shared lib     : bool      : n
   10.28  do_libelf_backend() {
   10.29      local destdir="/"
   10.30      local host
   10.31      local prefix
   10.32      local cflags
   10.33 +    local ldflags
   10.34      local shared
   10.35      local -a extra_config
   10.36      local arg
   10.37 @@ -114,6 +119,7 @@
   10.38      CC="${host}-gcc"                                        \
   10.39      RANLIB="${host}-ranlib"                                 \
   10.40      CFLAGS="${cflags} -fPIC"                                \
   10.41 +    LDFLAGS="${ldflags}"                                    \
   10.42      "${CT_SRC_DIR}/libelf-${CT_LIBELF_VERSION}/configure"   \
   10.43          --build=${CT_BUILD}                                 \
   10.44          --host=${host}                                      \
    11.1 --- a/scripts/crosstool-NG.sh.in	Mon Nov 19 15:20:13 2012 -0800
    11.2 +++ b/scripts/crosstool-NG.sh.in	Fri Nov 16 15:25:57 2012 +0100
    11.3 @@ -487,12 +487,22 @@
    11.4          rm -f "${tmp}"
    11.5      fi
    11.6  
    11.7 -    # Help gcc
    11.8 +    # Help build gcc
    11.9 +    # Explicitly optimise, else the lines below will overide the
   11.10 +    # package's default optimisation flags
   11.11 +    CT_CFLAGS_FOR_BUILD="-O2 -g"
   11.12 +    CT_CFLAGS_FOR_BUILD+=" ${CT_EXTRA_CFLAGS_FOR_BUILD}"
   11.13 +    CT_LDFLAGS_FOR_BUILD=
   11.14 +    CT_LDFLAGS_FOR_BUILD+=" ${CT_EXTRA_LDFLAGS_FOR_BUILD}"
   11.15 +    
   11.16 +    # Help host gcc
   11.17      # Explicitly optimise, else the lines below will overide the
   11.18      # package's default optimisation flags
   11.19      CT_CFLAGS_FOR_HOST="-O2 -g"
   11.20      [ "${CT_USE_PIPES}" = "y" ] && CT_CFLAGS_FOR_HOST+=" -pipe"
   11.21 -    CT_CFLAGS_FOR_HOST+=" ${CT_EXTRA_FLAGS_FOR_HOST}"
   11.22 +    CT_CFLAGS_FOR_HOST+=" ${CT_EXTRA_CFLAGS_FOR_HOST}"
   11.23 +    CT_LDFLAGS_FOR_HOST=
   11.24 +    CT_LDFLAGS_FOR_HOST+=" ${CT_EXTRA_LDFLAGS_FOR_HOST}"
   11.25  
   11.26      # Set the shell to be used by ./configure scripts and by Makefiles (those
   11.27      # that support it!).