summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/gcc/gcc-9.5/0025-handle-sysroot-support-for-nativesdk-gcc.patch
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-devtools/gcc/gcc-9.5/0025-handle-sysroot-support-for-nativesdk-gcc.patch')
-rw-r--r--meta/recipes-devtools/gcc/gcc-9.5/0025-handle-sysroot-support-for-nativesdk-gcc.patch346
1 files changed, 346 insertions, 0 deletions
diff --git a/meta/recipes-devtools/gcc/gcc-9.5/0025-handle-sysroot-support-for-nativesdk-gcc.patch b/meta/recipes-devtools/gcc/gcc-9.5/0025-handle-sysroot-support-for-nativesdk-gcc.patch
new file mode 100644
index 0000000000..59ac97eaed
--- /dev/null
+++ b/meta/recipes-devtools/gcc/gcc-9.5/0025-handle-sysroot-support-for-nativesdk-gcc.patch
@@ -0,0 +1,346 @@
1From 7d614a84709d7dc4a2529c3d529e2da8541f9fd4 Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Mon, 7 Dec 2015 23:39:54 +0000
4Subject: [PATCH 25/39] handle sysroot support for nativesdk-gcc
5
6Being able to build a nativesdk gcc is useful, particularly in cases
7where the host compiler may be of an incompatible version (or a 32
8bit compiler is needed).
9
10Sadly, building nativesdk-gcc is not straight forward. We install
11nativesdk-gcc into a relocatable location and this means that its
12library locations can change. "Normal" sysroot support doesn't help
13in this case since the values of paths like "libdir" change, not just
14base root directory of the system.
15
16In order to handle this we do two things:
17
18a) Add %r into spec file markup which can be used for injected paths
19 such as SYSTEMLIBS_DIR (see gcc_multilib_setup()).
20b) Add other paths which need relocation into a .gccrelocprefix section
21 which the relocation code will notice and adjust automatically.
22
23Upstream-Status: Inappropriate
24RP 2015/7/28
25
26Signed-off-by: Khem Raj <raj.khem@gmail.com>
27
28Added PREFIXVAR and EXEC_PREFIXVAR to support runtime relocation. Without
29these as part of the gccrelocprefix the system can't do runtime relocation
30if the executable is moved. (These paths were missed in the original
31implementation.)
32
33Signed-off-by: Mark Hatle <mark.hatle@kernel.crashing.org>
34---
35 c-family/c-opts.c | 4 +--
36 cppdefault.c | 63 +++++++++++++++++++++++++++++++++---------------------
37 cppdefault.h | 13 ++++-------
38 gcc.c | 20 ++++++++++++-----
39 incpath.c | 12 +++++-----
40 prefix.c | 4 +--
41 6 files changed, 68 insertions(+), 48 deletions(-)
42
43Index: gcc-9.3.0/gcc/cppdefault.c
44===================================================================
45--- gcc-9.3.0.orig/gcc/cppdefault.c
46+++ gcc-9.3.0/gcc/cppdefault.c
47@@ -35,6 +35,30 @@
48 # undef CROSS_INCLUDE_DIR
49 #endif
50
51+static char GPLUSPLUS_INCLUDE_DIRVAR[4096] __attribute__ ((section (".gccrelocprefix"))) = GPLUSPLUS_INCLUDE_DIR;
52+char GCC_INCLUDE_DIRVAR[4096] __attribute__ ((section (".gccrelocprefix"))) = GCC_INCLUDE_DIR;
53+static char GPLUSPLUS_TOOL_INCLUDE_DIRVAR[4096] __attribute__ ((section (".gccrelocprefix"))) = GPLUSPLUS_TOOL_INCLUDE_DIR;
54+static char GPLUSPLUS_BACKWARD_INCLUDE_DIRVAR[4096] __attribute__ ((section (".gccrelocprefix"))) = GPLUSPLUS_BACKWARD_INCLUDE_DIR;
55+static char STANDARD_STARTFILE_PREFIX_2VAR[4096] __attribute__ ((section (".gccrelocprefix"))) = STANDARD_STARTFILE_PREFIX_2 GCC_INCLUDE_SUBDIR_TARGET;
56+#ifdef LOCAL_INCLUDE_DIR
57+static char LOCAL_INCLUDE_DIRVAR[4096] __attribute__ ((section (".gccrelocprefix"))) = LOCAL_INCLUDE_DIR;
58+#endif
59+#ifdef PREFIX_INCLUDE_DIR
60+static char PREFIX_INCLUDE_DIRVAR[4096] __attribute__ ((section (".gccrelocprefix"))) = PREFIX_INCLUDE_DIR;
61+#endif
62+#ifdef FIXED_INCLUDE_DIR
63+static char FIXED_INCLUDE_DIRVAR[4096] __attribute__ ((section (".gccrelocprefix"))) = FIXED_INCLUDE_DIR;
64+#endif
65+#ifdef CROSS_INCLUDE_DIR
66+static char CROSS_INCLUDE_DIRVAR[4096] __attribute__ ((section (".gccrelocprefix"))) = CROSS_INCLUDE_DIR;
67+#endif
68+#ifdef TOOL_INCLUDE_DIR
69+static char TOOL_INCLUDE_DIRVAR[4096] __attribute__ ((section (".gccrelocprefix"))) = TOOL_INCLUDE_DIR;
70+#endif
71+#ifdef NATIVE_SYSTEM_HEADER_DIR
72+static char NATIVE_SYSTEM_HEADER_DIRVAR[4096] __attribute__ ((section (".gccrelocprefix"))) = NATIVE_SYSTEM_HEADER_DIR;
73+#endif
74+
75 const struct default_include cpp_include_defaults[]
76 #ifdef INCLUDE_DEFAULTS
77 = INCLUDE_DEFAULTS;
78@@ -42,38 +66,38 @@ const struct default_include cpp_include
79 = {
80 #ifdef GPLUSPLUS_INCLUDE_DIR
81 /* Pick up GNU C++ generic include files. */
82- { GPLUSPLUS_INCLUDE_DIR, "G++", 1, 1,
83+ { GPLUSPLUS_INCLUDE_DIRVAR, "G++", 1, 1,
84 GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 0 },
85 #endif
86 #ifdef GPLUSPLUS_TOOL_INCLUDE_DIR
87 /* Pick up GNU C++ target-dependent include files. */
88- { GPLUSPLUS_TOOL_INCLUDE_DIR, "G++", 1, 1,
89+ { GPLUSPLUS_TOOL_INCLUDE_DIRVAR, "G++", 1, 1,
90 GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 1 },
91 #endif
92 #ifdef GPLUSPLUS_BACKWARD_INCLUDE_DIR
93 /* Pick up GNU C++ backward and deprecated include files. */
94- { GPLUSPLUS_BACKWARD_INCLUDE_DIR, "G++", 1, 1,
95+ { GPLUSPLUS_BACKWARD_INCLUDE_DIRVAR, "G++", 1, 1,
96 GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 0 },
97 #endif
98 #ifdef GCC_INCLUDE_DIR
99 /* This is the dir for gcc's private headers. */
100- { GCC_INCLUDE_DIR, "GCC", 0, 0, 0, 0 },
101+ { GCC_INCLUDE_DIRVAR, "GCC", 0, 0, 0, 0 },
102 #endif
103 #ifdef GCC_INCLUDE_SUBDIR_TARGET
104 /* This is the dir for gcc's private headers under the specified sysroot. */
105- { STANDARD_STARTFILE_PREFIX_2 GCC_INCLUDE_SUBDIR_TARGET, "GCC", 0, 0, 1, 0 },
106+ { STANDARD_STARTFILE_PREFIX_2VAR, "GCC", 0, 0, 1, 0 },
107 #endif
108 #ifdef LOCAL_INCLUDE_DIR
109 /* /usr/local/include comes before the fixincluded header files. */
110- { LOCAL_INCLUDE_DIR, 0, 0, 1, 1, 2 },
111- { LOCAL_INCLUDE_DIR, 0, 0, 1, 1, 0 },
112+ { LOCAL_INCLUDE_DIRVAR, 0, 0, 1, 1, 2 },
113+ { LOCAL_INCLUDE_DIRVAR, 0, 0, 1, 1, 0 },
114 #endif
115 #ifdef PREFIX_INCLUDE_DIR
116- { PREFIX_INCLUDE_DIR, 0, 0, 1, 0, 0 },
117+ { PREFIX_INCLUDE_DIRVAR, 0, 0, 1, 0, 0 },
118 #endif
119 #ifdef FIXED_INCLUDE_DIR
120 /* This is the dir for fixincludes. */
121- { FIXED_INCLUDE_DIR, "GCC", 0, 0, 0,
122+ { FIXED_INCLUDE_DIRVAR, "GCC", 0, 0, 0,
123 /* A multilib suffix needs adding if different multilibs use
124 different headers. */
125 #ifdef SYSROOT_HEADERS_SUFFIX_SPEC
126@@ -85,33 +109,24 @@ const struct default_include cpp_include
127 #endif
128 #ifdef CROSS_INCLUDE_DIR
129 /* One place the target system's headers might be. */
130- { CROSS_INCLUDE_DIR, "GCC", 0, 0, 0, 0 },
131+ { CROSS_INCLUDE_DIRVAR, "GCC", 0, 0, 0, 0 },
132 #endif
133 #ifdef TOOL_INCLUDE_DIR
134 /* Another place the target system's headers might be. */
135- { TOOL_INCLUDE_DIR, "BINUTILS", 0, 1, 0, 0 },
136+ { TOOL_INCLUDE_DIRVAR, "BINUTILS", 0, 1, 0, 0 },
137 #endif
138 #ifdef NATIVE_SYSTEM_HEADER_DIR
139 /* /usr/include comes dead last. */
140- { NATIVE_SYSTEM_HEADER_DIR, NATIVE_SYSTEM_HEADER_COMPONENT, 0, 0, 1, 2 },
141- { NATIVE_SYSTEM_HEADER_DIR, NATIVE_SYSTEM_HEADER_COMPONENT, 0, 0, 1, 0 },
142+ { NATIVE_SYSTEM_HEADER_DIRVAR, NATIVE_SYSTEM_HEADER_COMPONENT, 0, 0, 1, 2 },
143+ { NATIVE_SYSTEM_HEADER_DIRVAR, NATIVE_SYSTEM_HEADER_COMPONENT, 0, 0, 1, 0 },
144 #endif
145 { 0, 0, 0, 0, 0, 0 }
146 };
147 #endif /* no INCLUDE_DEFAULTS */
148
149-#ifdef GCC_INCLUDE_DIR
150-const char cpp_GCC_INCLUDE_DIR[] = GCC_INCLUDE_DIR;
151-const size_t cpp_GCC_INCLUDE_DIR_len = sizeof GCC_INCLUDE_DIR - 8;
152-#else
153-const char cpp_GCC_INCLUDE_DIR[] = "";
154-const size_t cpp_GCC_INCLUDE_DIR_len = 0;
155-#endif
156-
157 /* The configured prefix. */
158-const char cpp_PREFIX[] = PREFIX;
159-const size_t cpp_PREFIX_len = sizeof PREFIX - 1;
160-const char cpp_EXEC_PREFIX[] = STANDARD_EXEC_PREFIX;
161+char PREFIXVAR[4096] __attribute__ ((section (".gccrelocprefix"))) = PREFIX;
162+char EXEC_PREFIXVAR[4096] __attribute__ ((section (".gccrelocprefix"))) = STANDARD_EXEC_PREFIX;
163
164 /* This value is set by cpp_relocated at runtime */
165 const char *gcc_exec_prefix;
166Index: gcc-9.3.0/gcc/cppdefault.h
167===================================================================
168--- gcc-9.3.0.orig/gcc/cppdefault.h
169+++ gcc-9.3.0/gcc/cppdefault.h
170@@ -33,7 +33,8 @@
171
172 struct default_include
173 {
174- const char *const fname; /* The name of the directory. */
175+ const char *fname; /* The name of the directory. */
176+
177 const char *const component; /* The component containing the directory
178 (see update_path in prefix.c) */
179 const char cplusplus; /* Only look here if we're compiling C++. */
180@@ -50,17 +51,13 @@ struct default_include
181 };
182
183 extern const struct default_include cpp_include_defaults[];
184-extern const char cpp_GCC_INCLUDE_DIR[];
185-extern const size_t cpp_GCC_INCLUDE_DIR_len;
186+extern char GCC_INCLUDE_DIRVAR[] __attribute__ ((section (".gccrelocprefix")));
187
188 /* The configure-time prefix, i.e., the value supplied as the argument
189 to --prefix=. */
190-extern const char cpp_PREFIX[];
191+extern char PREFIXVAR[] __attribute__ ((section (".gccrelocprefix")));
192 /* The length of the configure-time prefix. */
193-extern const size_t cpp_PREFIX_len;
194-/* The configure-time execution prefix. This is typically the lib/gcc
195- subdirectory of cpp_PREFIX. */
196-extern const char cpp_EXEC_PREFIX[];
197+extern char EXEC_PREFIXVAR[] __attribute__ ((section (".gccrelocprefix")));
198 /* The run-time execution prefix. This is typically the lib/gcc
199 subdirectory of the actual installation. */
200 extern const char *gcc_exec_prefix;
201Index: gcc-9.3.0/gcc/gcc.c
202===================================================================
203--- gcc-9.3.0.orig/gcc/gcc.c
204+++ gcc-9.3.0/gcc/gcc.c
205@@ -253,6 +253,8 @@ FILE *report_times_to_file = NULL;
206 #endif
207 static const char *target_system_root = DEFAULT_TARGET_SYSTEM_ROOT;
208
209+static char target_relocatable_prefix[4096] __attribute__ ((section (".gccrelocprefix"))) = SYSTEMLIBS_DIR;
210+
211 /* Nonzero means pass the updated target_system_root to the compiler. */
212
213 static int target_system_root_changed;
214@@ -527,6 +529,7 @@ or with constant text in a single argume
215 %G process LIBGCC_SPEC as a spec.
216 %R Output the concatenation of target_system_root and
217 target_sysroot_suffix.
218+ %r Output the base path target_relocatable_prefix
219 %S process STARTFILE_SPEC as a spec. A capital S is actually used here.
220 %E process ENDFILE_SPEC as a spec. A capital E is actually used here.
221 %C process CPP_SPEC as a spec.
222@@ -1500,10 +1503,10 @@ static const char *gcc_libexec_prefix;
223 gcc_exec_prefix is set because, in that case, we know where the
224 compiler has been installed, and use paths relative to that
225 location instead. */
226-static const char *const standard_exec_prefix = STANDARD_EXEC_PREFIX;
227-static const char *const standard_libexec_prefix = STANDARD_LIBEXEC_PREFIX;
228-static const char *const standard_bindir_prefix = STANDARD_BINDIR_PREFIX;
229-static const char *const standard_startfile_prefix = STANDARD_STARTFILE_PREFIX;
230+static char standard_exec_prefix[4096] __attribute__ ((section (".gccrelocprefix"))) = STANDARD_EXEC_PREFIX;
231+static char standard_libexec_prefix[4096] __attribute__ ((section (".gccrelocprefix"))) = STANDARD_LIBEXEC_PREFIX;
232+static char standard_bindir_prefix[4096] __attribute__ ((section (".gccrelocprefix"))) = STANDARD_BINDIR_PREFIX;
233+static char *const standard_startfile_prefix = STANDARD_STARTFILE_PREFIX;
234
235 /* For native compilers, these are well-known paths containing
236 components that may be provided by the system. For cross
237@@ -1511,9 +1514,9 @@ static const char *const standard_startf
238 static const char *md_exec_prefix = MD_EXEC_PREFIX;
239 static const char *md_startfile_prefix = MD_STARTFILE_PREFIX;
240 static const char *md_startfile_prefix_1 = MD_STARTFILE_PREFIX_1;
241-static const char *const standard_startfile_prefix_1
242+static char standard_startfile_prefix_1[4096] __attribute__ ((section (".gccrelocprefix")))
243 = STANDARD_STARTFILE_PREFIX_1;
244-static const char *const standard_startfile_prefix_2
245+static char standard_startfile_prefix_2[4096] __attribute__ ((section (".gccrelocprefix")))
246 = STANDARD_STARTFILE_PREFIX_2;
247
248 /* A relative path to be used in finding the location of tools
249@@ -5922,6 +5925,11 @@ do_spec_1 (const char *spec, int inswitc
250 }
251 break;
252
253+ case 'r':
254+ obstack_grow (&obstack, target_relocatable_prefix,
255+ strlen (target_relocatable_prefix));
256+ break;
257+
258 case 'S':
259 value = do_spec_1 (startfile_spec, 0, NULL);
260 if (value != 0)
261Index: gcc-9.3.0/gcc/c-family/c-opts.c
262===================================================================
263--- gcc-9.3.0.orig/gcc/c-family/c-opts.c
264+++ gcc-9.3.0/gcc/c-family/c-opts.c
265@@ -1382,8 +1382,8 @@ add_prefixed_path (const char *suffix, i
266 size_t prefix_len, suffix_len;
267
268 suffix_len = strlen (suffix);
269- prefix = iprefix ? iprefix : cpp_GCC_INCLUDE_DIR;
270- prefix_len = iprefix ? strlen (iprefix) : cpp_GCC_INCLUDE_DIR_len;
271+ prefix = iprefix ? iprefix : GCC_INCLUDE_DIRVAR;
272+ prefix_len = iprefix ? strlen (iprefix) : strlen(GCC_INCLUDE_DIRVAR) - 7;
273
274 path = (char *) xmalloc (prefix_len + suffix_len + 1);
275 memcpy (path, prefix, prefix_len);
276Index: gcc-9.3.0/gcc/incpath.c
277===================================================================
278--- gcc-9.3.0.orig/gcc/incpath.c
279+++ gcc-9.3.0/gcc/incpath.c
280@@ -131,7 +131,7 @@ add_standard_paths (const char *sysroot,
281 int relocated = cpp_relocated ();
282 size_t len;
283
284- if (iprefix && (len = cpp_GCC_INCLUDE_DIR_len) != 0)
285+ if (iprefix && (len = strlen(GCC_INCLUDE_DIRVAR) - 7) != 0)
286 {
287 /* Look for directories that start with the standard prefix.
288 "Translate" them, i.e. replace /usr/local/lib/gcc... with
289@@ -145,7 +145,7 @@ add_standard_paths (const char *sysroot,
290 now. */
291 if (sysroot && p->add_sysroot)
292 continue;
293- if (!filename_ncmp (p->fname, cpp_GCC_INCLUDE_DIR, len))
294+ if (!filename_ncmp (p->fname, GCC_INCLUDE_DIRVAR, len))
295 {
296 char *str = concat (iprefix, p->fname + len, NULL);
297 if (p->multilib == 1 && imultilib)
298@@ -185,7 +185,7 @@ add_standard_paths (const char *sysroot,
299 free (sysroot_no_trailing_dir_separator);
300 }
301 else if (!p->add_sysroot && relocated
302- && !filename_ncmp (p->fname, cpp_PREFIX, cpp_PREFIX_len))
303+ && !filename_ncmp (p->fname, PREFIXVAR, strlen(PREFIXVAR)))
304 {
305 static const char *relocated_prefix;
306 char *ostr;
307@@ -202,12 +202,12 @@ add_standard_paths (const char *sysroot,
308 dummy = concat (gcc_exec_prefix, "dummy", NULL);
309 relocated_prefix
310 = make_relative_prefix (dummy,
311- cpp_EXEC_PREFIX,
312- cpp_PREFIX);
313+ EXEC_PREFIXVAR,
314+ PREFIXVAR);
315 free (dummy);
316 }
317 ostr = concat (relocated_prefix,
318- p->fname + cpp_PREFIX_len,
319+ p->fname + strlen(PREFIXVAR),
320 NULL);
321 str = update_path (ostr, p->component);
322 free (ostr);
323Index: gcc-9.3.0/gcc/prefix.c
324===================================================================
325--- gcc-9.3.0.orig/gcc/prefix.c
326+++ gcc-9.3.0/gcc/prefix.c
327@@ -72,7 +72,9 @@ License along with GCC; see the file COP
328 #include "prefix.h"
329 #include "common/common-target.h"
330
331-static const char *std_prefix = PREFIX;
332+static const char PREFIXVAR[4096] __attribute__ ((section (".gccrelocprefix"))) = PREFIX;
333+
334+static const char *std_prefix = PREFIXVAR;
335
336 static const char *get_key_value (char *);
337 static char *translate_name (char *);
338@@ -212,7 +214,7 @@ translate_name (char *name)
339 prefix = getenv (key);
340
341 if (prefix == 0)
342- prefix = PREFIX;
343+ prefix = PREFIXVAR;
344
345 /* We used to strip trailing DIR_SEPARATORs here, but that can
346 sometimes yield a result with no separator when one was coded