~ubuntu-branches/ubuntu/precise/gccgo-4.7/precise

« back to all changes in this revision

Viewing changes to debian/patches/gcc-multiarch.diff

  • Committer: Package Import Robot
  • Author(s): Matthias Klose
  • Date: 2012-03-11 19:37:32 UTC
  • Revision ID: package-import@ubuntu.com-20120311193732-ty08ntcphseuouao
Tags: 4.7.0~rc1-0ubuntu1
* Build standalone gccgo-4.7 packages.
* libgo: Work around parse error of struct timex_ on ARM.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# DP: Add multiarch support to GCC.
 
2
# DP:
 
3
# DP: Convert the multilib option to a target triplet,
 
4
# DP: add multiarch include directories and libraries path:
 
5
# DP:   /usr/local/include/<arch>-linux-gnu
 
6
# DP:   /usr/include/<arch>-linux-gnu
 
7
# DP:   /usr/lib/<arch>-linux-gnu
 
8
# DP: to the system paths.
 
9
 
 
10
2011-08-18  Matthias Klose  <doko@ubuntu.com>
 
11
 
 
12
        * doc/invoke.texi: Document -print-multiarch.
 
13
        * Makefile.in (s-mlib): Pass MULTIARCH_DIRNAME to genmultilib.
 
14
        * genmultilib: Add new option for the multiarch name.
 
15
        * gcc.c (multiarch_dir): Define.
 
16
        (for_each_path): Search for multiarch suffixes.
 
17
        (driver_handle_option): Handle multiarch option.
 
18
        (do_spec_1): Pass -imultiarch if defined.
 
19
        (main): Print multiarch.
 
20
        (set_multilib_dir): Separate multilib and multiarch names
 
21
        from multilib_select.
 
22
        (print_multilib_info): Ignore multiarch names in multilib_select.
 
23
        * incpath.c (add_standard_paths): Search the multiarch include dirs.
 
24
        * cppdeault.h (default_include): Document multiarch in multilib
 
25
        member.
 
26
        * cppdefault.c: [LOCAL_INCLUDE_DIR, STANDARD_INCLUDE_DIR] Add an
 
27
        include directory for multiarch directories.
 
28
        * common.opt: New options --print-multiarch and -imultilib.
 
29
        * config/s390/t-linux64: Add multiarch names in MULTILIB_OSDIRNAMES.
 
30
        * config/sparc/t-linux64: Likewise.
 
31
        * config/powerpc/t-linux64: Likewise.
 
32
        * config/i386/t-linux64: Likewise.
 
33
        * config/mips/t-linux64: Likewise.
 
34
        * config/alpha/t-linux: Define MULTIARCH_DIRNAME.
 
35
        * config/arm/t-linux: Likewise.
 
36
        * config/i386/t-linux: Likewise.
 
37
        * config/pa/t-linux: Likewise.
 
38
        * config/sparc/t-linux: Likewise.
 
39
        * config/ia64/t-glibc: Define MULTIARCH_DIRNAME for linux target.
 
40
 
 
41
 
 
42
--- a/src/gcc/incpath.c (revision 182390)
 
43
+++ b/src/gcc/incpath.c (working copy)
 
44
@@ -150,8 +150,14 @@
 
45
              if (!filename_ncmp (p->fname, cpp_GCC_INCLUDE_DIR, len))
 
46
                {
 
47
                  char *str = concat (iprefix, p->fname + len, NULL);
 
48
-                 if (p->multilib && imultilib)
 
49
+                 if (p->multilib == 1 && imultilib)
 
50
                    str = concat (str, dir_separator_str, imultilib, NULL);
 
51
+                 else if (p->multilib == 2)
 
52
+                   {
 
53
+                     if (!imultiarch)
 
54
+                       continue;
 
55
+                     str = concat (str, dir_separator_str, imultiarch, NULL);
 
56
+                   }
 
57
                  add_path (str, SYSTEM, p->cxx_aware, false);
 
58
                }
 
59
            }
 
60
@@ -195,8 +201,14 @@
 
61
          else
 
62
            str = update_path (p->fname, p->component);
 
63
 
 
64
-         if (p->multilib && imultilib)
 
65
+         if (p->multilib == 1 && imultilib)
 
66
            str = concat (str, dir_separator_str, imultilib, NULL);
 
67
+         else if (p->multilib == 2)
 
68
+           {
 
69
+             if (!imultiarch)
 
70
+               continue;
 
71
+             str = concat (str, dir_separator_str, imultiarch, NULL);
 
72
+           }
 
73
 
 
74
          add_path (str, SYSTEM, p->cxx_aware, false);
 
75
        }
 
76
--- a/src/gcc/gcc.c     (revision 182390)
 
77
+++ b/src/gcc/gcc.c     (working copy)
 
78
@@ -1147,6 +1147,11 @@
 
79
    set_multilib_dir based on the compilation options.  */
 
80
 
 
81
 static const char *multilib_os_dir;
 
82
+
 
83
+/* Subdirectory to use for locating libraries in multiarch conventions.  Set by
 
84
+   set_multilib_dir based on the compilation options.  */
 
85
+
 
86
+static const char *multiarch_dir;
 
87
 
 
88
 /* Structure to keep track of the specs that have been defined so far.
 
89
    These are accessed using %(specname) in a compiler or link
 
90
@@ -2072,6 +2077,7 @@
 
91
   struct prefix_list *pl;
 
92
   const char *multi_dir = NULL;
 
93
   const char *multi_os_dir = NULL;
 
94
+  const char *multiarch_suffix = NULL;
 
95
   const char *multi_suffix;
 
96
   const char *just_multi_suffix;
 
97
   char *path = NULL;
 
98
@@ -2089,11 +2095,14 @@
 
99
     }
 
100
   if (do_multi && multilib_os_dir && strcmp (multilib_os_dir, ".") != 0)
 
101
     multi_os_dir = concat (multilib_os_dir, dir_separator_str, NULL);
 
102
+  if (multiarch_dir)
 
103
+    multiarch_suffix = concat (multiarch_dir, dir_separator_str, NULL);
 
104
 
 
105
   while (1)
 
106
     {
 
107
       size_t multi_dir_len = 0;
 
108
       size_t multi_os_dir_len = 0;
 
109
+      size_t multiarch_len = 0;
 
110
       size_t suffix_len;
 
111
       size_t just_suffix_len;
 
112
       size_t len;
 
113
@@ -2102,16 +2111,15 @@
 
114
        multi_dir_len = strlen (multi_dir);
 
115
       if (multi_os_dir)
 
116
        multi_os_dir_len = strlen (multi_os_dir);
 
117
+      if (multiarch_suffix)
 
118
+       multiarch_len = strlen (multiarch_suffix);
 
119
       suffix_len = strlen (multi_suffix);
 
120
       just_suffix_len = strlen (just_multi_suffix);
 
121
 
 
122
       if (path == NULL)
 
123
        {
 
124
          len = paths->max_len + extra_space + 1;
 
125
-         if (suffix_len > multi_os_dir_len)
 
126
-           len += suffix_len;
 
127
-         else
 
128
-           len += multi_os_dir_len;
 
129
+         len += MAX (MAX (suffix_len, multi_os_dir_len), multiarch_len);
 
130
          path = XNEWVEC (char, len);
 
131
        }
 
132
 
 
133
@@ -2140,6 +2148,16 @@
 
134
                break;
 
135
            }
 
136
 
 
137
+         /* Now try the multiarch path.  */
 
138
+         if (!skip_multi_dir
 
139
+             && !pl->require_machine_suffix && multiarch_dir)
 
140
+           {
 
141
+             memcpy (path + len, multiarch_suffix, multiarch_len + 1);
 
142
+             ret = callback (path, callback_info);
 
143
+             if (ret)
 
144
+               break;
 
145
+           }
 
146
+
 
147
          /* Now try the base path.  */
 
148
          if (!pl->require_machine_suffix
 
149
              && !(pl->os_multilib ? skip_multi_os_dir : skip_multi_dir))
 
150
@@ -3228,6 +3246,7 @@
 
151
     case OPT_print_multi_directory:
 
152
     case OPT_print_sysroot:
 
153
     case OPT_print_multi_os_directory:
 
154
+    case OPT_print_multiarch:
 
155
     case OPT_print_sysroot_headers_suffix:
 
156
     case OPT_time:
 
157
     case OPT_wrapper:
 
158
@@ -4880,6 +4899,15 @@
 
159
                  do_spec_1 (" ", 0, NULL);
 
160
                }
 
161
 
 
162
+             if (multiarch_dir)
 
163
+               {
 
164
+                 do_spec_1 ("-imultiarch", 1, NULL);
 
165
+                 /* Make this a separate argument.  */
 
166
+                 do_spec_1 (" ", 0, NULL);
 
167
+                 do_spec_1 (multiarch_dir, 1, NULL);
 
168
+                 do_spec_1 (" ", 0, NULL);
 
169
+               }
 
170
+
 
171
              if (gcc_exec_prefix)
 
172
                {
 
173
                  do_spec_1 ("-iprefix", 1, NULL);
 
174
@@ -6497,6 +6525,15 @@
 
175
       return (0);
 
176
     }
 
177
 
 
178
+  if (print_multiarch)
 
179
+    {
 
180
+      if (multiarch_dir == NULL)
 
181
+       printf ("\n");
 
182
+      else
 
183
+       printf ("%s\n", multiarch_dir);
 
184
+      return (0);
 
185
+    }
 
186
+
 
187
   if (print_sysroot)
 
188
     {
 
189
       if (target_system_root)
 
190
@@ -7472,10 +7509,26 @@
 
191
            q++;
 
192
          if (q < end)
 
193
            {
 
194
-             char *new_multilib_os_dir = XNEWVEC (char, end - q);
 
195
+             const char *q2 = q + 1;
 
196
+             char *new_multilib_os_dir;
 
197
+
 
198
+             while (q2 < end && *q2 != ':')
 
199
+               q2++;
 
200
+             if (*q2 == ':')
 
201
+               end = q2;
 
202
+             new_multilib_os_dir = XNEWVEC (char, end - q);
 
203
              memcpy (new_multilib_os_dir, q + 1, end - q - 1);
 
204
              new_multilib_os_dir[end - q - 1] = '\0';
 
205
-             multilib_os_dir = new_multilib_os_dir;
 
206
+             multilib_os_dir = *new_multilib_os_dir ? new_multilib_os_dir : ".";
 
207
+
 
208
+             end = this_path + this_path_len;
 
209
+             if (q2 < end && *q2 == ':')
 
210
+               {
 
211
+                 char *new_multiarch_dir = XNEWVEC (char, end - q2);
 
212
+                 memcpy (new_multiarch_dir, q2 + 1, end - q2 - 1);
 
213
+                 new_multiarch_dir[end - q2 - 1] = '\0';
 
214
+                 multiarch_dir = new_multiarch_dir;
 
215
+               }
 
216
              break;
 
217
            }
 
218
        }
 
219
@@ -7537,7 +7590,7 @@
 
220
       /* When --disable-multilib was used but target defines
 
221
         MULTILIB_OSDIRNAMES, entries starting with .: are there just
 
222
         to find multilib_os_dir, so skip them from output.  */
 
223
-      if (this_path[0] == '.' && this_path[1] == ':')
 
224
+      if (this_path[0] == '.' && this_path[1] == ':' && this_path[2] != ':')
 
225
        skip = 1;
 
226
 
 
227
       /* Check for matches with the multilib_exclusions. We don't bother
 
228
--- a/src/gcc/genmultilib       (revision 182390)
 
229
+++ b/src/gcc/genmultilib       (working copy)
 
230
@@ -73,6 +73,8 @@
 
231
 # the os directory names are used exclusively.  Use the mapping when
 
232
 # there is no one-to-one equivalence between GCC levels and the OS.
 
233
 
 
234
+# The optional eight argument is the multiarch name.
 
235
+
 
236
 # The last option should be "yes" if multilibs are enabled.  If it is not
 
237
 # "yes", all GCC multilib dir names will be ".".
 
238
 
 
239
@@ -121,7 +123,8 @@
 
240
 extra=$5
 
241
 exclusions=$6
 
242
 osdirnames=$7
 
243
-enable_multilib=$8
 
244
+multiarch=$8
 
245
+enable_multilib=$9
 
246
 
 
247
 echo "static const char *const multilib_raw[] = {"
 
248
 
 
249
@@ -222,6 +225,9 @@
 
250
 # names.
 
251
 toosdirnames=
 
252
 defaultosdirname=
 
253
+if [ -n "${multiarch}" ]; then
 
254
+  defaultosdirname=::${multiarch}
 
255
+fi
 
256
 if [ -n "${osdirnames}" ]; then
 
257
   set x ${osdirnames}
 
258
   shift
 
259
@@ -229,6 +235,9 @@
 
260
     case "$1" in
 
261
       .=*)
 
262
         defaultosdirname=`echo $1 | sed 's|^.=|:|'`
 
263
+       if [ -n "${multiarch}" ]; then
 
264
+         defaultosdirname=${defaultosdirname}:${multiarch}
 
265
+       fi
 
266
        shift
 
267
        ;;
 
268
       *=*)
 
269
@@ -314,13 +323,13 @@
 
270
     dirout=`echo ${combo} | sed -e 's/=/-/g'`
 
271
   fi
 
272
   # Remove the leading and trailing slashes.
 
273
-  dirout=`echo ${dirout} | sed -e 's|^/||' -e 's|/$||g'`
 
274
+  dirout=`echo ${dirout} | sed -e 's|^/||' -e 's|/*:/*|:|' -e 's|/$||g'`
 
275
 
 
276
   # Use the OS directory names rather than the option names.
 
277
   if [ -n "${toosdirnames}" ]; then
 
278
     osdirout=`echo ${combo} | sed ${toosdirnames}`
 
279
     # Remove the leading and trailing slashes.
 
280
-    osdirout=`echo ${osdirout} | sed -e 's|^/||' -e 's|/$||g'`
 
281
+    osdirout=`echo ${osdirout} | sed -e 's|^/||' -e 's|/*:/*|:|' -e 's|/$||g'`
 
282
     if [ "x${enable_multilib}" != xyes ]; then
 
283
       dirout=".:${osdirout}"
 
284
       disable_multilib=yes
 
285
--- a/src/gcc/configure.ac      (revision 182390)
 
286
+++ b/src/gcc/configure.ac      (working copy)
 
287
@@ -620,6 +620,21 @@
 
288
 [], [enable_multilib=yes])
 
289
 AC_SUBST(enable_multilib)
 
290
 
 
291
+# Determine whether or not multiarch is enabled.
 
292
+AC_ARG_ENABLE(multiarch,
 
293
+[AS_HELP_STRING([--enable-multiarch],
 
294
+               [enable support for multiarch paths])],
 
295
+[case "${withval}" in
 
296
+yes|no|auto-detect) enable_multiarch=$withval;;
 
297
+*) AC_MSG_ERROR(bad value ${withval} given for --enable-multiarch option) ;;
 
298
+esac], [enable_multiarch=auto-detect])
 
299
+AC_MSG_CHECKING(for multiarch configuration)
 
300
+AC_SUBST(enable_multiarch)
 
301
+AC_MSG_RESULT($enable_multiarch)
 
302
+
 
303
+# needed for setting the multiarch name on ARM
 
304
+AC_SUBST(with_float)
 
305
+
 
306
 # Enable __cxa_atexit for C++.
 
307
 AC_ARG_ENABLE(__cxa_atexit,
 
308
 [AS_HELP_STRING([--enable-__cxa_atexit], [enable __cxa_atexit for C++])],
 
309
--- a/src/gcc/cppdefault.c      (revision 182390)
 
310
+++ b/src/gcc/cppdefault.c      (working copy)
 
311
@@ -60,6 +60,7 @@
 
312
 #endif
 
313
 #ifdef LOCAL_INCLUDE_DIR
 
314
     /* /usr/local/include comes before the fixincluded header files.  */
 
315
+    { LOCAL_INCLUDE_DIR, 0, 0, 1, 1, 2 },
 
316
     { LOCAL_INCLUDE_DIR, 0, 0, 1, 1, 0 },
 
317
 #endif
 
318
 #ifdef PREFIX_INCLUDE_DIR
 
319
@@ -87,6 +88,7 @@
 
320
 #endif
 
321
 #ifdef NATIVE_SYSTEM_HEADER_DIR
 
322
     /* /usr/include comes dead last.  */
 
323
+    { NATIVE_SYSTEM_HEADER_DIR, NATIVE_SYSTEM_HEADER_COMPONENT, 0, 0, 1, 2 },
 
324
     { NATIVE_SYSTEM_HEADER_DIR, NATIVE_SYSTEM_HEADER_COMPONENT, 0, 0, 1, 0 },
 
325
 #endif
 
326
     { 0, 0, 0, 0, 0, 0 }
 
327
--- a/src/gcc/cppdefault.h      (revision 182390)
 
328
+++ b/src/gcc/cppdefault.h      (working copy)
 
329
@@ -43,9 +43,11 @@
 
330
                                   C++.  */
 
331
   const char add_sysroot;      /* FNAME should be prefixed by
 
332
                                   cpp_SYSROOT.  */
 
333
-  const char multilib;         /* FNAME should have the multilib path
 
334
-                                  specified with -imultilib
 
335
-                                  appended.  */
 
336
+  const char multilib;         /* FNAME should have appended
 
337
+                                  - the multilib path specified with -imultilib
 
338
+                                    when 1 is passed,
 
339
+                                  - the multiarch path specified with
 
340
+                                    -imultiarch, when 2 is passed.  */
 
341
 };
 
342
 
 
343
 extern const struct default_include cpp_include_defaults[];
 
344
--- a/src/gcc/common.opt        (revision 182390)
 
345
+++ b/src/gcc/common.opt        (working copy)
 
346
@@ -345,6 +345,9 @@
 
347
 -print-multi-os-directory
 
348
 Driver Alias(print-multi-os-directory)
 
349
 
 
350
+-print-multiarch
 
351
+Driver Alias(print-multiarch)
 
352
+
 
353
 -print-prog-name
 
354
 Driver Separate Alias(print-prog-name=)
 
355
 
 
356
@@ -2268,6 +2271,10 @@
 
357
 Common Joined Var(plugindir_string) Init(0)
 
358
 -iplugindir=<dir>      Set <dir> to be the default plugin directory
 
359
 
 
360
+imultiarch
 
361
+Common Joined Separate RejectDriver Var(imultiarch) Init(0)
 
362
+-imultiarch <dir>      Set <dir> to be the multiarch include subdirectory
 
363
+
 
364
 l
 
365
 Driver Joined Separate
 
366
 
 
367
@@ -2325,6 +2332,9 @@
 
368
 
 
369
 print-multi-os-directory
 
370
 Driver Var(print_multi_os_directory)
 
371
 
372
+print-multiarch
 
373
+Driver Var(print_multiarch)
 
374
 
 
375
 print-prog-name=
 
376
 Driver JoinedOrMissing Var(print_prog_name)
 
377
--- a/src/gcc/config.gcc        (revision 182390)
 
378
+++ b/src/gcc/config.gcc        (working copy)
 
379
@@ -1508,7 +1508,7 @@
 
380
        ;;
 
381
 ia64*-*-linux*)
 
382
        tm_file="${tm_file} dbxelf.h elfos.h gnu-user.h linux.h glibc-stdint.h ia64/sysv4.h ia64/linux.h"
 
383
-       tmake_file="${tmake_file} ia64/t-ia64 t-libunwind"
 
384
+       tmake_file="${tmake_file} ia64/t-ia64 ia64/t-glibc t-libunwind"
 
385
        target_cpu_default="MASK_GNU_AS|MASK_GNU_LD"
 
386
        ;;
 
387
 ia64*-*-hpux*)
 
388
@@ -2012,6 +2012,7 @@
 
389
                ;;
 
390
            *)
 
391
                tm_file="${tm_file} rs6000/linux.h glibc-stdint.h"
 
392
+               tmake_file="$tmake_file rs6000/t-linux"
 
393
                ;;
 
394
        esac
 
395
        case ${target} in
 
396
@@ -3467,10 +3468,14 @@
 
397
 
 
398
        i[34567]86-*-darwin* | x86_64-*-darwin*)
 
399
                ;;
 
400
-       i[34567]86-*-linux* | x86_64-*-linux* | \
 
401
-         i[34567]86-*-kfreebsd*-gnu | x86_64-*-kfreebsd*-gnu | \
 
402
-         i[34567]86-*-gnu*)
 
403
+       i[34567]86-*-linux* | x86_64-*-linux*)
 
404
                ;;
 
405
+       i[34567]86-*-kfreebsd*-gnu | x86_64-*-kfreebsd*-gnu)
 
406
+               tmake_file="${tmake_file} i386/t-linux i386/t-kfreebsd"
 
407
+               ;;
 
408
+       i[34567]86-*-gnu*)
 
409
+               tmake_file="${tmake_file} i386/t-linux i386/t-gnu"
 
410
+               ;;
 
411
        i[34567]86-*-solaris2* | x86_64-*-solaris2.1[0-9]*)
 
412
                ;;
 
413
        i[34567]86-*-cygwin* | i[34567]86-*-mingw* | x86_64-*-mingw*)
 
414
--- a/src/gcc/Makefile.in       (revision 182390)
 
415
+++ b/src/gcc/Makefile.in       (working copy)
 
416
@@ -352,6 +352,17 @@
 
417
 
 
418
 enable_plugin = @enable_plugin@
 
419
 
 
420
+# Multiarch support
 
421
+enable_multiarch = @enable_multiarch@
 
422
+with_float = @with_float@
 
423
+ifeq ($(enable_multiarch),yes)
 
424
+  if_multiarch = $(1)
 
425
+else ifeq ($(enable_multiarch),auto-detect)
 
426
+  if_multiarch = $(if $(wildcard $(shell echo $(SYSTEM_HEADER_DIR))/../../usr/lib/*/crti.o),$(1))
 
427
+else
 
428
+  if_multiarch =
 
429
+endif
 
430
+
 
431
 CPPLIB = ../libcpp/libcpp.a
 
432
 CPPINC = -I$(srcdir)/../libcpp/include
 
433
 
 
434
@@ -1832,10 +1843,11 @@
 
435
            "$(MULTILIB_EXTRA_OPTS)" \
 
436
            "$(MULTILIB_EXCLUSIONS)" \
 
437
            "$(MULTILIB_OSDIRNAMES)" \
 
438
+           "$(MULTIARCH_DIRNAME)" \
 
439
            "@enable_multilib@" \
 
440
            > tmp-mlib.h; \
 
441
        else \
 
442
-         $(SHELL) $(srcdir)/genmultilib '' '' '' '' '' '' '' no \
 
443
+         $(SHELL) $(srcdir)/genmultilib '' '' '' '' '' '' '' "$(MULTIARCH_DIRNAME)" no \
 
444
            > tmp-mlib.h; \
 
445
        fi
 
446
        $(SHELL) $(srcdir)/../move-if-change tmp-mlib.h multilib.h
 
447
--- a/src/gcc/config/alpha/t-linux      (revision 0)
 
448
+++ b/src/gcc/config/alpha/t-linux      (revision 0)
 
449
@@ -0,0 +1 @@
 
450
+MULTIARCH_DIRNAME = $(call if_multiarch,alpha-linux-gnu)
 
451
--- a/src/gcc/config/s390/t-linux64     (revision 182390)
 
452
+++ b/src/gcc/config/s390/t-linux64     (working copy)
 
453
@@ -7,4 +7,5 @@
 
454
 
 
455
 MULTILIB_OPTIONS = m64/m31
 
456
 MULTILIB_DIRNAMES = 64 32
 
457
-MULTILIB_OSDIRNAMES = ../lib64 $(if $(wildcard $(shell echo $(SYSTEM_HEADER_DIR))/../../usr/lib32),../lib32,../lib)
 
458
+MULTILIB_OSDIRNAMES = ../lib64$(call if_multiarch,:s390x-linux-gnu)
 
459
+MULTILIB_OSDIRNAMES += $(if $(wildcard $(shell echo $(SYSTEM_HEADER_DIR))/../../usr/lib32),../lib32,../lib)$(call if_multiarch,:s390-linux-gnu)
 
460
--- a/src/gcc/config/sparc/t-linux64    (revision 182390)
 
461
+++ b/src/gcc/config/sparc/t-linux64    (working copy)
 
462
@@ -26,4 +26,5 @@
 
463
 
 
464
 MULTILIB_OPTIONS = m64/m32
 
465
 MULTILIB_DIRNAMES = 64 32
 
466
-MULTILIB_OSDIRNAMES = ../lib64 $(if $(wildcard $(shell echo $(SYSTEM_HEADER_DIR))/../../usr/lib32),../lib32,../lib)
 
467
+MULTILIB_OSDIRNAMES = ../lib64$(call if_multiarch,:sparc64-linux-gnu)
 
468
+MULTILIB_OSDIRNAMES += $(if $(wildcard $(shell echo $(SYSTEM_HEADER_DIR))/../../usr/lib32),../lib32,../lib)$(call if_multiarch,:sparc-linux-gnu)
 
469
--- a/src/gcc/config/sparc/t-linux      (revision 0)
 
470
+++ b/src/gcc/config/sparc/t-linux      (revision 0)
 
471
@@ -0,0 +1 @@
 
472
+MULTIARCH_DIRNAME = $(call if_multiarch,sparc-linux-gnu)
 
473
--- a/src/gcc/config/i386/t-kfreebsd    (revision 0)
 
474
+++ b/src/gcc/config/i386/t-kfreebsd    (revision 0)
 
475
@@ -0,0 +1,5 @@
 
476
+MULTIARCH_DIRNAME = $(call if_multiarch,i386-kfreebsd-gnu)
 
477
+
 
478
+# MULTILIB_OSDIRNAMES are set in t-linux64.
 
479
+KFREEBSD_OS = $(filter kfreebsd%, $(word 3, $(subst -, ,$(target))))
 
480
+MULTILIB_OSDIRNAMES := $(subst linux,$(KFREEBSD_OS),$(MULTILIB_OSDIRNAMES))
 
481
--- a/src/gcc/config/i386/t-gnu (revision 0)
 
482
+++ b/src/gcc/config/i386/t-gnu (revision 0)
 
483
@@ -0,0 +1 @@
 
484
+MULTIARCH_DIRNAME = $(call if_multiarch,i386-gnu)
 
485
--- a/src/gcc/config/i386/t-linux       (revision 0)
 
486
+++ b/src/gcc/config/i386/t-linux       (revision 0)
 
487
@@ -0,0 +1 @@
 
488
+MULTIARCH_DIRNAME = $(call if_multiarch,i386-linux-gnu)
 
489
--- a/src/gcc/config/i386/t-linux64     (revision 182390)
 
490
+++ b/src/gcc/config/i386/t-linux64     (working copy)
 
491
@@ -34,6 +34,6 @@
 
492
 comma=,
 
493
 MULTILIB_OPTIONS    = $(subst $(comma),/,$(TM_MULTILIB_CONFIG))
 
494
 MULTILIB_DIRNAMES   = $(patsubst m%, %, $(subst /, ,$(MULTILIB_OPTIONS)))
 
495
-MULTILIB_OSDIRNAMES = m64=../lib64
 
496
-MULTILIB_OSDIRNAMES+= m32=$(if $(wildcard $(shell echo $(SYSTEM_HEADER_DIR))/../../usr/lib32),../lib32,../lib)
 
497
+MULTILIB_OSDIRNAMES = m64=../lib64$(call if_multiarch,:x86_64-linux-gnu)
 
498
+MULTILIB_OSDIRNAMES+= m32=$(if $(wildcard $(shell echo $(SYSTEM_HEADER_DIR))/../../usr/lib32),../lib32,../lib)$(call if_multiarch,:i386-linux-gnu)
 
499
 MULTILIB_OSDIRNAMES+= mx32=../libx32
 
500
--- a/src/gcc/config/ia64/t-glibc       (revision 0)
 
501
+++ b/src/gcc/config/ia64/t-glibc       (revision 0)
 
502
@@ -0,0 +1,3 @@
 
503
+ifneq (,$(findstring linux, $(target)))
 
504
+MULTIARCH_DIRNAME = $(call if_multiarch,ia64-linux-gnu)
 
505
+endif
 
506
--- a/src/gcc/config/m68k/t-linux       (revision 182390)
 
507
+++ b/src/gcc/config/m68k/t-linux       (working copy)
 
508
@@ -19,6 +19,8 @@
 
509
 # Only include multilibs for 680x0 and ColdFire CPUs with an MMU.
 
510
 M68K_MLIB_CPU += && ((CPU ~ "^m680") || (CPU ~ "^mcf")) && (FLAGS ~ "FL_MMU")
 
511
 
 
512
+MULTIARCH_DIRNAME = $(call if_multiarch,m68k-linux-gnu)
 
513
+
 
514
 # This rule uses MULTILIB_MATCHES to generate a definition of
 
515
 # SYSROOT_SUFFIX_SPEC.
 
516
 sysroot-suffix.h: $(srcdir)/config/m68k/print-sysroot-suffix.sh
 
517
--- a/src/gcc/config/rs6000/t-spe       (revision 182390)
 
518
+++ b/src/gcc/config/rs6000/t-spe       (working copy)
 
519
@@ -71,3 +71,6 @@
 
520
                          mabi=altivec/mlittle \
 
521
                          maltivec/mlittle \
 
522
                          maltivec/mabi=altivec/mlittle
 
523
+
 
524
+MULTIARCH_DIRNAME = powerpc-linux-gnuspe$(if $(findstring rs6000/e500-double.h, $(tm_file)),,v1)
 
525
+
 
526
--- a/src/gcc/config/rs6000/t-linux64   (revision 182390)
 
527
+++ b/src/gcc/config/rs6000/t-linux64   (working copy)
 
528
@@ -31,5 +31,7 @@
 
529
 MULTILIB_EXTRA_OPTS     = fPIC mstrict-align
 
530
 MULTILIB_EXCEPTIONS     = m64/msoft-float
 
531
 MULTILIB_EXCLUSIONS     = m64/!m32/msoft-float
 
532
-MULTILIB_OSDIRNAMES    = ../lib64 $(if $(wildcard $(shell echo $(SYSTEM_HEADER_DIR))/../../usr/lib32),../lib32,../lib) nof
 
533
+MULTILIB_OSDIRNAMES    = ../lib64$(call if_multiarch,:powerpc64-linux-gnu)
 
534
+MULTILIB_OSDIRNAMES    += $(if $(wildcard $(shell echo $(SYSTEM_HEADER_DIR))/../../usr/lib32),../lib32,../lib)$(call if_multiarch,:powerpc-linux-gnu)
 
535
+MULTILIB_OSDIRNAMES    += nof
 
536
 MULTILIB_MATCHES        = $(MULTILIB_MATCHES_FLOAT)
 
537
--- a/src/gcc/config/rs6000/t-linux     (revision 0)
 
538
+++ b/src/gcc/config/rs6000/t-linux     (revision 0)
 
539
@@ -0,0 +1 @@
 
540
+MULTIARCH_DIRNAME = powerpc-linux-gnu
 
541
--- a/src/gcc/config/arm/t-linux-eabi   (revision 182390)
 
542
+++ b/src/gcc/config/arm/t-linux-eabi   (working copy)
 
543
@@ -24,3 +24,6 @@
 
544
 #MULTILIB_OPTIONS     += mcpu=fa606te/mcpu=fa626te/mcpu=fmp626/mcpu=fa726te
 
545
 #MULTILIB_DIRNAMES    += fa606te fa626te fmp626 fa726te
 
546
 #MULTILIB_EXCEPTIONS  += *mthumb/*mcpu=fa606te *mthumb/*mcpu=fa626te *mthumb/*mcpu=fmp626 *mthumb/*mcpu=fa726te*
 
547
+
 
548
+ARM_EB = $(if $(findstring TARGET_BIG_ENDIAN_DEFAULT=1, $(tm_defines)),eb)
 
549
+MULTIARCH_DIRNAME = $(call if_multiarch,arm$(ARM_EB)-linux-gnueabi$(if $(filter hard,$(with_float)),hf))
 
550
--- a/src/gcc/config/pa/t-linux (revision 0)
 
551
+++ b/src/gcc/config/pa/t-linux (revision 0)
 
552
@@ -0,0 +1 @@
 
553
+MULTIARCH_DIRNAME = $(call if_multiarch,hppa-linux-gnu)
 
554
--- a/src/gcc/config/mips/t-linux64     (revision 182390)
 
555
+++ b/src/gcc/config/mips/t-linux64     (working copy)
 
556
@@ -18,4 +18,9 @@
 
557
 
 
558
 MULTILIB_OPTIONS = mabi=n32/mabi=32/mabi=64
 
559
 MULTILIB_DIRNAMES = n32 32 64
 
560
-MULTILIB_OSDIRNAMES = ../lib32 ../lib ../lib64
 
561
+MIPS_EL = $(if $(filter %el, $(firstword $(subst -, ,$(target)))),el)
 
562
+MIPS_SOFT = $(if $(filter MASK_SOFT_FLOAT_ABI, $(target_cpu_default)),soft)
 
563
+MULTILIB_OSDIRNAMES = \
 
564
+       ../lib32$(call if_multiarch,:mips64$(MIPS_EL)-linux-gnuabin32$(MIPS_SOFT)) \
 
565
+       ../lib$(call if_multiarch,:mips$(MIPS_EL)-linux-gnu$(MIPS_SOFT)) \
 
566
+       ../lib64$(call if_multiarch,:mips64$(MIPS_EL)-linux-gnuabi64$(MIPS_SOFT))
 
567
--- a/src/libstdc++-v3/python/hook.in
 
568
+++ b/src/libstdc++-v3/python/hook.in
 
569
@@ -47,7 +47,10 @@
 
570
     libdir = libdir[len (prefix):]
 
571
 
 
572
     # Compute the ".."s needed to get from libdir to the prefix.
 
573
-    dotdots = ('..' + os.sep) * len (libdir.split (os.sep))
 
574
+    backdirs = len (libdir.split (os.sep))
 
575
+    if not os.path.basename(os.path.dirname(__file__)).startswith('lib'):
 
576
+        backdirs += 1 # multiarch subdir
 
577
+    dotdots = ('..' + os.sep) * backdirs
 
578
 
 
579
     objfile = gdb.current_objfile ().filename
 
580
     dir_ = os.path.join (os.path.dirname (objfile), dotdots, pythondir)