binutils/binutils: add wrapper to gold and ld

When both gold and ld are installed, add a wrapper that calls
to either gold or ld.

In case the wrapper is installed, we also need to symlink ld.bfd
and ld.gold for the core_cc steps.

Signed-off-by: "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
This commit is contained in:
Yann E. MORIN"
2010-12-29 18:19:40 +01:00
parent 8a952d18e0
commit 2841bb7a35
3 changed files with 52 additions and 1 deletions

View File

@ -100,6 +100,7 @@ config BINUTILS_LINKER_LD_GOLD
depends on BINUTILS_HAS_GOLD depends on BINUTILS_HAS_GOLD
depends on EXPERIMENTAL depends on EXPERIMENTAL
select BINUTILS_GOLD_INSTALLED select BINUTILS_GOLD_INSTALLED
select BINUTILS_LINKER_BOTH
help help
Both the historical ld and the new gold linkers will be Both the historical ld and the new gold linkers will be
installed, with ld being the default linker used. installed, with ld being the default linker used.
@ -112,6 +113,7 @@ config BINUTILS_LINKER_GOLD_LD
depends on BINUTILS_HAS_GOLD depends on BINUTILS_HAS_GOLD
depends on EXPERIMENTAL depends on EXPERIMENTAL
select BINUTILS_GOLD_INSTALLED select BINUTILS_GOLD_INSTALLED
select BINUTILS_LINKER_BOTH
help help
Both the historical ld and the new gold linkers will be Both the historical ld and the new gold linkers will be
installed, with gold being the default linker used. installed, with gold being the default linker used.
@ -131,6 +133,9 @@ config BINUTILS_GOLD_THREADS
When configured with threads, gold can link in parallel, When configured with threads, gold can link in parallel,
possibly cooperating with a make jobserver. possibly cooperating with a make jobserver.
config BINUTILS_LINKER_BOTH
bool
config BINUTILS_LINKERS_LIST config BINUTILS_LINKERS_LIST
string string
default "ld" if BINUTILS_LINKER_LD default "ld" if BINUTILS_LINKER_LD
@ -138,6 +143,25 @@ config BINUTILS_LINKERS_LIST
default "ld,gold" if BINUTILS_LINKER_LD_GOLD default "ld,gold" if BINUTILS_LINKER_LD_GOLD
default "gold,ld" if BINUTILS_LINKER_GOLD_LD default "gold,ld" if BINUTILS_LINKER_GOLD_LD
config BINUTILS_LD_WRAPPER
bool
prompt "| Add ld wrapper"
depends on BINUTILS_LINKER_BOTH
help
Add an ld wrapper that calls to either gold or ld.
By default, the wrapper will call to the default wrapper,
but if you set the environment variable CTNG_LD_IS, you
can change which linker will get called:
CTNG_LD_IS=gold will unconditionally call the gold linker
CTNG_LD_IS=bfd will unconditionally call the old bfd ld linker
config BINUTILS_LINKER_DEFAULT
string
depends on BINUTILS_LD_WRAPPER
default "bfd" if BINUTILS_LINKER_LD_GOLD
default "gold" if BINUTILS_LINKER_GOLD_LD
endif # BINUTILS_HAS_GOLD endif # BINUTILS_HAS_GOLD
config BINUTILS_PLUGINS config BINUTILS_PLUGINS

View File

@ -0,0 +1,11 @@
#!/bin/sh
call_to=@@DEFAULT_LD@@
case "${CTNG_LD_IS}" in
bfd) call_to=bfd;;
gold) call_to=gold;;
esac
exec "${0}.${call_to}" "$@"
exit $?

View File

@ -19,6 +19,7 @@ do_binutils_extract() {
do_binutils() { do_binutils() {
local -a extra_config local -a extra_config
local -a extra_make_flags local -a extra_make_flags
local -a binutils_tools
mkdir -p "${CT_BUILD_DIR}/build-binutils" mkdir -p "${CT_BUILD_DIR}/build-binutils"
cd "${CT_BUILD_DIR}/build-binutils" cd "${CT_BUILD_DIR}/build-binutils"
@ -27,19 +28,24 @@ do_binutils() {
CT_DoLog EXTRA "Configuring binutils" CT_DoLog EXTRA "Configuring binutils"
binutils_tools=( ar as ld strip )
if [ "${CT_BINUTILS_HAS_GOLD}" = "y" ]; then if [ "${CT_BINUTILS_HAS_GOLD}" = "y" ]; then
case "${CT_BINUTILS_LINKERS_LIST}" in case "${CT_BINUTILS_LINKERS_LIST}" in
ld) ld)
extra_config+=( --enable-ld=yes --enable-gold=no ) extra_config+=( --enable-ld=yes --enable-gold=no )
binutils_tools+=( ld.bfd )
;; ;;
gold) gold)
extra_config+=( --enable-ld=no --enable-gold=yes ) extra_config+=( --enable-ld=no --enable-gold=yes )
binutils_tools+=( ld.gold )
;; ;;
ld,gold) ld,gold)
extra_config+=( --enable-ld=default --enable-gold=yes ) extra_config+=( --enable-ld=default --enable-gold=yes )
binutils_tools+=( ld.bfd ld.gold )
;; ;;
gold,ld) gold,ld)
extra_config+=( --enable-ld=yes --enable-gold=default ) extra_config+=( --enable-ld=yes --enable-gold=default )
binutils_tools+=( ld.bfd ld.gold )
;; ;;
esac esac
if [ "${CT_BINUTILS_GOLD_THREADED}" = "y" ]; then if [ "${CT_BINUTILS_GOLD_THREADED}" = "y" ]; then
@ -79,6 +85,16 @@ do_binutils() {
CT_DoLog EXTRA "Installing binutils" CT_DoLog EXTRA "Installing binutils"
CT_DoExecLog ALL make install CT_DoExecLog ALL make install
# Install the wrapper if needed
if [ "${CT_BINUTILS_LD_WRAPPER}" = "y" ]; then
CT_DoLog EXTRA "Installing ld wrapper"
rm -f "${CT_PREFIX_DIR}/bin/${CT_TARGET}-ld"
sed -r -e "s/@@DEFAULT_LD@@/${CT_BINUTILS_LINKER_DEFAULT}/" \
"${CT_LIB_DIR}/scripts/build/binutils/binutils-ld.in" \
>"${CT_PREFIX_DIR}/bin/${CT_TARGET}-ld"
chmod +x "${CT_PREFIX_DIR}/bin/${CT_TARGET}-ld"
fi
# Make those new tools available to the core C compilers to come. # Make those new tools available to the core C compilers to come.
# Note: some components want the ${TARGET}-{ar,as,ld,strip} commands as # Note: some components want the ${TARGET}-{ar,as,ld,strip} commands as
# well. Create that. # well. Create that.
@ -86,7 +102,7 @@ do_binutils() {
mkdir -p "${CT_CC_CORE_STATIC_PREFIX_DIR}/bin" mkdir -p "${CT_CC_CORE_STATIC_PREFIX_DIR}/bin"
mkdir -p "${CT_CC_CORE_SHARED_PREFIX_DIR}/${CT_TARGET}/bin" mkdir -p "${CT_CC_CORE_SHARED_PREFIX_DIR}/${CT_TARGET}/bin"
mkdir -p "${CT_CC_CORE_SHARED_PREFIX_DIR}/bin" mkdir -p "${CT_CC_CORE_SHARED_PREFIX_DIR}/bin"
for t in ar as ld strip; do for t in "${binutils_tools[@]}"; do
ln -sv "${CT_PREFIX_DIR}/bin/${CT_TARGET}-${t}" "${CT_CC_CORE_STATIC_PREFIX_DIR}/${CT_TARGET}/bin/${t}" ln -sv "${CT_PREFIX_DIR}/bin/${CT_TARGET}-${t}" "${CT_CC_CORE_STATIC_PREFIX_DIR}/${CT_TARGET}/bin/${t}"
ln -sv "${CT_PREFIX_DIR}/bin/${CT_TARGET}-${t}" "${CT_CC_CORE_STATIC_PREFIX_DIR}/bin/${CT_TARGET}-${t}" ln -sv "${CT_PREFIX_DIR}/bin/${CT_TARGET}-${t}" "${CT_CC_CORE_STATIC_PREFIX_DIR}/bin/${CT_TARGET}-${t}"
ln -sv "${CT_PREFIX_DIR}/bin/${CT_TARGET}-${t}" "${CT_CC_CORE_SHARED_PREFIX_DIR}/${CT_TARGET}/bin/${t}" ln -sv "${CT_PREFIX_DIR}/bin/${CT_TARGET}-${t}" "${CT_CC_CORE_SHARED_PREFIX_DIR}/${CT_TARGET}/bin/${t}"