]> git.pld-linux.org Git - packages/gcc.git/blame - issue4664051.patch
- rebuild with ppl 1.0
[packages/gcc.git] / issue4664051.patch
CommitLineData
a72e2d82
ER
1http://patchwork.ozlabs.org/patch/102292/
2http://codereview.appspot.com/4664051/
3http://sourceware.org/ml/binutils/2011-01/msg00178.html
4http://anonscm.debian.org/viewvc/gcccvs/branches/sid/gcc-4.6/debian/patches/gold-and-ld.diff
5
6Index: gcc/doc/invoke.texi
7===================================================================
8--- gcc/doc/invoke.texi (revision 175346)
9+++ gcc/doc/invoke.texi (working copy)
10@@ -418,7 +418,7 @@
11 -funit-at-a-time -funroll-all-loops -funroll-loops @gol
12 -funsafe-loop-optimizations -funsafe-math-optimizations -funswitch-loops @gol
13 -fvariable-expansion-in-unroller -fvect-cost-model -fvpt -fweb @gol
14--fwhole-program -fwpa -fuse-linker-plugin @gol
15+-fwhole-program -fwpa -fuse-ld -fuse-linker-plugin @gol
16 --param @var{name}=@var{value}
17 -O -O0 -O1 -O2 -O3 -Os -Ofast}
18
19@@ -8017,6 +8017,16 @@
20
21 Enabled at levels @option{-O}, @option{-O2}, @option{-O3}, @option{-Os}.
22
23+@item -fuse-ld=gold
24+Use the @command{gold} linker instead of the default linker.
25+This option is only necessary if GCC has been configured with
26+@option{--enable-gold} and @option{--enable-ld=default}.
27+
28+@item -fuse-ld=bfd
29+Use the @command{ld.bfd} linker instead of the default linker.
30+This option is only necessary if GCC has been configured with
31+@option{--enable-gold} and @option{--enable-ld}.
32+
33 @item -fcprop-registers
34 @opindex fcprop-registers
35 After register allocation and post-register allocation instruction splitting,
36Index: gcc/configure
37===================================================================
38--- gcc/configure (revision 175346)
39+++ gcc/configure (working copy)
40@@ -681,6 +681,7 @@
41 gcc_cv_objdump
42 ORIGINAL_NM_FOR_TARGET
43 gcc_cv_nm
44+ORIGINAL_GOLD_FOR_TARGET
45 ORIGINAL_LD_FOR_TARGET
46 ORIGINAL_PLUGIN_LD_FOR_TARGET
47 gcc_cv_ld
48@@ -21131,6 +21132,21 @@
49 fi
50 fi
51
52+gcc_cv_ld_gold_srcdir=`echo $srcdir | sed -e 's,/gcc$,,'`/gold
53+
54+if test "${gcc_cv_gold+set}" = set; then :
55+
56+else
57+
58+if test -f $gcc_cv_ld_gold_srcdir/configure.ac \
59+ && test -f ../gold/Makefile \
60+ && test x$build = x$host; then
61+ gcc_cv_gold=../gold/ld-new$build_exeext
62+else
63+ gcc_cv_gold=''
64+fi
65+fi
66+
67 ORIGINAL_PLUGIN_LD_FOR_TARGET=$gcc_cv_ld
68 PLUGIN_LD=`basename $gcc_cv_ld`
69
70@@ -21170,6 +21186,9 @@
71 ;;
72 esac
73
74+ORIGINAL_GOLD_FOR_TARGET=$gcc_cv_gold
75+
76+
77 { $as_echo "$as_me:${as_lineno-$LINENO}: checking what linker to use" >&5
78 $as_echo_n "checking what linker to use... " >&6; }
79 if test "$gcc_cv_ld" = ../ld/ld-new$build_exeext; then
80Index: gcc/gcc.c
81===================================================================
82--- gcc/gcc.c (revision 175346)
83+++ gcc/gcc.c (working copy)
84@@ -657,6 +657,9 @@
85 }"PLUGIN_COND_CLOSE" \
86 %{flto|flto=*:%<fcompare-debug*} \
87 %{flto} %{flto=*} %l " LINK_PIE_SPEC \
88+ "%{fuse-ld=gold:%{fuse-ld=bfd:%e-fuse-ld=gold and -fuse-ld=bfd may not be used together}} \
89+ %{fuse-ld=gold:-use-gold} \
90+ %{fuse-ld=bfd:-use-ld}" \
91 "%X %{o*} %{e*} %{N} %{n} %{r}\
92 %{s} %{t} %{u*} %{z} %{Z} %{!nostdlib:%{!nostartfiles:%S}}\
93 %{static:} %{L*} %(mfwrap) %(link_libgcc) %o\
94Index: gcc/opts.c
95===================================================================
96--- gcc/opts.c (revision 175346)
97+++ gcc/opts.c (working copy)
98@@ -1729,8 +1729,9 @@
99 dc->max_errors = value;
100 break;
101
102+ case OPT_fuse_ld_:
103 case OPT_fuse_linker_plugin:
104- /* No-op. Used by the driver and passed to us because it starts with f.*/
105+ /* No-op. Used by the driver and passed to us because it starts with f. */
106 break;
107
108 case OPT_Wuninitialized:
109Index: gcc/configure.ac
110===================================================================
111--- gcc/configure.ac (revision 175346)
112+++ gcc/configure.ac (working copy)
113@@ -1974,6 +1974,17 @@
114 AC_PATH_PROG(gcc_cv_ld, $LD_FOR_TARGET)
115 fi])
116
117+gcc_cv_ld_gold_srcdir=`echo $srcdir | sed -e 's,/gcc$,,'`/gold
118+
119+AS_VAR_SET_IF(gcc_cv_gold,, [
120+if test -f $gcc_cv_ld_gold_srcdir/configure.ac \
121+ && test -f ../gold/Makefile \
122+ && test x$build = x$host; then
123+ gcc_cv_gold=../gold/ld-new$build_exeext
124+else
125+ gcc_cv_gold=''
126+fi])
127+
128 ORIGINAL_PLUGIN_LD_FOR_TARGET=$gcc_cv_ld
129 PLUGIN_LD=`basename $gcc_cv_ld`
130 AC_ARG_WITH(plugin-ld,
131@@ -2003,6 +2014,9 @@
132 *) AC_CONFIG_FILES(collect-ld:exec-tool.in, [chmod +x collect-ld]) ;;
133 esac
134
135+ORIGINAL_GOLD_FOR_TARGET=$gcc_cv_gold
136+AC_SUBST(ORIGINAL_GOLD_FOR_TARGET)
137+
138 AC_MSG_CHECKING(what linker to use)
139 if test "$gcc_cv_ld" = ../ld/ld-new$build_exeext; then
140 # Single tree build which includes ld. We want to prefer it
141Index: gcc/exec-tool.in
142===================================================================
143--- gcc/exec-tool.in (revision 175346)
144+++ gcc/exec-tool.in (working copy)
145@@ -1,6 +1,6 @@
146 #! /bin/sh
147
148-# Copyright (C) 2007, 2008, 2010 Free Software Foundation, Inc.
149+# Copyright (C) 2007, 2008, 2010, 2011 Free Software Foundation, Inc.
150 # This file is part of GCC.
151
152 # GCC is free software; you can redistribute it and/or modify
153@@ -21,11 +21,13 @@
154
155 ORIGINAL_AS_FOR_TARGET="@ORIGINAL_AS_FOR_TARGET@"
156 ORIGINAL_LD_FOR_TARGET="@ORIGINAL_LD_FOR_TARGET@"
157+ORIGINAL_GOLD_FOR_TARGET="@ORIGINAL_GOLD_FOR_TARGET@"
158 ORIGINAL_PLUGIN_LD_FOR_TARGET="@ORIGINAL_PLUGIN_LD_FOR_TARGET@"
159 ORIGINAL_NM_FOR_TARGET="@ORIGINAL_NM_FOR_TARGET@"
160 exeext=@host_exeext@
161 fast_install=@enable_fast_install@
162 objdir=@objdir@
163+version="1.1"
164
165 invoked=`basename "$0"`
166 id=$invoked
167@@ -36,15 +38,44 @@
168 dir=gas
169 ;;
170 collect-ld)
171- # when using a linker plugin, gcc will always pass '-plugin' as the
172- # first or second option to the linker.
173- if test x"$1" = "x-plugin" || test x"$2" = "x-plugin"; then
174- original=$ORIGINAL_PLUGIN_LD_FOR_TARGET
175- else
176- original=$ORIGINAL_LD_FOR_TARGET
177+ prog=ld-new$exeext
178+ # Look for the a command line option
179+ # specifying the linker to be used.
180+ case " $* " in
181+ *\ -use-gold\ *)
182+ original=$ORIGINAL_GOLD_FOR_TARGET
183+ dir=gold
184+ ;;
185+ *\ -use-ld\ * | *\ -use-ld.bfd\ *)
186+ original=$ORIGINAL_LD_FOR_TARGET
187+ dir=ld
188+ ;;
189+ *\ -plugin\ *)
190+ original=$ORIGINAL_PLUGIN_LD_FOR_TARGET
191+ dir=ld
192+ ;;
193+ *)
194+ original=$ORIGINAL_LD_FOR_TARGET
195+ dir=ld
196+ ;;
197+ esac
198+
199+ # If the selected linker has not been configured then
200+ # try using the others, in the order PLUGIN-LD, LD, GOLD.
201+ if test x"$original" = x; then
202+ if test x"$ORIGINAL_PLUGIN_LD_FOR_TARGET" != x; then
203+ original=$ORIGINAL_PLUGIN_LD_FOR_TARGET
204+ dir=ld
205+ elif test x"$ORIGINAL_LD_FOR_TARGET" != x; then
206+ original=$ORIGINAL_LD_FOR_TARGET
207+ dir=ld
208+ elif test x"$ORIGINAL_GOLD_FOR_TARGET" != x; then
209+ original=$ORIGINAL_GOLD_FOR_TARGET
210+ dir=gold
211+ # Otherwise do nothing - the case statement below
212+ # will issue an error message for us.
213+ fi
214 fi
215- prog=ld-new$exeext
216- dir=ld
217 id=ld
218 ;;
219 nm)
220@@ -61,29 +92,58 @@
221 scriptdir=`cd "$tdir" && pwd`
222
223 if test -x $scriptdir/../$dir/$prog; then
224- test "$fast_install" = yes || exec $scriptdir/../$dir/$prog ${1+"$@"}
225+ if test "$fast_install" = yes; then
226+ # If libtool did everything it needs to do, there's a fast path.
227+ lt_prog=$scriptdir/../$dir/$objdir/lt-$prog
228
229- # if libtool did everything it needs to do, there's a fast path
230- lt_prog=$scriptdir/../$dir/$objdir/lt-$prog
231- test -x $lt_prog && exec $lt_prog ${1+"$@"}
232-
233- # libtool has not relinked ld-new yet, but we cannot just use the
234- # previous stage (because then the relinking would just never happen!).
235- # So we take extra care to use prev-ld/ld-new *on recursive calls*.
236- eval LT_RCU="\${LT_RCU_$id}"
237- test x"$LT_RCU" = x"1" && exec $scriptdir/../prev-$dir/$prog ${1+"$@"}
238-
239- eval LT_RCU_$id=1
240- export LT_RCU_$id
241- $scriptdir/../$dir/$prog ${1+"$@"}
242- result=$?
243- exit $result
244-
245+ if test -x $lt_prog; then
246+ original=$lt_prog
247+ else
248+ # Libtool has not relinked ld-new yet, but we cannot just use the
249+ # previous stage (because then the relinking would just never happen!).
250+ # So we take extra care to use prev-ld/ld-new *on recursive calls*.
251+ eval LT_RCU="\${LT_RCU_$id}"
252+ if test x"$LT_RCU" = x"1"; then
253+ original=$scriptdir/../prev-$dir/$prog
254+ else
255+ eval LT_RCU_$id=1
256+ export LT_RCU_$id
257+ case " $* " in
258+ *\ -v\ *)
259+ echo "$invoked $version"
260+ echo $scriptdir/../$dir/$prog $*
261+ ;;
262+ esac
263+ $scriptdir/../$dir/$prog ${1+"$@"}
264+ result=$?
265+ exit $result
266+ fi
267+ fi
268+ else
269+ original=$scriptdir/../$dir/$prog
270+ fi
271 else
272- exec $scriptdir/../prev-$dir/$prog ${1+"$@"}
273+ original=$scriptdir/../prev-$dir/$prog
274 fi
275 ;;
276- *)
277- exec $original ${1+"$@"}
278+ "")
279+ echo "$invoked: executable not configured"
280+ exit 1
281 ;;
282 esac
283+
284+# If -v has been used then display our version number
285+# and then echo the command we are about to invoke.
286+case " $* " in
287+ *\ -v\ *)
288+ echo "$invoked $version"
289+ echo $original $*
290+ ;;
291+esac
292+
293+if test -x $original; then
294+ exec "$original" ${1+"$@"}
295+else
296+ echo "$invoked: unable to locate executable: $original"
297+ exit 1
298+fi
299Index: gcc/common.opt
300===================================================================
301--- gcc/common.opt (revision 175346)
302+++ gcc/common.opt (working copy)
303@@ -2138,6 +2138,9 @@
304 Common Report Var(flag_unwind_tables) Optimization
305 Just generate unwind tables for exception handling
306
307+fuse-ld=
308+Common Joined Undocumented
309+
310 fuse-linker-plugin
311 Common Undocumented
312
313Index: gcc/collect2.c
314===================================================================
315--- gcc/collect2.c (revision 175346)
316+++ gcc/collect2.c (working copy)
317@@ -1075,17 +1075,19 @@
318 int
319 main (int argc, char **argv)
320 {
321- static const char *const ld_suffix = "ld";
322- static const char *const plugin_ld_suffix = PLUGIN_LD;
323- static const char *const real_ld_suffix = "real-ld";
324+ static const char *const ld_suffix = "ld";
325+ static const char *const gold_suffix = "ld.gold";
326+ static const char *const bfd_ld_suffix = "ld.bfd";
327+ static const char *const plugin_ld_suffix = PLUGIN_LD;
328+ static const char *const real_ld_suffix = "real-ld";
329 static const char *const collect_ld_suffix = "collect-ld";
330- static const char *const nm_suffix = "nm";
331- static const char *const gnm_suffix = "gnm";
332+ static const char *const nm_suffix = "nm";
333+ static const char *const gnm_suffix = "gnm";
334 #ifdef LDD_SUFFIX
335- static const char *const ldd_suffix = LDD_SUFFIX;
336+ static const char *const ldd_suffix = LDD_SUFFIX;
337 #endif
338- static const char *const strip_suffix = "strip";
339- static const char *const gstrip_suffix = "gstrip";
340+ static const char *const strip_suffix = "strip";
341+ static const char *const gstrip_suffix = "gstrip";
342
343 #ifdef CROSS_DIRECTORY_STRUCTURE
344 /* If we look for a program in the compiler directories, we just use
345@@ -1095,6 +1097,10 @@
346
347 const char *const full_ld_suffix =
348 concat(target_machine, "-", ld_suffix, NULL);
349+ const char *const full_gold_suffix =
350+ concat (target_machine, "-", gold_suffix, NULL);
351+ const char *const full_bfd_ld_suffix =
352+ concat (target_machine, "-", bfd_ld_suffix, NULL);
353 const char *const full_plugin_ld_suffix =
354 concat(target_machine, "-", plugin_ld_suffix, NULL);
355 const char *const full_nm_suffix =
356@@ -1110,15 +1116,17 @@
357 const char *const full_gstrip_suffix =
358 concat (target_machine, "-", gstrip_suffix, NULL);
359 #else
360- const char *const full_ld_suffix = ld_suffix;
361+ const char *const full_ld_suffix = ld_suffix;
362+ const char *const full_gold_suffix = gold_suffix;
363+ const char *const full_bfd_ld_suffix = bfd_ld_suffix;
364 const char *const full_plugin_ld_suffix = plugin_ld_suffix;
365- const char *const full_nm_suffix = nm_suffix;
366- const char *const full_gnm_suffix = gnm_suffix;
367+ const char *const full_nm_suffix = nm_suffix;
368+ const char *const full_gnm_suffix = gnm_suffix;
369 #ifdef LDD_SUFFIX
370- const char *const full_ldd_suffix = ldd_suffix;
371+ const char *const full_ldd_suffix = ldd_suffix;
372 #endif
373- const char *const full_strip_suffix = strip_suffix;
374- const char *const full_gstrip_suffix = gstrip_suffix;
375+ const char *const full_strip_suffix = strip_suffix;
376+ const char *const full_gstrip_suffix = gstrip_suffix;
377 #endif /* CROSS_DIRECTORY_STRUCTURE */
378
379 const char *arg;
380@@ -1132,7 +1140,13 @@
381 const char **c_ptr;
382 char **ld1_argv;
383 const char **ld1;
384- bool use_plugin = false;
385+ enum linker_select
386+ {
387+ DFLT_LINKER,
388+ PLUGIN_LINKER,
389+ GOLD_LINKER,
390+ BFD_LINKER
391+ } selected_linker = DFLT_LINKER;
392
393 /* The kinds of symbols we will have to consider when scanning the
394 outcome of a first pass link. This is ALL to start with, then might
395@@ -1209,15 +1223,21 @@
396 else if (! strcmp (argv[i], "-flto-partition=none"))
397 no_partition = true;
398 else if ((! strncmp (argv[i], "-flto=", 6)
399- || ! strcmp (argv[i], "-flto")) && ! use_plugin)
400+ || ! strcmp (argv[i], "-flto"))
401+ && selected_linker != PLUGIN_LINKER)
402 lto_mode = LTO_MODE_WHOPR;
403 else if (!strncmp (argv[i], "-fno-lto", 8))
404 lto_mode = LTO_MODE_NONE;
405 else if (! strcmp (argv[i], "-plugin"))
406 {
407- use_plugin = true;
408+ selected_linker = PLUGIN_LINKER;
409 lto_mode = LTO_MODE_NONE;
410 }
411+ else if (! strcmp (argv[i], "-use-gold"))
412+ selected_linker = GOLD_LINKER;
413+ else if (! strcmp (argv[i], "-use-ld"))
414+ selected_linker = BFD_LINKER;
415+
416 #ifdef COLLECT_EXPORT_LIST
417 /* since -brtl, -bexport, -b64 are not position dependent
418 also check for them here */
419@@ -1299,36 +1319,109 @@
420 /* Try to discover a valid linker/nm/strip to use. */
421
422 /* Maybe we know the right file to use (if not cross). */
423- ld_file_name = 0;
424+ ld_file_name = NULL;
425 #ifdef DEFAULT_LINKER
426 if (access (DEFAULT_LINKER, X_OK) == 0)
427 ld_file_name = DEFAULT_LINKER;
428- if (ld_file_name == 0)
429+ if (ld_file_name == NULL)
430 #endif
431 #ifdef REAL_LD_FILE_NAME
432 ld_file_name = find_a_file (&path, REAL_LD_FILE_NAME);
433- if (ld_file_name == 0)
434+ if (ld_file_name == NULL)
435 #endif
436 /* Search the (target-specific) compiler dirs for ld'. */
437 ld_file_name = find_a_file (&cpath, real_ld_suffix);
438 /* Likewise for `collect-ld'. */
439- if (ld_file_name == 0)
440+ if (ld_file_name == NULL)
441 ld_file_name = find_a_file (&cpath, collect_ld_suffix);
442 /* Search the compiler directories for `ld'. We have protection against
443 recursive calls in find_a_file. */
444- if (ld_file_name == 0)
445- ld_file_name = find_a_file (&cpath,
446- use_plugin
447- ? plugin_ld_suffix
448- : ld_suffix);
449+ if (ld_file_name == NULL)
450+ switch (selected_linker)
451+ {
452+ default:
453+ case DFLT_LINKER:
454+ ld_file_name = find_a_file (&cpath, ld_suffix);
455+ break;
456+ case PLUGIN_LINKER:
457+ ld_file_name = find_a_file (&cpath, plugin_ld_suffix);
458+ break;
459+ case GOLD_LINKER:
460+ ld_file_name = find_a_file (&cpath, gold_suffix);
461+ break;
462+ case BFD_LINKER:
463+ ld_file_name = find_a_file (&cpath, bfd_ld_suffix);
464+ break;
465+ }
466 /* Search the ordinary system bin directories
467 for `ld' (if native linking) or `TARGET-ld' (if cross). */
468- if (ld_file_name == 0)
469- ld_file_name = find_a_file (&path,
470- use_plugin
471- ? full_plugin_ld_suffix
472- : full_ld_suffix);
473+ if (ld_file_name == NULL)
474+ switch (selected_linker)
475+ {
476+ default:
477+ case DFLT_LINKER:
478+ ld_file_name = find_a_file (&path, full_ld_suffix);
479+ break;
480+ case PLUGIN_LINKER:
481+ ld_file_name = find_a_file (&path, full_plugin_ld_suffix);
482+ break;
483+ case GOLD_LINKER:
484+ ld_file_name = find_a_file (&path, full_gold_suffix);
485+ break;
486+ case BFD_LINKER:
487+ ld_file_name = find_a_file (&path, full_bfd_ld_suffix);
488+ break;
489+ }
490+ /* If we failed to find a plugin-capable linker, try the ordinary one. */
491+ if (ld_file_name == NULL && selected_linker == PLUGIN_LINKER)
492+ ld_file_name = find_a_file (&cpath, ld_suffix);
493
494+ if ((vflag || debug) && ld_file_name == NULL)
495+ {
496+ struct prefix_list * p;
497+ const char * s;
498+
499+ notice ("collect2: warning: unable to find linker.\n");
500+
501+#ifdef DEFAULT_LINKER
502+ notice (" Searched for this absolute executable:\n");
503+ notice (" %s\n", DEFAULT_LINKER);
504+#endif
505+
506+ notice (" Searched in these paths:\n");
507+ for (p = cpath.plist; p != NULL; p = p->next)
508+ notice (" %s\n", p->prefix);
509+ notice (" For these executables:\n");
510+ notice (" %s\n", real_ld_suffix);
511+ notice (" %s\n", collect_ld_suffix);
512+ switch (selected_linker)
513+ {
514+ default:
515+ case DFLT_LINKER: s = ld_suffix; break;
516+ case PLUGIN_LINKER: s = plugin_ld_suffix; break;
517+ case GOLD_LINKER: s = gold_suffix; break;
518+ case BFD_LINKER: s = bfd_ld_suffix; break;
519+ }
520+ notice (" %s\n", s);
521+
522+ notice (" And searched in these paths:\n");
523+ for (p = path.plist; p != NULL; p = p->next)
524+ notice (" %s\n", p->prefix);
525+ notice (" For these executables:\n");
526+#ifdef REAL_LD_FILE_NAME
527+ notice (" %s\n", REAL_LD_FILE_NAME);
528+#endif
529+ switch (selected_linker)
530+ {
531+ default:
532+ case DFLT_LINKER: s = full_ld_suffix; break;
533+ case PLUGIN_LINKER: s = full_plugin_ld_suffix; break;
534+ case GOLD_LINKER: s = full_gold_suffix; break;
535+ case BFD_LINKER: s = full_bfd_ld_suffix; break;
536+ }
537+ notice (" %s\n", s);
538+ }
539+
540 #ifdef REAL_NM_FILE_NAME
541 nm_file_name = find_a_file (&path, REAL_NM_FILE_NAME);
542 if (nm_file_name == 0)
This page took 0.321297 seconds and 4 git commands to generate.