/usr/src/gcc-4.9/debian/patches/gcc-multilib-multiarch.diff is in gcc-4.9-source 4.9.3-13ubuntu2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 | # DP: Don't auto-detect multilib osdirnames.
Index: b/src/gcc/config/sparc/t-linux64
===================================================================
--- a/src/gcc/config/sparc/t-linux64
+++ b/src/gcc/config/sparc/t-linux64
@@ -25,7 +25,12 @@
MULTILIB_OPTIONS = m64/m32
MULTILIB_DIRNAMES = 64 32
+ifneq (,$(findstring sparc64,$(target)))
+MULTILIB_OSDIRNAMES = ../lib$(call if_multiarch,:sparc64-linux-gnu)
+MULTILIB_OSDIRNAMES += ../lib32$(call if_multiarch,:sparc-linux-gnu)
+else
MULTILIB_OSDIRNAMES = ../lib64$(call if_multiarch,:sparc64-linux-gnu)
-MULTILIB_OSDIRNAMES += $(if $(wildcard $(shell echo $(SYSTEM_HEADER_DIR))/../../usr/lib32),../lib32,../lib)$(call if_multiarch,:sparc-linux-gnu)
+MULTILIB_OSDIRNAMES += ../lib$(call if_multiarch,:sparc-linux-gnu)
+endif
MULTIARCH_DIRNAME = $(call if_multiarch,sparc$(if $(findstring 64,$(target)),64)-linux-gnu)
Index: b/src/gcc/config/s390/t-linux64
===================================================================
--- a/src/gcc/config/s390/t-linux64
+++ b/src/gcc/config/s390/t-linux64
@@ -7,7 +7,12 @@
MULTILIB_OPTIONS = m64/m31
MULTILIB_DIRNAMES = 64 32
+ifneq (,$(findstring s390x,$(target)))
+MULTILIB_OSDIRNAMES = ../lib$(call if_multiarch,:s390x-linux-gnu)
+MULTILIB_OSDIRNAMES += ../lib32$(call if_multiarch,:s390-linux-gnu)
+else
MULTILIB_OSDIRNAMES = ../lib64$(call if_multiarch,:s390x-linux-gnu)
-MULTILIB_OSDIRNAMES += $(if $(wildcard $(shell echo $(SYSTEM_HEADER_DIR))/../../usr/lib32),../lib32,../lib)$(call if_multiarch,:s390-linux-gnu)
+MULTILIB_OSDIRNAMES += ../lib$(call if_multiarch,:s390-linux-gnu)
+endif
MULTIARCH_DIRNAME = $(call if_multiarch,s390$(if $(findstring s390x,$(target)),x)-linux-gnu)
Index: b/src/gcc/config/rs6000/t-linux64
===================================================================
--- a/src/gcc/config/rs6000/t-linux64
+++ b/src/gcc/config/rs6000/t-linux64
@@ -28,8 +28,13 @@
MULTILIB_OPTIONS := m64/m32
MULTILIB_DIRNAMES := 64 32
MULTILIB_EXTRA_OPTS :=
+ifneq (,$(findstring powerpc64,$(target)))
+MULTILIB_OSDIRNAMES := m64=../lib$(call if_multiarch,:powerpc64-linux-gnu)
+MULTILIB_OSDIRNAMES += m32=../lib32$(call if_multiarch,:powerpc-linux-gnu)
+else
MULTILIB_OSDIRNAMES := m64=../lib64$(call if_multiarch,:powerpc64-linux-gnu)
-MULTILIB_OSDIRNAMES += m32=$(if $(wildcard $(shell echo $(SYSTEM_HEADER_DIR))/../../usr/lib32),../lib32,../lib)$(call if_multiarch,:powerpc-linux-gnu)
+MULTILIB_OSDIRNAMES += m32=../lib$(call if_multiarch,:powerpc-linux-gnu)
+endif
MULTIARCH_DIRNAME = $(call if_multiarch,powerpc$(if $(findstring 64,$(target)),64)-linux-gnu)
Index: b/src/gcc/config/i386/t-linux64
===================================================================
--- a/src/gcc/config/i386/t-linux64
+++ b/src/gcc/config/i386/t-linux64
@@ -33,9 +33,19 @@
comma=,
MULTILIB_OPTIONS = $(subst $(comma),/,$(TM_MULTILIB_CONFIG))
MULTILIB_DIRNAMES = $(patsubst m%, %, $(subst /, ,$(MULTILIB_OPTIONS)))
+ifneq (,$(findstring gnux32,$(target)))
MULTILIB_OSDIRNAMES = m64=../lib64$(call if_multiarch,:x86_64-linux-gnu)
-MULTILIB_OSDIRNAMES+= m32=$(if $(wildcard $(shell echo $(SYSTEM_HEADER_DIR))/../../usr/lib32),../lib32,../lib)$(call if_multiarch,:i386-linux-gnu)
+MULTILIB_OSDIRNAMES+= m32=../lib32$(call if_multiarch,:i386-linux-gnu)
+MULTILIB_OSDIRNAMES+= mx32=../lib$(call if_multiarch,:x86_64-linux-gnux32)
+else ifneq (,$(findstring x86_64,$(target)))
+MULTILIB_OSDIRNAMES = m64=../lib$(call if_multiarch,:x86_64-linux-gnu)
+MULTILIB_OSDIRNAMES+= m32=../lib32$(call if_multiarch,:i386-linux-gnu)
MULTILIB_OSDIRNAMES+= mx32=../libx32$(call if_multiarch,:x86_64-linux-gnux32)
+else
+MULTILIB_OSDIRNAMES = m64=../lib64$(call if_multiarch,:x86_64-linux-gnu)
+MULTILIB_OSDIRNAMES+= m32=../lib$(call if_multiarch,:i386-linux-gnu)
+MULTILIB_OSDIRNAMES+= mx32=../libx32$(call if_multiarch,:x86_64-linux-gnux32)
+endif
ifneq (,$(findstring x86_64,$(target)))
ifneq (,$(findstring biarchx32.h,$(tm_include_list)))
Index: b/src/gcc/config/mips/t-linux64
===================================================================
--- a/src/gcc/config/mips/t-linux64
+++ b/src/gcc/config/mips/t-linux64
@@ -20,10 +20,23 @@
MULTILIB_DIRNAMES = n32 32 64
MIPS_EL = $(if $(filter %el, $(firstword $(subst -, ,$(target)))),el)
MIPS_SOFT = $(if $(strip $(filter MASK_SOFT_FLOAT_ABI, $(target_cpu_default)) $(filter soft, $(with_float))),soft)
+
+ifneq (,$(findstring gnuabi64,$(target)))
+MULTILIB_OSDIRNAMES = \
+ ../lib32$(call if_multiarch,:mips64$(MIPS_EL)-linux-gnuabin32$(MIPS_SOFT)) \
+ ../libo32$(call if_multiarch,:mips$(MIPS_EL)-linux-gnu$(MIPS_SOFT)) \
+ ../lib$(call if_multiarch,:mips64$(MIPS_EL)-linux-gnuabi64$(MIPS_SOFT))
+else ifneq (,$(findstring gnuabin32,$(target)))
+MULTILIB_OSDIRNAMES = \
+ ../lib$(call if_multiarch,:mips64$(MIPS_EL)-linux-gnuabin32$(MIPS_SOFT)) \
+ ../libo32$(call if_multiarch,:mips$(MIPS_EL)-linux-gnu$(MIPS_SOFT)) \
+ ../lib64$(call if_multiarch,:mips64$(MIPS_EL)-linux-gnuabi64$(MIPS_SOFT))
+else
MULTILIB_OSDIRNAMES = \
../lib32$(call if_multiarch,:mips64$(MIPS_EL)-linux-gnuabin32$(MIPS_SOFT)) \
../lib$(call if_multiarch,:mips$(MIPS_EL)-linux-gnu$(MIPS_SOFT)) \
../lib64$(call if_multiarch,:mips64$(MIPS_EL)-linux-gnuabi64$(MIPS_SOFT))
+endif
ifneq (,$(findstring abin32,$(target)))
MULTIARCH_DIRNAME = $(call if_multiarch,mips64$(MIPS_EL)-linux-gnuabin32$(MIPS_SOFT))
|