On Fri, Nov 22, 2013 at 2:50 PM, H.J. Lu <hongjiu...@intel.com> wrote: > Toplevel configure supports: > > # Handle --enable-gold, --enable-ld. > # --disable-gold [--enable-ld] > # Build only ld. Default option. > # --enable-gold [--enable-ld] > # Build both gold and ld. Install gold as "ld.gold", install ld > # as "ld.bfd" and "ld". > # --enable-gold=default [--enable-ld] > # Build both gold and ld. Install gold as "ld.gold" and "ld", > # install ld as "ld.bfd". > # --enable-gold[=default] --disable-ld > # Build only gold, which is then installed as both "ld.gold" and > # "ld". > # --enable-gold --enable-ld=default > # Build both gold (installed as "ld.gold") and ld (installed as "ld" > # and ld.bfd). > # In other words, ld is default > # --enable-gold=default --enable-ld=default > # Error. > > However, gcc directory doesn't handle --enable-gold=default properly. > This patch fixes --enable-gold=default. Tested on Linux/x86-64 with > GCC + binutils using: > > --enable-plugins --enable-threads --enable-gold=default > > With this fixed, I also added -fuse-ld=bfd/-fuse-ld=gold support to > exec-tool.in. Tested with > > ./xgcc -B./ -fuse-ld=bfd/-fuse-ld=gold > > on GCC: > > [hjl@gnu-6 gcc]$ ./xgcc -B./ -shared -Wl,-v x.o -fuse-ld=gold collect2 > version 4.9.0 20131122 (experimental) ./collect-ld --eh-frame-hdr -m > elf_x86_64 -shared -fuse-ld=gold /lib/../lib64/crti.o ./crtbeginS.o -L. > -L/lib/../lib64 -L/usr/lib/../lib64 -v x.o -lgcc --as-needed -lgcc_s > --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed ./crtendS.o > /lib/../lib64/crtn.o > GNU gold (Linux/GNU Binutils 2.24.51.0.2.20131118) 1.11 > [hjl@gnu-6 gcc]$ ./xgcc -B./ -shared -Wl,-v x.o -fuse-ld=bfd collect2 version > 4.9.0 20131122 (experimental) ./collect-ld --eh-frame-hdr -m elf_x86_64 > -shared -fuse-ld=bfd /lib/../lib64/crti.o ./crtbeginS.o -L. -L/lib/../lib64 > -L/usr/lib/../lib64 -v x.o -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc > --as-needed -lgcc_s --no-as-needed ./crtendS.o /lib/../lib64/crtn.o > GNU ld (Linux/GNU Binutils) 2.24.51.0.2.20131118 > [hjl@gnu-6 gcc]$ > > OK to to install?
Ok. Thanks, Richard. > Thanks. > > > H.J. > --- > 2013-01-07 H.J. Lu <hongjiu...@intel.com> > > * 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 76b738d068e8292f0e06fb4d17292d3fcad852e4 Mon Sep 17 00:00:00 2001 > From: "H.J. Lu" <hjl.to...@gmail.com> > Date: Mon, 7 Jan 2013 09:30:43 -0800 > > --- > gcc/ChangeLog.gold | 19 ++++++++++++++++++ > gcc/configure | 57 > ++++++++++++++++++++++++++++++++++++++++++++++++++++-- > gcc/configure.ac | 42 ++++++++++++++++++++++++++++++++++++++++ > gcc/exec-tool.in | 33 ++++++++++++++++++++++++------- > 4 files changed, 142 insertions(+), 9 deletions(-) > create mode 100644 gcc/ChangeLog.gold > > diff --git a/gcc/configure b/gcc/configure > index c9bbd65..fdf0cd0 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 5935a6e..91a22d5 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 6722ce5..76d0ef6 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 > + # 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 > + 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 > - original=$ORIGINAL_LD_FOR_TARGET > + dir=ld > fi > - prog=ld-new$exeext > - dir=ld > id=ld > ;; > nm) > -- > 1.8.3.1 >