1From aacfd6e14dd583b1fdc65691def61c5e1bc89708 Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Fri, 29 Mar 2013 09:24:50 +0400
4Subject: [PATCH] Define GLIBC_DYNAMIC_LINKER and UCLIBC_DYNAMIC_LINKER
5 relative to SYSTEMLIBS_DIR
6
7This patch defines GLIBC_DYNAMIC_LINKER and UCLIBC_DYNAMIC_LINKER
8relative to SYSTEMLIBS_DIR which can be set in generated headers
9This breaks the assumption of hardcoded multilib in gcc
10Change is only for the supported architectures in OE including
11SH, sparc, alpha for possible future support (if any)
12
13Removes the do_headerfix task in metadata
14
15Upstream-Status: Inappropriate [OE configuration]
16Signed-off-by: Khem Raj <raj.khem@gmail.com>
17---
18 gcc/config/aarch64/aarch64-linux.h |  4 ++--
19 gcc/config/alpha/linux-elf.h       |  4 ++--
20 gcc/config/arm/linux-eabi.h        |  6 +++---
21 gcc/config/arm/linux-elf.h         |  2 +-
22 gcc/config/i386/linux.h            |  4 ++--
23 gcc/config/i386/linux64.h          | 12 ++++++------
24 gcc/config/linux.h                 |  8 ++++----
25 gcc/config/loongarch/gnu-user.h    |  4 ++--
26 gcc/config/microblaze/linux.h      |  4 ++--
27 gcc/config/mips/linux.h            | 18 +++++++++---------
28 gcc/config/nios2/linux.h           |  4 ++--
29 gcc/config/riscv/linux.h           |  4 ++--
30 gcc/config/rs6000/linux64.h        | 15 +++++----------
31 gcc/config/rs6000/sysv4.h          |  4 ++--
32 gcc/config/s390/linux.h            |  8 ++++----
33 gcc/config/sh/linux.h              |  4 ++--
34 gcc/config/sparc/linux.h           |  2 +-
35 gcc/config/sparc/linux64.h         |  4 ++--
36 18 files changed, 53 insertions(+), 58 deletions(-)
37
38diff --git a/gcc/config/aarch64/aarch64-linux.h b/gcc/config/aarch64/aarch64-linux.h
39index 4277f03da2a..e4c92c03291 100644
40--- a/gcc/config/aarch64/aarch64-linux.h
41+++ b/gcc/config/aarch64/aarch64-linux.h
42@@ -21,10 +21,10 @@
43 #ifndef GCC_AARCH64_LINUX_H
44 #define GCC_AARCH64_LINUX_H
45
46-#define GLIBC_DYNAMIC_LINKER "/lib/ld-linux-aarch64%{mbig-endian:_be}%{mabi=ilp32:_ilp32}.so.1"
47+#define GLIBC_DYNAMIC_LINKER  SYSTEMLIBS_DIR "ld-linux-aarch64%{mbig-endian:_be}%{mabi=ilp32:_ilp32}.so.1"
48
49 #undef MUSL_DYNAMIC_LINKER
50-#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-aarch64%{mbig-endian:_be}%{mabi=ilp32:_ilp32}.so.1"
51+#define MUSL_DYNAMIC_LINKER  SYSTEMLIBS_DIR "ld-musl-aarch64%{mbig-endian:_be}%{mabi=ilp32:_ilp32}.so.1"
52
53 #undef  ASAN_CC1_SPEC
54 #define ASAN_CC1_SPEC "%{%:sanitize(address):-funwind-tables}"
55diff --git a/gcc/config/alpha/linux-elf.h b/gcc/config/alpha/linux-elf.h
56index 03f783f2ad1..4fa02668aa7 100644
57--- a/gcc/config/alpha/linux-elf.h
58+++ b/gcc/config/alpha/linux-elf.h
59@@ -23,8 +23,8 @@ along with GCC; see the file COPYING3.  If not see
60 #define EXTRA_SPECS \
61 { "elf_dynamic_linker", ELF_DYNAMIC_LINKER },
62
63-#define GLIBC_DYNAMIC_LINKER	"/lib/ld-linux.so.2"
64-#define UCLIBC_DYNAMIC_LINKER "/lib/ld-uClibc.so.0"
65+#define GLIBC_DYNAMIC_LINKER	SYSTEMLIBS_DIR "ld-linux.so.2"
66+#define UCLIBC_DYNAMIC_LINKER  SYSTEMLIBS_DIR "ld-uClibc.so.0"
67 #if DEFAULT_LIBC == LIBC_UCLIBC
68 #define CHOOSE_DYNAMIC_LINKER(G, U) "%{mglibc:" G ";:" U "}"
69 #elif DEFAULT_LIBC == LIBC_GLIBC
70diff --git a/gcc/config/arm/linux-eabi.h b/gcc/config/arm/linux-eabi.h
71index a119875599d..dce7f59eeea 100644
72--- a/gcc/config/arm/linux-eabi.h
73+++ b/gcc/config/arm/linux-eabi.h
74@@ -62,8 +62,8 @@
75    GLIBC_DYNAMIC_LINKER_DEFAULT and TARGET_DEFAULT_FLOAT_ABI.  */
76
77 #undef  GLIBC_DYNAMIC_LINKER
78-#define GLIBC_DYNAMIC_LINKER_SOFT_FLOAT "/lib/ld-linux.so.3"
79-#define GLIBC_DYNAMIC_LINKER_HARD_FLOAT "/lib/ld-linux-armhf.so.3"
80+#define GLIBC_DYNAMIC_LINKER_SOFT_FLOAT SYSTEMLIBS_DIR "ld-linux.so.3"
81+#define GLIBC_DYNAMIC_LINKER_HARD_FLOAT SYSTEMLIBS_DIR "ld-linux-armhf.so.3"
82 #define GLIBC_DYNAMIC_LINKER_DEFAULT GLIBC_DYNAMIC_LINKER_SOFT_FLOAT
83
84 #define GLIBC_DYNAMIC_LINKER \
85@@ -86,7 +86,7 @@
86 #define MUSL_DYNAMIC_LINKER_E "%{mbig-endian:eb}"
87 #endif
88 #define MUSL_DYNAMIC_LINKER \
89-  "/lib/ld-musl-arm" MUSL_DYNAMIC_LINKER_E "%{mfloat-abi=hard:hf}%{mfdpic:-fdpic}.so.1"
90+  SYSTEMLIBS_DIR "ld-musl-arm" MUSL_DYNAMIC_LINKER_E "%{mfloat-abi=hard:hf}%{mfdpic:-fdpic}.so.1"
91
92 /* At this point, bpabi.h will have clobbered LINK_SPEC.  We want to
93    use the GNU/Linux version, not the generic BPABI version.  */
94diff --git a/gcc/config/arm/linux-elf.h b/gcc/config/arm/linux-elf.h
95index 7b7b7cbbe14..98ef2267117 100644
96--- a/gcc/config/arm/linux-elf.h
97+++ b/gcc/config/arm/linux-elf.h
98@@ -60,7 +60,7 @@
99
100 #define LIBGCC_SPEC "%{mfloat-abi=soft*:-lfloat} -lgcc"
101
102-#define GLIBC_DYNAMIC_LINKER "/lib/ld-linux.so.2"
103+#define GLIBC_DYNAMIC_LINKER SYSTEMLIBS_DIR "ld-linux.so.2"
104
105 #define LINUX_TARGET_LINK_SPEC  "%{h*} \
106    %{static:-Bstatic} \
107diff --git a/gcc/config/i386/linux.h b/gcc/config/i386/linux.h
108index bbb7cc7115e..7d9272040ee 100644
109--- a/gcc/config/i386/linux.h
110+++ b/gcc/config/i386/linux.h
111@@ -20,7 +20,7 @@ along with GCC; see the file COPYING3.  If not see
112 <http://www.gnu.org/licenses/>.  */
113
114 #define GNU_USER_LINK_EMULATION "elf_i386"
115-#define GLIBC_DYNAMIC_LINKER "/lib/ld-linux.so.2"
116+#define GLIBC_DYNAMIC_LINKER SYSTEMLIBS_DIR "ld-linux.so.2"
117
118 #undef MUSL_DYNAMIC_LINKER
119-#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-i386.so.1"
120+#define MUSL_DYNAMIC_LINKER SYSTEMLIBS_DIR "ld-musl-i386.so.1"
121diff --git a/gcc/config/i386/linux64.h b/gcc/config/i386/linux64.h
122index 2bd9f48e271..dbbe7ca5440 100644
123--- a/gcc/config/i386/linux64.h
124+++ b/gcc/config/i386/linux64.h
125@@ -27,13 +27,13 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
126 #define GNU_USER_LINK_EMULATION64 "elf_x86_64"
127 #define GNU_USER_LINK_EMULATIONX32 "elf32_x86_64"
128
129-#define GLIBC_DYNAMIC_LINKER32 "/lib/ld-linux.so.2"
130-#define GLIBC_DYNAMIC_LINKER64 "/lib64/ld-linux-x86-64.so.2"
131-#define GLIBC_DYNAMIC_LINKERX32 "/libx32/ld-linux-x32.so.2"
132+#define GLIBC_DYNAMIC_LINKER32 SYSTEMLIBS_DIR "ld-linux.so.2"
133+#define GLIBC_DYNAMIC_LINKER64 SYSTEMLIBS_DIR "ld-linux-x86-64.so.2"
134+#define GLIBC_DYNAMIC_LINKERX32 SYSTEMLIBS_DIR "ld-linux-x32.so.2"
135
136 #undef MUSL_DYNAMIC_LINKER32
137-#define MUSL_DYNAMIC_LINKER32 "/lib/ld-musl-i386.so.1"
138+#define MUSL_DYNAMIC_LINKER32 SYSTEMLIBS_DIR "ld-musl-i386.so.1"
139 #undef MUSL_DYNAMIC_LINKER64
140-#define MUSL_DYNAMIC_LINKER64 "/lib/ld-musl-x86_64.so.1"
141+#define MUSL_DYNAMIC_LINKER64 SYSTEMLIBS_DIR "ld-musl-x86_64.so.1"
142 #undef MUSL_DYNAMIC_LINKERX32
143-#define MUSL_DYNAMIC_LINKERX32 "/lib/ld-musl-x32.so.1"
144+#define MUSL_DYNAMIC_LINKERX32 SYSTEMLIBS_DIR "ld-musl-x32.so.1"
145diff --git a/gcc/config/linux.h b/gcc/config/linux.h
146index e3aca79cccc..6491c6b84f5 100644
147--- a/gcc/config/linux.h
148+++ b/gcc/config/linux.h
149@@ -86,10 +86,10 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
150    GLIBC_DYNAMIC_LINKER must be defined for each target using them, or
151    GLIBC_DYNAMIC_LINKER32 and GLIBC_DYNAMIC_LINKER64 for targets
152    supporting both 32-bit and 64-bit compilation.  */
153-#define UCLIBC_DYNAMIC_LINKER "/lib/ld-uClibc.so.0"
154-#define UCLIBC_DYNAMIC_LINKER32 "/lib/ld-uClibc.so.0"
155-#define UCLIBC_DYNAMIC_LINKER64 "/lib/ld64-uClibc.so.0"
156-#define UCLIBC_DYNAMIC_LINKERX32 "/lib/ldx32-uClibc.so.0"
157+#define UCLIBC_DYNAMIC_LINKER SYSTEMLIBS_DIR "ld-uClibc.so.0"
158+#define UCLIBC_DYNAMIC_LINKER32 SYSTEMLIBS_DIR "ld-uClibc.so.0"
159+#define UCLIBC_DYNAMIC_LINKER64 SYSTEMLIBS_DIR "ld64-uClibc.so.0"
160+#define UCLIBC_DYNAMIC_LINKERX32 SYSTEMLIBS_DIR "ldx32-uClibc.so.0"
161 #define BIONIC_DYNAMIC_LINKER "/system/bin/linker"
162 #define BIONIC_DYNAMIC_LINKER32 "/system/bin/linker"
163 #define BIONIC_DYNAMIC_LINKER64 "/system/bin/linker64"
164diff --git a/gcc/config/loongarch/gnu-user.h b/gcc/config/loongarch/gnu-user.h
165index aecaa02a199..62f88f7f9a2 100644
166--- a/gcc/config/loongarch/gnu-user.h
167+++ b/gcc/config/loongarch/gnu-user.h
168@@ -31,11 +31,11 @@ along with GCC; see the file COPYING3.  If not see
169
170 #undef GLIBC_DYNAMIC_LINKER
171 #define GLIBC_DYNAMIC_LINKER \
172-  "/lib" ABI_GRLEN_SPEC "/ld-linux-loongarch-" ABI_SPEC ".so.1"
173+  SYSTEMLIBS_DIR "ld-linux-loongarch-" ABI_SPEC ".so.1"
174
175 #undef MUSL_DYNAMIC_LINKER
176 #define MUSL_DYNAMIC_LINKER \
177-  "/lib" ABI_GRLEN_SPEC "/ld-musl-loongarch-" ABI_SPEC ".so.1"
178+  SYSTEMLIBS_DIR "ld-musl-loongarch-" ABI_SPEC ".so.1"
179
180 #undef GNU_USER_TARGET_LINK_SPEC
181 #define GNU_USER_TARGET_LINK_SPEC \
182diff --git a/gcc/config/microblaze/linux.h b/gcc/config/microblaze/linux.h
183index e2e2c421c52..6f26480e3b5 100644
184--- a/gcc/config/microblaze/linux.h
185+++ b/gcc/config/microblaze/linux.h
186@@ -28,7 +28,7 @@
187 #undef TLS_NEEDS_GOT
188 #define TLS_NEEDS_GOT 1
189
190-#define GLIBC_DYNAMIC_LINKER "/lib/ld.so.1"
191+#define GLIBC_DYNAMIC_LINKER SYSTEMLIBS_DIR "/ld.so.1"
192 #define UCLIBC_DYNAMIC_LINKER "/lib/ld-uClibc.so.0"
193
194 #if TARGET_BIG_ENDIAN_DEFAULT == 0 /* LE */
195@@ -38,7 +38,7 @@
196 #endif
197
198 #undef MUSL_DYNAMIC_LINKER
199-#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-microblaze" MUSL_DYNAMIC_LINKER_E ".so.1"
200+#define MUSL_DYNAMIC_LINKER SYSTEMLIBS_DIR "ld-musl-microblaze" MUSL_DYNAMIC_LINKER_E ".so.1"
201
202 #undef  SUBTARGET_EXTRA_SPECS
203 #define SUBTARGET_EXTRA_SPECS \
204diff --git a/gcc/config/mips/linux.h b/gcc/config/mips/linux.h
205index 5add34ea134..34692b433b8 100644
206--- a/gcc/config/mips/linux.h
207+++ b/gcc/config/mips/linux.h
208@@ -22,29 +22,29 @@ along with GCC; see the file COPYING3.  If not see
209 #define GNU_USER_LINK_EMULATIONN32 "elf32%{EB:b}%{EL:l}tsmipn32"
210
211 #define GLIBC_DYNAMIC_LINKER32 \
212-  "%{mnan=2008:/lib/ld-linux-mipsn8.so.1;:/lib/ld.so.1}"
213+  "%{mnan=2008:" SYSTEMLIBS_DIR "ld-linux-mipsn8.so.1;:" SYSTEMLIBS_DIR "ld.so.1}"
214 #define GLIBC_DYNAMIC_LINKER64 \
215-  "%{mnan=2008:/lib64/ld-linux-mipsn8.so.1;:/lib64/ld.so.1}"
216+  "%{mnan=2008:" SYSTEMLIBS_DIR "ld-linux-mipsn8.so.1;:" SYSTEMLIBS_DIR "ld.so.1}"
217 #define GLIBC_DYNAMIC_LINKERN32 \
218-  "%{mnan=2008:/lib32/ld-linux-mipsn8.so.1;:/lib32/ld.so.1}"
219+  "%{mnan=2008:" SYSTEMLIBS_DIR "ld-linux-mipsn8.so.1;:" SYSTEMLIBS_DIR "ld.so.1}"
220
221 #undef UCLIBC_DYNAMIC_LINKER32
222 #define UCLIBC_DYNAMIC_LINKER32 \
223-  "%{mnan=2008:/lib/ld-uClibc-mipsn8.so.0;:/lib/ld-uClibc.so.0}"
224+  "%{mnan=2008:" SYSTEMLIBS_DIR "ld-uClibc-mipsn8.so.0;:" SYSTEMLIBS_DIR "ld-uClibc.so.0}"
225 #undef UCLIBC_DYNAMIC_LINKER64
226 #define UCLIBC_DYNAMIC_LINKER64 \
227-  "%{mnan=2008:/lib/ld64-uClibc-mipsn8.so.0;:/lib/ld64-uClibc.so.0}"
228+  "%{mnan=2008:" SYSTEMLIBS_DIR "ld64-uClibc-mipsn8.so.0;:" SYSTEMLIBS_DIR "ld64-uClibc.so.0}"
229 #define UCLIBC_DYNAMIC_LINKERN32 \
230-  "%{mnan=2008:/lib32/ld-uClibc-mipsn8.so.0;:/lib32/ld-uClibc.so.0}"
231+  "%{mnan=2008:" SYSTEMLIBS_DIR "ld-uClibc-mipsn8.so.0;:" SYSTEMLIBS_DIR "ld-uClibc.so.0}"
232
233 #undef MUSL_DYNAMIC_LINKER32
234 #define MUSL_DYNAMIC_LINKER32 \
235-  "/lib/ld-musl-mips%{mips32r6|mips64r6:r6}%{EL:el}%{msoft-float:-sf}.so.1"
236+  SYSTEMLIBS_DIR "ld-musl-mips%{mips32r6|mips64r6:r6}%{EL:el}%{msoft-float:-sf}.so.1"
237 #undef MUSL_DYNAMIC_LINKER64
238 #define MUSL_DYNAMIC_LINKER64 \
239-  "/lib/ld-musl-mips64%{mips64r6:r6}%{EL:el}%{msoft-float:-sf}.so.1"
240+  SYSTEMLIBS_DIR "ld-musl-mips64%{mips64r6:r6}%{EL:el}%{msoft-float:-sf}.so.1"
241 #define MUSL_DYNAMIC_LINKERN32 \
242-  "/lib/ld-musl-mipsn32%{mips64r6:r6}%{EL:el}%{msoft-float:-sf}.so.1"
243+  SYSTEMLIBS_DIR "ld-musl-mipsn32%{mips64r6:r6}%{EL:el}%{msoft-float:-sf}.so.1"
244
245 #define BIONIC_DYNAMIC_LINKERN32 "/system/bin/linker32"
246 #define GNU_USER_DYNAMIC_LINKERN32 \
247diff --git a/gcc/config/nios2/linux.h b/gcc/config/nios2/linux.h
248index 2ce097ebbce..1d45d7b4962 100644
249--- a/gcc/config/nios2/linux.h
250+++ b/gcc/config/nios2/linux.h
251@@ -29,10 +29,10 @@
252 #undef CPP_SPEC
253 #define CPP_SPEC "%{posix:-D_POSIX_SOURCE} %{pthread:-D_REENTRANT}"
254
255-#define GLIBC_DYNAMIC_LINKER "/lib/ld-linux-nios2.so.1"
256+#define GLIBC_DYNAMIC_LINKER SYSTEMLIBS_DIR "ld-linux-nios2.so.1"
257
258 #undef MUSL_DYNAMIC_LINKER
259-#define MUSL_DYNAMIC_LINKER  "/lib/ld-musl-nios2.so.1"
260+#define MUSL_DYNAMIC_LINKER  SYSTEMLIBS_DIR "ld-musl-nios2.so.1"
261
262 #undef LINK_SPEC
263 #define LINK_SPEC LINK_SPEC_ENDIAN \
264diff --git a/gcc/config/riscv/linux.h b/gcc/config/riscv/linux.h
265index 3e625e0f867..dc3afc97e27 100644
266--- a/gcc/config/riscv/linux.h
267+++ b/gcc/config/riscv/linux.h
268@@ -22,7 +22,7 @@ along with GCC; see the file COPYING3.  If not see
269     GNU_USER_TARGET_OS_CPP_BUILTINS();				\
270   } while (0)
271
272-#define GLIBC_DYNAMIC_LINKER "/lib/ld-linux-riscv" XLEN_SPEC "-" ABI_SPEC ".so.1"
273+#define GLIBC_DYNAMIC_LINKER SYSTEMLIBS_DIR "ld-linux-riscv" XLEN_SPEC "-" ABI_SPEC ".so.1"
274
275 #define MUSL_ABI_SUFFIX \
276   "%{mabi=ilp32:-sf}" \
277@@ -33,7 +33,7 @@ along with GCC; see the file COPYING3.  If not see
278   "%{mabi=lp64d:}"
279
280 #undef MUSL_DYNAMIC_LINKER
281-#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-riscv" XLEN_SPEC MUSL_ABI_SUFFIX ".so.1"
282+#define MUSL_DYNAMIC_LINKER SYSTEMLIBS_DIR "ld-musl-riscv" XLEN_SPEC MUSL_ABI_SUFFIX ".so.1"
283
284 #define ICACHE_FLUSH_FUNC "__riscv_flush_icache"
285
286diff --git a/gcc/config/rs6000/linux64.h b/gcc/config/rs6000/linux64.h
287index 9e457033d11..2ddab7c99c1 100644
288--- a/gcc/config/rs6000/linux64.h
289+++ b/gcc/config/rs6000/linux64.h
290@@ -339,24 +339,19 @@ extern int dot_symbols;
291 #undef	LINK_OS_DEFAULT_SPEC
292 #define LINK_OS_DEFAULT_SPEC "%(link_os_linux)"
293
294-#define GLIBC_DYNAMIC_LINKER32 "%(dynamic_linker_prefix)/lib/ld.so.1"
295-
296+#define GLIBC_DYNAMIC_LINKER32 SYSTEMLIBS_DIR "ld.so.1"
297 #ifdef LINUX64_DEFAULT_ABI_ELFv2
298-#define GLIBC_DYNAMIC_LINKER64 \
299-"%{mabi=elfv1:%(dynamic_linker_prefix)/lib64/ld64.so.1;" \
300-":%(dynamic_linker_prefix)/lib64/ld64.so.2}"
301+#define GLIBC_DYNAMIC_LINKER64 "%{mabi=elfv1:" SYSTEMLIBS_DIR "ld64.so.1;:" SYSTEMLIBS_DIR "ld64.so.2}"
302 #else
303-#define GLIBC_DYNAMIC_LINKER64 \
304-"%{mabi=elfv2:%(dynamic_linker_prefix)/lib64/ld64.so.2;" \
305-":%(dynamic_linker_prefix)/lib64/ld64.so.1}"
306+#define GLIBC_DYNAMIC_LINKER64 "%{mabi=elfv2:" SYSTEMLIBS_DIR "ld64.so.2;:" SYSTEMLIBS_DIR "ld64.so.1}"
307 #endif
308
309 #undef MUSL_DYNAMIC_LINKER32
310 #define MUSL_DYNAMIC_LINKER32 \
311-  "/lib/ld-musl-powerpc" MUSL_DYNAMIC_LINKER_E "%{msoft-float:-sf}.so.1"
312+  SYSTEMLIBS_DIR "ld-musl-powerpc" MUSL_DYNAMIC_LINKER_E "%{msoft-float:-sf}.so.1"
313 #undef MUSL_DYNAMIC_LINKER64
314 #define MUSL_DYNAMIC_LINKER64 \
315-  "/lib/ld-musl-powerpc64" MUSL_DYNAMIC_LINKER_E "%{msoft-float:-sf}.so.1"
316+  SYSTEMLIBS_DIR "ld-musl-powerpc64" MUSL_DYNAMIC_LINKER_E "%{msoft-float:-sf}.so.1"
317
318 #undef  DEFAULT_ASM_ENDIAN
319 #if (TARGET_DEFAULT & MASK_LITTLE_ENDIAN)
320diff --git a/gcc/config/rs6000/sysv4.h b/gcc/config/rs6000/sysv4.h
321index ae932fc22f0..26db003cb3a 100644
322--- a/gcc/config/rs6000/sysv4.h
323+++ b/gcc/config/rs6000/sysv4.h
324@@ -771,10 +771,10 @@ GNU_USER_TARGET_CC1_SPEC
325
326 #define MUSL_DYNAMIC_LINKER_E ENDIAN_SELECT("","le","")
327
328-#define GLIBC_DYNAMIC_LINKER "/lib/ld.so.1"
329+#define GLIBC_DYNAMIC_LINKER SYSTEMLIBS_DIR "ld.so.1"
330 #undef MUSL_DYNAMIC_LINKER
331 #define MUSL_DYNAMIC_LINKER \
332-  "/lib/ld-musl-powerpc" MUSL_DYNAMIC_LINKER_E "%{msoft-float:-sf}.so.1"
333+  SYSTEMLIBS_DIR "ld-musl-powerpc" MUSL_DYNAMIC_LINKER_E "%{msoft-float:-sf}.so.1"
334
335 #ifndef GNU_USER_DYNAMIC_LINKER
336 #define GNU_USER_DYNAMIC_LINKER GLIBC_DYNAMIC_LINKER
337diff --git a/gcc/config/s390/linux.h b/gcc/config/s390/linux.h
338index 02aa1edaff8..fab268d61f4 100644
339--- a/gcc/config/s390/linux.h
340+++ b/gcc/config/s390/linux.h
341@@ -72,13 +72,13 @@ along with GCC; see the file COPYING3.  If not see
342 #define MULTILIB_DEFAULTS { "m31" }
343 #endif
344
345-#define GLIBC_DYNAMIC_LINKER32 "/lib/ld.so.1"
346-#define GLIBC_DYNAMIC_LINKER64 "/lib/ld64.so.1"
347+#define GLIBC_DYNAMIC_LINKER32 SYSTEMLIBS_DIR "ld.so.1"
348+#define GLIBC_DYNAMIC_LINKER64 SYSTEMLIBS_DIR "ld64.so.1"
349
350 #undef MUSL_DYNAMIC_LINKER32
351-#define MUSL_DYNAMIC_LINKER32 "/lib/ld-musl-s390.so.1"
352+#define MUSL_DYNAMIC_LINKER32 SYSTEMLIBS_DIR "ld-musl-s390.so.1"
353 #undef MUSL_DYNAMIC_LINKER64
354-#define MUSL_DYNAMIC_LINKER64 "/lib/ld-musl-s390x.so.1"
355+#define MUSL_DYNAMIC_LINKER64 SYSTEMLIBS_DIR "ld-musl-s390x.so.1"
356
357 #undef  LINK_SPEC
358 #define LINK_SPEC \
359diff --git a/gcc/config/sh/linux.h b/gcc/config/sh/linux.h
360index 29f5902b98b..83d1e53e6e2 100644
361--- a/gcc/config/sh/linux.h
362+++ b/gcc/config/sh/linux.h
363@@ -61,10 +61,10 @@ along with GCC; see the file COPYING3.  If not see
364
365 #undef MUSL_DYNAMIC_LINKER
366 #define MUSL_DYNAMIC_LINKER \
367-  "/lib/ld-musl-sh" MUSL_DYNAMIC_LINKER_E MUSL_DYNAMIC_LINKER_FP \
368+  SYSTEMLIBS_DIR "ld-musl-sh" MUSL_DYNAMIC_LINKER_E MUSL_DYNAMIC_LINKER_FP \
369   "%{mfdpic:-fdpic}.so.1"
370
371-#define GLIBC_DYNAMIC_LINKER "/lib/ld-linux.so.2"
372+#define GLIBC_DYNAMIC_LINKER SYSTEMLIBS_DIR "ld-linux.so.2"
373
374 #undef SUBTARGET_LINK_EMUL_SUFFIX
375 #define SUBTARGET_LINK_EMUL_SUFFIX "%{mfdpic:_fd;:_linux}"
376diff --git a/gcc/config/sparc/linux.h b/gcc/config/sparc/linux.h
377index 0e33b3cac2c..84f29adbb35 100644
378--- a/gcc/config/sparc/linux.h
379+++ b/gcc/config/sparc/linux.h
380@@ -78,7 +78,7 @@ extern const char *host_detect_local_cpu (int argc, const char **argv);
381    When the -shared link option is used a final link is not being
382    done.  */
383
384-#define GLIBC_DYNAMIC_LINKER "/lib/ld-linux.so.2"
385+#define GLIBC_DYNAMIC_LINKER SYSTEMLIBS_DIR "ld-linux.so.2"
386
387 #undef  LINK_SPEC
388 #define LINK_SPEC "-m elf32_sparc %{shared:-shared} \
389diff --git a/gcc/config/sparc/linux64.h b/gcc/config/sparc/linux64.h
390index f1cc0a19e49..94bc2032803 100644
391--- a/gcc/config/sparc/linux64.h
392+++ b/gcc/config/sparc/linux64.h
393@@ -78,8 +78,8 @@ along with GCC; see the file COPYING3.  If not see
394    When the -shared link option is used a final link is not being
395    done.  */
396
397-#define GLIBC_DYNAMIC_LINKER32 "/lib/ld-linux.so.2"
398-#define GLIBC_DYNAMIC_LINKER64 "/lib64/ld-linux.so.2"
399+#define GLIBC_DYNAMIC_LINKER32 SYSTEMLIBS_DIR "ld-linux.so.2"
400+#define GLIBC_DYNAMIC_LINKER64 SYSTEMLIBS_DIR "ld-linux.so.2"
401
402 #ifdef SPARC_BI_ARCH
403
404