diff options
-rw-r--r-- | meta/recipes-devtools/gcc/gcc-9.2/0025-handle-sysroot-support-for-nativesdk-gcc.patch | 185 |
1 files changed, 159 insertions, 26 deletions
diff --git a/meta/recipes-devtools/gcc/gcc-9.2/0025-handle-sysroot-support-for-nativesdk-gcc.patch b/meta/recipes-devtools/gcc/gcc-9.2/0025-handle-sysroot-support-for-nativesdk-gcc.patch index ba62bc1fd3..2e7a444b58 100644 --- a/meta/recipes-devtools/gcc/gcc-9.2/0025-handle-sysroot-support-for-nativesdk-gcc.patch +++ b/meta/recipes-devtools/gcc/gcc-9.2/0025-handle-sysroot-support-for-nativesdk-gcc.patch | |||
@@ -24,22 +24,32 @@ Upstream-Status: Inappropriate | |||
24 | RP 2015/7/28 | 24 | RP 2015/7/28 |
25 | 25 | ||
26 | Signed-off-by: Khem Raj <raj.khem@gmail.com> | 26 | Signed-off-by: Khem Raj <raj.khem@gmail.com> |
27 | |||
28 | Added PREFIXVAR and EXEC_PREFIXVAR to support runtime relocation. Without | ||
29 | these as part of the gccrelocprefix the system can't do runtime relocation | ||
30 | if the executable is moved. (These paths were missed in the original | ||
31 | implementation.) | ||
32 | |||
33 | Signed-off-by: Mark Hatle <mark.hatle@kernel.crashing.org> | ||
27 | --- | 34 | --- |
28 | gcc/cppdefault.c | 50 +++++++++++++++++++++++++++++++++++------------- | 35 | c-family/c-opts.c | 4 +-- |
29 | gcc/cppdefault.h | 3 ++- | 36 | cppdefault.c | 63 +++++++++++++++++++++++++++++++++--------------------- |
30 | gcc/gcc.c | 20 +++++++++++++------ | 37 | cppdefault.h | 13 ++++------- |
31 | 3 files changed, 53 insertions(+), 20 deletions(-) | 38 | gcc.c | 20 ++++++++++++----- |
39 | incpath.c | 12 +++++----- | ||
40 | prefix.c | 4 +-- | ||
41 | 6 files changed, 68 insertions(+), 48 deletions(-) | ||
32 | 42 | ||
33 | diff --git a/gcc/cppdefault.c b/gcc/cppdefault.c | 43 | Index: gcc-9.2.0/gcc/cppdefault.c |
34 | index 980e2bd47a7..39b6059efdc 100644 | 44 | =================================================================== |
35 | --- a/gcc/cppdefault.c | 45 | --- gcc-9.2.0.orig/gcc/cppdefault.c |
36 | +++ b/gcc/cppdefault.c | 46 | +++ gcc-9.2.0/gcc/cppdefault.c |
37 | @@ -35,6 +35,30 @@ | 47 | @@ -35,6 +35,30 @@ |
38 | # undef CROSS_INCLUDE_DIR | 48 | # undef CROSS_INCLUDE_DIR |
39 | #endif | 49 | #endif |
40 | 50 | ||
41 | +static char GPLUSPLUS_INCLUDE_DIRVAR[4096] __attribute__ ((section (".gccrelocprefix"))) = GPLUSPLUS_INCLUDE_DIR; | 51 | +static char GPLUSPLUS_INCLUDE_DIRVAR[4096] __attribute__ ((section (".gccrelocprefix"))) = GPLUSPLUS_INCLUDE_DIR; |
42 | +static char GCC_INCLUDE_DIRVAR[4096] __attribute__ ((section (".gccrelocprefix"))) = GCC_INCLUDE_DIR; | 52 | +char GCC_INCLUDE_DIRVAR[4096] __attribute__ ((section (".gccrelocprefix"))) = GCC_INCLUDE_DIR; |
43 | +static char GPLUSPLUS_TOOL_INCLUDE_DIRVAR[4096] __attribute__ ((section (".gccrelocprefix"))) = GPLUSPLUS_TOOL_INCLUDE_DIR; | 53 | +static char GPLUSPLUS_TOOL_INCLUDE_DIRVAR[4096] __attribute__ ((section (".gccrelocprefix"))) = GPLUSPLUS_TOOL_INCLUDE_DIR; |
44 | +static char GPLUSPLUS_BACKWARD_INCLUDE_DIRVAR[4096] __attribute__ ((section (".gccrelocprefix"))) = GPLUSPLUS_BACKWARD_INCLUDE_DIR; | 54 | +static char GPLUSPLUS_BACKWARD_INCLUDE_DIRVAR[4096] __attribute__ ((section (".gccrelocprefix"))) = GPLUSPLUS_BACKWARD_INCLUDE_DIR; |
45 | +static char STANDARD_STARTFILE_PREFIX_2VAR[4096] __attribute__ ((section (".gccrelocprefix"))) = STANDARD_STARTFILE_PREFIX_2 GCC_INCLUDE_SUBDIR_TARGET; | 55 | +static char STANDARD_STARTFILE_PREFIX_2VAR[4096] __attribute__ ((section (".gccrelocprefix"))) = STANDARD_STARTFILE_PREFIX_2 GCC_INCLUDE_SUBDIR_TARGET; |
@@ -65,7 +75,7 @@ index 980e2bd47a7..39b6059efdc 100644 | |||
65 | const struct default_include cpp_include_defaults[] | 75 | const struct default_include cpp_include_defaults[] |
66 | #ifdef INCLUDE_DEFAULTS | 76 | #ifdef INCLUDE_DEFAULTS |
67 | = INCLUDE_DEFAULTS; | 77 | = INCLUDE_DEFAULTS; |
68 | @@ -42,38 +66,38 @@ const struct default_include cpp_include_defaults[] | 78 | @@ -42,38 +66,38 @@ const struct default_include cpp_include |
69 | = { | 79 | = { |
70 | #ifdef GPLUSPLUS_INCLUDE_DIR | 80 | #ifdef GPLUSPLUS_INCLUDE_DIR |
71 | /* Pick up GNU C++ generic include files. */ | 81 | /* Pick up GNU C++ generic include files. */ |
@@ -113,7 +123,7 @@ index 980e2bd47a7..39b6059efdc 100644 | |||
113 | /* A multilib suffix needs adding if different multilibs use | 123 | /* A multilib suffix needs adding if different multilibs use |
114 | different headers. */ | 124 | different headers. */ |
115 | #ifdef SYSROOT_HEADERS_SUFFIX_SPEC | 125 | #ifdef SYSROOT_HEADERS_SUFFIX_SPEC |
116 | @@ -85,16 +109,16 @@ const struct default_include cpp_include_defaults[] | 126 | @@ -85,33 +109,24 @@ const struct default_include cpp_include |
117 | #endif | 127 | #endif |
118 | #ifdef CROSS_INCLUDE_DIR | 128 | #ifdef CROSS_INCLUDE_DIR |
119 | /* One place the target system's headers might be. */ | 129 | /* One place the target system's headers might be. */ |
@@ -134,10 +144,29 @@ index 980e2bd47a7..39b6059efdc 100644 | |||
134 | #endif | 144 | #endif |
135 | { 0, 0, 0, 0, 0, 0 } | 145 | { 0, 0, 0, 0, 0, 0 } |
136 | }; | 146 | }; |
137 | diff --git a/gcc/cppdefault.h b/gcc/cppdefault.h | 147 | #endif /* no INCLUDE_DEFAULTS */ |
138 | index e2d96f1e760..29fa5f815c8 100644 | 148 | |
139 | --- a/gcc/cppdefault.h | 149 | -#ifdef GCC_INCLUDE_DIR |
140 | +++ b/gcc/cppdefault.h | 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; | ||
166 | Index: gcc-9.2.0/gcc/cppdefault.h | ||
167 | =================================================================== | ||
168 | --- gcc-9.2.0.orig/gcc/cppdefault.h | ||
169 | +++ gcc-9.2.0/gcc/cppdefault.h | ||
141 | @@ -33,7 +33,8 @@ | 170 | @@ -33,7 +33,8 @@ |
142 | 171 | ||
143 | struct default_include | 172 | struct default_include |
@@ -148,10 +177,31 @@ index e2d96f1e760..29fa5f815c8 100644 | |||
148 | const char *const component; /* The component containing the directory | 177 | const char *const component; /* The component containing the directory |
149 | (see update_path in prefix.c) */ | 178 | (see update_path in prefix.c) */ |
150 | const char cplusplus; /* Only look here if we're compiling C++. */ | 179 | const char cplusplus; /* Only look here if we're compiling C++. */ |
151 | diff --git a/gcc/gcc.c b/gcc/gcc.c | 180 | @@ -50,17 +51,13 @@ struct default_include |
152 | index 1a3704b2763..db0e2934038 100644 | 181 | }; |
153 | --- a/gcc/gcc.c | 182 | |
154 | +++ b/gcc/gcc.c | 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; | ||
201 | Index: gcc-9.2.0/gcc/gcc.c | ||
202 | =================================================================== | ||
203 | --- gcc-9.2.0.orig/gcc/gcc.c | ||
204 | +++ gcc-9.2.0/gcc/gcc.c | ||
155 | @@ -253,6 +253,8 @@ FILE *report_times_to_file = NULL; | 205 | @@ -253,6 +253,8 @@ FILE *report_times_to_file = NULL; |
156 | #endif | 206 | #endif |
157 | static const char *target_system_root = DEFAULT_TARGET_SYSTEM_ROOT; | 207 | static const char *target_system_root = DEFAULT_TARGET_SYSTEM_ROOT; |
@@ -161,7 +211,7 @@ index 1a3704b2763..db0e2934038 100644 | |||
161 | /* Nonzero means pass the updated target_system_root to the compiler. */ | 211 | /* Nonzero means pass the updated target_system_root to the compiler. */ |
162 | 212 | ||
163 | static int target_system_root_changed; | 213 | static int target_system_root_changed; |
164 | @@ -527,6 +529,7 @@ or with constant text in a single argument. | 214 | @@ -527,6 +529,7 @@ or with constant text in a single argume |
165 | %G process LIBGCC_SPEC as a spec. | 215 | %G process LIBGCC_SPEC as a spec. |
166 | %R Output the concatenation of target_system_root and | 216 | %R Output the concatenation of target_system_root and |
167 | target_sysroot_suffix. | 217 | target_sysroot_suffix. |
@@ -169,7 +219,7 @@ index 1a3704b2763..db0e2934038 100644 | |||
169 | %S process STARTFILE_SPEC as a spec. A capital S is actually used here. | 219 | %S process STARTFILE_SPEC as a spec. A capital S is actually used here. |
170 | %E process ENDFILE_SPEC as a spec. A capital E is actually used here. | 220 | %E process ENDFILE_SPEC as a spec. A capital E is actually used here. |
171 | %C process CPP_SPEC as a spec. | 221 | %C process CPP_SPEC as a spec. |
172 | @@ -1493,10 +1496,10 @@ static const char *gcc_libexec_prefix; | 222 | @@ -1500,10 +1503,10 @@ static const char *gcc_libexec_prefix; |
173 | gcc_exec_prefix is set because, in that case, we know where the | 223 | gcc_exec_prefix is set because, in that case, we know where the |
174 | compiler has been installed, and use paths relative to that | 224 | compiler has been installed, and use paths relative to that |
175 | location instead. */ | 225 | location instead. */ |
@@ -184,7 +234,7 @@ index 1a3704b2763..db0e2934038 100644 | |||
184 | 234 | ||
185 | /* For native compilers, these are well-known paths containing | 235 | /* For native compilers, these are well-known paths containing |
186 | components that may be provided by the system. For cross | 236 | components that may be provided by the system. For cross |
187 | @@ -1504,9 +1507,9 @@ static const char *const standard_startfile_prefix = STANDARD_STARTFILE_PREFIX; | 237 | @@ -1511,9 +1514,9 @@ static const char *const standard_startf |
188 | static const char *md_exec_prefix = MD_EXEC_PREFIX; | 238 | static const char *md_exec_prefix = MD_EXEC_PREFIX; |
189 | static const char *md_startfile_prefix = MD_STARTFILE_PREFIX; | 239 | static const char *md_startfile_prefix = MD_STARTFILE_PREFIX; |
190 | static const char *md_startfile_prefix_1 = MD_STARTFILE_PREFIX_1; | 240 | static const char *md_startfile_prefix_1 = MD_STARTFILE_PREFIX_1; |
@@ -196,7 +246,7 @@ index 1a3704b2763..db0e2934038 100644 | |||
196 | = STANDARD_STARTFILE_PREFIX_2; | 246 | = STANDARD_STARTFILE_PREFIX_2; |
197 | 247 | ||
198 | /* A relative path to be used in finding the location of tools | 248 | /* A relative path to be used in finding the location of tools |
199 | @@ -5915,6 +5918,11 @@ do_spec_1 (const char *spec, int inswitch, const char *soft_matched_part) | 249 | @@ -5922,6 +5925,11 @@ do_spec_1 (const char *spec, int inswitc |
200 | } | 250 | } |
201 | break; | 251 | break; |
202 | 252 | ||
@@ -208,6 +258,89 @@ index 1a3704b2763..db0e2934038 100644 | |||
208 | case 'S': | 258 | case 'S': |
209 | value = do_spec_1 (startfile_spec, 0, NULL); | 259 | value = do_spec_1 (startfile_spec, 0, NULL); |
210 | if (value != 0) | 260 | if (value != 0) |
211 | -- | 261 | Index: gcc-9.2.0/gcc/c-family/c-opts.c |
212 | 2.22.1 | 262 | =================================================================== |
213 | 263 | --- gcc-9.2.0.orig/gcc/c-family/c-opts.c | |
264 | +++ gcc-9.2.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); | ||
276 | Index: gcc-9.2.0/gcc/incpath.c | ||
277 | =================================================================== | ||
278 | --- gcc-9.2.0.orig/gcc/incpath.c | ||
279 | +++ gcc-9.2.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); | ||
323 | Index: gcc-9.2.0/gcc/prefix.c | ||
324 | =================================================================== | ||
325 | --- gcc-9.2.0.orig/gcc/prefix.c | ||
326 | +++ gcc-9.2.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 | ||