This is the mail archive of the crossgcc@sourceware.org mailing list for the crossgcc project.

See the CrossGCC FAQ for lots more information.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH 3 of 3] binutils/binutils: add wrapper to gold and ld


# HG changeset patch
# User "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
# Date 1293487628 -3600
# Node ID 383b7c9a07ea81fc312b745c244a2b4c06e2c986
# Parent  5bebac13929312c92642cc777f94234c4a55e494
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>

diff --git a/config/binutils/binutils.in b/config/binutils/binutils.in
--- a/config/binutils/binutils.in
+++ b/config/binutils/binutils.in
@@ -94,6 +94,7 @@
     prompt "ld, gold"
     depends on BINUTILS_HAS_GOLD
     depends on EXPERIMENTAL
+    select BINUTILS_LINKER_BOTH
     help
       Both the historical ld and the new gold linkers will be
       installed, with ld being the default linker used.
@@ -105,6 +106,7 @@
     prompt "gold, ld"
     depends on BINUTILS_HAS_GOLD
     depends on EXPERIMENTAL
+    select BINUTILS_LINKER_BOTH
     help
       Both the historical ld and the new gold linkers will be
       installed, with gold being the default linker used.
@@ -113,6 +115,9 @@
 
 endchoice # Enable linkers
 
+config BINUTILS_LINKER_BOTH
+    bool
+
 config BINUTILS_LINKERS_LIST
     string
     default "ld"        if BINUTILS_LINKER_LD
@@ -120,6 +125,25 @@
     default "ld,gold"   if BINUTILS_LINKER_LD_GOLD
     default "gold,ld"   if BINUTILS_LINKER_GOLD_LD
 
+config BINUTILS_LINKER_DEFAULT
+    string
+    depends on BINUTILS_LINKER_BOTH
+    default "bfd"   if BINUTILS_LINKER_LD_GOLD
+    default "gold"  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
+
 endif # BINUTILS_HAS_GOLD
 
 config BINUTILS_EXTRA_CONFIG
diff --git a/scripts/build/binutils/binutils-ld.in b/scripts/build/binutils/binutils-ld.in
new file mode 100644
--- /dev/null
+++ b/scripts/build/binutils/binutils-ld.in
@@ -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 $?
diff --git a/scripts/build/binutils/binutils.sh b/scripts/build/binutils/binutils.sh
--- a/scripts/build/binutils/binutils.sh
+++ b/scripts/build/binutils/binutils.sh
@@ -19,6 +19,7 @@
 do_binutils() {
     local -a extra_config
     local -a extra_make_flags
+    local -a binutils_tools
 
     mkdir -p "${CT_BUILD_DIR}/build-binutils"
     cd "${CT_BUILD_DIR}/build-binutils"
@@ -27,12 +28,25 @@
 
     CT_DoLog EXTRA "Configuring binutils"
 
+    binutils_tools=( ar as ld strip )
     case "${CT_BINUTILS_HAS_GOLD}:${CT_BINUTILS_LINKERS_LIST}" in
-        y:ld)       extra_config+=( --enable-ld=yes     --enable-gold=no        );;
-        y:gold)     extra_config+=( --enable-ld=no      --enable-gold=yes       );;
-        y:ld,gold)  extra_config+=( --enable-ld=default --enable-gold=yes       );;
-        y:gold,ld)  extra_config+=( --enable-ld=yes     --enable-gold=default   );;
-        *)          ;;
+        y:ld)
+            extra_config+=( --enable-ld=yes --enable-gold=no )
+            binutils_tools+=( ld.bfd )
+            ;;
+        y:gold)
+            extra_config+=( --enable-ld=no --enable-gold=yes )
+            binutils_tools+=( ld.gold )
+            ;;
+        y:ld,gold)
+            extra_config+=( --enable-ld=default --enable-gold=yes )
+            binutils_tools+=( ld.bfd ld.gold )
+            ;;
+        y:gold,ld)
+            extra_config+=( --enable-ld=yes --enable-gold=default )
+            binutils_tools+=( ld.bfd ld.gold )
+            ;;
+        *)  ;;
     esac
 
     CT_DoLog DEBUG "Extra config passed: '${extra_config[*]}'"
@@ -64,6 +78,16 @@
     CT_DoLog EXTRA "Installing binutils"
     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.
     # Note: some components want the ${TARGET}-{ar,as,ld,strip} commands as
     # well. Create that.
@@ -71,7 +95,7 @@
     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}/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}/bin/${CT_TARGET}-${t}"
         ln -sv "${CT_PREFIX_DIR}/bin/${CT_TARGET}-${t}" "${CT_CC_CORE_SHARED_PREFIX_DIR}/${CT_TARGET}/bin/${t}"

--
For unsubscribe information see http://sourceware.org/lists.html#faq


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]