1.1 --- a/config/binutils/binutils.in Sun Jan 02 13:52:16 2011 +0100
1.2 +++ b/config/binutils/binutils.in Wed Dec 29 18:19:40 2010 +0100
1.3 @@ -100,6 +100,7 @@
1.4 depends on BINUTILS_HAS_GOLD
1.5 depends on EXPERIMENTAL
1.6 select BINUTILS_GOLD_INSTALLED
1.7 + select BINUTILS_LINKER_BOTH
1.8 help
1.9 Both the historical ld and the new gold linkers will be
1.10 installed, with ld being the default linker used.
1.11 @@ -112,6 +113,7 @@
1.12 depends on BINUTILS_HAS_GOLD
1.13 depends on EXPERIMENTAL
1.14 select BINUTILS_GOLD_INSTALLED
1.15 + select BINUTILS_LINKER_BOTH
1.16 help
1.17 Both the historical ld and the new gold linkers will be
1.18 installed, with gold being the default linker used.
1.19 @@ -131,6 +133,9 @@
1.20 When configured with threads, gold can link in parallel,
1.21 possibly cooperating with a make jobserver.
1.22
1.23 +config BINUTILS_LINKER_BOTH
1.24 + bool
1.25 +
1.26 config BINUTILS_LINKERS_LIST
1.27 string
1.28 default "ld" if BINUTILS_LINKER_LD
1.29 @@ -138,6 +143,25 @@
1.30 default "ld,gold" if BINUTILS_LINKER_LD_GOLD
1.31 default "gold,ld" if BINUTILS_LINKER_GOLD_LD
1.32
1.33 +config BINUTILS_LD_WRAPPER
1.34 + bool
1.35 + prompt "| Add ld wrapper"
1.36 + depends on BINUTILS_LINKER_BOTH
1.37 + help
1.38 + Add an ld wrapper that calls to either gold or ld.
1.39 +
1.40 + By default, the wrapper will call to the default wrapper,
1.41 + but if you set the environment variable CTNG_LD_IS, you
1.42 + can change which linker will get called:
1.43 + CTNG_LD_IS=gold will unconditionally call the gold linker
1.44 + CTNG_LD_IS=bfd will unconditionally call the old bfd ld linker
1.45 +
1.46 +config BINUTILS_LINKER_DEFAULT
1.47 + string
1.48 + depends on BINUTILS_LD_WRAPPER
1.49 + default "bfd" if BINUTILS_LINKER_LD_GOLD
1.50 + default "gold" if BINUTILS_LINKER_GOLD_LD
1.51 +
1.52 endif # BINUTILS_HAS_GOLD
1.53
1.54 config BINUTILS_PLUGINS
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
2.2 +++ b/scripts/build/binutils/binutils-ld.in Wed Dec 29 18:19:40 2010 +0100
2.3 @@ -0,0 +1,11 @@
2.4 +#!/bin/sh
2.5 +
2.6 +call_to=@@DEFAULT_LD@@
2.7 +
2.8 +case "${CTNG_LD_IS}" in
2.9 + bfd) call_to=bfd;;
2.10 + gold) call_to=gold;;
2.11 +esac
2.12 +
2.13 +exec "${0}.${call_to}" "$@"
2.14 +exit $?
3.1 --- a/scripts/build/binutils/binutils.sh Sun Jan 02 13:52:16 2011 +0100
3.2 +++ b/scripts/build/binutils/binutils.sh Wed Dec 29 18:19:40 2010 +0100
3.3 @@ -19,6 +19,7 @@
3.4 do_binutils() {
3.5 local -a extra_config
3.6 local -a extra_make_flags
3.7 + local -a binutils_tools
3.8
3.9 mkdir -p "${CT_BUILD_DIR}/build-binutils"
3.10 cd "${CT_BUILD_DIR}/build-binutils"
3.11 @@ -27,19 +28,24 @@
3.12
3.13 CT_DoLog EXTRA "Configuring binutils"
3.14
3.15 + binutils_tools=( ar as ld strip )
3.16 if [ "${CT_BINUTILS_HAS_GOLD}" = "y" ]; then
3.17 case "${CT_BINUTILS_LINKERS_LIST}" in
3.18 ld)
3.19 extra_config+=( --enable-ld=yes --enable-gold=no )
3.20 + binutils_tools+=( ld.bfd )
3.21 ;;
3.22 gold)
3.23 extra_config+=( --enable-ld=no --enable-gold=yes )
3.24 + binutils_tools+=( ld.gold )
3.25 ;;
3.26 ld,gold)
3.27 extra_config+=( --enable-ld=default --enable-gold=yes )
3.28 + binutils_tools+=( ld.bfd ld.gold )
3.29 ;;
3.30 gold,ld)
3.31 extra_config+=( --enable-ld=yes --enable-gold=default )
3.32 + binutils_tools+=( ld.bfd ld.gold )
3.33 ;;
3.34 esac
3.35 if [ "${CT_BINUTILS_GOLD_THREADED}" = "y" ]; then
3.36 @@ -79,6 +85,16 @@
3.37 CT_DoLog EXTRA "Installing binutils"
3.38 CT_DoExecLog ALL make install
3.39
3.40 + # Install the wrapper if needed
3.41 + if [ "${CT_BINUTILS_LD_WRAPPER}" = "y" ]; then
3.42 + CT_DoLog EXTRA "Installing ld wrapper"
3.43 + rm -f "${CT_PREFIX_DIR}/bin/${CT_TARGET}-ld"
3.44 + sed -r -e "s/@@DEFAULT_LD@@/${CT_BINUTILS_LINKER_DEFAULT}/" \
3.45 + "${CT_LIB_DIR}/scripts/build/binutils/binutils-ld.in" \
3.46 + >"${CT_PREFIX_DIR}/bin/${CT_TARGET}-ld"
3.47 + chmod +x "${CT_PREFIX_DIR}/bin/${CT_TARGET}-ld"
3.48 + fi
3.49 +
3.50 # Make those new tools available to the core C compilers to come.
3.51 # Note: some components want the ${TARGET}-{ar,as,ld,strip} commands as
3.52 # well. Create that.
3.53 @@ -86,7 +102,7 @@
3.54 mkdir -p "${CT_CC_CORE_STATIC_PREFIX_DIR}/bin"
3.55 mkdir -p "${CT_CC_CORE_SHARED_PREFIX_DIR}/${CT_TARGET}/bin"
3.56 mkdir -p "${CT_CC_CORE_SHARED_PREFIX_DIR}/bin"
3.57 - for t in ar as ld strip; do
3.58 + for t in "${binutils_tools[@]}"; do
3.59 ln -sv "${CT_PREFIX_DIR}/bin/${CT_TARGET}-${t}" "${CT_CC_CORE_STATIC_PREFIX_DIR}/${CT_TARGET}/bin/${t}"
3.60 ln -sv "${CT_PREFIX_DIR}/bin/${CT_TARGET}-${t}" "${CT_CC_CORE_STATIC_PREFIX_DIR}/bin/${CT_TARGET}-${t}"
3.61 ln -sv "${CT_PREFIX_DIR}/bin/${CT_TARGET}-${t}" "${CT_CC_CORE_SHARED_PREFIX_DIR}/${CT_TARGET}/bin/${t}"