~ubuntu-branches/debian/sid/gnat-4.4/sid

« back to all changes in this revision

Viewing changes to debian/patches/gold-and-ld.diff

  • Committer: Bazaar Package Importer
  • Author(s): Ludovic Brenta
  • Date: 2010-05-09 23:28:13 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20100509232813-bykj33gg0mc34opr
Tags: 4.4.4-2
* debian/control.m4, debian/control: make upgrades from Lenny work without
  broken packages or hard decisions.
  (gnat-4.4): replace all previous versions of gnat-X.Y.
  (libgnat{vsn,prj}4.4-dev):
  - Replace the corresponding 4.3 package in addition to Conflicting with it.
  - Suggest the -dbg package, too.
  (libgnat{vsn,prj}4.4-dbg):
  - Depend on the -dev package, too.
  - Do not recommend gnat-gdb, superseded by gdb.
  (libgnatprj4.4-dbg): do not recommend libgnatprj-dev, no longer in the archive.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# DP: Enable both gold and ld in a single toolchain.
 
2
# DP: New option -fuse-ld=ld.bfd, -fuse-ld=gold.
 
3
 
 
4
Index: gcc/gcc.c
 
5
===================================================================
 
6
--- a/src/gcc/gcc.c     (revision
 
7
+++ b/src/gcc/gcc.c     (working
 
8
@@ -726,7 +726,11 @@
 
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)\
 
21
Index: gcc/opts.c
 
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.  */
 
27
       break;
 
28
 
 
29
+    case OPT_fuse_ld_:
 
30
+      /* No-op. Used by the driver and passed to us because it starts with f.  */
 
31
+      break;
 
32
+
 
33
     default:
 
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)
 
42
 fi])
 
43
 
 
44
+gcc_cv_ld_gold_srcdir=`echo $srcdir | sed -e 's,/gcc$,,'`/gold
 
45
+
 
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
 
51
+else
 
52
+        gcc_cv_gold=''
 
53
+fi])
 
54
+
 
55
 ORIGINAL_LD_FOR_TARGET=$gcc_cv_ld
 
56
 AC_SUBST(ORIGINAL_LD_FOR_TARGET)
 
57
 case "$ORIGINAL_LD_FOR_TARGET" in
 
58
@@ -1918,6 +1929,9 @@
 
59
   *) AC_CONFIG_FILES(collect-ld:exec-tool.in, [chmod +x collect-ld]) ;;
 
60
 esac 
 
61
 
 
62
+ORIGINAL_GOLD_FOR_TARGET=$gcc_cv_gold
 
63
+AC_SUBST(ORIGINAL_GOLD_FOR_TARGET)
 
64
+
 
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
 
72
@@ -1,6 +1,6 @@
 
73
 #! /bin/sh
 
74
 
 
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.
 
78
 
 
79
 # GCC is free software; you can redistribute it and/or modify
 
80
@@ -21,10 +21,12 @@
 
81
 
 
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@"
 
86
 exeext=@host_exeext@
 
87
 fast_install=@enable_fast_install@
 
88
 objdir=@objdir@
 
89
+version="1.1"
 
90
 
 
91
 invoked=`basename "$0"`
 
92
 case "$invoked" in
 
93
@@ -33,48 +35,111 @@
 
94
     prog=as-new$exeext
 
95
     dir=gas
 
96
     ;;
 
97
-  collect-ld)
 
98
-    original=$ORIGINAL_LD_FOR_TARGET
 
99
-    prog=ld-new$exeext
 
100
-    dir=ld
 
101
-    ;;
 
102
   nm)
 
103
     original=$ORIGINAL_NM_FOR_TARGET
 
104
     prog=nm-new$exeext
 
105
     dir=binutils
 
106
     ;;
 
107
+  collect-ld)
 
108
+    prog=ld-new$exeext
 
109
+    # Look for the a command line option
 
110
+    # specifying the linker to be used.
 
111
+    case " $* " in
 
112
+      *\ -use-gold\ *)
 
113
+        original=$ORIGINAL_GOLD_FOR_TARGET
 
114
+       dir=gold
 
115
+        ;;
 
116
+      *\ -use-ld\ * | *\ -use-ld.bfd\ *)
 
117
+        original=$ORIGINAL_LD_FOR_TARGET
 
118
+        dir=ld
 
119
+        ;;
 
120
+#      *\ -plugin\ *)
 
121
+#        original=$ORIGINAL_PLUGIN_LD_FOR_TARGET
 
122
+#        dir=ld
 
123
+#      ;;
 
124
+      *)
 
125
+        original=$ORIGINAL_LD_FOR_TARGET
 
126
+        dir=ld
 
127
+       ;;
 
128
+    esac
 
129
+
 
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
 
135
+#        dir=ld
 
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
 
139
+        dir=ld
 
140
+      elif test x"$ORIGINAL_GOLD_FOR_TARGET" != x; then
 
141
+        original=$ORIGINAL_GOLD_FOR_TARGET
 
142
+        dir=gold
 
143
+      # Otherwise do nothing - the case statement below
 
144
+      # will issue an error message for us.
 
145
+      fi
 
146
+    fi
 
147
+    ;;
 
148
 esac
 
149
 
 
150
 case "$original" in
 
151
   ../*)
 
152
-    # compute absolute path of the location of this script
 
153
+    # Compute absolute path of the location of this script
 
154
     tdir=`dirname "$0"`
 
155
     scriptdir=`cd "$tdir" && pwd`
 
156
 
 
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 
 
162
 
 
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+"$@"}
 
166
-
 
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+"$@"}
 
171
-
 
172
-      LT_RCU=1; export LT_RCU
 
173
-      $scriptdir/../$dir/$prog ${1+"$@"}
 
174
-      result=$?
 
175
-      exit $result
 
176
-
 
177
+       if test -x $lt_prog; then
 
178
+         original=$lt_prog
 
179
+        else
 
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
 
185
+          else
 
186
+            LT_RCU=1; export LT_RCU
 
187
+            case " $* " in
 
188
+              *\ -v\ *)
 
189
+               echo "$invoked $version"
 
190
+               echo $scriptdir/../$dir/$prog $*
 
191
+               ;;
 
192
+            esac
 
193
+            $scriptdir/../$dir/$prog ${1+"$@"}
 
194
+            result=$?
 
195
+            exit $result
 
196
+          fi
 
197
+        fi
 
198
+      else
 
199
+       original=$scriptdir/../$dir/$prog
 
200
+      fi
 
201
     else
 
202
-      exec $scriptdir/../prev-$dir/$prog ${1+"$@"}
 
203
+      original=$scriptdir/../prev-$dir/$prog
 
204
     fi
 
205
     ;;
 
206
-  *)
 
207
-    exec "$original" ${1+"$@"}
 
208
+  "")
 
209
+    echo "$invoked: executable not configured"
 
210
+    exit 1
 
211
     ;;
 
212
 esac
 
213
 
 
214
+# If -v has been used then display our version number
 
215
+# and then echo the command we are about to invoke.
 
216
+case " $* " in
 
217
+  *\ -v\ *)
 
218
+    echo "$invoked $version"
 
219
+    echo $original $*
 
220
+    ;;
 
221
+esac
 
222
 
 
223
+if test -x $original; then
 
224
+  exec "$original" ${1+"$@"}
 
225
+else
 
226
+  echo "$invoked: unable to locate executable: $original"
 
227
+  exit 1
 
228
+fi
 
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
 
236
 
 
237
+fuse-ld=
 
238
+Common Joined Undocumented
 
239
+
 
240
 fvar-tracking
 
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
 
247
@@ -766,6 +766,8 @@
 
248
 main (int argc, char **argv)
 
249
 {
 
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";
 
256
@@ -784,6 +786,10 @@
 
257
 
 
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 =
 
267
@@ -798,6 +804,8 @@
 
268
     concat (target_machine, "-", gstrip_suffix, NULL);
 
269
 #else
 
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;
 
275
 #ifdef LDD_SUFFIX
 
276
@@ -818,6 +826,12 @@
 
277
   const char **c_ptr;
 
278
   char **ld1_argv;
 
279
   const char **ld1;
 
280
+  enum linker_select
 
281
+  {
 
282
+    DFLT_LINKER,
 
283
+    GOLD_LINKER,
 
284
+    BFD_LINKER
 
285
+  } selected_linker = DFLT_LINKER;
 
286
   char **ld2_argv;
 
287
   const char **ld2;
 
288
   char **object_lst;
 
289
@@ -875,6 +890,10 @@
 
290
       {
 
291
        if (! strcmp (argv[i], "-debug"))
 
292
          debug = 1;
 
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;
 
297
       }
 
298
     vflag = debug;
 
299
   }
 
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)
 
308
+      {
 
309
+      default:
 
310
+      case DFLT_LINKER:
 
311
+       ld_file_name = find_a_file (&cpath, ld_suffix);
 
312
+       break;
 
313
+      case GOLD_LINKER:
 
314
+       ld_file_name = find_a_file (&cpath, gold_suffix);
 
315
+       break;
 
316
+      case BFD_LINKER:
 
317
+       ld_file_name = find_a_file (&cpath, bfd_ld_suffix);
 
318
+       break;
 
319
+      }
 
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)
 
326
+      {
 
327
+      default:
 
328
+      case DFLT_LINKER:
 
329
+       ld_file_name = find_a_file (&path, full_ld_suffix);
 
330
+       break;
 
331
+      case GOLD_LINKER:
 
332
+       ld_file_name = find_a_file (&path, full_gold_suffix);
 
333
+       break;
 
334
+      case BFD_LINKER:
 
335
+       ld_file_name = find_a_file (&path, full_bfd_ld_suffix);
 
336
+       break;
 
337
+      }
 
338
 
 
339
+  if ((vflag || debug) && ld_file_name == NULL)
 
340
+    {
 
341
+      struct prefix_list * p;
 
342
+      const char * s;
 
343
+
 
344
+      notice ("collect2: warning: unable to find linker.\n");
 
345
+
 
346
+#ifdef DEFAULT_LINKER
 
347
+      notice (" Searched for this absolute executable:\n");
 
348
+      notice (" %s\n", DEFAULT_LINKER);
 
349
+#endif
 
350
+
 
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)
 
358
+      {
 
359
+      default:
 
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;
 
363
+      }
 
364
+      notice ("  %s\n", s);
 
365
+
 
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);
 
372
+#endif
 
373
+      switch (selected_linker)
 
374
+      {
 
375
+      default:
 
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;
 
379
+      }
 
380
+      notice ("  %s\n", s);
 
381
+    }
 
382
+
 
383
 #ifdef REAL_NM_FILE_NAME
 
384
   nm_file_name = find_a_file (&path, REAL_NM_FILE_NAME);
 
385
   if (nm_file_name == 0)
 
386
Index: configure.ac
 
387
===================================================================
 
388
--- a/src/configure.ac  (revision
 
389
+++ b/src/configure.ac  (working
 
390
@@ -165,7 +165,7 @@
 
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"
 
397
 
 
398
 # libgcj represents the runtime libraries only used by gcj.
 
399
@@ -294,37 +294,57 @@
 
400
 esac
 
401
 
 
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
 
408
 
 
409
 AC_ARG_ENABLE(gold,
 
410
-[  --enable-gold           use gold instead of ld],
 
411
+[  --enable-gold[[=ARG]]     build gold [[ARG={both}[[/{gold,ld}]]]]],
 
412
 ENABLE_GOLD=$enableval,
 
413
 ENABLE_GOLD=no)
 
414
-if test "${ENABLE_GOLD}" = "yes"; then
 
415
-  # Check for ELF target.
 
416
-  is_elf=no
 
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.
 
424
+    is_elf=no
 
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*)
 
431
+            ;;
 
432
+          *)
 
433
+            is_elf=yes
 
434
+            ;;
 
435
+        esac
 
436
+    esac
 
437
+
 
438
+    if test "$is_elf" = "yes"; then
 
439
+      # Check for target supported by gold.
 
440
       case "${target}" in
 
441
-        *-*-linux*aout* | *-*-linux*oldld*)
 
442
+        i?86-*-* | x86_64-*-* | sparc*-*-* | powerpc*-*-* | arm*-*-*)
 
443
+         case "${ENABLE_GOLD}" in 
 
444
+         both*)
 
445
+            configdirs="$configdirs gold"
 
446
+           ;;
 
447
+         *)
 
448
+            configdirs="`echo " ${configdirs} " | sed -e 's/ ld / gold /'`"
 
449
+           ;;
 
450
+         esac
 
451
+         ENABLE_GOLD=yes
 
452
           ;;
 
453
-        *)
 
454
-          is_elf=yes
 
455
-          ;;
 
456
       esac
 
457
+    fi
 
458
+    ;;
 
459
+  no)
 
460
+    ;;
 
461
+  *)
 
462
+    AC_MSG_ERROR([invalid --enable-gold argument])
 
463
+    ;;
 
464
   esac
 
465
 
 
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 /'`"
 
471
-        ;;
 
472
-    esac
 
473
-  fi
 
474
-fi
 
475
-
 
476
 # Configure extra directories which are host specific
 
477
 
 
478
 case "${host}" in