public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: "H.J. Lu" <hjl.tools@gmail.com>
To: Ian Lance Taylor <iant@google.com>
Cc: Roland McGrath <roland@redhat.com>,
	binutils@sourceware.org, gcc@gcc.gnu.org
Subject: Re: PATCH: Support --enable-gold=both --with-linker=[bfd|gold]
Date: Tue, 12 Jan 2010 15:27:00 -0000	[thread overview]
Message-ID: <6dc9ffc81001120726t2d9b249q475df0bec2a7b5ab@mail.gmail.com> (raw)
In-Reply-To: <6dc9ffc81001052023t68bcd4a3w62bc4a515f9cdb38@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 9478 bytes --]

On Tue, Jan 5, 2010 at 8:23 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
> On Tue, Jan 5, 2010 at 11:08 AM, Ian Lance Taylor <iant@google.com> wrote:
>> "H.J. Lu" <hjl.tools@gmail.com> writes:
>
>>
>>> diff --git a/configure.ac b/configure.ac
>>> index 407ab59..b349633 100644
>>> --- a/configure.ac
>>> +++ b/configure.ac
>>> @@ -311,10 +311,11 @@ esac
>>>  # Handle --enable-gold.
>>>
>>>  AC_ARG_ENABLE(gold,
>>> -[  --enable-gold           use gold instead of ld],
>>> +[  --enable-gold[[=ARG]]     build gold [[ARG={yes,both}]]],
>>>  ENABLE_GOLD=$enableval,
>>>  ENABLE_GOLD=no)
>>> -if test "${ENABLE_GOLD}" = "yes"; then
>>> +case "${ENABLE_GOLD}" in
>>> +yes|both)
>>>    # Check for ELF target.
>>>    is_elf=no
>>>    case "${target}" in
>>> @@ -334,11 +335,17 @@ if test "${ENABLE_GOLD}" = "yes"; then
>>>      # Check for target supported by gold.
>>>      case "${target}" in
>>>        i?86-*-* | x86_64-*-* | sparc*-*-* | powerpc*-*-* | arm*-*-*)
>>> -        configdirs="`echo " ${configdirs} " | sed -e 's/ ld / gold /'`"
>>> +        if test "${ENABLE_GOLD}" = both; then
>>> +          configdirs="$configdirs gold"
>>> +     else
>>> +          configdirs="`echo " ${configdirs} " | sed -e 's/ ld / gold /'`"
>>> +     fi
>>>          ;;
>>>      esac
>>>    fi
>>> -fi
>>> +  ENABLE_GOLD=yes
>>> +  ;;
>>> +esac
>>
>> You should have an error case here to ensure that --enable-gold only
>> has the values "yes", "both", or "no".  --enable-gold=foo should give
>> an error.
>>
>> This patch uses two configure options: one to build both gold and ld,
>> and one to select which linker is the default.  Why not use just one
>> configure option?  Perhaps something like:
>>    --enable-gold              Build only gold, gold is default
>>    --disable-gold [default]   Build only GNU ld, GNU ld is default
>>    --enable-gold=no           Same
>>    --enable-gold=both         Build both gold and GNU ld, gold is default
>>    --enable-gold=both/gold    Same
>>    --enable-gold=both/bfd     Build both gold and GNU ld, GNU ld is default
>
> Done.
>
>> But of course this approach is conditional on whether there should be
>> some way to select the linker to use at runtime.
>>
>>
>>
>>> diff --git a/gold/Makefile.am b/gold/Makefile.am
>>> index 8d8b617..85b103b 100644
>>> --- a/gold/Makefile.am
>>> +++ b/gold/Makefile.am
>>> @@ -163,12 +163,20 @@ check: libgold.a
>>>
>>>  install-exec-local: ld-new$(EXEEXT)
>>>       $(mkinstalldirs) $(DESTDIR)$(bindir) $(DESTDIR)$(tooldir)/bin
>>> -     n=`echo ld | sed '$(transform)'`; \
>>> +     n=`echo @installed_linker@ | sed '$(transform)'`; \
>>>       $(INSTALL_PROGRAM) ld-new$(EXEEXT) $(DESTDIR)$(bindir)/$${n}$(EXEEXT); \
>>> -     if test "$(bindir)" != "$(tooldir)/bin"; then \
>>> -       rm -f $(DESTDIR)$(tooldir)/bin/ld$(EXEEXT); \
>>> -       ln $(DESTDIR)$(bindir)/$${n}$(EXEEXT) $(DESTDIR)$(tooldir)/bin/ld$(EXEEXT) >/dev/null 2>/dev/null \
>>> +     if test "@linker@" = "ld.gold"; then \
>>> +       if test "@installed_linker@" != "ld"; then \
>>> +         ld=`echo ld | sed '$(transform)'`; \
>>> +         rm -f $(DESTDIR)$(bindir)/$${ld}$(EXEEXT); \
>>> +         ln $(DESTDIR)$(bindir)/$${n}$(EXEEXT) $(DESTDIR)$(bindir)/$${ld}$(EXEEXT) >/dev/null 2>/dev/null \
>>> +         || $(INSTALL_PROGRAM) ld-new$(EXEEXT) $(DESTDIR)$(bindir)/$${ld}$(EXEEXT); \
>>> +       fi; \
>>> +       if test "$(bindir)" != "$(tooldir)/bin"; then \
>>> +         rm -f $(DESTDIR)$(tooldir)/bin/ld$(EXEEXT); \
>>> +         ln $(DESTDIR)$(bindir)/$${n}$(EXEEXT) $(DESTDIR)$(tooldir)/bin/ld$(EXEEXT) >/dev/null 2>/dev/null \
>>>           || $(INSTALL_PROGRAM) ld-new$(EXEEXT) $(DESTDIR)$(tooldir)/bin/ld$(EXEEXT); \
>>> +       fi; \
>>>       fi
>>
>> In Makefile.am you don't need to use @@ quoting in rules.  You can
>> just use $(installed_linker) and $(linker).
>>
>
> Done.
>
>>
>>> diff --git a/gold/configure.ac b/gold/configure.ac
>>> index 85e23f9..10389a9 100644
>>> --- a/gold/configure.ac
>>> +++ b/gold/configure.ac
>>> @@ -38,6 +38,29 @@ AC_DEFINE_UNQUOTED(TARGET_SYSTEM_ROOT, "$sysroot",
>>>  AC_DEFINE_UNQUOTED(TARGET_SYSTEM_ROOT_RELOCATABLE, $sysroot_relocatable,
>>>    [Whether the system root can be relocated])
>>>
>>> +AC_ARG_ENABLE(gold,
>>> +[  --enable-gold[[=ARG]]     build gold [[ARG={yes,both}]]],
>>> +[if test "${enableval}" = "both"; then
>>> +   bfd_linker=ld.bfd
>>> +   installed_linker=ld.gold
>>> + else
>>> +   bfd_linker=ld.gold
>>> +   installed_linker=ld
>>> + fi],
>>> +[bfd_linker=ld.bfd
>>> + installed_linker=ld])
>>> +AC_SUBST(installed_linker)
>>
>> It seems rather weird to set a variable named bfd_linker to be
>> ld.gold.  What does that mean?
>
> Rewritten.
>
>>
>>> +AC_ARG_ENABLE(linker,
>>> +[  --enable-linker=[[ARG]]   specify the default linker [[ARG={bfd,gold}]]],
>>> +[if test "${enableval}" = "gold"; then
>>> +   linker=ld.gold
>>> + else
>>> +   linker=$bfd_linker
>>> + fi],
>>> +[linker=$bfd_linker])
>>> +AC_SUBST(linker)
>>
>> You should give an error if --enable-linker is used with an
>> unrecognized value.
>
> Done.
>
>>
>>> --- a/ld/Makefile.am
>>> +++ b/ld/Makefile.am
>>> @@ -95,7 +95,7 @@ CXX_FOR_TARGET = ` \
>>>      fi; \
>>>    fi`
>>>
>>> -transform = s/^ld-new$$/ld/;@program_transform_name@
>>> +transform = s/^ld-new$$/@installed_linker@/;$(program_transform_name)
>>>  bin_PROGRAMS = ld-new
>>>  info_TEXINFOS = ld.texinfo
>>>  ld_TEXINFOS = configdoc.texi
>>
>> $(installed_linker).  Although actually as far as I can tell this line
>> is completely unnecessary.  Only constant strings are passed to
>> $(transform), and those constant strings never include ld-new.
>>
>
> I'd like to keep it in this patch.  We can have a separate patch to remove it.
>
>>> -install-exec-local: ld-new$(EXEEXT)
>>> +install-exec-local: ld-new$(EXEEXT) install-binPROGRAMS
>>>       $(mkinstalldirs) $(DESTDIR)$(tooldir)/bin
>>> -     n=`echo ld | sed '$(transform)'`; \
>>> -     if [ "$(bindir)/$$n$(EXEEXT)" != "$(tooldir)/bin/ld$(EXEEXT)" ]; then \
>>> -       rm -f $(DESTDIR)$(tooldir)/bin/ld$(EXEEXT); \
>>> -       ln $(DESTDIR)$(bindir)/$$n$(EXEEXT) $(DESTDIR)$(tooldir)/bin/ld$(EXEEXT) >/dev/null 2>/dev/null \
>>> -       || $(LIBTOOL) --mode=install $(INSTALL_PROGRAM) ld-new$(EXEEXT) $(DESTDIR)$(tooldir)/bin/ld$(EXEEXT); \
>>> +     n=`echo @installed_linker@ | sed '$(transform)'`; \
>>> +     if test "@linker@" = "ld.bfd"; then \
>>> +       if test "@installed_linker@" != "ld"; then \
>>> +         ld=`echo ld | sed '$(transform)'`; \
>>> +         rm -f $(DESTDIR)$(bindir)/$$ld$(EXEEXT); \
>>> +         ln $(DESTDIR)$(bindir)/$$n$(EXEEXT) $(DESTDIR)$(bindir)/$$ld$(EXEEXT) >/dev/null 2>/dev/null \
>>> +         || $(LIBTOOL) --mode=install $(INSTALL_PROGRAM) ld-new$(EXEEXT) $(DESTDIR)$(bindir)/$$ld$(EXEEXT); \
>>> +       fi; \
>>> +       if test "$(bindir)/$$n$(EXEEXT)" != "$(tooldir)/bin/ld$(EXEEXT)"; then \
>>> +         rm -f $(DESTDIR)$(tooldir)/bin/ld$(EXEEXT); \
>>> +         ln $(DESTDIR)$(bindir)/$$n$(EXEEXT) $(DESTDIR)$(tooldir)/bin/ld$(EXEEXT) >/dev/null 2>/dev/null \
>>> +         || $(LIBTOOL) --mode=install $(INSTALL_PROGRAM) ld-new$(EXEEXT) $(DESTDIR)$(tooldir)/bin/ld$(EXEEXT); \
>>> +       fi; \
>>>       fi
>>
>> Here also use $(VAR) rather than @VAR@.
>
> Done.
>
>>
>>> diff --git a/ld/configure.in b/ld/configure.in
>>> index c4655f5..9786953 100644
>>> --- a/ld/configure.in
>>> +++ b/ld/configure.in
>>> @@ -69,6 +69,29 @@ AC_SUBST(use_sysroot)
>>>  AC_SUBST(TARGET_SYSTEM_ROOT)
>>>  AC_SUBST(TARGET_SYSTEM_ROOT_DEFINE)
>>>
>>> +AC_ARG_ENABLE(gold,
>>> +[  --enable-gold[[=ARG]]     build gold [[ARG={yes,both}]]],
>>> +[if test "${enableval}" = "both"; then
>>> +  gold_linker=ld.gold
>>> +  installed_linker=ld.bfd
>>> +else
>>> +  gold_linker=ld.bfd
>>> +  installed_linker=ld
>>> +fi],
>>> +[gold_linker=ld.bfd
>>> + installed_linker=ld])
>>> +AC_SUBST(installed_linker)
>>
>> How can gold_linker be set to ld.bfd?
>>
>
> Rewritten.
>
> Thanks.
>
>
> --
> H.J.
> ---
> 2010-01-05  Roland McGrath  <roland@redhat.com>
>            H.J. Lu  <hongjiu.lu@intel.com>
>
>        * configure.ac (--enable-gold): Support both, both/gold and
>        both/bfd to add gold to configdirs without removing ld.
>        * configure: Regenerated.
>
> gold/
>
> 2010-01-05  H.J. Lu  <hongjiu.lu@intel.com>
>
>        * Makefile.am (install-exec-local): Install as $(installed_linker).
>        Install as ld if $(linker) == "ld.gold" and $(installed_linker)
>        != "ld".
>        * Makefile.in: Regenerated.
>
>        * configure.ac (--enable-gold): Support both, both/gold and
>        both/bfd.
>        * configure: Regenerated.
>
> ld/
>
> 2010-01-05  H.J. Lu  <hongjiu.lu@intel.com>
>
>        * Makefile.am (transform): Install as $(installed_linker).
>        (install-exec-local): Depend on install-binPROGRAMS.  Install
>        as $(installed_linker).  Install as ld if $(linker) == "ld.bfd"
>        and $(installed_linker) != "ld".
>        * Makefile.in: Regenerated.
>
>        * configure.in (--enable-gold): Support both, both/gold and
>        both/bfd.
>        * configure: Regenerated.
>

Here is the updated patch to set ENABLE_GOLD to yes only if
target is supported.

Any comments?

Thanks.


-- 
H.J.

[-- Attachment #2: binutils-gold-7.patch --]
[-- Type: text/plain, Size: 17124 bytes --]

2010-01-05  Roland McGrath  <roland@redhat.com>
	    H.J. Lu  <hongjiu.lu@intel.com>

	* configure.ac (--enable-gold): Support both, both/gold and
	both/bfd to add gold to configdirs without removing ld.
	* configure: Regenerated.

gold/

2010-01-05  H.J. Lu  <hongjiu.lu@intel.com>

	* Makefile.am (install-exec-local): Install as $(installed_linker).
	Install as ld if $(linker) == "ld.gold" and $(installed_linker)
	!= "ld".
	* Makefile.in: Regenerated.

	* configure.ac (--enable-gold): Support both, both/gold and
	both/bfd.
	* configure: Regenerated.

ld/

2010-01-05  H.J. Lu  <hongjiu.lu@intel.com>

	* Makefile.am (transform): Install as $(installed_linker).
	(install-exec-local): Depend on install-binPROGRAMS.  Install
	as $(installed_linker).  Install as ld if $(linker) == "ld.bfd"
	and $(installed_linker) != "ld".
	* Makefile.in: Regenerated.

	* configure.in (--enable-gold): Support both, both/gold and
	both/bfd.
	* configure: Regenerated.

diff --git a/configure b/configure
index 9aa4685..1946a2c 100755
--- a/configure
+++ b/configure
@@ -1482,7 +1482,7 @@ Optional Features:
   --disable-option-checking  ignore unrecognized --enable/--with options
   --disable-FEATURE       do not include FEATURE (same as --enable-FEATURE=no)
   --enable-FEATURE[=ARG]  include FEATURE [ARG=yes]
-  --enable-gold           use gold instead of ld
+  --enable-gold[=ARG]     build gold [ARG={both}[[/{gold,bfd}]]]
   --enable-libada         build libada directory
   --enable-libssp         build libssp directory
   --enable-build-with-cxx build with C++ compiler instead of C compiler
@@ -3068,6 +3068,12 @@ case ${with_newlib} in
 esac
 
 # Handle --enable-gold.
+#   --enable-gold		Build only gold, gold is default
+#   --disable-gold [default]	Build only GNU ld, GNU ld is default
+#   --enable-gold=both		Build both gold and GNU ld, gold is default
+#   --enable-gold=both/gold	Same
+#   --enable-gold=both/bfd	Build both gold and GNU ld, GNU ld is
+#				default
 
 # Check whether --enable-gold was given.
 if test "${enable_gold+set}" = set; then :
@@ -3076,7 +3082,8 @@ else
   ENABLE_GOLD=no
 fi
 
-if test "${ENABLE_GOLD}" = "yes"; then
+case "${ENABLE_GOLD}" in
+yes|both|both/gold|both/bfd)
   # Check for ELF target.
   is_elf=no
   case "${target}" in
@@ -3096,11 +3103,25 @@ if test "${ENABLE_GOLD}" = "yes"; then
     # Check for target supported by gold.
     case "${target}" in
       i?86-*-* | x86_64-*-* | sparc*-*-* | powerpc*-*-* | arm*-*-*)
-        configdirs="`echo " ${configdirs} " | sed -e 's/ ld / gold /'`"
+	case "${ENABLE_GOLD}" in
+	both*)
+          configdirs="$configdirs gold"
+	  ;;
+	*)
+          configdirs="`echo " ${configdirs} " | sed -e 's/ ld / gold /'`"
+	  ;;
+	esac
+	ENABLE_GOLD=yes
         ;;
     esac
   fi
-fi
+  ;;
+no)
+  ;;
+*)
+  as_fn_error "invalid --enable-gold argument" "$LINENO" 5
+  ;;
+esac
 
 # Configure extra directories which are host specific
 
diff --git a/configure.ac b/configure.ac
index 596b527..562756f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -314,12 +314,19 @@ case ${with_newlib} in
 esac
 
 # Handle --enable-gold.
+#   --enable-gold		Build only gold, gold is default
+#   --disable-gold [default]	Build only GNU ld, GNU ld is default
+#   --enable-gold=both		Build both gold and GNU ld, gold is default
+#   --enable-gold=both/gold	Same
+#   --enable-gold=both/bfd	Build both gold and GNU ld, GNU ld is
+#				default
 
 AC_ARG_ENABLE(gold,
-[  --enable-gold           use gold instead of ld],
+[  --enable-gold[[=ARG]]     build gold [[ARG={both}[[/{gold,bfd}]]]]],
 ENABLE_GOLD=$enableval,
 ENABLE_GOLD=no)
-if test "${ENABLE_GOLD}" = "yes"; then
+case "${ENABLE_GOLD}" in 
+yes|both|both/gold|both/bfd)
   # Check for ELF target.
   is_elf=no
   case "${target}" in
@@ -339,11 +346,25 @@ if test "${ENABLE_GOLD}" = "yes"; then
     # Check for target supported by gold.
     case "${target}" in
       i?86-*-* | x86_64-*-* | sparc*-*-* | powerpc*-*-* | arm*-*-*)
-        configdirs="`echo " ${configdirs} " | sed -e 's/ ld / gold /'`"
+	case "${ENABLE_GOLD}" in 
+	both*)
+          configdirs="$configdirs gold"
+	  ;;
+	*)
+          configdirs="`echo " ${configdirs} " | sed -e 's/ ld / gold /'`"
+	  ;;
+	esac
+	ENABLE_GOLD=yes
         ;;
     esac
   fi
-fi
+  ;;
+no)
+  ;;
+*)
+  AC_MSG_ERROR([invalid --enable-gold argument])
+  ;;
+esac
 
 # Configure extra directories which are host specific
 
diff --git a/gold/Makefile.am b/gold/Makefile.am
index 784f821..552c2b1 100644
--- a/gold/Makefile.am
+++ b/gold/Makefile.am
@@ -175,12 +175,20 @@ check: libgold.a
 
 install-exec-local: ld-new$(EXEEXT)
 	$(mkinstalldirs) $(DESTDIR)$(bindir) $(DESTDIR)$(tooldir)/bin
-	n=`echo ld | sed '$(transform)'`; \
+	n=`echo $(installed_linker) | sed '$(transform)'`; \
 	$(INSTALL_PROGRAM) ld-new$(EXEEXT) $(DESTDIR)$(bindir)/$${n}$(EXEEXT); \
-	if test "$(bindir)" != "$(tooldir)/bin"; then \
-	  rm -f $(DESTDIR)$(tooldir)/bin/ld$(EXEEXT); \
-	  ln $(DESTDIR)$(bindir)/$${n}$(EXEEXT) $(DESTDIR)$(tooldir)/bin/ld$(EXEEXT) >/dev/null 2>/dev/null \
+	if test "$(linker)" = "ld.gold"; then \
+	  if test "$(installed_linker)" != "ld"; then \
+	    ld=`echo ld | sed '$(transform)'`; \
+	    rm -f $(DESTDIR)$(bindir)/$${ld}$(EXEEXT); \
+	    ln $(DESTDIR)$(bindir)/$${n}$(EXEEXT) $(DESTDIR)$(bindir)/$${ld}$(EXEEXT) >/dev/null 2>/dev/null \
+	    || $(INSTALL_PROGRAM) ld-new$(EXEEXT) $(DESTDIR)$(bindir)/$${ld}$(EXEEXT); \
+	  fi; \
+	  if test "$(bindir)" != "$(tooldir)/bin"; then \
+	    rm -f $(DESTDIR)$(tooldir)/bin/ld$(EXEEXT); \
+	    ln $(DESTDIR)$(bindir)/$${n}$(EXEEXT) $(DESTDIR)$(tooldir)/bin/ld$(EXEEXT) >/dev/null 2>/dev/null \
 	    || $(INSTALL_PROGRAM) ld-new$(EXEEXT) $(DESTDIR)$(tooldir)/bin/ld$(EXEEXT); \
+	  fi; \
 	fi
 
 # We want install to imply install-info as per GNU standards, despite
diff --git a/gold/Makefile.in b/gold/Makefile.in
index e118a51..68be5b9 100644
--- a/gold/Makefile.in
+++ b/gold/Makefile.in
@@ -306,8 +306,10 @@ htmldir = @htmldir@
 includedir = @includedir@
 infodir = @infodir@
 install_sh = @install_sh@
+installed_linker = @installed_linker@
 libdir = @libdir@
 libexecdir = @libexecdir@
+linker = @linker@
 localedir = @localedir@
 localstatedir = @localstatedir@
 mandir = @mandir@
@@ -1223,12 +1225,20 @@ check: libgold.a
 
 install-exec-local: ld-new$(EXEEXT)
 	$(mkinstalldirs) $(DESTDIR)$(bindir) $(DESTDIR)$(tooldir)/bin
-	n=`echo ld | sed '$(transform)'`; \
+	n=`echo $(installed_linker) | sed '$(transform)'`; \
 	$(INSTALL_PROGRAM) ld-new$(EXEEXT) $(DESTDIR)$(bindir)/$${n}$(EXEEXT); \
-	if test "$(bindir)" != "$(tooldir)/bin"; then \
-	  rm -f $(DESTDIR)$(tooldir)/bin/ld$(EXEEXT); \
-	  ln $(DESTDIR)$(bindir)/$${n}$(EXEEXT) $(DESTDIR)$(tooldir)/bin/ld$(EXEEXT) >/dev/null 2>/dev/null \
+	if test "$(linker)" = "ld.gold"; then \
+	  if test "@installed_linke@" != "ld"; then \
+	    ld=`echo ld | sed '$(transform)'`; \
+	    rm -f $(DESTDIR)$(bindir)/$${ld}$(EXEEXT); \
+	    ln $(DESTDIR)$(bindir)/$${n}$(EXEEXT) $(DESTDIR)$(bindir)/$${ld}$(EXEEXT) >/dev/null 2>/dev/null \
+	    || $(INSTALL_PROGRAM) ld-new$(EXEEXT) $(DESTDIR)$(bindir)/$${ld}$(EXEEXT); \
+	  fi; \
+	  if test "$(bindir)" != "$(tooldir)/bin"; then \
+	    rm -f $(DESTDIR)$(tooldir)/bin/ld$(EXEEXT); \
+	    ln $(DESTDIR)$(bindir)/$${n}$(EXEEXT) $(DESTDIR)$(tooldir)/bin/ld$(EXEEXT) >/dev/null 2>/dev/null \
 	    || $(INSTALL_PROGRAM) ld-new$(EXEEXT) $(DESTDIR)$(tooldir)/bin/ld$(EXEEXT); \
+	  fi; \
 	fi
 
 # We want install to imply install-info as per GNU standards, despite
diff --git a/gold/configure b/gold/configure
index 4817e44..34d3794 100755
--- a/gold/configure
+++ b/gold/configure
@@ -682,6 +682,8 @@ PLUGINS_FALSE
 PLUGINS_TRUE
 THREADS_FALSE
 THREADS_TRUE
+linker
+installed_linker
 am__untar
 am__tar
 AMTAR
@@ -759,6 +761,7 @@ ac_subst_files=''
 ac_user_opts='
 enable_option_checking
 with_sysroot
+enable_gold
 enable_threads
 enable_plugins
 enable_targets
@@ -1403,6 +1406,7 @@ Optional Features:
   --disable-option-checking  ignore unrecognized --enable/--with options
   --disable-FEATURE       do not include FEATURE (same as --enable-FEATURE=no)
   --enable-FEATURE[=ARG]  include FEATURE [ARG=yes]
+  --enable-gold[=ARG]     build gold [ARG={both}[[/{gold,bfd}]]]
   --enable-threads        multi-threaded linking
   --enable-plugins        linker plugins
   --enable-targets        alternative target configurations
@@ -3227,6 +3231,33 @@ cat >>confdefs.h <<_ACEOF
 _ACEOF
 
 
+# Check whether --enable-gold was given.
+if test "${enable_gold+set}" = set; then :
+  enableval=$enable_gold; case "${enableval}" in
+ yes)
+   installed_linker=ld
+   linker=ld.gold
+   ;;
+ both|both/gold)
+   installed_linker=ld.gold
+   linker=ld.gold
+   ;;
+ both/bfd)
+   installed_linker=ld.gold
+   linker=ld.bfd
+   ;;
+ *)
+   as_fn_error "invalid --enable-gold argument" "$LINENO" 5
+   ;;
+ esac
+else
+  installed_linker=ld
+ linker=ld.gold
+fi
+
+
+
+
 # Check whether --enable-threads was given.
 if test "${enable_threads+set}" = set; then :
   enableval=$enable_threads; case "${enableval}" in
diff --git a/gold/configure.ac b/gold/configure.ac
index 7102670..d6b855b 100644
--- a/gold/configure.ac
+++ b/gold/configure.ac
@@ -38,6 +38,32 @@ AC_DEFINE_UNQUOTED(TARGET_SYSTEM_ROOT, "$sysroot",
 AC_DEFINE_UNQUOTED(TARGET_SYSTEM_ROOT_RELOCATABLE, $sysroot_relocatable,
   [Whether the system root can be relocated])
 
+dnl "installed_linker" is the installed gold linker name.
+dnl "linker" is the linker to be installed as the default linker, ld.
+AC_ARG_ENABLE(gold,
+[  --enable-gold[[=ARG]]     build gold [[ARG={both}[[/{gold,bfd}]]]]],
+[case "${enableval}" in 
+ yes)
+   installed_linker=ld
+   linker=ld.gold
+   ;;
+ both|both/gold)
+   installed_linker=ld.gold
+   linker=ld.gold
+   ;;
+ both/bfd)
+   installed_linker=ld.gold
+   linker=ld.bfd
+   ;;
+ *)
+   AC_MSG_ERROR([invalid --enable-gold argument])
+   ;;
+ esac],
+[installed_linker=ld
+ linker=ld.gold])
+AC_SUBST(installed_linker)
+AC_SUBST(linker)
+
 dnl For now threads are a configure time option.
 AC_ARG_ENABLE([threads],
 [  --enable-threads        multi-threaded linking],
diff --git a/ld/Makefile.am b/ld/Makefile.am
index c1d3dbf..b54d27f 100644
--- a/ld/Makefile.am
+++ b/ld/Makefile.am
@@ -95,7 +95,7 @@ CXX_FOR_TARGET = ` \
     fi; \
   fi`
 
-transform = s/^ld-new$$/ld/;@program_transform_name@
+transform = s/^ld-new$$/$(installed_linker)/;$(program_transform_name)
 bin_PROGRAMS = ld-new
 info_TEXINFOS = ld.texinfo
 ld_TEXINFOS = configdoc.texi
@@ -1959,13 +1959,21 @@ CLEANFILES = dep.sed DEP DEPA DEP1 DEP2 spu_ovl.s spu_ovl.o spu_icache.s spu_ica
 
 .PHONY: install-exec-local install-data-local
 
-install-exec-local: ld-new$(EXEEXT)
+install-exec-local: ld-new$(EXEEXT) install-binPROGRAMS
 	$(mkinstalldirs) $(DESTDIR)$(tooldir)/bin
-	n=`echo ld | sed '$(transform)'`; \
-	if [ "$(bindir)/$$n$(EXEEXT)" != "$(tooldir)/bin/ld$(EXEEXT)" ]; then \
-	  rm -f $(DESTDIR)$(tooldir)/bin/ld$(EXEEXT); \
-	  ln $(DESTDIR)$(bindir)/$$n$(EXEEXT) $(DESTDIR)$(tooldir)/bin/ld$(EXEEXT) >/dev/null 2>/dev/null \
-	  || $(LIBTOOL) --mode=install $(INSTALL_PROGRAM) ld-new$(EXEEXT) $(DESTDIR)$(tooldir)/bin/ld$(EXEEXT); \
+	n=`echo $(installed_linker) | sed '$(transform)'`; \
+	if test "$(linker)" = "ld.bfd"; then \
+	  if test "$(installed_linker)" != "ld"; then \
+	    ld=`echo ld | sed '$(transform)'`; \
+	    rm -f $(DESTDIR)$(bindir)/$$ld$(EXEEXT); \
+	    ln $(DESTDIR)$(bindir)/$$n$(EXEEXT) $(DESTDIR)$(bindir)/$$ld$(EXEEXT) >/dev/null 2>/dev/null \
+	    || $(LIBTOOL) --mode=install $(INSTALL_PROGRAM) ld-new$(EXEEXT) $(DESTDIR)$(bindir)/$$ld$(EXEEXT); \
+	  fi; \
+	  if test "$(bindir)/$$n$(EXEEXT)" != "$(tooldir)/bin/ld$(EXEEXT)"; then \
+	    rm -f $(DESTDIR)$(tooldir)/bin/ld$(EXEEXT); \
+	    ln $(DESTDIR)$(bindir)/$$n$(EXEEXT) $(DESTDIR)$(tooldir)/bin/ld$(EXEEXT) >/dev/null 2>/dev/null \
+	    || $(LIBTOOL) --mode=install $(INSTALL_PROGRAM) ld-new$(EXEEXT) $(DESTDIR)$(tooldir)/bin/ld$(EXEEXT); \
+	  fi; \
 	fi
 
 install-data-local:
diff --git a/ld/Makefile.in b/ld/Makefile.in
index e7f23d8..af8923a 100644
--- a/ld/Makefile.in
+++ b/ld/Makefile.in
@@ -155,7 +155,7 @@ CTAGS = ctags
 DEJATOOL = $(PACKAGE)
 RUNTESTDEFAULTFLAGS = --tool $$tool --srcdir $$srcdir
 DIST_SUBDIRS = $(SUBDIRS)
-transform = s/^ld-new$$/ld/;@program_transform_name@
+transform = s/^ld-new$$/$(installed_linker)/;$(program_transform_name)
 ACLOCAL = @ACLOCAL@
 AMTAR = @AMTAR@
 AR = @AR@
@@ -296,8 +296,10 @@ htmldir = @htmldir@
 includedir = @includedir@
 infodir = @infodir@
 install_sh = @install_sh@
+installed_linker = @installed_linker@
 libdir = @libdir@
 libexecdir = @libexecdir@
+linker = @linker@
 localedir = @localedir@
 localstatedir = @localstatedir@
 mandir = @mandir@
@@ -3276,13 +3278,21 @@ mostlyclean-local:
 
 .PHONY: install-exec-local install-data-local
 
-install-exec-local: ld-new$(EXEEXT)
+install-exec-local: ld-new$(EXEEXT) install-binPROGRAMS
 	$(mkinstalldirs) $(DESTDIR)$(tooldir)/bin
-	n=`echo ld | sed '$(transform)'`; \
-	if [ "$(bindir)/$$n$(EXEEXT)" != "$(tooldir)/bin/ld$(EXEEXT)" ]; then \
-	  rm -f $(DESTDIR)$(tooldir)/bin/ld$(EXEEXT); \
-	  ln $(DESTDIR)$(bindir)/$$n$(EXEEXT) $(DESTDIR)$(tooldir)/bin/ld$(EXEEXT) >/dev/null 2>/dev/null \
-	  || $(LIBTOOL) --mode=install $(INSTALL_PROGRAM) ld-new$(EXEEXT) $(DESTDIR)$(tooldir)/bin/ld$(EXEEXT); \
+	n=`echo $(installed_linker) | sed '$(transform)'`; \
+	if test "$(linker)" = "ld.bfd"; then \
+	  if test "$(installed_linker)" != "ld"; then \
+	    ld=`echo ld | sed '$(transform)'`; \
+	    rm -f $(DESTDIR)$(bindir)/$$ld$(EXEEXT); \
+	    ln $(DESTDIR)$(bindir)/$$n$(EXEEXT) $(DESTDIR)$(bindir)/$$ld$(EXEEXT) >/dev/null 2>/dev/null \
+	    || $(LIBTOOL) --mode=install $(INSTALL_PROGRAM) ld-new$(EXEEXT) $(DESTDIR)$(bindir)/$$ld$(EXEEXT); \
+	  fi; \
+	  if test "$(bindir)/$$n$(EXEEXT)" != "$(tooldir)/bin/ld$(EXEEXT)"; then \
+	    rm -f $(DESTDIR)$(tooldir)/bin/ld$(EXEEXT); \
+	    ln $(DESTDIR)$(bindir)/$$n$(EXEEXT) $(DESTDIR)$(tooldir)/bin/ld$(EXEEXT) >/dev/null 2>/dev/null \
+	    || $(LIBTOOL) --mode=install $(INSTALL_PROGRAM) ld-new$(EXEEXT) $(DESTDIR)$(tooldir)/bin/ld$(EXEEXT); \
+	  fi; \
 	fi
 
 install-data-local:
diff --git a/ld/configure b/ld/configure
index cb89d84..dfaa60c 100755
--- a/ld/configure
+++ b/ld/configure
@@ -657,6 +657,8 @@ GREP
 CPP
 NO_WERROR
 WARN_CFLAGS
+linker
+installed_linker
 TARGET_SYSTEM_ROOT_DEFINE
 TARGET_SYSTEM_ROOT
 use_sysroot
@@ -761,6 +763,7 @@ with_lib_path
 enable_targets
 enable_64_bit_bfd
 with_sysroot
+enable_gold
 enable_got
 enable_werror
 enable_build_warnings
@@ -1409,6 +1412,7 @@ Optional Features:
 			  (and sometimes confusing) to the casual installer
   --enable-targets        alternative target configurations
   --enable-64-bit-bfd     64-bit support (on hosts with narrower word sizes)
+  --enable-gold[=ARG]     build gold [ARG={both}[[/{gold,bfd}]]]
   --enable-got=<type>     GOT handling scheme (target, single, negative,
                           multigot)
   --enable-werror         treat compile warnings as errors
@@ -4164,6 +4168,33 @@ fi
 
 
 
+# Check whether --enable-gold was given.
+if test "${enable_gold+set}" = set; then :
+  enableval=$enable_gold; case "${enableval}" in
+ both|both/gold)
+   installed_linker=ld.bfd
+   linker=ld.gold
+   ;;
+ both/bfd)
+   installed_linker=ld.bfd
+   linker=ld.bfd
+   ;;
+ no)
+   installed_linker=ld
+   linker=ld.bfd
+   ;;
+ *)
+   as_fn_error "invalid --enable-gold argument" "$LINENO" 5
+   ;;
+ esac
+else
+  installed_linker=ld
+ linker=ld.bfd
+fi
+
+
+
+
 # Check whether --enable-got was given.
 if test "${enable_got+set}" = set; then :
   enableval=$enable_got; case "${enableval}" in
@@ -11575,7 +11606,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11578 "configure"
+#line 11609 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -11681,7 +11712,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11684 "configure"
+#line 11715 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
diff --git a/ld/configure.in b/ld/configure.in
index 4bbc8f8..450fe5d 100644
--- a/ld/configure.in
+++ b/ld/configure.in
@@ -69,6 +69,32 @@ AC_SUBST(use_sysroot)
 AC_SUBST(TARGET_SYSTEM_ROOT)
 AC_SUBST(TARGET_SYSTEM_ROOT_DEFINE)
 
+dnl "installed_linker" is the installed BFD linker name.
+dnl "linker" is the linker to be installed as the default linker, ld.
+AC_ARG_ENABLE(gold, 
+[  --enable-gold[[=ARG]]     build gold [[ARG={both}[[/{gold,bfd}]]]]],
+[case "${enableval}" in 
+ both|both/gold)
+   installed_linker=ld.bfd
+   linker=ld.gold
+   ;;
+ both/bfd)
+   installed_linker=ld.bfd
+   linker=ld.bfd
+   ;;
+ no)
+   installed_linker=ld
+   linker=ld.bfd
+   ;;
+ *)
+   AC_MSG_ERROR([invalid --enable-gold argument])
+   ;;
+ esac],
+[installed_linker=ld
+ linker=ld.bfd])
+AC_SUBST(installed_linker)
+AC_SUBST(linker)
+
 AC_ARG_ENABLE([got],
 AS_HELP_STRING([--enable-got=<type>],
                [GOT handling scheme (target, single, negative, multigot)]),

      reply	other threads:[~2010-01-12 15:27 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-11-02 22:06 H.J. Lu
2009-11-03 22:19 ` H.J. Lu
2009-11-03 22:23   ` Roland McGrath
2009-11-03 23:28     ` H.J. Lu
2009-11-04  5:09       ` Roland McGrath
2009-11-04 14:47         ` H.J. Lu
2010-01-05 19:08       ` Ian Lance Taylor
2010-01-05 21:12         ` Roland McGrath
2010-01-05 21:35           ` Ian Lance Taylor
2010-01-05 21:40             ` H.J. Lu
2010-01-05 22:29               ` Ian Lance Taylor
2010-01-05 23:48                 ` Matthias Klose
2010-01-05 23:00             ` Roland McGrath
2010-01-05 23:52               ` Matthias Klose
2010-01-06  1:01                 ` Roland McGrath
2010-01-06  1:42                   ` Daniel Jacobowitz
2010-01-06 21:49                     ` Roland McGrath
2010-01-06  0:24               ` Ian Lance Taylor
2010-01-06  4:23         ` H.J. Lu
2010-01-12 15:27           ` H.J. Lu [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6dc9ffc81001120726t2d9b249q475df0bec2a7b5ab@mail.gmail.com \
    --to=hjl.tools@gmail.com \
    --cc=binutils@sourceware.org \
    --cc=gcc@gcc.gnu.org \
    --cc=iant@google.com \
    --cc=roland@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).