* PATCH: Support --enable-gold=both --with-linker=[bfd|gold] @ 2009-11-02 22:06 H.J. Lu 2009-11-03 22:19 ` H.J. Lu 0 siblings, 1 reply; 20+ messages in thread From: H.J. Lu @ 2009-11-02 22:06 UTC (permalink / raw) To: binutils; +Cc: roland, gcc Hi, This patch adds --enable-gold=both --with-linker=[bfd|gold] so that we can build both ld and gold. This patch will 1. Install ld as ld.bfd 2. Install gold as ld.gold 3. Install one of them as ld, selected by --with-linker. If needed, gcc install invoke gold as ld.gold and ld as ld.bfd. Any comments? Thanks. H.J. -- 2009-11-03 Roland McGrath <roland@redhat.com> * configure.ac (--enable-gold): Accept --enable-gold=both to add gold to configdirs without removing ld. * configure: Regenerated. gold/ 2009-11-03 H.J. Lu <hongjiu.lu@intel.com> * Makefile.am (install-exec-local): Install as ld.gold. Install as ld if "@linker@" == "ld.gold". * Makefile.in: Regenerated. * configure.ac (linker): New substituted variable. Set by --enable-gold and --with-linker. * configure: Regenerated. ld/ 2009-11-03 H.J. Lu <hongjiu.lu@intel.com> * Makefile.am (transform): Install as ld.bfd (install-exec-local): Depend on install-binPROGRAMS. Install as ld.gold. Install as ld if "@linker@" == "ld.bfd". * Makefile.in: Regenerated. * configure.ac (linker): New substituted variable. Set by --enable-gold and --with-linker. * configure: Regenerated. diff --git a/configure b/configure index 1ece75c..7e7076a 100755 --- a/configure +++ b/configure @@ -3076,7 +3076,8 @@ else ENABLE_GOLD=no fi -if test "${ENABLE_GOLD}" = "yes"; then +case "${ENABLE_GOLD}" in +yes|both) # Check for ELF target. is_elf=no case "${target}" in @@ -3096,11 +3097,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 # Configure extra directories which are host specific diff --git a/configure.ac b/configure.ac index 407ab59..b07ad23 100644 --- a/configure.ac +++ b/configure.ac @@ -314,7 +314,8 @@ AC_ARG_ENABLE(gold, [ --enable-gold use gold instead of ld], 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 # Configure extra directories which are host specific diff --git a/gold/Makefile.am b/gold/Makefile.am index 8d8b617..1747a92 100644 --- a/gold/Makefile.am +++ b/gold/Makefile.am @@ -163,12 +163,18 @@ check: libgold.a install-exec-local: ld-new$(EXEEXT) $(mkinstalldirs) $(DESTDIR)$(bindir) $(DESTDIR)$(tooldir)/bin - n=`echo ld | sed '$(transform)'`; \ + n=`echo ld.gold | 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 \ + 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); \ + 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 d4c689b..fce401c 100644 --- a/gold/Makefile.in +++ b/gold/Makefile.in @@ -305,6 +305,7 @@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ +linker = @linker@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ @@ -1200,12 +1201,18 @@ check: libgold.a install-exec-local: ld-new$(EXEEXT) $(mkinstalldirs) $(DESTDIR)$(bindir) $(DESTDIR)$(tooldir)/bin - n=`echo ld | sed '$(transform)'`; \ + n=`echo ld.gold | 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 \ + 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); \ + 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 e4eb9fb..efc3e03 100755 --- a/gold/configure +++ b/gold/configure @@ -682,6 +682,7 @@ PLUGINS_FALSE PLUGINS_TRUE THREADS_FALSE THREADS_TRUE +linker am__untar am__tar AMTAR @@ -759,6 +760,8 @@ ac_subst_files='' ac_user_opts=' enable_option_checking with_sysroot +enable_gold +with_linker 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 Enable gold --enable-threads multi-threaded linking --enable-plugins linker plugins --enable-targets alternative target configurations @@ -1418,6 +1422,7 @@ Optional Packages: --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) --with-sysroot=DIR search for usr/lib et al within DIR + --with-linker=bfd,gold Specify the default linker Some influential environment variables: CC C compiler command @@ -3227,6 +3232,32 @@ cat >>confdefs.h <<_ACEOF _ACEOF +# Check whether --enable-gold was given. +if test "${enable_gold+set}" = set; then : + enableval=$enable_gold; if test "${enableval}" = "both"; then + installed_linker=ld.bfd + else + installed_linker=ld.gold + fi +else + installed_linker=ld.bfd +fi + + + +# Check whether --with-linker was given. +if test "${with_linker+set}" = set; then : + withval=$with_linker; if test "$withval" = "gold"; then + linker=ld.gold + else + linker=$installed_linker + fi +else + linker=$installed_linker +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 85e23f9..9a23706 100644 --- a/gold/configure.ac +++ b/gold/configure.ac @@ -38,6 +38,24 @@ 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 Enable gold], +[if test "${enableval}" = "both"; then + installed_linker=ld.bfd + else + installed_linker=ld.gold + fi], +[installed_linker=ld.bfd]) + +AC_ARG_WITH(linker, [ --with-linker=[bfd,gold] Specify the default linker], +[if test "$withval" = "gold"; then + linker=ld.gold + else + linker=$installed_linker + fi], +[linker=$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..4af6ced 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$$/ld.bfd/;$(program_transform_name) bin_PROGRAMS = ld-new info_TEXINFOS = ld.texinfo ld_TEXINFOS = configdoc.texi @@ -1959,13 +1959,19 @@ 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 ld.bfd | sed '$(transform)'`; \ + if test "@linker@" = "ld.bfd"; 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); \ + 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 0da0fff..9124abc 100644 --- a/ld/Makefile.in +++ b/ld/Makefile.in @@ -152,7 +152,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$$/ld.bfd/;$(program_transform_name) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AR = @AR@ @@ -295,6 +295,7 @@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ +linker = @linker@ localedir = @localedir@ localstatedir = @localstatedir@ lt_ECHO = @lt_ECHO@ @@ -3274,13 +3275,19 @@ 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 ld.bfd | sed '$(transform)'`; \ + if test "@linker@" = "ld.bfd"; 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); \ + 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 9eb6a17..834a070 100755 --- a/ld/configure +++ b/ld/configure @@ -797,6 +797,7 @@ GREP CPP NO_WERROR WARN_CFLAGS +linker TARGET_SYSTEM_ROOT_DEFINE TARGET_SYSTEM_ROOT use_sysroot @@ -901,6 +902,8 @@ with_lib_path enable_targets enable_64_bit_bfd with_sysroot +enable_gold +with_linker enable_got enable_werror enable_build_warnings @@ -1548,6 +1551,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 Enable gold --enable-got=<type> GOT handling scheme (target, single, negative, multigot) --enable-werror treat compile warnings as errors @@ -1565,6 +1569,7 @@ Optional Packages: --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) --with-lib-path=dir1:dir2... set default LIB_PATH --with-sysroot=DIR Search for usr/lib et al within DIR. + --with-linker=bfd,gold Specify the default linker --with-pic try to use only PIC/non-PIC objects [default=use both] --with-gnu-ld assume the C compiler uses GNU ld [default=no] @@ -4302,6 +4307,30 @@ fi +# Check whether --enable-gold was given. +if test "${enable_gold+set}" = set; then : + enableval=$enable_gold; if test "${enableval}" = "both"; then + installed_linker=ld.gold + fi +else + installed_linker=ld.bfd +fi + + + +# Check whether --with-linker was given. +if test "${with_linker+set}" = set; then : + withval=$with_linker; if test "$withval" = "gold"; then + linker=$installed_linker + else + linker=ld.bfd + fi +else + linker=ld.bfd +fi + + + # Check whether --enable-got was given. if test "${enable_got+set}" = set; then : enableval=$enable_got; case "${enableval}" in @@ -6087,13 +6116,13 @@ if test "${lt_cv_nm_interface+set}" = set; then : else lt_cv_nm_interface="BSD nm" echo "int some_variable = 0;" > conftest.$ac_ext - (eval echo "\"\$as_me:6090: $ac_compile\"" >&5) + (eval echo "\"\$as_me:6119: $ac_compile\"" >&5) (eval "$ac_compile" 2>conftest.err) cat conftest.err >&5 - (eval echo "\"\$as_me:6093: $NM \\\"conftest.$ac_objext\\\"\"" >&5) + (eval echo "\"\$as_me:6122: $NM \\\"conftest.$ac_objext\\\"\"" >&5) (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out) cat conftest.err >&5 - (eval echo "\"\$as_me:6096: output\"" >&5) + (eval echo "\"\$as_me:6125: output\"" >&5) cat conftest.out >&5 if $GREP 'External.*some_variable' conftest.out > /dev/null; then lt_cv_nm_interface="MS dumpbin" @@ -7298,7 +7327,7 @@ ia64-*-hpux*) ;; *-*-irix6*) # Find out which ABI we are using. - echo '#line 7301 "configure"' > conftest.$ac_ext + echo '#line 7330 "configure"' > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? @@ -8560,11 +8589,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:8563: $lt_compile\"" >&5) + (eval echo "\"\$as_me:8592: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:8567: \$? = $ac_status" >&5 + echo "$as_me:8596: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -8899,11 +8928,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:8902: $lt_compile\"" >&5) + (eval echo "\"\$as_me:8931: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:8906: \$? = $ac_status" >&5 + echo "$as_me:8935: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -9004,11 +9033,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:9007: $lt_compile\"" >&5) + (eval echo "\"\$as_me:9036: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:9011: \$? = $ac_status" >&5 + echo "$as_me:9040: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -9059,11 +9088,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:9062: $lt_compile\"" >&5) + (eval echo "\"\$as_me:9091: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:9066: \$? = $ac_status" >&5 + echo "$as_me:9095: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -11441,7 +11470,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 11444 "configure" +#line 11473 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -11537,7 +11566,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 11540 "configure" +#line 11569 "configure" #include "confdefs.h" #if HAVE_DLFCN_H diff --git a/ld/configure.in b/ld/configure.in index c4655f5..d6752c1 100644 --- a/ld/configure.in +++ b/ld/configure.in @@ -69,6 +69,22 @@ AC_SUBST(use_sysroot) AC_SUBST(TARGET_SYSTEM_ROOT) AC_SUBST(TARGET_SYSTEM_ROOT_DEFINE) +AC_ARG_ENABLE([gold], +[ --enable-gold Enable gold], +[if test "${enableval}" = "both"; then + installed_linker=ld.gold + fi], +[installed_linker=ld.bfd]) + +AC_ARG_WITH(linker, [ --with-linker=[bfd,gold] Specify the default linker], +[if test "$withval" = "gold"; then + linker=$installed_linker + else + linker=ld.bfd + fi], +[linker=ld.bfd]) +AC_SUBST(linker) + AC_ARG_ENABLE([got], AS_HELP_STRING([--enable-got=<type>], [GOT handling scheme (target, single, negative, multigot)]), ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: PATCH: Support --enable-gold=both --with-linker=[bfd|gold] 2009-11-02 22:06 PATCH: Support --enable-gold=both --with-linker=[bfd|gold] H.J. Lu @ 2009-11-03 22:19 ` H.J. Lu 2009-11-03 22:23 ` Roland McGrath 0 siblings, 1 reply; 20+ messages in thread From: H.J. Lu @ 2009-11-03 22:19 UTC (permalink / raw) To: H.J. Lu; +Cc: binutils, roland, gcc [-- Attachment #1: Type: text/plain, Size: 1690 bytes --] On Mon, Nov 2, 2009 at 3:06 PM, H.J. Lu <hongjiu.lu@intel.com> wrote: > Hi, > > This patch adds --enable-gold=both --with-linker=[bfd|gold] so that we > can build both ld and gold. This patch will > > 1. Install ld as ld.bfd > 2. Install gold as ld.gold > 3. Install one of them as ld, selected by --with-linker. > > If needed, gcc install invoke gold as ld.gold and ld as ld.bfd. Any > comments? > Here is the updated patch. It installs ld.bfd/ld.gold only if both linkers are enabled. H.J. --- 2009-11-03 Roland McGrath <roland@redhat.com> H.J. Lu <hongjiu.lu@intel.com> * configure.ac (--enable-gold): Accept --enable-gold=both to add gold to configdirs without removing ld. * configure: Regenerated. gold/ 2009-11-03 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 (installed_linker): New substituted variable. Set by --enable-gold. (linker): New substituted variable. Set by --enable-gold and --with-linker. * configure: Regenerated. ld/ 2009-11-03 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.ac (installed_linker): New substituted variable. Set by --enable-gold. (linker): New substituted variable. Set by --enable-gold and --with-linker. * configure: Regenerated. [-- Attachment #2: binutils-gold-2.patch --] [-- Type: text/plain, Size: 20770 bytes --] 2009-11-03 Roland McGrath <roland@redhat.com> H.J. Lu <hongjiu.lu@intel.com> * configure.ac (--enable-gold): Accept --enable-gold=both to add gold to configdirs without removing ld. * configure: Regenerated. gold/ 2009-11-03 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 (installed_linker): New substituted variable. Set by --enable-gold. (linker): New substituted variable. Set by --enable-gold and --with-linker. * configure: Regenerated. ld/ 2009-11-03 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.ac (installed_linker): New substituted variable. Set by --enable-gold. (linker): New substituted variable. Set by --enable-gold and --with-linker. * configure: Regenerated. diff --git a/configure b/configure index 1ece75c..e353f63 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={yes,both}] --enable-libada build libada directory --enable-libssp build libssp directory --enable-build-with-cxx build with C++ compiler instead of C compiler @@ -3076,7 +3076,8 @@ else ENABLE_GOLD=no fi -if test "${ENABLE_GOLD}" = "yes"; then +case "${ENABLE_GOLD}" in +yes|both) # Check for ELF target. is_elf=no case "${target}" in @@ -3096,11 +3097,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 # Configure extra directories which are host specific 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 # Configure extra directories which are host specific 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 # We want install to imply install-info as per GNU standards, despite diff --git a/gold/Makefile.in b/gold/Makefile.in index d4c689b..9b5c860 100644 --- a/gold/Makefile.in +++ b/gold/Makefile.in @@ -303,8 +303,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@ @@ -1200,12 +1202,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 e4eb9fb..11cd48b 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,8 @@ ac_subst_files='' ac_user_opts=' enable_option_checking with_sysroot +enable_gold +with_linker enable_threads enable_plugins enable_targets @@ -1403,6 +1407,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={yes,both}] --enable-threads multi-threaded linking --enable-plugins linker plugins --enable-targets alternative target configurations @@ -1418,6 +1423,7 @@ Optional Packages: --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) --with-sysroot=DIR search for usr/lib et al within DIR + --with-linker=[ARG] specify the default linker [ARG={bfd,gold}] Some influential environment variables: CC C compiler command @@ -3227,6 +3233,36 @@ cat >>confdefs.h <<_ACEOF _ACEOF +# Check whether --enable-gold was given. +if test "${enable_gold+set}" = set; then : + enableval=$enable_gold; if test "${enableval}" = "both"; then + bfd_linker=ld.bfd + installed_linker=ld.gold + else + bfd_linker=ld.gold + installed_linker=ld + fi +else + bfd_linker=ld.bfd + installed_linker=ld +fi + + + + +# Check whether --with-linker was given. +if test "${with_linker+set}" = set; then : + withval=$with_linker; if test "$withval" = "gold"; then + linker=ld.gold + else + linker=$bfd_linker + fi +else + linker=$bfd_linker +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 85e23f9..8a74b38 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) + +AC_ARG_WITH(linker, +[ --with-linker=[[ARG]] specify the default linker [[ARG={bfd,gold}]]], +[if test "$withval" = "gold"; then + linker=ld.gold + else + linker=$bfd_linker + fi], +[linker=$bfd_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..1930a8b 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 0da0fff..2c5ab4a 100644 --- a/ld/Makefile.in +++ b/ld/Makefile.in @@ -152,7 +152,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@ @@ -293,8 +293,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@ lt_ECHO = @lt_ECHO@ @@ -3274,13 +3276,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 9eb6a17..4c091d5 100755 --- a/ld/configure +++ b/ld/configure @@ -797,6 +797,8 @@ GREP CPP NO_WERROR WARN_CFLAGS +linker +installed_linker TARGET_SYSTEM_ROOT_DEFINE TARGET_SYSTEM_ROOT use_sysroot @@ -901,6 +903,8 @@ with_lib_path enable_targets enable_64_bit_bfd with_sysroot +enable_gold +with_linker enable_got enable_werror enable_build_warnings @@ -1548,6 +1552,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={yes,both}] --enable-got=<type> GOT handling scheme (target, single, negative, multigot) --enable-werror treat compile warnings as errors @@ -1565,6 +1570,7 @@ Optional Packages: --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) --with-lib-path=dir1:dir2... set default LIB_PATH --with-sysroot=DIR Search for usr/lib et al within DIR. + --with-linker=[ARG] specify the default linker [ARG={bfd,gold}] --with-pic try to use only PIC/non-PIC objects [default=use both] --with-gnu-ld assume the C compiler uses GNU ld [default=no] @@ -4302,6 +4308,36 @@ fi +# Check whether --enable-gold was given. +if test "${enable_gold+set}" = set; then : + enableval=$enable_gold; if test "${enableval}" = "both"; then + gold_linker=ld.gold + installed_linker=ld.bfd +else + gold_linker=ld.bfd + installed_linker=ld +fi +else + gold_linker=ld.bfd + installed_linker=ld +fi + + + + +# Check whether --with-linker was given. +if test "${with_linker+set}" = set; then : + withval=$with_linker; if test "$withval" = "gold"; then + linker=$gold_linker + else + linker=ld.bfd + fi +else + linker=ld.bfd +fi + + + # Check whether --enable-got was given. if test "${enable_got+set}" = set; then : enableval=$enable_got; case "${enableval}" in @@ -6087,13 +6123,13 @@ if test "${lt_cv_nm_interface+set}" = set; then : else lt_cv_nm_interface="BSD nm" echo "int some_variable = 0;" > conftest.$ac_ext - (eval echo "\"\$as_me:6090: $ac_compile\"" >&5) + (eval echo "\"\$as_me:6126: $ac_compile\"" >&5) (eval "$ac_compile" 2>conftest.err) cat conftest.err >&5 - (eval echo "\"\$as_me:6093: $NM \\\"conftest.$ac_objext\\\"\"" >&5) + (eval echo "\"\$as_me:6129: $NM \\\"conftest.$ac_objext\\\"\"" >&5) (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out) cat conftest.err >&5 - (eval echo "\"\$as_me:6096: output\"" >&5) + (eval echo "\"\$as_me:6132: output\"" >&5) cat conftest.out >&5 if $GREP 'External.*some_variable' conftest.out > /dev/null; then lt_cv_nm_interface="MS dumpbin" @@ -7298,7 +7334,7 @@ ia64-*-hpux*) ;; *-*-irix6*) # Find out which ABI we are using. - echo '#line 7301 "configure"' > conftest.$ac_ext + echo '#line 7337 "configure"' > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? @@ -8560,11 +8596,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:8563: $lt_compile\"" >&5) + (eval echo "\"\$as_me:8599: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:8567: \$? = $ac_status" >&5 + echo "$as_me:8603: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -8899,11 +8935,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:8902: $lt_compile\"" >&5) + (eval echo "\"\$as_me:8938: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:8906: \$? = $ac_status" >&5 + echo "$as_me:8942: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -9004,11 +9040,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:9007: $lt_compile\"" >&5) + (eval echo "\"\$as_me:9043: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:9011: \$? = $ac_status" >&5 + echo "$as_me:9047: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -9059,11 +9095,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:9062: $lt_compile\"" >&5) + (eval echo "\"\$as_me:9098: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:9066: \$? = $ac_status" >&5 + echo "$as_me:9102: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -11441,7 +11477,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 11444 "configure" +#line 11480 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -11537,7 +11573,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 11540 "configure" +#line 11576 "configure" #include "confdefs.h" #if HAVE_DLFCN_H diff --git a/ld/configure.in b/ld/configure.in index c4655f5..bff1d5e 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) + +AC_ARG_WITH(linker, +[ --with-linker=[[ARG]] specify the default linker [[ARG={bfd,gold}]]], +[if test "$withval" = "gold"; then + linker=$gold_linker + else + linker=ld.bfd + fi], +[linker=ld.bfd]) +AC_SUBST(linker) + AC_ARG_ENABLE([got], AS_HELP_STRING([--enable-got=<type>], [GOT handling scheme (target, single, negative, multigot)]), ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: PATCH: Support --enable-gold=both --with-linker=[bfd|gold] 2009-11-03 22:19 ` H.J. Lu @ 2009-11-03 22:23 ` Roland McGrath 2009-11-03 23:28 ` H.J. Lu 0 siblings, 1 reply; 20+ messages in thread From: Roland McGrath @ 2009-11-03 22:23 UTC (permalink / raw) To: H.J. Lu; +Cc: binutils, gcc --with is wrong for this. It's not about the ambient system built against. It's a feature selection for how you build binutils, which means --enable. ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: PATCH: Support --enable-gold=both --with-linker=[bfd|gold] 2009-11-03 22:23 ` Roland McGrath @ 2009-11-03 23:28 ` H.J. Lu 2009-11-04 5:09 ` Roland McGrath 2010-01-05 19:08 ` Ian Lance Taylor 0 siblings, 2 replies; 20+ messages in thread From: H.J. Lu @ 2009-11-03 23:28 UTC (permalink / raw) To: Roland McGrath; +Cc: binutils, gcc [-- Attachment #1: Type: text/plain, Size: 280 bytes --] On Tue, Nov 3, 2009 at 3:23 PM, Roland McGrath <roland@redhat.com> wrote: > --with is wrong for this. It's not about the ambient system built against. > It's a feature selection for how you build binutils, which means --enable. > Here is the updated patch. -- H.J. [-- Attachment #2: binutils-gold-3.patch --] [-- Type: text/plain, Size: 20098 bytes --] 2009-11-03 Roland McGrath <roland@redhat.com> H.J. Lu <hongjiu.lu@intel.com> * configure.ac (--enable-gold): Accept --enable-gold=both to add gold to configdirs without removing ld. * configure: Regenerated. gold/ 2009-11-03 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 (installed_linker): New substituted variable. Set by --enable-gold. (linker): New substituted variable. Set by --enable-gold and --enable-linker. * configure: Regenerated. ld/ 2009-11-03 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.ac (installed_linker): New substituted variable. Set by --enable-gold. (linker): New substituted variable. Set by --enable-gold and --enable-linker. * configure: Regenerated. diff --git a/configure b/configure index 1ece75c..e353f63 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={yes,both}] --enable-libada build libada directory --enable-libssp build libssp directory --enable-build-with-cxx build with C++ compiler instead of C compiler @@ -3076,7 +3076,8 @@ else ENABLE_GOLD=no fi -if test "${ENABLE_GOLD}" = "yes"; then +case "${ENABLE_GOLD}" in +yes|both) # Check for ELF target. is_elf=no case "${target}" in @@ -3096,11 +3097,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 # Configure extra directories which are host specific 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 # Configure extra directories which are host specific 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 # We want install to imply install-info as per GNU standards, despite diff --git a/gold/Makefile.in b/gold/Makefile.in index d4c689b..9b5c860 100644 --- a/gold/Makefile.in +++ b/gold/Makefile.in @@ -303,8 +303,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@ @@ -1200,12 +1202,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 e4eb9fb..407e580 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,8 @@ ac_subst_files='' ac_user_opts=' enable_option_checking with_sysroot +enable_gold +enable_linker enable_threads enable_plugins enable_targets @@ -1403,6 +1407,8 @@ 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={yes,both}] + --enable-linker=[ARG] specify the default linker [ARG={bfd,gold}] --enable-threads multi-threaded linking --enable-plugins linker plugins --enable-targets alternative target configurations @@ -3227,6 +3233,35 @@ cat >>confdefs.h <<_ACEOF _ACEOF +# Check whether --enable-gold was given. +if test "${enable_gold+set}" = set; then : + enableval=$enable_gold; if test "${enableval}" = "both"; then + bfd_linker=ld.bfd + installed_linker=ld.gold + else + bfd_linker=ld.gold + installed_linker=ld + fi +else + bfd_linker=ld.bfd + installed_linker=ld +fi + + + +# Check whether --enable-linker was given. +if test "${enable_linker+set}" = set; then : + enableval=$enable_linker; if test "${enableval}" = "gold"; then + linker=ld.gold + else + linker=$bfd_linker + fi +else + linker=$bfd_linker +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 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) + +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) + 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..1930a8b 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 0da0fff..2c5ab4a 100644 --- a/ld/Makefile.in +++ b/ld/Makefile.in @@ -152,7 +152,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@ @@ -293,8 +293,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@ lt_ECHO = @lt_ECHO@ @@ -3274,13 +3276,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 9eb6a17..088a24d 100755 --- a/ld/configure +++ b/ld/configure @@ -797,6 +797,8 @@ GREP CPP NO_WERROR WARN_CFLAGS +linker +installed_linker TARGET_SYSTEM_ROOT_DEFINE TARGET_SYSTEM_ROOT use_sysroot @@ -901,6 +903,8 @@ with_lib_path enable_targets enable_64_bit_bfd with_sysroot +enable_gold +enable_linker enable_got enable_werror enable_build_warnings @@ -1548,6 +1552,8 @@ 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={yes,both}] + --enable-linker=[ARG] specify the default linker [ARG={bfd,gold}] --enable-got=<type> GOT handling scheme (target, single, negative, multigot) --enable-werror treat compile warnings as errors @@ -4302,6 +4308,35 @@ fi +# Check whether --enable-gold was given. +if test "${enable_gold+set}" = set; then : + enableval=$enable_gold; if test "${enableval}" = "both"; then + gold_linker=ld.gold + installed_linker=ld.bfd +else + gold_linker=ld.bfd + installed_linker=ld +fi +else + gold_linker=ld.bfd + installed_linker=ld +fi + + + +# Check whether --enable-linker was given. +if test "${enable_linker+set}" = set; then : + enableval=$enable_linker; if test "${enableval}" = "gold"; then + linker=$gold_linker + else + linker=ld.bfd + fi +else + linker=ld.bfd +fi + + + # Check whether --enable-got was given. if test "${enable_got+set}" = set; then : enableval=$enable_got; case "${enableval}" in @@ -6087,13 +6122,13 @@ if test "${lt_cv_nm_interface+set}" = set; then : else lt_cv_nm_interface="BSD nm" echo "int some_variable = 0;" > conftest.$ac_ext - (eval echo "\"\$as_me:6090: $ac_compile\"" >&5) + (eval echo "\"\$as_me:6125: $ac_compile\"" >&5) (eval "$ac_compile" 2>conftest.err) cat conftest.err >&5 - (eval echo "\"\$as_me:6093: $NM \\\"conftest.$ac_objext\\\"\"" >&5) + (eval echo "\"\$as_me:6128: $NM \\\"conftest.$ac_objext\\\"\"" >&5) (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out) cat conftest.err >&5 - (eval echo "\"\$as_me:6096: output\"" >&5) + (eval echo "\"\$as_me:6131: output\"" >&5) cat conftest.out >&5 if $GREP 'External.*some_variable' conftest.out > /dev/null; then lt_cv_nm_interface="MS dumpbin" @@ -7298,7 +7333,7 @@ ia64-*-hpux*) ;; *-*-irix6*) # Find out which ABI we are using. - echo '#line 7301 "configure"' > conftest.$ac_ext + echo '#line 7336 "configure"' > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? @@ -8560,11 +8595,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:8563: $lt_compile\"" >&5) + (eval echo "\"\$as_me:8598: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:8567: \$? = $ac_status" >&5 + echo "$as_me:8602: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -8899,11 +8934,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:8902: $lt_compile\"" >&5) + (eval echo "\"\$as_me:8937: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:8906: \$? = $ac_status" >&5 + echo "$as_me:8941: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -9004,11 +9039,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:9007: $lt_compile\"" >&5) + (eval echo "\"\$as_me:9042: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:9011: \$? = $ac_status" >&5 + echo "$as_me:9046: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -9059,11 +9094,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:9062: $lt_compile\"" >&5) + (eval echo "\"\$as_me:9097: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:9066: \$? = $ac_status" >&5 + echo "$as_me:9101: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -11441,7 +11476,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 11444 "configure" +#line 11479 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -11537,7 +11572,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 11540 "configure" +#line 11575 "configure" #include "confdefs.h" #if HAVE_DLFCN_H 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) + +AC_ARG_ENABLE(linker, +[ --enable-linker=[[ARG]] specify the default linker [[ARG={bfd,gold}]]], +[if test "${enableval}" = "gold"; then + linker=$gold_linker + else + linker=ld.bfd + fi], +[linker=ld.bfd]) +AC_SUBST(linker) + AC_ARG_ENABLE([got], AS_HELP_STRING([--enable-got=<type>], [GOT handling scheme (target, single, negative, multigot)]), ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: PATCH: Support --enable-gold=both --with-linker=[bfd|gold] 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 1 sibling, 1 reply; 20+ messages in thread From: Roland McGrath @ 2009-11-04 5:09 UTC (permalink / raw) To: H.J. Lu; +Cc: binutils, gcc I can't really tell how that's different from the patch I posted. It looks fine to me. Thanks, Roland ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: PATCH: Support --enable-gold=both --with-linker=[bfd|gold] 2009-11-04 5:09 ` Roland McGrath @ 2009-11-04 14:47 ` H.J. Lu 0 siblings, 0 replies; 20+ messages in thread From: H.J. Lu @ 2009-11-04 14:47 UTC (permalink / raw) To: Roland McGrath; +Cc: binutils, gcc On Tue, Nov 3, 2009 at 9:09 PM, Roland McGrath <roland@redhat.com> wrote: > I can't really tell how that's different from the patch I posted. > It looks fine to me. > The difference is you can set the default linker. -- H.J. ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: PATCH: Support --enable-gold=both --with-linker=[bfd|gold] 2009-11-03 23:28 ` H.J. Lu 2009-11-04 5:09 ` Roland McGrath @ 2010-01-05 19:08 ` Ian Lance Taylor 2010-01-05 21:12 ` Roland McGrath 2010-01-06 4:23 ` H.J. Lu 1 sibling, 2 replies; 20+ messages in thread From: Ian Lance Taylor @ 2010-01-05 19:08 UTC (permalink / raw) To: H.J. Lu; +Cc: Roland McGrath, binutils, gcc "H.J. Lu" <hjl.tools@gmail.com> writes: > On Tue, Nov 3, 2009 at 3:23 PM, Roland McGrath <roland@redhat.com> wrote: >> --with is wrong for this. It's not about the ambient system built against. >> It's a feature selection for how you build binutils, which means --enable. >> > > Here is the updated patch. I'm still not entirely convinced that this is the way to go. It seems to me that ideally one wants to be able to select the linker at runtime. I don't see how this patch supports that. What am I missing? This patch would be easier to review if you omitted the generated files. Do any of the binutils maintainers have any comments on the best approach here? > 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 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). > 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? > +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. > --- 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. > -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@. > 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? Ian ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: PATCH: Support --enable-gold=both --with-linker=[bfd|gold] 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-06 4:23 ` H.J. Lu 1 sibling, 1 reply; 20+ messages in thread From: Roland McGrath @ 2010-01-05 21:12 UTC (permalink / raw) To: Ian Lance Taylor; +Cc: H.J. Lu, binutils, gcc > I'm still not entirely convinced that this is the way to go. It seems > to me that ideally one wants to be able to select the linker at > runtime. I don't see how this patch supports that. What am I > missing? It covers the first step by letting you run "ld.bfd" or "ld.gold" to choose. Having the two binaries installed by those names is a good start and seems likely to be part of how any fancier plan would work, so why not start there? This setup is compatible with using "alternatives" to switch a $(bindir)/ld symlink. Using "alternatives" is outside the scope of what 'make install' should do, so having it install a plain symlink makes sense. Packagers will drop the ld symlink and do their own thing. (This is exactly what we are doing now in Fedora >= 13.) Another obvious approach is to add a wrapper script for $(bindir)/ld that groks an argument like --gold or --bfd to choose which real ld to run. That could be used by hand and by gcc -Wl,--gold, etc. That is also fine by me. But it requires inventing some new plan for where the system-wide default is configured. IMHO it seems better just to leave that sort of thing to packagers. Thanks, Roland ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: PATCH: Support --enable-gold=both --with-linker=[bfd|gold] 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 23:00 ` Roland McGrath 0 siblings, 2 replies; 20+ messages in thread From: Ian Lance Taylor @ 2010-01-05 21:35 UTC (permalink / raw) To: Roland McGrath; +Cc: H.J. Lu, binutils, gcc Roland McGrath <roland@redhat.com> writes: >> I'm still not entirely convinced that this is the way to go. It seems >> to me that ideally one wants to be able to select the linker at >> runtime. I don't see how this patch supports that. What am I >> missing? > > It covers the first step by letting you run "ld.bfd" or "ld.gold" to > choose. Having the two binaries installed by those names is a good start > and seems likely to be part of how any fancier plan would work, so why not > start there? Mainly because an alternative is to install them in subdirectories with the name ld. Then gcc can run them directly using a -B option. I don't know which approach is best. Ian ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: PATCH: Support --enable-gold=both --with-linker=[bfd|gold] 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:00 ` Roland McGrath 1 sibling, 1 reply; 20+ messages in thread From: H.J. Lu @ 2010-01-05 21:40 UTC (permalink / raw) To: Ian Lance Taylor; +Cc: Roland McGrath, binutils, gcc On Tue, Jan 5, 2010 at 1:35 PM, Ian Lance Taylor <iant@google.com> wrote: > Roland McGrath <roland@redhat.com> writes: > >>> I'm still not entirely convinced that this is the way to go. It seems >>> to me that ideally one wants to be able to select the linker at >>> runtime. I don't see how this patch supports that. What am I >>> missing? >> >> It covers the first step by letting you run "ld.bfd" or "ld.gold" to >> choose. Having the two binaries installed by those names is a good start >> and seems likely to be part of how any fancier plan would work, so why not >> start there? > > Mainly because an alternative is to install them in subdirectories > with the name ld. Then gcc can run them directly using a -B option. > I don't know which approach is best. > Plugin only works with gold. So I configured my gcc with -with-plugin-ld=ld.gold If both linkers have the same name, it will be harder to use ld by default and use gold only for plugin. -- H.J. ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: PATCH: Support --enable-gold=both --with-linker=[bfd|gold] 2010-01-05 21:40 ` H.J. Lu @ 2010-01-05 22:29 ` Ian Lance Taylor 2010-01-05 23:48 ` Matthias Klose 0 siblings, 1 reply; 20+ messages in thread From: Ian Lance Taylor @ 2010-01-05 22:29 UTC (permalink / raw) To: H.J. Lu; +Cc: Roland McGrath, binutils, gcc "H.J. Lu" <hjl.tools@gmail.com> writes: > On Tue, Jan 5, 2010 at 1:35 PM, Ian Lance Taylor <iant@google.com> wrote: >> Roland McGrath <roland@redhat.com> writes: >> >>>> I'm still not entirely convinced that this is the way to go. It seems >>>> to me that ideally one wants to be able to select the linker at >>>> runtime. I don't see how this patch supports that. What am I >>>> missing? >>> >>> It covers the first step by letting you run "ld.bfd" or "ld.gold" to >>> choose. Having the two binaries installed by those names is a good start >>> and seems likely to be part of how any fancier plan would work, so why not >>> start there? >> >> Mainly because an alternative is to install them in subdirectories >> with the name ld. Then gcc can run them directly using a -B option. >> I don't know which approach is best. >> > > Plugin only works with gold. So I configured my gcc with > > -with-plugin-ld=ld.gold > > If both linkers have the same name, it will be harder to > use ld by default and use gold only for plugin. The issue can be addressed with symlinks. Of course, if we have a way to tell gcc the linker to use, by name, at runtime, that will also work. Ian ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: PATCH: Support --enable-gold=both --with-linker=[bfd|gold] 2010-01-05 22:29 ` Ian Lance Taylor @ 2010-01-05 23:48 ` Matthias Klose 0 siblings, 0 replies; 20+ messages in thread From: Matthias Klose @ 2010-01-05 23:48 UTC (permalink / raw) To: Ian Lance Taylor; +Cc: H.J. Lu, Roland McGrath, binutils, gcc On 05.01.2010 23:29, Ian Lance Taylor wrote: > "H.J. Lu"<hjl.tools@gmail.com> writes: > >> On Tue, Jan 5, 2010 at 1:35 PM, Ian Lance Taylor<iant@google.com> wrote: >>> Roland McGrath<roland@redhat.com> writes: >>> >>>>> I'm still not entirely convinced that this is the way to go. It seems >>>>> to me that ideally one wants to be able to select the linker at >>>>> runtime. I don't see how this patch supports that. What am I >>>>> missing? >>>> >>>> It covers the first step by letting you run "ld.bfd" or "ld.gold" to >>>> choose. Having the two binaries installed by those names is a good start >>>> and seems likely to be part of how any fancier plan would work, so why not >>>> start there? >>> >>> Mainly because an alternative is to install them in subdirectories >>> with the name ld. Then gcc can run them directly using a -B option. >>> I don't know which approach is best. >>> >> >> Plugin only works with gold. So I configured my gcc with >> >> -with-plugin-ld=ld.gold >> >> If both linkers have the same name, it will be harder to >> use ld by default and use gold only for plugin. > > The issue can be addressed with symlinks. > > Of course, if we have a way to tell gcc the linker to use, by name, at > runtime, that will also work. symlinks are only a solution for a globally configured default. when building a package which requires a specific linker, you'll have to work with explicit build-depends/build-conflicts which need package installation/removal for building a single package. this might be feasible for a machine used by a single developer, but not for a machine where you don't have root access, and you still want to be able to use both ld versions. For this kind of setup an option interpreted by the gcc driver like --ld=<ld> would be useful. even managing this symlink with alternatives or diversions gives you the flexibility. Matthias ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: PATCH: Support --enable-gold=both --with-linker=[bfd|gold] 2010-01-05 21:35 ` Ian Lance Taylor 2010-01-05 21:40 ` H.J. Lu @ 2010-01-05 23:00 ` Roland McGrath 2010-01-05 23:52 ` Matthias Klose 2010-01-06 0:24 ` Ian Lance Taylor 1 sibling, 2 replies; 20+ messages in thread From: Roland McGrath @ 2010-01-05 23:00 UTC (permalink / raw) To: Ian Lance Taylor; +Cc: H.J. Lu, binutils, gcc > Mainly because an alternative is to install them in subdirectories > with the name ld. Then gcc can run them directly using a -B option. > I don't know which approach is best. I think it keeps things simplest for humans to understand if the actual binaries are available as ld.bfd and ld.gold. If you then want some obscure directory names containing an "ld" for gcc's use, then make those symlinks. Personally, I think -Wl,--gold (via $(bindir)/ld being a wrapper script) is nicer than -B/usr/libexec/binutils/gold/ or whatnot. Thanks, Roland ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: PATCH: Support --enable-gold=both --with-linker=[bfd|gold] 2010-01-05 23:00 ` Roland McGrath @ 2010-01-05 23:52 ` Matthias Klose 2010-01-06 1:01 ` Roland McGrath 2010-01-06 0:24 ` Ian Lance Taylor 1 sibling, 1 reply; 20+ messages in thread From: Matthias Klose @ 2010-01-05 23:52 UTC (permalink / raw) To: Roland McGrath; +Cc: Ian Lance Taylor, H.J. Lu, binutils, gcc On 05.01.2010 23:59, Roland McGrath wrote: >> I'm still not entirely convinced that this is the way to go. It seems >> to me that ideally one wants to be able to select the linker at >> runtime. I don't see how this patch supports that. What am I >> missing? > > It covers the first step by letting you run "ld.bfd" or "ld.gold" to > choose. Having the two binaries installed by those names is a good start > and seems likely to be part of how any fancier plan would work, so why not > start there? agreed on this. >> Mainly because an alternative is to install them in subdirectories >> with the name ld. Then gcc can run them directly using a -B option. >> I don't know which approach is best. > > I think it keeps things simplest for humans to understand if the actual > binaries are available as ld.bfd and ld.gold. If you then want some > obscure directory names containing an "ld" for gcc's use, then make those > symlinks. Personally, I think -Wl,--gold (via $(bindir)/ld being a wrapper > script) is nicer than -B/usr/libexec/binutils/gold/ or whatnot. why not make this more explicit by adding an option --ld<ld> which is directly understood by the gcc driver? Matthias ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: PATCH: Support --enable-gold=both --with-linker=[bfd|gold] 2010-01-05 23:52 ` Matthias Klose @ 2010-01-06 1:01 ` Roland McGrath 2010-01-06 1:42 ` Daniel Jacobowitz 0 siblings, 1 reply; 20+ messages in thread From: Roland McGrath @ 2010-01-06 1:01 UTC (permalink / raw) To: Matthias Klose; +Cc: Ian Lance Taylor, H.J. Lu, binutils, gcc > why not make this more explicit by adding an option --ld<ld> which is > directly understood by the gcc driver? Feel free to send some gcc patches. I see no point in this. We have -Wl. ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: PATCH: Support --enable-gold=both --with-linker=[bfd|gold] 2010-01-06 1:01 ` Roland McGrath @ 2010-01-06 1:42 ` Daniel Jacobowitz 2010-01-06 21:49 ` Roland McGrath 0 siblings, 1 reply; 20+ messages in thread From: Daniel Jacobowitz @ 2010-01-06 1:42 UTC (permalink / raw) To: Roland McGrath; +Cc: Matthias Klose, Ian Lance Taylor, H.J. Lu, binutils, gcc On Tue, Jan 05, 2010 at 05:01:24PM -0800, Roland McGrath wrote: > > why not make this more explicit by adding an option --ld<ld> which is > > directly understood by the gcc driver? > > Feel free to send some gcc patches. I see no point in this. > We have -Wl. I deal with a lot of host systems where shell scripts aren't a viable option for ld. Why make everyone write the wrapper script? Makes sense to me to have gcc decide. -- Daniel Jacobowitz CodeSourcery ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: PATCH: Support --enable-gold=both --with-linker=[bfd|gold] 2010-01-06 1:42 ` Daniel Jacobowitz @ 2010-01-06 21:49 ` Roland McGrath 0 siblings, 0 replies; 20+ messages in thread From: Roland McGrath @ 2010-01-06 21:49 UTC (permalink / raw) To: Daniel Jacobowitz Cc: Matthias Klose, Ian Lance Taylor, H.J. Lu, binutils, gcc > > Feel free to send some gcc patches. I see no point in this. > > We have -Wl. > > I deal with a lot of host systems where shell scripts aren't a viable > option for ld. Why make everyone write the wrapper script? Makes > sense to me to have gcc decide. Like I said, I don't object to any new gcc hacks people want to do. Nor to people just choosing directories for .../ld symlinks in their packaging and using -B. I just don't really care about that. The --enable-gold=both installation setup is enough for me and I don't want merging that delayed any more because of discussing more ideas we might add on top. Thanks, Roland ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: PATCH: Support --enable-gold=both --with-linker=[bfd|gold] 2010-01-05 23:00 ` Roland McGrath 2010-01-05 23:52 ` Matthias Klose @ 2010-01-06 0:24 ` Ian Lance Taylor 1 sibling, 0 replies; 20+ messages in thread From: Ian Lance Taylor @ 2010-01-06 0:24 UTC (permalink / raw) To: Roland McGrath; +Cc: H.J. Lu, binutils, gcc Roland McGrath <roland@redhat.com> writes: >> Mainly because an alternative is to install them in subdirectories >> with the name ld. Then gcc can run them directly using a -B option. >> I don't know which approach is best. > > I think it keeps things simplest for humans to understand if the actual > binaries are available as ld.bfd and ld.gold. If you then want some > obscure directory names containing an "ld" for gcc's use, then make those > symlinks. Personally, I think -Wl,--gold (via $(bindir)/ld being a wrapper > script) is nicer than -B/usr/libexec/binutils/gold/ or whatnot. OK, HJ's approach is OK with me. I would still like another binutils maintainer to take a look at the patch, once he updates it for my comments. Ian ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: PATCH: Support --enable-gold=both --with-linker=[bfd|gold] 2010-01-05 19:08 ` Ian Lance Taylor 2010-01-05 21:12 ` Roland McGrath @ 2010-01-06 4:23 ` H.J. Lu 2010-01-12 15:27 ` H.J. Lu 1 sibling, 1 reply; 20+ messages in thread From: H.J. Lu @ 2010-01-06 4:23 UTC (permalink / raw) To: Ian Lance Taylor; +Cc: Roland McGrath, binutils, gcc [-- Attachment #1: Type: text/plain, Size: 8877 bytes --] 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. [-- Attachment #2: binutils-gold-6.patch --] [-- Type: text/x-csrc, Size: 7764 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.ac b/configure.ac index 53ca32c..6e626b1 100644 --- a/configure.ac +++ b/configure.ac @@ -309,12 +309,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 @@ -334,11 +341,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 ;; esac fi -fi + ENABLE_GOLD=yes + ;; +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 9c9ed1a..32a37e6 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/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/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)]), ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: PATCH: Support --enable-gold=both --with-linker=[bfd|gold] 2010-01-06 4:23 ` H.J. Lu @ 2010-01-12 15:27 ` H.J. Lu 0 siblings, 0 replies; 20+ messages in thread From: H.J. Lu @ 2010-01-12 15:27 UTC (permalink / raw) To: Ian Lance Taylor; +Cc: Roland McGrath, binutils, gcc [-- 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)]), ^ permalink raw reply [flat|nested] 20+ messages in thread
end of thread, other threads:[~2010-01-12 15:27 UTC | newest] Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2009-11-02 22:06 PATCH: Support --enable-gold=both --with-linker=[bfd|gold] 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 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).