1
# DP: Enable both gold and ld in a single toolchain.
2
# DP: New option -fuse-ld=ld.bfd, -fuse-ld=gold.
5
===================================================================
6
--- a/src/gcc/gcc.c (revision
7
+++ b/src/gcc/gcc.c (working
9
#ifndef LINK_COMMAND_SPEC
10
#define LINK_COMMAND_SPEC "\
11
%{!fsyntax-only:%{!c:%{!M:%{!MM:%{!E:%{!S:\
12
- %(linker) %l " LINK_PIE_SPEC "%X %{o*} %{A} %{d} %{e*} %{m} %{N} %{n} %{r}\
13
+ %(linker) %l " LINK_PIE_SPEC \
14
+ "%{fuse-ld=gold:%{fuse-ld=bfd:%e-fuse-ld=gold and -fuse-ld=bfd may not be used together}} \
15
+ %{fuse-ld=gold:-use-gold} \
16
+ %{fuse-ld=bfd:-use-ld}" \
17
+ "%X %{o*} %{A} %{d} %{e*} %{m} %{N} %{n} %{r}\
18
%{s} %{t} %{u*} %{x} %{z} %{Z} %{!A:%{!nostdlib:%{!nostartfiles:%S}}}\
19
%{static:} %{L*} %(mfwrap) %(link_libgcc) %o\
20
%{fopenmp|ftree-parallelize-loops=*:%:include(libgomp.spec)%(link_gomp)} %(mflib)\
22
===================================================================
23
--- a/src/gcc/opts.c (revision
24
+++ b/src/gcc/opts.c (working
25
@@ -2062,6 +2062,10 @@
26
/* These are no-ops, preserved for backward compatibility. */
30
+ /* No-op. Used by the driver and passed to us because it starts with f. */
34
/* If the flag was handled in a standard way, assume the lack of
35
processing here is intentional. */
36
Index: gcc/configure.ac
37
===================================================================
38
--- a/src/gcc/configure.ac (revision
39
+++ b/src/gcc/configure.ac (working
40
@@ -1911,6 +1911,17 @@
41
AC_PATH_PROG(gcc_cv_ld, $LD_FOR_TARGET)
44
+gcc_cv_ld_gold_srcdir=`echo $srcdir | sed -e 's,/gcc$,,'`/gold
46
+AS_VAR_SET_IF(gcc_cv_gold,, [
47
+if test -f $gcc_cv_ld_gold_srcdir/configure.ac \
48
+ && test -f ../gold/Makefile \
49
+ && test x$build = x$host; then
50
+ gcc_cv_gold=../gold/ld-new$build_exeext
55
ORIGINAL_LD_FOR_TARGET=$gcc_cv_ld
56
AC_SUBST(ORIGINAL_LD_FOR_TARGET)
57
case "$ORIGINAL_LD_FOR_TARGET" in
59
*) AC_CONFIG_FILES(collect-ld:exec-tool.in, [chmod +x collect-ld]) ;;
62
+ORIGINAL_GOLD_FOR_TARGET=$gcc_cv_gold
63
+AC_SUBST(ORIGINAL_GOLD_FOR_TARGET)
65
AC_MSG_CHECKING(what linker to use)
66
if test "$gcc_cv_ld" = ../ld/ld-new$build_exeext; then
67
# Single tree build which includes ld. We want to prefer it
68
Index: gcc/exec-tool.in
69
===================================================================
70
--- a/src/gcc/exec-tool.in (revision
71
+++ b/src/gcc/exec-tool.in (working
75
-# Copyright (C) 2007, 2008 Free Software Foundation, Inc.
76
+# Copyright (C) 2007, 2008, 2010 Free Software Foundation, Inc.
77
# This file is part of GCC.
79
# GCC is free software; you can redistribute it and/or modify
82
ORIGINAL_AS_FOR_TARGET="@ORIGINAL_AS_FOR_TARGET@"
83
ORIGINAL_LD_FOR_TARGET="@ORIGINAL_LD_FOR_TARGET@"
84
+ORIGINAL_GOLD_FOR_TARGET="@ORIGINAL_GOLD_FOR_TARGET@"
85
ORIGINAL_NM_FOR_TARGET="@ORIGINAL_NM_FOR_TARGET@"
87
fast_install=@enable_fast_install@
91
invoked=`basename "$0"`
98
- original=$ORIGINAL_LD_FOR_TARGET
103
original=$ORIGINAL_NM_FOR_TARGET
109
+ # Look for the a command line option
110
+ # specifying the linker to be used.
113
+ original=$ORIGINAL_GOLD_FOR_TARGET
116
+ *\ -use-ld\ * | *\ -use-ld.bfd\ *)
117
+ original=$ORIGINAL_LD_FOR_TARGET
121
+# original=$ORIGINAL_PLUGIN_LD_FOR_TARGET
125
+ original=$ORIGINAL_LD_FOR_TARGET
130
+ # If the selected linker has not been configured then
131
+ # try using the others, in the order PLUGIN-LD, LD, GOLD.
132
+ if test x"$original" = x; then
133
+# if test x"$ORIGINAL_PLUGIN_LD_FOR_TARGET" != x; then
134
+# original=$ORIGINAL_PLUGIN_LD_FOR_TARGET
136
+# elif test x"$ORIGINAL_LD_FOR_TARGET" != x; then
137
+ if test x"$ORIGINAL_LD_FOR_TARGET" != x; then
138
+ original=$ORIGINAL_LD_FOR_TARGET
140
+ elif test x"$ORIGINAL_GOLD_FOR_TARGET" != x; then
141
+ original=$ORIGINAL_GOLD_FOR_TARGET
143
+ # Otherwise do nothing - the case statement below
144
+ # will issue an error message for us.
152
- # compute absolute path of the location of this script
153
+ # Compute absolute path of the location of this script
155
scriptdir=`cd "$tdir" && pwd`
157
if test -x $scriptdir/../$dir/$prog; then
158
- test "$fast_install" = yes || exec $scriptdir/../$dir/$prog ${1+"$@"}
159
+ if test "$fast_install" = yes; then
160
+ # If libtool did everything it needs to do, there's a fast path.
161
+ lt_prog=$scriptdir/../$dir/$objdir/lt-$prog
163
- # if libtool did everything it needs to do, there's a fast path
164
- lt_prog=$scriptdir/../$dir/$objdir/lt-$prog
165
- test -x $lt_prog && exec $lt_prog ${1+"$@"}
167
- # libtool has not relinked ld-new yet, but we cannot just use the
168
- # previous stage (because then the relinking would just never happen!).
169
- # So we take extra care to use prev-ld/ld-new *on recursive calls*.
170
- test x"$LT_RCU" = x"1" && exec $scriptdir/../prev-$dir/$prog ${1+"$@"}
172
- LT_RCU=1; export LT_RCU
173
- $scriptdir/../$dir/$prog ${1+"$@"}
177
+ if test -x $lt_prog; then
180
+ # Libtool has not relinked ld-new yet, but we cannot just use the
181
+ # previous stage (because then the relinking would just never happen!).
182
+ # So we take extra care to use prev-ld/ld-new *on recursive calls*.
183
+ if test x"$LT_RCU" = x"1"; then
184
+ original=$scriptdir/../prev-$dir/$prog
186
+ LT_RCU=1; export LT_RCU
189
+ echo "$invoked $version"
190
+ echo $scriptdir/../$dir/$prog $*
193
+ $scriptdir/../$dir/$prog ${1+"$@"}
199
+ original=$scriptdir/../$dir/$prog
202
- exec $scriptdir/../prev-$dir/$prog ${1+"$@"}
203
+ original=$scriptdir/../prev-$dir/$prog
207
- exec "$original" ${1+"$@"}
209
+ echo "$invoked: executable not configured"
214
+# If -v has been used then display our version number
215
+# and then echo the command we are about to invoke.
218
+ echo "$invoked $version"
223
+if test -x $original; then
224
+ exec "$original" ${1+"$@"}
226
+ echo "$invoked: unable to locate executable: $original"
229
Index: gcc/common.opt
230
===================================================================
231
--- a/src/gcc/common.opt (revision
232
+++ b/src/gcc/common.opt (working
233
@@ -1299,6 +1299,9 @@
234
Common Report Var(flag_unwind_tables) Optimization
235
Just generate unwind tables for exception handling
238
+Common Joined Undocumented
241
Common Report Var(flag_var_tracking) VarExists Optimization
242
Perform variable tracking
243
Index: gcc/collect2.c
244
===================================================================
245
--- a/src/gcc/collect2.c (revision
246
+++ b/src/gcc/collect2.c (working
248
main (int argc, char **argv)
250
static const char *const ld_suffix = "ld";
251
+ static const char *const gold_suffix = "gold";
252
+ static const char *const bfd_ld_suffix = "ld.bfd";
253
static const char *const real_ld_suffix = "real-ld";
254
static const char *const collect_ld_suffix = "collect-ld";
255
static const char *const nm_suffix = "nm";
258
const char *const full_ld_suffix =
259
concat(target_machine, "-", ld_suffix, NULL);
260
+ const char *const full_gold_suffix =
261
+ concat (target_machine, "-", gold_suffix, NULL);
262
+ const char *const full_bfd_ld_suffix =
263
+ concat (target_machine, "-", bfd_ld_suffix, NULL);
264
const char *const full_nm_suffix =
265
concat (target_machine, "-", nm_suffix, NULL);
266
const char *const full_gnm_suffix =
268
concat (target_machine, "-", gstrip_suffix, NULL);
270
const char *const full_ld_suffix = ld_suffix;
271
+ const char *const full_gold_suffix = gold_suffix;
272
+ const char *const full_bfd_ld_suffix = bfd_ld_suffix;
273
const char *const full_nm_suffix = nm_suffix;
274
const char *const full_gnm_suffix = gnm_suffix;
285
+ } selected_linker = DFLT_LINKER;
291
if (! strcmp (argv[i], "-debug"))
293
+ else if (! strcmp (argv[i], "-use-gold"))
294
+ selected_linker = GOLD_LINKER;
295
+ else if (! strcmp (argv[i], "-use-ld"))
296
+ selected_linker = BFD_LINKER;
300
@@ -954,13 +973,81 @@
301
ld_file_name = find_a_file (&cpath, collect_ld_suffix);
302
/* Search the compiler directories for `ld'. We have protection against
303
recursive calls in find_a_file. */
304
- if (ld_file_name == 0)
305
- ld_file_name = find_a_file (&cpath, ld_suffix);
306
+ if (ld_file_name == NULL)
307
+ switch (selected_linker)
311
+ ld_file_name = find_a_file (&cpath, ld_suffix);
314
+ ld_file_name = find_a_file (&cpath, gold_suffix);
317
+ ld_file_name = find_a_file (&cpath, bfd_ld_suffix);
320
/* Search the ordinary system bin directories
321
for `ld' (if native linking) or `TARGET-ld' (if cross). */
322
- if (ld_file_name == 0)
323
- ld_file_name = find_a_file (&path, full_ld_suffix);
324
+ if (ld_file_name == NULL)
325
+ switch (selected_linker)
329
+ ld_file_name = find_a_file (&path, full_ld_suffix);
332
+ ld_file_name = find_a_file (&path, full_gold_suffix);
335
+ ld_file_name = find_a_file (&path, full_bfd_ld_suffix);
339
+ if ((vflag || debug) && ld_file_name == NULL)
341
+ struct prefix_list * p;
344
+ notice ("collect2: warning: unable to find linker.\n");
346
+#ifdef DEFAULT_LINKER
347
+ notice (" Searched for this absolute executable:\n");
348
+ notice (" %s\n", DEFAULT_LINKER);
351
+ notice (" Searched in these paths:\n");
352
+ for (p = cpath.plist; p != NULL; p = p->next)
353
+ notice (" %s\n", p->prefix);
354
+ notice (" For these executables:\n");
355
+ notice (" %s\n", real_ld_suffix);
356
+ notice (" %s\n", collect_ld_suffix);
357
+ switch (selected_linker)
360
+ case DFLT_LINKER: s = ld_suffix; break;
361
+ case GOLD_LINKER: s = gold_suffix; break;
362
+ case BFD_LINKER: s = bfd_ld_suffix; break;
364
+ notice (" %s\n", s);
366
+ notice (" And searched in these paths:\n");
367
+ for (p = path.plist; p != NULL; p = p->next)
368
+ notice (" %s\n", p->prefix);
369
+ notice (" For these executables:\n");
370
+#ifdef REAL_LD_FILE_NAME
371
+ notice (" %s\n", REAL_LD_FILE_NAME);
373
+ switch (selected_linker)
376
+ case DFLT_LINKER: s = full_ld_suffix; break;
377
+ case GOLD_LINKER: s = full_gold_suffix; break;
378
+ case BFD_LINKER: s = full_bfd_ld_suffix; break;
380
+ notice (" %s\n", s);
383
#ifdef REAL_NM_FILE_NAME
384
nm_file_name = find_a_file (&path, REAL_NM_FILE_NAME);
385
if (nm_file_name == 0)
387
===================================================================
388
--- a/src/configure.ac (revision
389
+++ b/src/configure.ac (working
391
# know that we are building the simulator.
392
# binutils, gas and ld appear in that order because it makes sense to run
393
# "make check" in that particular order.
394
-# If --enable-gold is used, "gold" will replace "ld".
395
+# If --enable-gold is used, "gold" may replace "ld".
396
host_tools="texinfo byacc flex bison binutils gas ld fixincludes gcc sid sim gdb make patch prms send-pr gprof etc expect dejagnu ash bash bzip2 m4 autoconf automake libtool diff rcs fileutils shellutils time textutils wdiff find uudecode hello tar gzip indent recode release sed utils guile perl gawk findutils gettext zip fastjar gnattools"
398
# libgcj represents the runtime libraries only used by gcj.
399
@@ -294,37 +294,57 @@
402
# Handle --enable-gold.
403
+# --enable-gold Build only gold
404
+# --disable-gold [default] Build only ld
405
+# --enable-gold=both Build both gold and ld, ld is default
406
+# --enable-gold=both/ld Same
407
+# --enable-gold=both/gold Build both gold and ld, gold is default, ld is renamed ld.bfd
410
-[ --enable-gold use gold instead of ld],
411
+[ --enable-gold[[=ARG]] build gold [[ARG={both}[[/{gold,ld}]]]]],
412
ENABLE_GOLD=$enableval,
414
-if test "${ENABLE_GOLD}" = "yes"; then
415
- # Check for ELF target.
417
- case "${target}" in
418
- *-*-elf* | *-*-sysv4* | *-*-unixware* | *-*-eabi* | hppa*64*-*-hpux* \
419
- | *-*-linux* | frv-*-uclinux* | *-*-irix5* | *-*-irix6* \
420
- | *-*-netbsd* | *-*-openbsd* | *-*-freebsd* | *-*-solaris2*)
421
+ case "${ENABLE_GOLD}" in
422
+ yes|both|both/gold|both/ld)
423
+ # Check for ELF target.
425
+ case "${target}" in
426
+ *-*-elf* | *-*-sysv4* | *-*-unixware* | *-*-eabi* | hppa*64*-*-hpux* \
427
+ | *-*-linux* | frv-*-uclinux* | *-*-irix5* | *-*-irix6* \
428
+ | *-*-netbsd* | *-*-openbsd* | *-*-freebsd* | *-*-solaris2* | *-*-nto*)
429
+ case "${target}" in
430
+ *-*-linux*aout* | *-*-linux*oldld*)
438
+ if test "$is_elf" = "yes"; then
439
+ # Check for target supported by gold.
441
- *-*-linux*aout* | *-*-linux*oldld*)
442
+ i?86-*-* | x86_64-*-* | sparc*-*-* | powerpc*-*-* | arm*-*-*)
443
+ case "${ENABLE_GOLD}" in
445
+ configdirs="$configdirs gold"
448
+ configdirs="`echo " ${configdirs} " | sed -e 's/ ld / gold /'`"
462
+ AC_MSG_ERROR([invalid --enable-gold argument])
466
- if test "$is_elf" = "yes"; then
467
- # Check for target supported by gold.
468
- case "${target}" in
469
- i?86-*-* | x86_64-*-* | sparc*-*-* | powerpc*-*-*)
470
- configdirs="`echo " ${configdirs} " | sed -e 's/ ld / gold /'`"
476
# Configure extra directories which are host specific