From 40f213e6f5bf36a5678a1ff5a75773d02df67f53 Mon Sep 17 00:00:00 2001 From: "H.J. Lu" Date: Tue, 26 Nov 2013 13:31:25 +0000 Subject: [PATCH] Add -fuse-ld=bfd/-fuse-ld=gold support to exec-tool.in PR bootstrap/55552 * configure.ac (install_gold_as_default): New. Set to yes for --disable-ld or --enable-gold=default. (gcc_cv_ld_gold_srcdir): New. (gcc_cv_ld): Also check in-tree gold if install_gold_as_default is yes. (ORIGINAL_LD_BFD_FOR_TARGET): New AC_SUBST. (ORIGINAL_LD_GOLD_FOR_TARGET): Likewise. * configure: Regenerated. * exec-tool.in (ORIGINAL_LD_BFD_FOR_TARGET): New variable. (ORIGINAL_LD_GOLD_FOR_TARGET): Likewise. (original) [collect-ld && -fuse-ld=bfd]: Set to $ORIGINAL_LD_BFD_FOR_TARGET. (original) [collect-ld && -fuse-ld=gold]: Set to $ORIGINAL_LD_GOLD_FOR_TARGET. (dir) [collect-ld && ../gold/ld-new]: Set to gold. (fast_install) [collect-ld && ../gold/ld-new]: Set to yes. From-SVN: r205392 --- gcc/ChangeLog | 21 ++++++++++++++++++ gcc/configure | 57 ++++++++++++++++++++++++++++++++++++++++++++++-- gcc/configure.ac | 42 +++++++++++++++++++++++++++++++++++ gcc/exec-tool.in | 35 ++++++++++++++++++++++------- 4 files changed, 145 insertions(+), 10 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 7974b5798f0..d63759e2c8c 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,24 @@ +2013-11-26 H.J. Lu + + PR bootstrap/55552 + * configure.ac (install_gold_as_default): New. Set to yes for + --disable-ld or --enable-gold=default. + (gcc_cv_ld_gold_srcdir): New. + (gcc_cv_ld): Also check in-tree gold if install_gold_as_default + is yes. + (ORIGINAL_LD_BFD_FOR_TARGET): New AC_SUBST. + (ORIGINAL_LD_GOLD_FOR_TARGET): Likewise. + * configure: Regenerated. + + * exec-tool.in (ORIGINAL_LD_BFD_FOR_TARGET): New variable. + (ORIGINAL_LD_GOLD_FOR_TARGET): Likewise. + (original) [collect-ld && -fuse-ld=bfd]: Set to + $ORIGINAL_LD_BFD_FOR_TARGET. + (original) [collect-ld && -fuse-ld=gold]: Set to + $ORIGINAL_LD_GOLD_FOR_TARGET. + (dir) [collect-ld && ../gold/ld-new]: Set to gold. + (fast_install) [collect-ld && ../gold/ld-new]: Set to yes. + 2013-11-26 Terry Guo * config/arm/arm.c (require_pic_register): Handle high pic base diff --git a/gcc/configure b/gcc/configure index c9bbd653e52..fdf0cd0819b 100755 --- a/gcc/configure +++ b/gcc/configure @@ -682,6 +682,8 @@ gcc_cv_readelf gcc_cv_objdump ORIGINAL_NM_FOR_TARGET gcc_cv_nm +ORIGINAL_LD_GOLD_FOR_TARGET +ORIGINAL_LD_BFD_FOR_TARGET ORIGINAL_LD_FOR_TARGET ORIGINAL_PLUGIN_LD_FOR_TARGET gcc_cv_ld @@ -911,6 +913,8 @@ enable_static with_pic enable_fast_install enable_libtool_lock +enable_ld +enable_gold with_plugin_ld enable_gnu_indirect_function enable_initfini_array @@ -1624,6 +1628,8 @@ Optional Features: --enable-fast-install[=PKGS] optimize for fast installation [default=yes] --disable-libtool-lock avoid locking (might break parallel builds) + --enable-ld[=ARG] build ld [ARG={default,yes,no}] + --enable-gold[=ARG] build gold [ARG={default,yes,no}] --enable-gnu-indirect-function enable the use of the @gnu_indirect_function to glibc systems @@ -17913,7 +17919,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 17916 "configure" +#line 17922 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -18019,7 +18025,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 18022 "configure" +#line 18028 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -21397,6 +21403,39 @@ $as_echo "$gcc_cv_as" >&6; } in_tree_gas=no fi +default_ld= +# Check whether --enable-ld was given. +if test "${enable_ld+set}" = set; then : + enableval=$enable_ld; case "${enableval}" in + no) + default_ld=ld.gold + ;; + esac +fi + + +# Check whether --enable-gold was given. +if test "${enable_gold+set}" = set; then : + enableval=$enable_gold; case "${enableval}" in + default) + install_gold_as_default=yes + ;; + yes) + if test x${default_ld} != x; then + install_gold_as_default=yes + fi + ;; + no) + ;; + *) + as_fn_error "invalid --enable-gold argument" "$LINENO" 5 + ;; + esac +else + install_gold_as_default=no +fi + + # Identify the linker which will work hand-in-glove with the newly # built GCC, so that we can examine its features. This is the linker # which will be driven by the driver program. @@ -21407,6 +21446,7 @@ fi gcc_cv_gld_major_version= gcc_cv_gld_minor_version= gcc_cv_ld_gld_srcdir=`echo $srcdir | sed -e 's,/gcc$,,'`/ld +gcc_cv_ld_gold_srcdir=`echo $srcdir | sed -e 's,/gcc$,,'`/gold gcc_cv_ld_bfd_srcdir=`echo $srcdir | sed -e 's,/gcc$,,'`/bfd if test "${gcc_cv_ld+set}" = set; then : @@ -21415,6 +21455,11 @@ else if test -x "$DEFAULT_LINKER"; then gcc_cv_ld="$DEFAULT_LINKER" +elif test $install_gold_as_default = yes \ + && test -f $gcc_cv_ld_gold_srcdir/configure.ac \ + && test -f ../gold/Makefile \ + && test x$build = x$host; then + gcc_cv_ld=../gold/ld-new$build_exeext elif test -f $gcc_cv_ld_gld_srcdir/configure.in \ && test -f ../ld/Makefile \ && test x$build = x$host; then @@ -21544,12 +21589,20 @@ $as_echo "newly built ld" >&6; } esac gcc_cv_gld_major_version=`expr "$gcc_cv_gld_version" : "VERSION=\([0-9]*\)"` gcc_cv_gld_minor_version=`expr "$gcc_cv_gld_version" : "VERSION=[0-9]*\.\([0-9]*\)"` + ORIGINAL_LD_BFD_FOR_TARGET=../ld/ld-new$build_exeext + ORIGINAL_LD_GOLD_FOR_TARGET=../gold/ld-new$build_exeext else { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_ld" >&5 $as_echo "$gcc_cv_ld" >&6; } in_tree_ld=no + gcc_cvs_ld_program=`dirname $gcc_cv_ld`/`basename $gcc_cv_ld $host_exeext` + ORIGINAL_LD_BFD_FOR_TARGET=${gcc_cvs_ld_program}.bfd$host_exeext + ORIGINAL_LD_GOLD_FOR_TARGET=${gcc_cvs_ld_program}.gold$host_exeext fi + + + # Figure out what nm we will be using. gcc_cv_binutils_srcdir=`echo $srcdir | sed -e 's,/gcc$,,'`/binutils if test "${gcc_cv_nm+set}" = set; then : diff --git a/gcc/configure.ac b/gcc/configure.ac index 5935a6ede94..91a22d58cf7 100644 --- a/gcc/configure.ac +++ b/gcc/configure.ac @@ -2016,6 +2016,34 @@ else in_tree_gas=no fi +default_ld= +AC_ARG_ENABLE(ld, +[[ --enable-ld[=ARG] build ld [ARG={default,yes,no}]]], +[case "${enableval}" in + no) + default_ld=ld.gold + ;; + esac]) + +AC_ARG_ENABLE(gold, +[[ --enable-gold[=ARG] build gold [ARG={default,yes,no}]]], +[case "${enableval}" in + default) + install_gold_as_default=yes + ;; + yes) + if test x${default_ld} != x; then + install_gold_as_default=yes + fi + ;; + no) + ;; + *) + AC_MSG_ERROR([invalid --enable-gold argument]) + ;; + esac], +[install_gold_as_default=no]) + # Identify the linker which will work hand-in-glove with the newly # built GCC, so that we can examine its features. This is the linker # which will be driven by the driver program. @@ -2026,11 +2054,17 @@ fi gcc_cv_gld_major_version= gcc_cv_gld_minor_version= gcc_cv_ld_gld_srcdir=`echo $srcdir | sed -e 's,/gcc$,,'`/ld +gcc_cv_ld_gold_srcdir=`echo $srcdir | sed -e 's,/gcc$,,'`/gold gcc_cv_ld_bfd_srcdir=`echo $srcdir | sed -e 's,/gcc$,,'`/bfd AS_VAR_SET_IF(gcc_cv_ld,, [ if test -x "$DEFAULT_LINKER"; then gcc_cv_ld="$DEFAULT_LINKER" +elif test $install_gold_as_default = yes \ + && test -f $gcc_cv_ld_gold_srcdir/configure.ac \ + && test -f ../gold/Makefile \ + && test x$build = x$host; then + gcc_cv_ld=../gold/ld-new$build_exeext elif test -f $gcc_cv_ld_gld_srcdir/configure.in \ && test -f ../ld/Makefile \ && test x$build = x$host; then @@ -2112,11 +2146,19 @@ changequote(,)dnl gcc_cv_gld_major_version=`expr "$gcc_cv_gld_version" : "VERSION=\([0-9]*\)"` gcc_cv_gld_minor_version=`expr "$gcc_cv_gld_version" : "VERSION=[0-9]*\.\([0-9]*\)"` changequote([,])dnl + ORIGINAL_LD_BFD_FOR_TARGET=../ld/ld-new$build_exeext + ORIGINAL_LD_GOLD_FOR_TARGET=../gold/ld-new$build_exeext else AC_MSG_RESULT($gcc_cv_ld) in_tree_ld=no + gcc_cvs_ld_program=`dirname $gcc_cv_ld`/`basename $gcc_cv_ld $host_exeext` + ORIGINAL_LD_BFD_FOR_TARGET=${gcc_cvs_ld_program}.bfd$host_exeext + ORIGINAL_LD_GOLD_FOR_TARGET=${gcc_cvs_ld_program}.gold$host_exeext fi +AC_SUBST(ORIGINAL_LD_BFD_FOR_TARGET) +AC_SUBST(ORIGINAL_LD_GOLD_FOR_TARGET) + # Figure out what nm we will be using. gcc_cv_binutils_srcdir=`echo $srcdir | sed -e 's,/gcc$,,'`/binutils AS_VAR_SET_IF(gcc_cv_nm,, [ diff --git a/gcc/exec-tool.in b/gcc/exec-tool.in index 6722ce52030..76d0ef65ab1 100644 --- a/gcc/exec-tool.in +++ b/gcc/exec-tool.in @@ -21,6 +21,8 @@ ORIGINAL_AS_FOR_TARGET="@ORIGINAL_AS_FOR_TARGET@" ORIGINAL_LD_FOR_TARGET="@ORIGINAL_LD_FOR_TARGET@" +ORIGINAL_LD_BFD_FOR_TARGET="@ORIGINAL_LD_BFD_FOR_TARGET@" +ORIGINAL_LD_GOLD_FOR_TARGET="@ORIGINAL_LD_GOLD_FOR_TARGET@" ORIGINAL_PLUGIN_LD_FOR_TARGET="@ORIGINAL_PLUGIN_LD_FOR_TARGET@" ORIGINAL_NM_FOR_TARGET="@ORIGINAL_NM_FOR_TARGET@" exeext=@host_exeext@ @@ -36,15 +38,32 @@ case "$invoked" in dir=gas ;; collect-ld) - # when using a linker plugin, gcc will always pass '-plugin' as the - # first or second option to the linker. - if test x"$1" = "x-plugin" || test x"$2" = "x-plugin"; then - original=$ORIGINAL_PLUGIN_LD_FOR_TARGET - else - original=$ORIGINAL_LD_FOR_TARGET - fi + # Check -fuse-ld=bfd and -fuse-ld=gold + case " $* " in + *\ -fuse-ld=bfd\ *) + original=$ORIGINAL_LD_BFD_FOR_TARGET + ;; + *\ -fuse-ld=gold\ *) + original=$ORIGINAL_LD_GOLD_FOR_TARGET + ;; + *) + # when using a linker plugin, gcc will always pass '-plugin' as the + # first or second option to the linker. + if test x"$1" = "x-plugin" || test x"$2" = "x-plugin"; then + original=$ORIGINAL_PLUGIN_LD_FOR_TARGET + else + original=$ORIGINAL_LD_FOR_TARGET + fi + ;; + esac prog=ld-new$exeext - dir=ld + if test "$original" = ../gold/ld-new$exeext; then + dir=gold + # No need to handle relink since gold doesn't use libtool. + fast_install=yes + else + dir=ld + fi id=ld ;; nm)