File: | build/gcc/gcc.cc |
Warning: | line 2837, column 8 Null pointer passed to 2nd parameter expecting 'nonnull' |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
1 | /* Compiler driver program that can handle many languages. | |||
2 | Copyright (C) 1987-2023 Free Software Foundation, Inc. | |||
3 | ||||
4 | This file is part of GCC. | |||
5 | ||||
6 | GCC is free software; you can redistribute it and/or modify it under | |||
7 | the terms of the GNU General Public License as published by the Free | |||
8 | Software Foundation; either version 3, or (at your option) any later | |||
9 | version. | |||
10 | ||||
11 | GCC is distributed in the hope that it will be useful, but WITHOUT ANY | |||
12 | WARRANTY; without even the implied warranty of MERCHANTABILITY or | |||
13 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |||
14 | for more details. | |||
15 | ||||
16 | You should have received a copy of the GNU General Public License | |||
17 | along with GCC; see the file COPYING3. If not see | |||
18 | <http://www.gnu.org/licenses/>. */ | |||
19 | ||||
20 | /* This program is the user interface to the C compiler and possibly to | |||
21 | other compilers. It is used because compilation is a complicated procedure | |||
22 | which involves running several programs and passing temporary files between | |||
23 | them, forwarding the users switches to those programs selectively, | |||
24 | and deleting the temporary files at the end. | |||
25 | ||||
26 | CC recognizes how to compile each input file by suffixes in the file names. | |||
27 | Once it knows which kind of compilation to perform, the procedure for | |||
28 | compilation is specified by a string called a "spec". */ | |||
29 | ||||
30 | #define INCLUDE_STRING | |||
31 | #include "config.h" | |||
32 | #include "system.h" | |||
33 | #include "coretypes.h" | |||
34 | #include "multilib.h" /* before tm.h */ | |||
35 | #include "tm.h" | |||
36 | #include "xregex.h" | |||
37 | #include "obstack.h" | |||
38 | #include "intl.h" | |||
39 | #include "prefix.h" | |||
40 | #include "opt-suggestions.h" | |||
41 | #include "gcc.h" | |||
42 | #include "diagnostic.h" | |||
43 | #include "flags.h" | |||
44 | #include "opts.h" | |||
45 | #include "filenames.h" | |||
46 | #include "spellcheck.h" | |||
47 | #include "opts-jobserver.h" | |||
48 | #include "common/common-target.h" | |||
49 | ||||
50 | ||||
51 | ||||
52 | /* Manage the manipulation of env vars. | |||
53 | ||||
54 | We poison "getenv" and "putenv", so that all enviroment-handling is | |||
55 | done through this class. Note that poisoning happens in the | |||
56 | preprocessor at the identifier level, and doesn't distinguish between | |||
57 | env.getenv (); | |||
58 | and | |||
59 | getenv (); | |||
60 | Hence we need to use "get" for the accessor method, not "getenv". */ | |||
61 | ||||
62 | struct env_manager | |||
63 | { | |||
64 | public: | |||
65 | void init (bool can_restore, bool debug); | |||
66 | const char *get (const char *name); | |||
67 | void xput (const char *string); | |||
68 | void restore (); | |||
69 | ||||
70 | private: | |||
71 | bool m_can_restore; | |||
72 | bool m_debug; | |||
73 | struct kv | |||
74 | { | |||
75 | char *m_key; | |||
76 | char *m_value; | |||
77 | }; | |||
78 | vec<kv> m_keys; | |||
79 | ||||
80 | }; | |||
81 | ||||
82 | /* The singleton instance of class env_manager. */ | |||
83 | ||||
84 | static env_manager env; | |||
85 | ||||
86 | /* Initializer for class env_manager. | |||
87 | ||||
88 | We can't do this as a constructor since we have a statically | |||
89 | allocated instance ("env" above). */ | |||
90 | ||||
91 | void | |||
92 | env_manager::init (bool can_restore, bool debug) | |||
93 | { | |||
94 | m_can_restore = can_restore; | |||
95 | m_debug = debug; | |||
96 | } | |||
97 | ||||
98 | /* Get the value of NAME within the environment. Essentially | |||
99 | a wrapper for ::getenv, but adding logging, and the possibility | |||
100 | of caching results. */ | |||
101 | ||||
102 | const char * | |||
103 | env_manager::get (const char *name) | |||
104 | { | |||
105 | const char *result = ::getenv (name); | |||
106 | if (m_debug) | |||
107 | fprintf (stderrstderr, "env_manager::getenv (%s) -> %s\n", name, result); | |||
108 | return result; | |||
109 | } | |||
110 | ||||
111 | /* Put the given KEY=VALUE entry STRING into the environment. | |||
112 | If the env_manager was initialized with CAN_RESTORE set, then | |||
113 | also record the old value of KEY within the environment, so that it | |||
114 | can be later restored. */ | |||
115 | ||||
116 | void | |||
117 | env_manager::xput (const char *string) | |||
118 | { | |||
119 | if (m_debug) | |||
120 | fprintf (stderrstderr, "env_manager::xput (%s)\n", string); | |||
121 | if (verbose_flagglobal_options.x_verbose_flag) | |||
122 | fnotice (stderrstderr, "%s\n", string); | |||
123 | ||||
124 | if (m_can_restore) | |||
125 | { | |||
126 | char *equals = strchr (const_cast <char *> (string), '='); | |||
127 | gcc_assert (equals)((void)(!(equals) ? fancy_abort ("/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/gcc.cc" , 127, __FUNCTION__), 0 : 0)); | |||
128 | ||||
129 | struct kv kv; | |||
130 | kv.m_key = xstrndup (string, equals - string); | |||
131 | const char *cur_value = ::getenv (kv.m_key); | |||
132 | if (m_debug) | |||
133 | fprintf (stderrstderr, "saving old value: %s\n",cur_value); | |||
134 | kv.m_value = cur_value ? xstrdup (cur_value) : NULLnullptr; | |||
135 | m_keys.safe_push (kv); | |||
136 | } | |||
137 | ||||
138 | ::putenv (CONST_CAST (char *, string)(const_cast<char *> ((string)))); | |||
139 | } | |||
140 | ||||
141 | /* Undo any xputenv changes made since last restore. | |||
142 | Can only be called if the env_manager was initialized with | |||
143 | CAN_RESTORE enabled. */ | |||
144 | ||||
145 | void | |||
146 | env_manager::restore () | |||
147 | { | |||
148 | unsigned int i; | |||
149 | struct kv *item; | |||
150 | ||||
151 | gcc_assert (m_can_restore)((void)(!(m_can_restore) ? fancy_abort ("/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/gcc.cc" , 151, __FUNCTION__), 0 : 0)); | |||
152 | ||||
153 | FOR_EACH_VEC_ELT_REVERSE (m_keys, i, item)for (i = (m_keys).length () - 1; (m_keys).iterate ((i), & (item)); (i)--) | |||
154 | { | |||
155 | if (m_debug) | |||
156 | printf ("restoring saved key: %s value: %s\n", item->m_key, item->m_value); | |||
157 | if (item->m_value) | |||
158 | ::setenv (item->m_key, item->m_value, 1); | |||
159 | else | |||
160 | ::unsetenv (item->m_key); | |||
161 | free (item->m_key); | |||
162 | free (item->m_value); | |||
163 | } | |||
164 | ||||
165 | m_keys.truncate (0); | |||
166 | } | |||
167 | ||||
168 | /* Forbid other uses of getenv and putenv. */ | |||
169 | #if (GCC_VERSION(4 * 1000 + 2) >= 3000) | |||
170 | #pragma GCC poison getenv putenv | |||
171 | #endif | |||
172 | ||||
173 | ||||
174 | ||||
175 | /* By default there is no special suffix for target executables. */ | |||
176 | #ifdef TARGET_EXECUTABLE_SUFFIX"" | |||
177 | #define HAVE_TARGET_EXECUTABLE_SUFFIX | |||
178 | #else | |||
179 | #define TARGET_EXECUTABLE_SUFFIX"" "" | |||
180 | #endif | |||
181 | ||||
182 | /* By default there is no special suffix for host executables. */ | |||
183 | #ifdef HOST_EXECUTABLE_SUFFIX"" | |||
184 | #define HAVE_HOST_EXECUTABLE_SUFFIX | |||
185 | #else | |||
186 | #define HOST_EXECUTABLE_SUFFIX"" "" | |||
187 | #endif | |||
188 | ||||
189 | /* By default, the suffix for target object files is ".o". */ | |||
190 | #ifdef TARGET_OBJECT_SUFFIX".o" | |||
191 | #define HAVE_TARGET_OBJECT_SUFFIX | |||
192 | #else | |||
193 | #define TARGET_OBJECT_SUFFIX".o" ".o" | |||
194 | #endif | |||
195 | ||||
196 | static const char dir_separator_str[] = { DIR_SEPARATOR'/', 0 }; | |||
197 | ||||
198 | /* Most every one is fine with LIBRARY_PATH. For some, it conflicts. */ | |||
199 | #ifndef LIBRARY_PATH_ENV"LIBRARY_PATH" | |||
200 | #define LIBRARY_PATH_ENV"LIBRARY_PATH" "LIBRARY_PATH" | |||
201 | #endif | |||
202 | ||||
203 | /* If a stage of compilation returns an exit status >= 1, | |||
204 | compilation of that file ceases. */ | |||
205 | ||||
206 | #define MIN_FATAL_STATUS1 1 | |||
207 | ||||
208 | /* Flag set by cppspec.cc to 1. */ | |||
209 | int is_cpp_driver; | |||
210 | ||||
211 | /* Flag set to nonzero if an @file argument has been supplied to gcc. */ | |||
212 | static bool at_file_supplied; | |||
213 | ||||
214 | /* Definition of string containing the arguments given to configure. */ | |||
215 | #include "configargs.h" | |||
216 | ||||
217 | /* Flag saying to print the command line options understood by gcc and its | |||
218 | sub-processes. */ | |||
219 | ||||
220 | static int print_help_list; | |||
221 | ||||
222 | /* Flag saying to print the version of gcc and its sub-processes. */ | |||
223 | ||||
224 | static int print_version; | |||
225 | ||||
226 | /* Flag that stores string prefix for which we provide bash completion. */ | |||
227 | ||||
228 | static const char *completion = NULLnullptr; | |||
229 | ||||
230 | /* Flag indicating whether we should ONLY print the command and | |||
231 | arguments (like verbose_flag) without executing the command. | |||
232 | Displayed arguments are quoted so that the generated command | |||
233 | line is suitable for execution. This is intended for use in | |||
234 | shell scripts to capture the driver-generated command line. */ | |||
235 | static int verbose_only_flag; | |||
236 | ||||
237 | /* Flag indicating how to print command line options of sub-processes. */ | |||
238 | ||||
239 | static int print_subprocess_help; | |||
240 | ||||
241 | /* Linker suffix passed to -fuse-ld=... */ | |||
242 | static const char *use_ld; | |||
243 | ||||
244 | /* Whether we should report subprocess execution times to a file. */ | |||
245 | ||||
246 | FILE *report_times_to_file = NULLnullptr; | |||
247 | ||||
248 | /* Nonzero means place this string before uses of /, so that include | |||
249 | and library files can be found in an alternate location. */ | |||
250 | ||||
251 | #ifdef TARGET_SYSTEM_ROOT | |||
252 | #define DEFAULT_TARGET_SYSTEM_ROOT(0) (TARGET_SYSTEM_ROOT) | |||
253 | #else | |||
254 | #define DEFAULT_TARGET_SYSTEM_ROOT(0) (0) | |||
255 | #endif | |||
256 | static const char *target_system_root = DEFAULT_TARGET_SYSTEM_ROOT(0); | |||
257 | ||||
258 | /* Nonzero means pass the updated target_system_root to the compiler. */ | |||
259 | ||||
260 | static int target_system_root_changed; | |||
261 | ||||
262 | /* Nonzero means append this string to target_system_root. */ | |||
263 | ||||
264 | static const char *target_sysroot_suffix = 0; | |||
265 | ||||
266 | /* Nonzero means append this string to target_system_root for headers. */ | |||
267 | ||||
268 | static const char *target_sysroot_hdrs_suffix = 0; | |||
269 | ||||
270 | /* Nonzero means write "temp" files in source directory | |||
271 | and use the source file's name in them, and don't delete them. */ | |||
272 | ||||
273 | static enum save_temps { | |||
274 | SAVE_TEMPS_NONE, /* no -save-temps */ | |||
275 | SAVE_TEMPS_CWD, /* -save-temps in current directory */ | |||
276 | SAVE_TEMPS_DUMP, /* -save-temps in dumpdir */ | |||
277 | SAVE_TEMPS_OBJ /* -save-temps in object directory */ | |||
278 | } save_temps_flag; | |||
279 | ||||
280 | /* Set this iff the dumppfx implied by a -save-temps=* option is to | |||
281 | override a -dumpdir option, if any. */ | |||
282 | static bool save_temps_overrides_dumpdir = false; | |||
283 | ||||
284 | /* -dumpdir, -dumpbase and -dumpbase-ext flags passed in, possibly | |||
285 | rearranged as they are to be passed down, e.g., dumpbase and | |||
286 | dumpbase_ext may be cleared if integrated with dumpdir or | |||
287 | dropped. */ | |||
288 | static char *dumpdir, *dumpbase, *dumpbase_ext; | |||
289 | ||||
290 | /* Usually the length of the string in dumpdir. However, during | |||
291 | linking, it may be shortened to omit a driver-added trailing dash, | |||
292 | by then replaced with a trailing period, that is still to be passed | |||
293 | to sub-processes in -dumpdir, but not to be generally used in spec | |||
294 | filename expansions. See maybe_run_linker. */ | |||
295 | static size_t dumpdir_length = 0; | |||
296 | ||||
297 | /* Set if the last character in dumpdir is (or was) a dash that the | |||
298 | driver added to dumpdir after dumpbase or linker output name. */ | |||
299 | static bool dumpdir_trailing_dash_added = false; | |||
300 | ||||
301 | /* Basename of dump and aux outputs, computed from dumpbase (given or | |||
302 | derived from output name), to override input_basename in non-%w %b | |||
303 | et al. */ | |||
304 | static char *outbase; | |||
305 | static size_t outbase_length = 0; | |||
306 | ||||
307 | /* The compiler version. */ | |||
308 | ||||
309 | static const char *compiler_version; | |||
310 | ||||
311 | /* The target version. */ | |||
312 | ||||
313 | static const char *const spec_version = DEFAULT_TARGET_VERSION"13.0.1"; | |||
314 | ||||
315 | /* The target machine. */ | |||
316 | ||||
317 | static const char *spec_machine = DEFAULT_TARGET_MACHINE"x86_64-pc-linux-gnu"; | |||
318 | static const char *spec_host_machine = DEFAULT_REAL_TARGET_MACHINE"x86_64-pc-linux-gnu"; | |||
319 | ||||
320 | /* List of offload targets. Separated by colon. Empty string for | |||
321 | -foffload=disable. */ | |||
322 | ||||
323 | static char *offload_targets = NULLnullptr; | |||
324 | ||||
325 | #if OFFLOAD_DEFAULTED | |||
326 | /* Set to true if -foffload has not been used and offload_targets | |||
327 | is set to the configured in default. */ | |||
328 | static bool offload_targets_default; | |||
329 | #endif | |||
330 | ||||
331 | /* Nonzero if cross-compiling. | |||
332 | When -b is used, the value comes from the `specs' file. */ | |||
333 | ||||
334 | #ifdef CROSS_DIRECTORY_STRUCTURE | |||
335 | static const char *cross_compile = "1"; | |||
336 | #else | |||
337 | static const char *cross_compile = "0"; | |||
338 | #endif | |||
339 | ||||
340 | /* Greatest exit code of sub-processes that has been encountered up to | |||
341 | now. */ | |||
342 | static int greatest_status = 1; | |||
343 | ||||
344 | /* This is the obstack which we use to allocate many strings. */ | |||
345 | ||||
346 | static struct obstack obstack; | |||
347 | ||||
348 | /* This is the obstack to build an environment variable to pass to | |||
349 | collect2 that describes all of the relevant switches of what to | |||
350 | pass the compiler in building the list of pointers to constructors | |||
351 | and destructors. */ | |||
352 | ||||
353 | static struct obstack collect_obstack; | |||
354 | ||||
355 | /* Forward declaration for prototypes. */ | |||
356 | struct path_prefix; | |||
357 | struct prefix_list; | |||
358 | ||||
359 | static void init_spec (void); | |||
360 | static void store_arg (const char *, int, int); | |||
361 | static void insert_wrapper (const char *); | |||
362 | static char *load_specs (const char *); | |||
363 | static void read_specs (const char *, bool, bool); | |||
364 | static void set_spec (const char *, const char *, bool); | |||
365 | static struct compiler *lookup_compiler (const char *, size_t, const char *); | |||
366 | static char *build_search_list (const struct path_prefix *, const char *, | |||
367 | bool, bool); | |||
368 | static void xputenv (const char *); | |||
369 | static void putenv_from_prefixes (const struct path_prefix *, const char *, | |||
370 | bool); | |||
371 | static int access_check (const char *, int); | |||
372 | static char *find_a_file (const struct path_prefix *, const char *, int, bool); | |||
373 | static char *find_a_program (const char *); | |||
374 | static void add_prefix (struct path_prefix *, const char *, const char *, | |||
375 | int, int, int); | |||
376 | static void add_sysrooted_prefix (struct path_prefix *, const char *, | |||
377 | const char *, int, int, int); | |||
378 | static char *skip_whitespace (char *); | |||
379 | static void delete_if_ordinary (const char *); | |||
380 | static void delete_temp_files (void); | |||
381 | static void delete_failure_queue (void); | |||
382 | static void clear_failure_queue (void); | |||
383 | static int check_live_switch (int, int); | |||
384 | static const char *handle_braces (const char *); | |||
385 | static inline bool input_suffix_matches (const char *, const char *); | |||
386 | static inline bool switch_matches (const char *, const char *, int); | |||
387 | static inline void mark_matching_switches (const char *, const char *, int); | |||
388 | static inline void process_marked_switches (void); | |||
389 | static const char *process_brace_body (const char *, const char *, const char *, int, int); | |||
390 | static const struct spec_function *lookup_spec_function (const char *); | |||
391 | static const char *eval_spec_function (const char *, const char *, const char *); | |||
392 | static const char *handle_spec_function (const char *, bool *, const char *); | |||
393 | static char *save_string (const char *, int); | |||
394 | static void set_collect_gcc_options (void); | |||
395 | static int do_spec_1 (const char *, int, const char *); | |||
396 | static int do_spec_2 (const char *, const char *); | |||
397 | static void do_option_spec (const char *, const char *); | |||
398 | static void do_self_spec (const char *); | |||
399 | static const char *find_file (const char *); | |||
400 | static int is_directory (const char *, bool); | |||
401 | static const char *validate_switches (const char *, bool, bool); | |||
402 | static void validate_all_switches (void); | |||
403 | static inline void validate_switches_from_spec (const char *, bool); | |||
404 | static void give_switch (int, int); | |||
405 | static int default_arg (const char *, int); | |||
406 | static void set_multilib_dir (void); | |||
407 | static void print_multilib_info (void); | |||
408 | static void display_help (void); | |||
409 | static void add_preprocessor_option (const char *, int); | |||
410 | static void add_assembler_option (const char *, int); | |||
411 | static void add_linker_option (const char *, int); | |||
412 | static void process_command (unsigned int, struct cl_decoded_option *); | |||
413 | static int execute (void); | |||
414 | static void alloc_args (void); | |||
415 | static void clear_args (void); | |||
416 | static void fatal_signal (int); | |||
417 | #if defined(ENABLE_SHARED_LIBGCC1) && !defined(REAL_LIBGCC_SPEC) | |||
418 | static void init_gcc_specs (struct obstack *, const char *, const char *, | |||
419 | const char *); | |||
420 | #endif | |||
421 | #if defined(HAVE_TARGET_OBJECT_SUFFIX) || defined(HAVE_TARGET_EXECUTABLE_SUFFIX) | |||
422 | static const char *convert_filename (const char *, int, int); | |||
423 | #endif | |||
424 | ||||
425 | static void try_generate_repro (const char **argv); | |||
426 | static const char *getenv_spec_function (int, const char **); | |||
427 | static const char *if_exists_spec_function (int, const char **); | |||
428 | static const char *if_exists_else_spec_function (int, const char **); | |||
429 | static const char *if_exists_then_else_spec_function (int, const char **); | |||
430 | static const char *sanitize_spec_function (int, const char **); | |||
431 | static const char *replace_outfile_spec_function (int, const char **); | |||
432 | static const char *remove_outfile_spec_function (int, const char **); | |||
433 | static const char *version_compare_spec_function (int, const char **); | |||
434 | static const char *include_spec_function (int, const char **); | |||
435 | static const char *find_file_spec_function (int, const char **); | |||
436 | static const char *find_plugindir_spec_function (int, const char **); | |||
437 | static const char *print_asm_header_spec_function (int, const char **); | |||
438 | static const char *compare_debug_dump_opt_spec_function (int, const char **); | |||
439 | static const char *compare_debug_self_opt_spec_function (int, const char **); | |||
440 | static const char *pass_through_libs_spec_func (int, const char **); | |||
441 | static const char *dumps_spec_func (int, const char **); | |||
442 | static const char *greater_than_spec_func (int, const char **); | |||
443 | static const char *debug_level_greater_than_spec_func (int, const char **); | |||
444 | static const char *dwarf_version_greater_than_spec_func (int, const char **); | |||
445 | static const char *find_fortran_preinclude_file (int, const char **); | |||
446 | static char *convert_white_space (char *); | |||
447 | static char *quote_spec (char *); | |||
448 | static char *quote_spec_arg (char *); | |||
449 | static bool not_actual_file_p (const char *); | |||
450 | ||||
451 | ||||
452 | /* The Specs Language | |||
453 | ||||
454 | Specs are strings containing lines, each of which (if not blank) | |||
455 | is made up of a program name, and arguments separated by spaces. | |||
456 | The program name must be exact and start from root, since no path | |||
457 | is searched and it is unreliable to depend on the current working directory. | |||
458 | Redirection of input or output is not supported; the subprograms must | |||
459 | accept filenames saying what files to read and write. | |||
460 | ||||
461 | In addition, the specs can contain %-sequences to substitute variable text | |||
462 | or for conditional text. Here is a table of all defined %-sequences. | |||
463 | Note that spaces are not generated automatically around the results of | |||
464 | expanding these sequences; therefore, you can concatenate them together | |||
465 | or with constant text in a single argument. | |||
466 | ||||
467 | %% substitute one % into the program name or argument. | |||
468 | %" substitute an empty argument. | |||
469 | %i substitute the name of the input file being processed. | |||
470 | %b substitute the basename for outputs related with the input file | |||
471 | being processed. This is often a substring of the input file name, | |||
472 | up to (and not including) the last period but, unless %w is active, | |||
473 | it is affected by the directory selected by -save-temps=*, by | |||
474 | -dumpdir, and, in case of multiple compilations, even by -dumpbase | |||
475 | and -dumpbase-ext and, in case of linking, by the linker output | |||
476 | name. When %w is active, it derives the main output name only from | |||
477 | the input file base name; when it is not, it names aux/dump output | |||
478 | file. | |||
479 | %B same as %b, but include the input file suffix (text after the last | |||
480 | period). | |||
481 | %gSUFFIX | |||
482 | substitute a file name that has suffix SUFFIX and is chosen | |||
483 | once per compilation, and mark the argument a la %d. To reduce | |||
484 | exposure to denial-of-service attacks, the file name is now | |||
485 | chosen in a way that is hard to predict even when previously | |||
486 | chosen file names are known. For example, `%g.s ... %g.o ... %g.s' | |||
487 | might turn into `ccUVUUAU.s ccXYAXZ12.o ccUVUUAU.s'. SUFFIX matches | |||
488 | the regexp "[.0-9A-Za-z]*%O"; "%O" is treated exactly as if it | |||
489 | had been pre-processed. Previously, %g was simply substituted | |||
490 | with a file name chosen once per compilation, without regard | |||
491 | to any appended suffix (which was therefore treated just like | |||
492 | ordinary text), making such attacks more likely to succeed. | |||
493 | %|SUFFIX | |||
494 | like %g, but if -pipe is in effect, expands simply to "-". | |||
495 | %mSUFFIX | |||
496 | like %g, but if -pipe is in effect, expands to nothing. (We have both | |||
497 | %| and %m to accommodate differences between system assemblers; see | |||
498 | the AS_NEEDS_DASH_FOR_PIPED_INPUT target macro.) | |||
499 | %uSUFFIX | |||
500 | like %g, but generates a new temporary file name even if %uSUFFIX | |||
501 | was already seen. | |||
502 | %USUFFIX | |||
503 | substitutes the last file name generated with %uSUFFIX, generating a | |||
504 | new one if there is no such last file name. In the absence of any | |||
505 | %uSUFFIX, this is just like %gSUFFIX, except they don't share | |||
506 | the same suffix "space", so `%g.s ... %U.s ... %g.s ... %U.s' | |||
507 | would involve the generation of two distinct file names, one | |||
508 | for each `%g.s' and another for each `%U.s'. Previously, %U was | |||
509 | simply substituted with a file name chosen for the previous %u, | |||
510 | without regard to any appended suffix. | |||
511 | %jSUFFIX | |||
512 | substitutes the name of the HOST_BIT_BUCKET, if any, and if it is | |||
513 | writable, and if save-temps is off; otherwise, substitute the name | |||
514 | of a temporary file, just like %u. This temporary file is not | |||
515 | meant for communication between processes, but rather as a junk | |||
516 | disposal mechanism. | |||
517 | %.SUFFIX | |||
518 | substitutes .SUFFIX for the suffixes of a matched switch's args when | |||
519 | it is subsequently output with %*. SUFFIX is terminated by the next | |||
520 | space or %. | |||
521 | %d marks the argument containing or following the %d as a | |||
522 | temporary file name, so that file will be deleted if GCC exits | |||
523 | successfully. Unlike %g, this contributes no text to the argument. | |||
524 | %w marks the argument containing or following the %w as the | |||
525 | "output file" of this compilation. This puts the argument | |||
526 | into the sequence of arguments that %o will substitute later. | |||
527 | %V indicates that this compilation produces no "output file". | |||
528 | %W{...} | |||
529 | like %{...} but marks the last argument supplied within as a file | |||
530 | to be deleted on failure. | |||
531 | %@{...} | |||
532 | like %{...} but puts the result into a FILE and substitutes @FILE | |||
533 | if an @file argument has been supplied. | |||
534 | %o substitutes the names of all the output files, with spaces | |||
535 | automatically placed around them. You should write spaces | |||
536 | around the %o as well or the results are undefined. | |||
537 | %o is for use in the specs for running the linker. | |||
538 | Input files whose names have no recognized suffix are not compiled | |||
539 | at all, but they are included among the output files, so they will | |||
540 | be linked. | |||
541 | %O substitutes the suffix for object files. Note that this is | |||
542 | handled specially when it immediately follows %g, %u, or %U | |||
543 | (with or without a suffix argument) because of the need for | |||
544 | those to form complete file names. The handling is such that | |||
545 | %O is treated exactly as if it had already been substituted, | |||
546 | except that %g, %u, and %U do not currently support additional | |||
547 | SUFFIX characters following %O as they would following, for | |||
548 | example, `.o'. | |||
549 | %I Substitute any of -iprefix (made from GCC_EXEC_PREFIX), -isysroot | |||
550 | (made from TARGET_SYSTEM_ROOT), -isystem (made from COMPILER_PATH | |||
551 | and -B options) and -imultilib as necessary. | |||
552 | %s current argument is the name of a library or startup file of some sort. | |||
553 | Search for that file in a standard list of directories | |||
554 | and substitute the full name found. | |||
555 | %T current argument is the name of a linker script. | |||
556 | Search for that file in the current list of directories to scan for | |||
557 | libraries. If the file is located, insert a --script option into the | |||
558 | command line followed by the full path name found. If the file is | |||
559 | not found then generate an error message. | |||
560 | Note: the current working directory is not searched. | |||
561 | %eSTR Print STR as an error message. STR is terminated by a newline. | |||
562 | Use this when inconsistent options are detected. | |||
563 | %nSTR Print STR as a notice. STR is terminated by a newline. | |||
564 | %x{OPTION} Accumulate an option for %X. | |||
565 | %X Output the accumulated linker options specified by compilations. | |||
566 | %Y Output the accumulated assembler options specified by compilations. | |||
567 | %Z Output the accumulated preprocessor options specified by compilations. | |||
568 | %a process ASM_SPEC as a spec. | |||
569 | This allows config.h to specify part of the spec for running as. | |||
570 | %A process ASM_FINAL_SPEC as a spec. A capital A is actually | |||
571 | used here. This can be used to run a post-processor after the | |||
572 | assembler has done its job. | |||
573 | %D Dump out a -L option for each directory in startfile_prefixes. | |||
574 | If multilib_dir is set, extra entries are generated with it affixed. | |||
575 | %l process LINK_SPEC as a spec. | |||
576 | %L process LIB_SPEC as a spec. | |||
577 | %M Output multilib_os_dir. | |||
578 | %G process LIBGCC_SPEC as a spec. | |||
579 | %R Output the concatenation of target_system_root and | |||
580 | target_sysroot_suffix. | |||
581 | %S process STARTFILE_SPEC as a spec. A capital S is actually used here. | |||
582 | %E process ENDFILE_SPEC as a spec. A capital E is actually used here. | |||
583 | %C process CPP_SPEC as a spec. | |||
584 | %1 process CC1_SPEC as a spec. | |||
585 | %2 process CC1PLUS_SPEC as a spec. | |||
586 | %* substitute the variable part of a matched option. (See below.) | |||
587 | Note that each comma in the substituted string is replaced by | |||
588 | a single space. A space is appended after the last substition | |||
589 | unless there is more text in current sequence. | |||
590 | %<S remove all occurrences of -S from the command line. | |||
591 | Note - this command is position dependent. % commands in the | |||
592 | spec string before this one will see -S, % commands in the | |||
593 | spec string after this one will not. | |||
594 | %>S Similar to "%<S", but keep it in the GCC command line. | |||
595 | %<S* remove all occurrences of all switches beginning with -S from the | |||
596 | command line. | |||
597 | %:function(args) | |||
598 | Call the named function FUNCTION, passing it ARGS. ARGS is | |||
599 | first processed as a nested spec string, then split into an | |||
600 | argument vector in the usual fashion. The function returns | |||
601 | a string which is processed as if it had appeared literally | |||
602 | as part of the current spec. | |||
603 | %{S} substitutes the -S switch, if that switch was given to GCC. | |||
604 | If that switch was not specified, this substitutes nothing. | |||
605 | Here S is a metasyntactic variable. | |||
606 | %{S*} substitutes all the switches specified to GCC whose names start | |||
607 | with -S. This is used for -o, -I, etc; switches that take | |||
608 | arguments. GCC considers `-o foo' as being one switch whose | |||
609 | name starts with `o'. %{o*} would substitute this text, | |||
610 | including the space; thus, two arguments would be generated. | |||
611 | %{S*&T*} likewise, but preserve order of S and T options (the order | |||
612 | of S and T in the spec is not significant). Can be any number | |||
613 | of ampersand-separated variables; for each the wild card is | |||
614 | optional. Useful for CPP as %{D*&U*&A*}. | |||
615 | ||||
616 | %{S:X} substitutes X, if the -S switch was given to GCC. | |||
617 | %{!S:X} substitutes X, if the -S switch was NOT given to GCC. | |||
618 | %{S*:X} substitutes X if one or more switches whose names start | |||
619 | with -S was given to GCC. Normally X is substituted only | |||
620 | once, no matter how many such switches appeared. However, | |||
621 | if %* appears somewhere in X, then X will be substituted | |||
622 | once for each matching switch, with the %* replaced by the | |||
623 | part of that switch that matched the '*'. A space will be | |||
624 | appended after the last substition unless there is more | |||
625 | text in current sequence. | |||
626 | %{.S:X} substitutes X, if processing a file with suffix S. | |||
627 | %{!.S:X} substitutes X, if NOT processing a file with suffix S. | |||
628 | %{,S:X} substitutes X, if processing a file which will use spec S. | |||
629 | %{!,S:X} substitutes X, if NOT processing a file which will use spec S. | |||
630 | ||||
631 | %{S|T:X} substitutes X if either -S or -T was given to GCC. This may be | |||
632 | combined with '!', '.', ',', and '*' as above binding stronger | |||
633 | than the OR. | |||
634 | If %* appears in X, all of the alternatives must be starred, and | |||
635 | only the first matching alternative is substituted. | |||
636 | %{%:function(args):X} | |||
637 | Call function named FUNCTION with args ARGS. If the function | |||
638 | returns non-NULL, then X is substituted, if it returns | |||
639 | NULL, it isn't substituted. | |||
640 | %{S:X; if S was given to GCC, substitutes X; | |||
641 | T:Y; else if T was given to GCC, substitutes Y; | |||
642 | :D} else substitutes D. There can be as many clauses as you need. | |||
643 | This may be combined with '.', '!', ',', '|', and '*' as above. | |||
644 | ||||
645 | %(Spec) processes a specification defined in a specs file as *Spec: | |||
646 | ||||
647 | The switch matching text S in a %{S}, %{S:X}, or similar construct can use | |||
648 | a backslash to ignore the special meaning of the character following it, | |||
649 | thus allowing literal matching of a character that is otherwise specially | |||
650 | treated. For example, %{std=iso9899\:1999:X} substitutes X if the | |||
651 | -std=iso9899:1999 option is given. | |||
652 | ||||
653 | The conditional text X in a %{S:X} or similar construct may contain | |||
654 | other nested % constructs or spaces, or even newlines. They are | |||
655 | processed as usual, as described above. Trailing white space in X is | |||
656 | ignored. White space may also appear anywhere on the left side of the | |||
657 | colon in these constructs, except between . or * and the corresponding | |||
658 | word. | |||
659 | ||||
660 | The -O, -f, -g, -m, and -W switches are handled specifically in these | |||
661 | constructs. If another value of -O or the negated form of a -f, -m, or | |||
662 | -W switch is found later in the command line, the earlier switch | |||
663 | value is ignored, except with {S*} where S is just one letter; this | |||
664 | passes all matching options. | |||
665 | ||||
666 | The character | at the beginning of the predicate text is used to indicate | |||
667 | that a command should be piped to the following command, but only if -pipe | |||
668 | is specified. | |||
669 | ||||
670 | Note that it is built into GCC which switches take arguments and which | |||
671 | do not. You might think it would be useful to generalize this to | |||
672 | allow each compiler's spec to say which switches take arguments. But | |||
673 | this cannot be done in a consistent fashion. GCC cannot even decide | |||
674 | which input files have been specified without knowing which switches | |||
675 | take arguments, and it must know which input files to compile in order | |||
676 | to tell which compilers to run. | |||
677 | ||||
678 | GCC also knows implicitly that arguments starting in `-l' are to be | |||
679 | treated as compiler output files, and passed to the linker in their | |||
680 | proper position among the other output files. */ | |||
681 | ||||
682 | /* Define the macros used for specs %a, %l, %L, %S, %C, %1. */ | |||
683 | ||||
684 | /* config.h can define ASM_SPEC to provide extra args to the assembler | |||
685 | or extra switch-translations. */ | |||
686 | #ifndef ASM_SPEC"%{" "m16|m32" ":--32} %{" "m16|m32|mx32:;" ":--64} %{" "mx32" ":--x32} %{msse2avx:%{!mavx:-msse2avx}}" | |||
687 | #define ASM_SPEC"%{" "m16|m32" ":--32} %{" "m16|m32|mx32:;" ":--64} %{" "mx32" ":--x32} %{msse2avx:%{!mavx:-msse2avx}}" "" | |||
688 | #endif | |||
689 | ||||
690 | /* config.h can define ASM_FINAL_SPEC to run a post processor after | |||
691 | the assembler has run. */ | |||
692 | #ifndef ASM_FINAL_SPEC"%{gsplit-dwarf: \n objcopy --extract-dwo %{c:%{o*:%*}%{!o*:%w%b%O}}%{!c:%U%O} %b.dwo \n objcopy --strip-dwo %{c:%{o*:%*}%{!o*:%w%b%O}}%{!c:%U%O} }" | |||
693 | #define ASM_FINAL_SPEC"%{gsplit-dwarf: \n objcopy --extract-dwo %{c:%{o*:%*}%{!o*:%w%b%O}}%{!c:%U%O} %b.dwo \n objcopy --strip-dwo %{c:%{o*:%*}%{!o*:%w%b%O}}%{!c:%U%O} }" \ | |||
694 | "%{gsplit-dwarf: \n\ | |||
695 | objcopy --extract-dwo \ | |||
696 | %{c:%{o*:%*}%{!o*:%w%b%O}}%{!c:%U%O} \ | |||
697 | %b.dwo \n\ | |||
698 | objcopy --strip-dwo \ | |||
699 | %{c:%{o*:%*}%{!o*:%w%b%O}}%{!c:%U%O} \ | |||
700 | }" | |||
701 | #endif | |||
702 | ||||
703 | /* config.h can define CPP_SPEC to provide extra args to the C preprocessor | |||
704 | or extra switch-translations. */ | |||
705 | #ifndef CPP_SPEC"%{posix:-D_POSIX_SOURCE} %{pthread:-D_REENTRANT}" | |||
706 | #define CPP_SPEC"%{posix:-D_POSIX_SOURCE} %{pthread:-D_REENTRANT}" "" | |||
707 | #endif | |||
708 | ||||
709 | /* Operating systems can define OS_CC1_SPEC to provide extra args to cc1 and | |||
710 | cc1plus or extra switch-translations. The OS_CC1_SPEC is appended | |||
711 | to CC1_SPEC in the initialization of cc1_spec. */ | |||
712 | #ifndef OS_CC1_SPEC"" | |||
713 | #define OS_CC1_SPEC"" "" | |||
714 | #endif | |||
715 | ||||
716 | /* config.h can define CC1_SPEC to provide extra args to cc1 and cc1plus | |||
717 | or extra switch-translations. */ | |||
718 | #ifndef CC1_SPEC"%{" "!mandroid" "|tno-android-cc:" "%(cc1_cpu) %{profile:-p}" ";:" "%(cc1_cpu) %{profile:-p}" " " "%{!mglibc:%{!muclibc:%{!mbionic: -mbionic}}} " "%{!fno-pic:%{!fno-PIC:%{!fpic:%{!fPIC: -fPIC}}}}" "}" | |||
719 | #define CC1_SPEC"%{" "!mandroid" "|tno-android-cc:" "%(cc1_cpu) %{profile:-p}" ";:" "%(cc1_cpu) %{profile:-p}" " " "%{!mglibc:%{!muclibc:%{!mbionic: -mbionic}}} " "%{!fno-pic:%{!fno-PIC:%{!fpic:%{!fPIC: -fPIC}}}}" "}" "" | |||
720 | #endif | |||
721 | ||||
722 | /* config.h can define CC1PLUS_SPEC to provide extra args to cc1plus | |||
723 | or extra switch-translations. */ | |||
724 | #ifndef CC1PLUS_SPEC"" | |||
725 | #define CC1PLUS_SPEC"" "" | |||
726 | #endif | |||
727 | ||||
728 | /* config.h can define LINK_SPEC to provide extra args to the linker | |||
729 | or extra switch-translations. */ | |||
730 | #ifndef LINK_SPEC"%{" "!mandroid" "|tno-android-ld:" "%{" "m16|m32|mx32:;" ":-m " "elf_x86_64" "} %{" "m16|m32" ":-m " "elf_i386" "} %{" "mx32" ":-m " "elf32_x86_64" "} %{shared:-shared} %{!shared: %{!static: %{!static-pie: %{rdynamic:-export-dynamic} %{" "m16|m32" ":-dynamic-linker " "%{" "muclibc" ":" "/lib/ld-uClibc.so.0" ";:%{" "mbionic" ":" "/system/bin/linker" ";:%{" "mmusl" ":" "/lib/ld-musl-i386.so.1" ";:" "/lib/ld-linux.so.2" "}}}" "} %{" "m16|m32|mx32:;" ":-dynamic-linker " "%{" "muclibc" ":" "/lib/ld64-uClibc.so.0" ";:%{" "mbionic" ":" "/system/bin/linker64" ";:%{" "mmusl" ":" "/lib/ld-musl-x86_64.so.1" ";:" "/lib64/ld-linux-x86-64.so.2" "}}}" "} %{" "mx32" ":-dynamic-linker " "%{" "muclibc" ":" "/lib/ldx32-uClibc.so.0" ";:%{" "mbionic" ":" "/system/bin/linkerx32" ";:%{" "mmusl" ":" "/lib/ld-musl-x32.so.1" ";:" "/libx32/ld-linux-x32.so.2" "}}}" "}}} %{static:-static} %{static-pie:-static -pie --no-dynamic-linker -z text}}" ";:" "%{" "m16|m32|mx32:;" ":-m " "elf_x86_64" "} %{" "m16|m32" ":-m " "elf_i386" "} %{" "mx32" ":-m " "elf32_x86_64" "} %{shared:-shared} %{!shared: %{!static: %{!static-pie: %{rdynamic:-export-dynamic} %{" "m16|m32" ":-dynamic-linker " "%{" "muclibc" ":" "/lib/ld-uClibc.so.0" ";:%{" "mbionic" ":" "/system/bin/linker" ";:%{" "mmusl" ":" "/lib/ld-musl-i386.so.1" ";:" "/lib/ld-linux.so.2" "}}}" "} %{" "m16|m32|mx32:;" ":-dynamic-linker " "%{" "muclibc" ":" "/lib/ld64-uClibc.so.0" ";:%{" "mbionic" ":" "/system/bin/linker64" ";:%{" "mmusl" ":" "/lib/ld-musl-x86_64.so.1" ";:" "/lib64/ld-linux-x86-64.so.2" "}}}" "} %{" "mx32" ":-dynamic-linker " "%{" "muclibc" ":" "/lib/ldx32-uClibc.so.0" ";:%{" "mbionic" ":" "/system/bin/linkerx32" ";:%{" "mmusl" ":" "/lib/ld-musl-x32.so.1" ";:" "/libx32/ld-linux-x32.so.2" "}}}" "}}} %{static:-static} %{static-pie:-static -pie --no-dynamic-linker -z text}}" " " "%{shared: -Bsymbolic}" "}" | |||
731 | #define LINK_SPEC"%{" "!mandroid" "|tno-android-ld:" "%{" "m16|m32|mx32:;" ":-m " "elf_x86_64" "} %{" "m16|m32" ":-m " "elf_i386" "} %{" "mx32" ":-m " "elf32_x86_64" "} %{shared:-shared} %{!shared: %{!static: %{!static-pie: %{rdynamic:-export-dynamic} %{" "m16|m32" ":-dynamic-linker " "%{" "muclibc" ":" "/lib/ld-uClibc.so.0" ";:%{" "mbionic" ":" "/system/bin/linker" ";:%{" "mmusl" ":" "/lib/ld-musl-i386.so.1" ";:" "/lib/ld-linux.so.2" "}}}" "} %{" "m16|m32|mx32:;" ":-dynamic-linker " "%{" "muclibc" ":" "/lib/ld64-uClibc.so.0" ";:%{" "mbionic" ":" "/system/bin/linker64" ";:%{" "mmusl" ":" "/lib/ld-musl-x86_64.so.1" ";:" "/lib64/ld-linux-x86-64.so.2" "}}}" "} %{" "mx32" ":-dynamic-linker " "%{" "muclibc" ":" "/lib/ldx32-uClibc.so.0" ";:%{" "mbionic" ":" "/system/bin/linkerx32" ";:%{" "mmusl" ":" "/lib/ld-musl-x32.so.1" ";:" "/libx32/ld-linux-x32.so.2" "}}}" "}}} %{static:-static} %{static-pie:-static -pie --no-dynamic-linker -z text}}" ";:" "%{" "m16|m32|mx32:;" ":-m " "elf_x86_64" "} %{" "m16|m32" ":-m " "elf_i386" "} %{" "mx32" ":-m " "elf32_x86_64" "} %{shared:-shared} %{!shared: %{!static: %{!static-pie: %{rdynamic:-export-dynamic} %{" "m16|m32" ":-dynamic-linker " "%{" "muclibc" ":" "/lib/ld-uClibc.so.0" ";:%{" "mbionic" ":" "/system/bin/linker" ";:%{" "mmusl" ":" "/lib/ld-musl-i386.so.1" ";:" "/lib/ld-linux.so.2" "}}}" "} %{" "m16|m32|mx32:;" ":-dynamic-linker " "%{" "muclibc" ":" "/lib/ld64-uClibc.so.0" ";:%{" "mbionic" ":" "/system/bin/linker64" ";:%{" "mmusl" ":" "/lib/ld-musl-x86_64.so.1" ";:" "/lib64/ld-linux-x86-64.so.2" "}}}" "} %{" "mx32" ":-dynamic-linker " "%{" "muclibc" ":" "/lib/ldx32-uClibc.so.0" ";:%{" "mbionic" ":" "/system/bin/linkerx32" ";:%{" "mmusl" ":" "/lib/ld-musl-x32.so.1" ";:" "/libx32/ld-linux-x32.so.2" "}}}" "}}} %{static:-static} %{static-pie:-static -pie --no-dynamic-linker -z text}}" " " "%{shared: -Bsymbolic}" "}" "" | |||
732 | #endif | |||
733 | ||||
734 | /* config.h can define LIB_SPEC to override the default libraries. */ | |||
735 | #ifndef LIB_SPEC"%{" "!mandroid" "|tno-android-ld:" "%{pthread:-lpthread} " "%{shared:-lc} %{!shared:%{profile:-lc_p}%{!profile:-lc}}" ";:" "%{shared:-lc} %{!shared:%{profile:-lc_p}%{!profile:-lc}}" " " "%{!static: -ldl}" "}" | |||
736 | #define LIB_SPEC"%{" "!mandroid" "|tno-android-ld:" "%{pthread:-lpthread} " "%{shared:-lc} %{!shared:%{profile:-lc_p}%{!profile:-lc}}" ";:" "%{shared:-lc} %{!shared:%{profile:-lc_p}%{!profile:-lc}}" " " "%{!static: -ldl}" "}" "%{!shared:%{g*:-lg} %{!p:%{!pg:-lc}}%{p:-lc_p}%{pg:-lc_p}}" | |||
737 | #endif | |||
738 | ||||
739 | /* When using -fsplit-stack we need to wrap pthread_create, in order | |||
740 | to initialize the stack guard. We always use wrapping, rather than | |||
741 | shared library ordering, and we keep the wrapper function in | |||
742 | libgcc. This is not yet a real spec, though it could become one; | |||
743 | it is currently just stuffed into LINK_SPEC. FIXME: This wrapping | |||
744 | only works with GNU ld and gold. */ | |||
745 | #ifdef HAVE_GOLD_NON_DEFAULT_SPLIT_STACK | |||
746 | #define STACK_SPLIT_SPEC" %{fsplit-stack: --wrap=pthread_create}" " %{fsplit-stack: -fuse-ld=gold --wrap=pthread_create}" | |||
747 | #else | |||
748 | #define STACK_SPLIT_SPEC" %{fsplit-stack: --wrap=pthread_create}" " %{fsplit-stack: --wrap=pthread_create}" | |||
749 | #endif | |||
750 | ||||
751 | #ifndef LIBASAN_SPEC" %{static-libasan|static:%:include(libsanitizer.spec)%(link_libasan)}" | |||
752 | #define STATIC_LIBASAN_LIBS" %{static-libasan|static:%:include(libsanitizer.spec)%(link_libasan)}" \ | |||
753 | " %{static-libasan|static:%:include(libsanitizer.spec)%(link_libasan)}" | |||
754 | #ifdef LIBASAN_EARLY_SPEC"%{!shared:libasan_preinit%O%s} " "%{static-libasan:%{!shared:" "-Bstatic" " --whole-archive -lasan --no-whole-archive " "-Bdynamic" "}}%{!static-libasan:-lasan}" | |||
755 | #define LIBASAN_SPEC" %{static-libasan|static:%:include(libsanitizer.spec)%(link_libasan)}" STATIC_LIBASAN_LIBS" %{static-libasan|static:%:include(libsanitizer.spec)%(link_libasan)}" | |||
756 | #elif defined(HAVE_LD_STATIC_DYNAMIC1) | |||
757 | #define LIBASAN_SPEC" %{static-libasan|static:%:include(libsanitizer.spec)%(link_libasan)}" "%{static-libasan:" LD_STATIC_OPTION"-Bstatic" \ | |||
758 | "} -lasan %{static-libasan:" LD_DYNAMIC_OPTION"-Bdynamic" "}" \ | |||
759 | STATIC_LIBASAN_LIBS" %{static-libasan|static:%:include(libsanitizer.spec)%(link_libasan)}" | |||
760 | #else | |||
761 | #define LIBASAN_SPEC" %{static-libasan|static:%:include(libsanitizer.spec)%(link_libasan)}" "-lasan" STATIC_LIBASAN_LIBS" %{static-libasan|static:%:include(libsanitizer.spec)%(link_libasan)}" | |||
762 | #endif | |||
763 | #endif | |||
764 | ||||
765 | #ifndef LIBASAN_EARLY_SPEC"%{!shared:libasan_preinit%O%s} " "%{static-libasan:%{!shared:" "-Bstatic" " --whole-archive -lasan --no-whole-archive " "-Bdynamic" "}}%{!static-libasan:-lasan}" | |||
766 | #define LIBASAN_EARLY_SPEC"%{!shared:libasan_preinit%O%s} " "%{static-libasan:%{!shared:" "-Bstatic" " --whole-archive -lasan --no-whole-archive " "-Bdynamic" "}}%{!static-libasan:-lasan}" "" | |||
767 | #endif | |||
768 | ||||
769 | #ifndef LIBHWASAN_SPEC" %{static-libhwasan|static:%:include(libsanitizer.spec)%(link_libhwasan)}" | |||
770 | #define STATIC_LIBHWASAN_LIBS" %{static-libhwasan|static:%:include(libsanitizer.spec)%(link_libhwasan)}" \ | |||
771 | " %{static-libhwasan|static:%:include(libsanitizer.spec)%(link_libhwasan)}" | |||
772 | #ifdef LIBHWASAN_EARLY_SPEC"%{!shared:libhwasan_preinit%O%s} " "%{static-libhwasan:%{!shared:" "-Bstatic" " --whole-archive -lhwasan --no-whole-archive " "-Bdynamic" "}}%{!static-libhwasan:-lhwasan}" | |||
773 | #define LIBHWASAN_SPEC" %{static-libhwasan|static:%:include(libsanitizer.spec)%(link_libhwasan)}" STATIC_LIBHWASAN_LIBS" %{static-libhwasan|static:%:include(libsanitizer.spec)%(link_libhwasan)}" | |||
774 | #elif defined(HAVE_LD_STATIC_DYNAMIC1) | |||
775 | #define LIBHWASAN_SPEC" %{static-libhwasan|static:%:include(libsanitizer.spec)%(link_libhwasan)}" "%{static-libhwasan:" LD_STATIC_OPTION"-Bstatic" \ | |||
776 | "} -lhwasan %{static-libhwasan:" LD_DYNAMIC_OPTION"-Bdynamic" "}" \ | |||
777 | STATIC_LIBHWASAN_LIBS" %{static-libhwasan|static:%:include(libsanitizer.spec)%(link_libhwasan)}" | |||
778 | #else | |||
779 | #define LIBHWASAN_SPEC" %{static-libhwasan|static:%:include(libsanitizer.spec)%(link_libhwasan)}" "-lhwasan" STATIC_LIBHWASAN_LIBS" %{static-libhwasan|static:%:include(libsanitizer.spec)%(link_libhwasan)}" | |||
780 | #endif | |||
781 | #endif | |||
782 | ||||
783 | #ifndef LIBHWASAN_EARLY_SPEC"%{!shared:libhwasan_preinit%O%s} " "%{static-libhwasan:%{!shared:" "-Bstatic" " --whole-archive -lhwasan --no-whole-archive " "-Bdynamic" "}}%{!static-libhwasan:-lhwasan}" | |||
784 | #define LIBHWASAN_EARLY_SPEC"%{!shared:libhwasan_preinit%O%s} " "%{static-libhwasan:%{!shared:" "-Bstatic" " --whole-archive -lhwasan --no-whole-archive " "-Bdynamic" "}}%{!static-libhwasan:-lhwasan}" "" | |||
785 | #endif | |||
786 | ||||
787 | #ifndef LIBTSAN_SPEC" %{static-libtsan|static:%:include(libsanitizer.spec)%(link_libtsan)}" | |||
788 | #define STATIC_LIBTSAN_LIBS" %{static-libtsan|static:%:include(libsanitizer.spec)%(link_libtsan)}" \ | |||
789 | " %{static-libtsan|static:%:include(libsanitizer.spec)%(link_libtsan)}" | |||
790 | #ifdef LIBTSAN_EARLY_SPEC"%{!shared:libtsan_preinit%O%s} " "%{static-libtsan:%{!shared:" "-Bstatic" " --whole-archive -ltsan --no-whole-archive " "-Bdynamic" "}}%{!static-libtsan:-ltsan}" | |||
791 | #define LIBTSAN_SPEC" %{static-libtsan|static:%:include(libsanitizer.spec)%(link_libtsan)}" STATIC_LIBTSAN_LIBS" %{static-libtsan|static:%:include(libsanitizer.spec)%(link_libtsan)}" | |||
792 | #elif defined(HAVE_LD_STATIC_DYNAMIC1) | |||
793 | #define LIBTSAN_SPEC" %{static-libtsan|static:%:include(libsanitizer.spec)%(link_libtsan)}" "%{static-libtsan:" LD_STATIC_OPTION"-Bstatic" \ | |||
794 | "} -ltsan %{static-libtsan:" LD_DYNAMIC_OPTION"-Bdynamic" "}" \ | |||
795 | STATIC_LIBTSAN_LIBS" %{static-libtsan|static:%:include(libsanitizer.spec)%(link_libtsan)}" | |||
796 | #else | |||
797 | #define LIBTSAN_SPEC" %{static-libtsan|static:%:include(libsanitizer.spec)%(link_libtsan)}" "-ltsan" STATIC_LIBTSAN_LIBS" %{static-libtsan|static:%:include(libsanitizer.spec)%(link_libtsan)}" | |||
798 | #endif | |||
799 | #endif | |||
800 | ||||
801 | #ifndef LIBTSAN_EARLY_SPEC"%{!shared:libtsan_preinit%O%s} " "%{static-libtsan:%{!shared:" "-Bstatic" " --whole-archive -ltsan --no-whole-archive " "-Bdynamic" "}}%{!static-libtsan:-ltsan}" | |||
802 | #define LIBTSAN_EARLY_SPEC"%{!shared:libtsan_preinit%O%s} " "%{static-libtsan:%{!shared:" "-Bstatic" " --whole-archive -ltsan --no-whole-archive " "-Bdynamic" "}}%{!static-libtsan:-ltsan}" "" | |||
803 | #endif | |||
804 | ||||
805 | #ifndef LIBLSAN_SPEC" %{static-liblsan|static:%:include(libsanitizer.spec)%(link_liblsan)}" | |||
806 | #define STATIC_LIBLSAN_LIBS" %{static-liblsan|static:%:include(libsanitizer.spec)%(link_liblsan)}" \ | |||
807 | " %{static-liblsan|static:%:include(libsanitizer.spec)%(link_liblsan)}" | |||
808 | #ifdef LIBLSAN_EARLY_SPEC"%{!shared:liblsan_preinit%O%s} " "%{static-liblsan:%{!shared:" "-Bstatic" " --whole-archive -llsan --no-whole-archive " "-Bdynamic" "}}%{!static-liblsan:-llsan}" | |||
809 | #define LIBLSAN_SPEC" %{static-liblsan|static:%:include(libsanitizer.spec)%(link_liblsan)}" STATIC_LIBLSAN_LIBS" %{static-liblsan|static:%:include(libsanitizer.spec)%(link_liblsan)}" | |||
810 | #elif defined(HAVE_LD_STATIC_DYNAMIC1) | |||
811 | #define LIBLSAN_SPEC" %{static-liblsan|static:%:include(libsanitizer.spec)%(link_liblsan)}" "%{static-liblsan:" LD_STATIC_OPTION"-Bstatic" \ | |||
812 | "} -llsan %{static-liblsan:" LD_DYNAMIC_OPTION"-Bdynamic" "}" \ | |||
813 | STATIC_LIBLSAN_LIBS" %{static-liblsan|static:%:include(libsanitizer.spec)%(link_liblsan)}" | |||
814 | #else | |||
815 | #define LIBLSAN_SPEC" %{static-liblsan|static:%:include(libsanitizer.spec)%(link_liblsan)}" "-llsan" STATIC_LIBLSAN_LIBS" %{static-liblsan|static:%:include(libsanitizer.spec)%(link_liblsan)}" | |||
816 | #endif | |||
817 | #endif | |||
818 | ||||
819 | #ifndef LIBLSAN_EARLY_SPEC"%{!shared:liblsan_preinit%O%s} " "%{static-liblsan:%{!shared:" "-Bstatic" " --whole-archive -llsan --no-whole-archive " "-Bdynamic" "}}%{!static-liblsan:-llsan}" | |||
820 | #define LIBLSAN_EARLY_SPEC"%{!shared:liblsan_preinit%O%s} " "%{static-liblsan:%{!shared:" "-Bstatic" " --whole-archive -llsan --no-whole-archive " "-Bdynamic" "}}%{!static-liblsan:-llsan}" "" | |||
821 | #endif | |||
822 | ||||
823 | #ifndef LIBUBSAN_SPEC"%{static-libubsan:" "-Bstatic" "} -lubsan %{static-libubsan:" "-Bdynamic" "}" " %{static-libubsan|static:%:include(libsanitizer.spec)%(link_libubsan)}" | |||
824 | #define STATIC_LIBUBSAN_LIBS" %{static-libubsan|static:%:include(libsanitizer.spec)%(link_libubsan)}" \ | |||
825 | " %{static-libubsan|static:%:include(libsanitizer.spec)%(link_libubsan)}" | |||
826 | #ifdef HAVE_LD_STATIC_DYNAMIC1 | |||
827 | #define LIBUBSAN_SPEC"%{static-libubsan:" "-Bstatic" "} -lubsan %{static-libubsan:" "-Bdynamic" "}" " %{static-libubsan|static:%:include(libsanitizer.spec)%(link_libubsan)}" "%{static-libubsan:" LD_STATIC_OPTION"-Bstatic" \ | |||
828 | "} -lubsan %{static-libubsan:" LD_DYNAMIC_OPTION"-Bdynamic" "}" \ | |||
829 | STATIC_LIBUBSAN_LIBS" %{static-libubsan|static:%:include(libsanitizer.spec)%(link_libubsan)}" | |||
830 | #else | |||
831 | #define LIBUBSAN_SPEC"%{static-libubsan:" "-Bstatic" "} -lubsan %{static-libubsan:" "-Bdynamic" "}" " %{static-libubsan|static:%:include(libsanitizer.spec)%(link_libubsan)}" "-lubsan" STATIC_LIBUBSAN_LIBS" %{static-libubsan|static:%:include(libsanitizer.spec)%(link_libubsan)}" | |||
832 | #endif | |||
833 | #endif | |||
834 | ||||
835 | /* Linker options for compressed debug sections. */ | |||
836 | #if HAVE_LD_COMPRESS_DEBUG2 == 0 | |||
837 | /* No linker support. */ | |||
838 | #define LINK_COMPRESS_DEBUG_SPEC" %{gz|gz=zlib:" "--compress-debug-sections" "=zlib}" " %{gz=none:" "--compress-debug-sections" "=none}" " %{gz=zstd:" "--compress-debug-sections" "=zstd}" " %{gz=zlib-gnu:}" \ | |||
839 | " %{gz*:%e-gz is not supported in this configuration} " | |||
840 | #elif HAVE_LD_COMPRESS_DEBUG2 == 1 | |||
841 | /* ELF gABI style. */ | |||
842 | #define LINK_COMPRESS_DEBUG_SPEC" %{gz|gz=zlib:" "--compress-debug-sections" "=zlib}" " %{gz=none:" "--compress-debug-sections" "=none}" " %{gz=zstd:" "--compress-debug-sections" "=zstd}" " %{gz=zlib-gnu:}" \ | |||
843 | " %{gz|gz=zlib:" LD_COMPRESS_DEBUG_OPTION"--compress-debug-sections" "=zlib}" \ | |||
844 | " %{gz=none:" LD_COMPRESS_DEBUG_OPTION"--compress-debug-sections" "=none}" \ | |||
845 | " %{gz=zstd:%e-gz=zstd is not supported in this configuration} " \ | |||
846 | " %{gz=zlib-gnu:}" /* Ignore silently zlib-gnu option value. */ | |||
847 | #elif HAVE_LD_COMPRESS_DEBUG2 == 2 | |||
848 | /* ELF gABI style and ZSTD. */ | |||
849 | #define LINK_COMPRESS_DEBUG_SPEC" %{gz|gz=zlib:" "--compress-debug-sections" "=zlib}" " %{gz=none:" "--compress-debug-sections" "=none}" " %{gz=zstd:" "--compress-debug-sections" "=zstd}" " %{gz=zlib-gnu:}" \ | |||
850 | " %{gz|gz=zlib:" LD_COMPRESS_DEBUG_OPTION"--compress-debug-sections" "=zlib}" \ | |||
851 | " %{gz=none:" LD_COMPRESS_DEBUG_OPTION"--compress-debug-sections" "=none}" \ | |||
852 | " %{gz=zstd:" LD_COMPRESS_DEBUG_OPTION"--compress-debug-sections" "=zstd}" \ | |||
853 | " %{gz=zlib-gnu:}" /* Ignore silently zlib-gnu option value. */ | |||
854 | #else | |||
855 | #error Unknown value for HAVE_LD_COMPRESS_DEBUG2. | |||
856 | #endif | |||
857 | ||||
858 | /* config.h can define LIBGCC_SPEC to override how and when libgcc.a is | |||
859 | included. */ | |||
860 | #ifndef LIBGCC_SPEC"-lgcc" | |||
861 | #if defined(REAL_LIBGCC_SPEC) | |||
862 | #define LIBGCC_SPEC"-lgcc" REAL_LIBGCC_SPEC | |||
863 | #elif defined(LINK_LIBGCC_SPECIAL_1) | |||
864 | /* Have gcc do the search for libgcc.a. */ | |||
865 | #define LIBGCC_SPEC"-lgcc" "libgcc.a%s" | |||
866 | #else | |||
867 | #define LIBGCC_SPEC"-lgcc" "-lgcc" | |||
868 | #endif | |||
869 | #endif | |||
870 | ||||
871 | /* config.h can define STARTFILE_SPEC to override the default crt0 files. */ | |||
872 | #ifndef STARTFILE_SPEC"%{" "!mandroid" "|tno-android-ld:" "%{shared:; pg|p|profile:%{static-pie:grcrt1.o%s;:gcrt1.o%s}; static:crt1.o%s; static-pie:rcrt1.o%s; " "pie" ":Scrt1.o%s; :crt1.o%s} " "crti.o%s" " %{static:crtbeginT.o%s; shared|static-pie|" "pie" ":crtbeginS.o%s; :crtbegin.o%s} %{fvtable-verify=none:%s; fvtable-verify=preinit:vtv_start_preinit.o%s; fvtable-verify=std:vtv_start.o%s} " "" ";:" "%{shared: crtbegin_so%O%s;:" " %{static: crtbegin_static%O%s;: crtbegin_dynamic%O%s}}" "}" | |||
873 | #define STARTFILE_SPEC"%{" "!mandroid" "|tno-android-ld:" "%{shared:; pg|p|profile:%{static-pie:grcrt1.o%s;:gcrt1.o%s}; static:crt1.o%s; static-pie:rcrt1.o%s; " "pie" ":Scrt1.o%s; :crt1.o%s} " "crti.o%s" " %{static:crtbeginT.o%s; shared|static-pie|" "pie" ":crtbeginS.o%s; :crtbegin.o%s} %{fvtable-verify=none:%s; fvtable-verify=preinit:vtv_start_preinit.o%s; fvtable-verify=std:vtv_start.o%s} " "" ";:" "%{shared: crtbegin_so%O%s;:" " %{static: crtbegin_static%O%s;: crtbegin_dynamic%O%s}}" "}" \ | |||
874 | "%{!shared:%{pg:gcrt0%O%s}%{!pg:%{p:mcrt0%O%s}%{!p:crt0%O%s}}}" | |||
875 | #endif | |||
876 | ||||
877 | /* config.h can define ENDFILE_SPEC to override the default crtn files. */ | |||
878 | #ifndef ENDFILE_SPEC"%{" "!mandroid" "|tno-android-ld:" "%{mdaz-ftz:crtfastmath.o%s;Ofast|ffast-math|funsafe-math-optimizations:%{!shared:%{!mno-daz-ftz:crtfastmath.o%s}}} %{mpc32:crtprec32.o%s} %{mpc64:crtprec64.o%s} %{mpc80:crtprec80.o%s}" " " "%{!static:%{fvtable-verify=none:%s; fvtable-verify=preinit:vtv_end_preinit.o%s; fvtable-verify=std:vtv_end.o%s}} %{static:crtend.o%s; shared|static-pie|" "pie" ":crtendS.o%s; :crtend.o%s} " "crtn.o%s" " " "" ";:" "%{mdaz-ftz:crtfastmath.o%s;Ofast|ffast-math|funsafe-math-optimizations:%{!shared:%{!mno-daz-ftz:crtfastmath.o%s}}} %{mpc32:crtprec32.o%s} %{mpc64:crtprec64.o%s} %{mpc80:crtprec80.o%s}" " " "%{shared: crtend_so%O%s;: crtend_android%O%s}" "}" | |||
879 | #define ENDFILE_SPEC"%{" "!mandroid" "|tno-android-ld:" "%{mdaz-ftz:crtfastmath.o%s;Ofast|ffast-math|funsafe-math-optimizations:%{!shared:%{!mno-daz-ftz:crtfastmath.o%s}}} %{mpc32:crtprec32.o%s} %{mpc64:crtprec64.o%s} %{mpc80:crtprec80.o%s}" " " "%{!static:%{fvtable-verify=none:%s; fvtable-verify=preinit:vtv_end_preinit.o%s; fvtable-verify=std:vtv_end.o%s}} %{static:crtend.o%s; shared|static-pie|" "pie" ":crtendS.o%s; :crtend.o%s} " "crtn.o%s" " " "" ";:" "%{mdaz-ftz:crtfastmath.o%s;Ofast|ffast-math|funsafe-math-optimizations:%{!shared:%{!mno-daz-ftz:crtfastmath.o%s}}} %{mpc32:crtprec32.o%s} %{mpc64:crtprec64.o%s} %{mpc80:crtprec80.o%s}" " " "%{shared: crtend_so%O%s;: crtend_android%O%s}" "}" "" | |||
880 | #endif | |||
881 | ||||
882 | #ifndef LINKER_NAME"collect2" | |||
883 | #define LINKER_NAME"collect2" "collect2" | |||
884 | #endif | |||
885 | ||||
886 | #ifdef HAVE_AS_DEBUG_PREFIX_MAP1 | |||
887 | #define ASM_MAP" %{ffile-prefix-map=*:--debug-prefix-map %*} %{fdebug-prefix-map=*:--debug-prefix-map %*}" " %{ffile-prefix-map=*:--debug-prefix-map %*} %{fdebug-prefix-map=*:--debug-prefix-map %*}" | |||
888 | #else | |||
889 | #define ASM_MAP" %{ffile-prefix-map=*:--debug-prefix-map %*} %{fdebug-prefix-map=*:--debug-prefix-map %*}" "" | |||
890 | #endif | |||
891 | ||||
892 | /* Assembler options for compressed debug sections. */ | |||
893 | #if HAVE_LD_COMPRESS_DEBUG2 == 0 | |||
894 | /* Reject if the linker cannot write compressed debug sections. */ | |||
895 | #define ASM_COMPRESS_DEBUG_SPEC" %{gz|gz=zlib:" "--compress-debug-sections" "=zlib}" " %{gz=none:" "--compress-debug-sections" "=none}" " %{gz=zstd:" "--compress-debug-sections" "=zstd}" " %{gz=zlib-gnu:}" \ | |||
896 | " %{gz*:%e-gz is not supported in this configuration} " | |||
897 | #else /* HAVE_LD_COMPRESS_DEBUG >= 1 */ | |||
898 | #if HAVE_AS_COMPRESS_DEBUG2 == 0 | |||
899 | /* No assembler support. Ignore silently. */ | |||
900 | #define ASM_COMPRESS_DEBUG_SPEC" %{gz|gz=zlib:" "--compress-debug-sections" "=zlib}" " %{gz=none:" "--compress-debug-sections" "=none}" " %{gz=zstd:" "--compress-debug-sections" "=zstd}" " %{gz=zlib-gnu:}" \ | |||
901 | " %{gz*:} " | |||
902 | #elif HAVE_AS_COMPRESS_DEBUG2 == 1 | |||
903 | /* ELF gABI style. */ | |||
904 | #define ASM_COMPRESS_DEBUG_SPEC" %{gz|gz=zlib:" "--compress-debug-sections" "=zlib}" " %{gz=none:" "--compress-debug-sections" "=none}" " %{gz=zstd:" "--compress-debug-sections" "=zstd}" " %{gz=zlib-gnu:}" \ | |||
905 | " %{gz|gz=zlib:" AS_COMPRESS_DEBUG_OPTION"--compress-debug-sections" "=zlib}" \ | |||
906 | " %{gz=none:" AS_COMPRESS_DEBUG_OPTION"--compress-debug-sections" "=none}" \ | |||
907 | " %{gz=zlib-gnu:}" /* Ignore silently zlib-gnu option value. */ | |||
908 | #elif HAVE_AS_COMPRESS_DEBUG2 == 2 | |||
909 | /* ELF gABI style and ZSTD. */ | |||
910 | #define ASM_COMPRESS_DEBUG_SPEC" %{gz|gz=zlib:" "--compress-debug-sections" "=zlib}" " %{gz=none:" "--compress-debug-sections" "=none}" " %{gz=zstd:" "--compress-debug-sections" "=zstd}" " %{gz=zlib-gnu:}" \ | |||
911 | " %{gz|gz=zlib:" AS_COMPRESS_DEBUG_OPTION"--compress-debug-sections" "=zlib}" \ | |||
912 | " %{gz=none:" AS_COMPRESS_DEBUG_OPTION"--compress-debug-sections" "=none}" \ | |||
913 | " %{gz=zstd:" AS_COMPRESS_DEBUG_OPTION"--compress-debug-sections" "=zstd}" \ | |||
914 | " %{gz=zlib-gnu:}" /* Ignore silently zlib-gnu option value. */ | |||
915 | #else | |||
916 | #error Unknown value for HAVE_AS_COMPRESS_DEBUG2. | |||
917 | #endif | |||
918 | #endif /* HAVE_LD_COMPRESS_DEBUG >= 1 */ | |||
919 | ||||
920 | /* Define ASM_DEBUG_SPEC to be a spec suitable for translating '-g' | |||
921 | to the assembler, when compiling assembly sources only. */ | |||
922 | #ifndef ASM_DEBUG_SPEC"%{g*:%{%:debug-level-gt(0):" "" "}}" " %{ffile-prefix-map=*:--debug-prefix-map %*} %{fdebug-prefix-map=*:--debug-prefix-map %*}" | |||
923 | # if defined(HAVE_AS_GDWARF_5_DEBUG_FLAG1) && defined(HAVE_AS_WORKING_DWARF_N_FLAG1) | |||
924 | /* If --gdwarf-N is supported and as can handle even compiler generated | |||
925 | .debug_line with it, supply --gdwarf-N in ASM_DEBUG_OPTION_SPEC rather | |||
926 | than in ASM_DEBUG_SPEC, so that it applies to both .s and .c etc. | |||
927 | compilations. */ | |||
928 | # define ASM_DEBUG_DWARF_OPTION"" "" | |||
929 | # elif defined(HAVE_AS_GDWARF_5_DEBUG_FLAG1) && !defined(HAVE_LD_BROKEN_PE_DWARF5) | |||
930 | # define ASM_DEBUG_DWARF_OPTION"" "%{%:dwarf-version-gt(4):--gdwarf-5;" \ | |||
931 | "%:dwarf-version-gt(3):--gdwarf-4;" \ | |||
932 | "%:dwarf-version-gt(2):--gdwarf-3;" \ | |||
933 | ":--gdwarf2}" | |||
934 | # else | |||
935 | # define ASM_DEBUG_DWARF_OPTION"" "--gdwarf2" | |||
936 | # endif | |||
937 | # if defined(DWARF2_DEBUGGING_INFO1) && defined(HAVE_AS_GDWARF2_DEBUG_FLAG1) | |||
938 | # define ASM_DEBUG_SPEC"%{g*:%{%:debug-level-gt(0):" "" "}}" " %{ffile-prefix-map=*:--debug-prefix-map %*} %{fdebug-prefix-map=*:--debug-prefix-map %*}" "%{g*:%{%:debug-level-gt(0):" \ | |||
939 | ASM_DEBUG_DWARF_OPTION"" "}}" ASM_MAP" %{ffile-prefix-map=*:--debug-prefix-map %*} %{fdebug-prefix-map=*:--debug-prefix-map %*}" | |||
940 | # endif | |||
941 | # endif | |||
942 | #ifndef ASM_DEBUG_SPEC"%{g*:%{%:debug-level-gt(0):" "" "}}" " %{ffile-prefix-map=*:--debug-prefix-map %*} %{fdebug-prefix-map=*:--debug-prefix-map %*}" | |||
943 | # define ASM_DEBUG_SPEC"%{g*:%{%:debug-level-gt(0):" "" "}}" " %{ffile-prefix-map=*:--debug-prefix-map %*} %{fdebug-prefix-map=*:--debug-prefix-map %*}" "" | |||
944 | #endif | |||
945 | ||||
946 | /* Define ASM_DEBUG_OPTION_SPEC to be a spec suitable for translating '-g' | |||
947 | to the assembler when compiling all sources. */ | |||
948 | #ifndef ASM_DEBUG_OPTION_SPEC"%{g*:%{%:debug-level-gt(0):" "%{%:dwarf-version-gt(4):--gdwarf-5 ;" "%:dwarf-version-gt(3):--gdwarf-4 ;" "%:dwarf-version-gt(2):--gdwarf-3 ;" ":--gdwarf2 }" "}}" | |||
949 | # if defined(HAVE_AS_GDWARF_5_DEBUG_FLAG1) && defined(HAVE_AS_WORKING_DWARF_N_FLAG1) | |||
950 | # define ASM_DEBUG_OPTION_DWARF_OPT"%{%:dwarf-version-gt(4):--gdwarf-5 ;" "%:dwarf-version-gt(3):--gdwarf-4 ;" "%:dwarf-version-gt(2):--gdwarf-3 ;" ":--gdwarf2 }" \ | |||
951 | "%{%:dwarf-version-gt(4):--gdwarf-5 ;" \ | |||
952 | "%:dwarf-version-gt(3):--gdwarf-4 ;" \ | |||
953 | "%:dwarf-version-gt(2):--gdwarf-3 ;" \ | |||
954 | ":--gdwarf2 }" | |||
955 | # if defined(DWARF2_DEBUGGING_INFO1) | |||
956 | # define ASM_DEBUG_OPTION_SPEC"%{g*:%{%:debug-level-gt(0):" "%{%:dwarf-version-gt(4):--gdwarf-5 ;" "%:dwarf-version-gt(3):--gdwarf-4 ;" "%:dwarf-version-gt(2):--gdwarf-3 ;" ":--gdwarf2 }" "}}" "%{g*:%{%:debug-level-gt(0):" \ | |||
957 | ASM_DEBUG_OPTION_DWARF_OPT"%{%:dwarf-version-gt(4):--gdwarf-5 ;" "%:dwarf-version-gt(3):--gdwarf-4 ;" "%:dwarf-version-gt(2):--gdwarf-3 ;" ":--gdwarf2 }" "}}" | |||
958 | # endif | |||
959 | # endif | |||
960 | #endif | |||
961 | #ifndef ASM_DEBUG_OPTION_SPEC"%{g*:%{%:debug-level-gt(0):" "%{%:dwarf-version-gt(4):--gdwarf-5 ;" "%:dwarf-version-gt(3):--gdwarf-4 ;" "%:dwarf-version-gt(2):--gdwarf-3 ;" ":--gdwarf2 }" "}}" | |||
962 | # define ASM_DEBUG_OPTION_SPEC"%{g*:%{%:debug-level-gt(0):" "%{%:dwarf-version-gt(4):--gdwarf-5 ;" "%:dwarf-version-gt(3):--gdwarf-4 ;" "%:dwarf-version-gt(2):--gdwarf-3 ;" ":--gdwarf2 }" "}}" "" | |||
963 | #endif | |||
964 | ||||
965 | /* Here is the spec for running the linker, after compiling all files. */ | |||
966 | ||||
967 | /* This is overridable by the target in case they need to specify the | |||
968 | -lgcc and -lc order specially, yet not require them to override all | |||
969 | of LINK_COMMAND_SPEC. */ | |||
970 | #ifndef LINK_GCC_C_SEQUENCE_SPEC"%{static|static-pie:--start-group} %G %{!nolibc:%L} %{static|static-pie:--end-group}%{!static:%{!static-pie:%G}}" | |||
971 | #define LINK_GCC_C_SEQUENCE_SPEC"%{static|static-pie:--start-group} %G %{!nolibc:%L} %{static|static-pie:--end-group}%{!static:%{!static-pie:%G}}" "%G %{!nolibc:%L %G}" | |||
972 | #endif | |||
973 | ||||
974 | #ifndef LINK_SSP_SPEC"%{fstack-protector|fstack-protector-all" "|fstack-protector-strong|fstack-protector-explicit:}" | |||
975 | #ifdef TARGET_LIBC_PROVIDES_SSP1 | |||
976 | #define LINK_SSP_SPEC"%{fstack-protector|fstack-protector-all" "|fstack-protector-strong|fstack-protector-explicit:}" "%{fstack-protector|fstack-protector-all" \ | |||
977 | "|fstack-protector-strong|fstack-protector-explicit:}" | |||
978 | #else | |||
979 | #define LINK_SSP_SPEC"%{fstack-protector|fstack-protector-all" "|fstack-protector-strong|fstack-protector-explicit:}" "%{fstack-protector|fstack-protector-all" \ | |||
980 | "|fstack-protector-strong|fstack-protector-explicit" \ | |||
981 | ":-lssp_nonshared -lssp}" | |||
982 | #endif | |||
983 | #endif | |||
984 | ||||
985 | #ifdef ENABLE_DEFAULT_PIE | |||
986 | #define PIE_SPEC"pie" "!no-pie" | |||
987 | #define NO_FPIE1_SPEC"fpie" ":;" "fno-pie" | |||
988 | #define FPIE1_SPEC"fpie" NO_FPIE1_SPEC"fpie" ":;" ":;" | |||
989 | #define NO_FPIE2_SPEC"fPIE" ":;" "fno-PIE" | |||
990 | #define FPIE2_SPEC"fPIE" NO_FPIE2_SPEC"fPIE" ":;" ":;" | |||
991 | #define NO_FPIE_SPEC"fpie" "|" "fPIE" ":;" NO_FPIE1_SPEC"fpie" ":;" "|" NO_FPIE2_SPEC"fPIE" ":;" | |||
992 | #define FPIE_SPEC"fpie" "|" "fPIE" NO_FPIE_SPEC"fpie" "|" "fPIE" ":;" ":;" | |||
993 | #define NO_FPIC1_SPEC"fpic" ":;" "fno-pic" | |||
994 | #define FPIC1_SPEC"fpic" NO_FPIC1_SPEC"fpic" ":;" ":;" | |||
995 | #define NO_FPIC2_SPEC"fPIC" ":;" "fno-PIC" | |||
996 | #define FPIC2_SPEC"fPIC" NO_FPIC2_SPEC"fPIC" ":;" ":;" | |||
997 | #define NO_FPIC_SPEC"fpic" "|" "fPIC" ":;" NO_FPIC1_SPEC"fpic" ":;" "|" NO_FPIC2_SPEC"fPIC" ":;" | |||
998 | #define FPIC_SPEC"fpic" "|" "fPIC" NO_FPIC_SPEC"fpic" "|" "fPIC" ":;" ":;" | |||
999 | #define NO_FPIE1_AND_FPIC1_SPEC"fpie" "|" "fpic" ":;" NO_FPIE1_SPEC"fpie" ":;" "|" NO_FPIC1_SPEC"fpic" ":;" | |||
1000 | #define FPIE1_OR_FPIC1_SPEC"fpie" "|" "fpic" NO_FPIE1_AND_FPIC1_SPEC"fpie" "|" "fpic" ":;" ":;" | |||
1001 | #define NO_FPIE2_AND_FPIC2_SPECFPIE1_OR_FPIC2_SPEC ":;" NO_FPIE2_SPEC"fPIE" ":;" "|" NO_FPIC2_SPEC"fPIC" ":;" | |||
1002 | #define FPIE2_OR_FPIC2_SPEC"fPIE" "|" "fPIC" NO_FPIE2_AND_FPIC2_SPECFPIE1_OR_FPIC2_SPEC ":;" ":;" | |||
1003 | #define NO_FPIE_AND_FPIC_SPEC"fpie" "|" "fPIE" "|" "fpic" "|" "fPIC" ":;" NO_FPIE_SPEC"fpie" "|" "fPIE" ":;" "|" NO_FPIC_SPEC"fpic" "|" "fPIC" ":;" | |||
1004 | #define FPIE_OR_FPIC_SPEC"fpie" "|" "fPIE" "|" "fpic" "|" "fPIC" NO_FPIE_AND_FPIC_SPEC"fpie" "|" "fPIE" "|" "fpic" "|" "fPIC" ":;" ":;" | |||
1005 | #else | |||
1006 | #define PIE_SPEC"pie" "pie" | |||
1007 | #define FPIE1_SPEC"fpie" "fpie" | |||
1008 | #define NO_FPIE1_SPEC"fpie" ":;" FPIE1_SPEC"fpie" ":;" | |||
1009 | #define FPIE2_SPEC"fPIE" "fPIE" | |||
1010 | #define NO_FPIE2_SPEC"fPIE" ":;" FPIE2_SPEC"fPIE" ":;" | |||
1011 | #define FPIE_SPEC"fpie" "|" "fPIE" FPIE1_SPEC"fpie" "|" FPIE2_SPEC"fPIE" | |||
1012 | #define NO_FPIE_SPEC"fpie" "|" "fPIE" ":;" FPIE_SPEC"fpie" "|" "fPIE" ":;" | |||
1013 | #define FPIC1_SPEC"fpic" "fpic" | |||
1014 | #define NO_FPIC1_SPEC"fpic" ":;" FPIC1_SPEC"fpic" ":;" | |||
1015 | #define FPIC2_SPEC"fPIC" "fPIC" | |||
1016 | #define NO_FPIC2_SPEC"fPIC" ":;" FPIC2_SPEC"fPIC" ":;" | |||
1017 | #define FPIC_SPEC"fpic" "|" "fPIC" FPIC1_SPEC"fpic" "|" FPIC2_SPEC"fPIC" | |||
1018 | #define NO_FPIC_SPEC"fpic" "|" "fPIC" ":;" FPIC_SPEC"fpic" "|" "fPIC" ":;" | |||
1019 | #define FPIE1_OR_FPIC1_SPEC"fpie" "|" "fpic" FPIE1_SPEC"fpie" "|" FPIC1_SPEC"fpic" | |||
1020 | #define NO_FPIE1_AND_FPIC1_SPEC"fpie" "|" "fpic" ":;" FPIE1_OR_FPIC1_SPEC"fpie" "|" "fpic" ":;" | |||
1021 | #define FPIE2_OR_FPIC2_SPEC"fPIE" "|" "fPIC" FPIE2_SPEC"fPIE" "|" FPIC2_SPEC"fPIC" | |||
1022 | #define NO_FPIE2_AND_FPIC2_SPECFPIE1_OR_FPIC2_SPEC ":;" FPIE1_OR_FPIC2_SPEC ":;" | |||
1023 | #define FPIE_OR_FPIC_SPEC"fpie" "|" "fPIE" "|" "fpic" "|" "fPIC" FPIE_SPEC"fpie" "|" "fPIE" "|" FPIC_SPEC"fpic" "|" "fPIC" | |||
1024 | #define NO_FPIE_AND_FPIC_SPEC"fpie" "|" "fPIE" "|" "fpic" "|" "fPIC" ":;" FPIE_OR_FPIC_SPEC"fpie" "|" "fPIE" "|" "fpic" "|" "fPIC" ":;" | |||
1025 | #endif | |||
1026 | ||||
1027 | #ifndef LINK_PIE_SPEC"%{static|shared|r:;" "pie" ":" "-pie" "} " | |||
1028 | #ifdef HAVE_LD_PIE1 | |||
1029 | #ifndef LD_PIE_SPEC"-pie" | |||
1030 | #define LD_PIE_SPEC"-pie" "-pie" | |||
1031 | #endif | |||
1032 | #else | |||
1033 | #define LD_PIE_SPEC"-pie" "" | |||
1034 | #endif | |||
1035 | #define LINK_PIE_SPEC"%{static|shared|r:;" "pie" ":" "-pie" "} " "%{static|shared|r:;" PIE_SPEC"pie" ":" LD_PIE_SPEC"-pie" "} " | |||
1036 | #endif | |||
1037 | ||||
1038 | #ifndef LINK_BUILDID_SPEC | |||
1039 | # if defined(HAVE_LD_BUILDID1) && defined(ENABLE_LD_BUILDID) | |||
1040 | # define LINK_BUILDID_SPEC "%{!r:--build-id} " | |||
1041 | # endif | |||
1042 | #endif | |||
1043 | ||||
1044 | #ifndef LTO_PLUGIN_SPEC"" | |||
1045 | #define LTO_PLUGIN_SPEC"" "" | |||
1046 | #endif | |||
1047 | ||||
1048 | /* Conditional to test whether the LTO plugin is used or not. | |||
1049 | FIXME: For slim LTO we will need to enable plugin unconditionally. This | |||
1050 | still cause problems with PLUGIN_LD != LD and when plugin is built but | |||
1051 | not useable. For GCC 4.6 we don't support slim LTO and thus we can enable | |||
1052 | plugin only when LTO is enabled. We still honor explicit | |||
1053 | -fuse-linker-plugin if the linker used understands -plugin. */ | |||
1054 | ||||
1055 | /* The linker has some plugin support. */ | |||
1056 | #if HAVE_LTO_PLUGIN2 > 0 | |||
1057 | /* The linker used has full plugin support, use LTO plugin by default. */ | |||
1058 | #if HAVE_LTO_PLUGIN2 == 2 | |||
1059 | #define PLUGIN_COND"!fno-use-linker-plugin:%{!fno-lto" "!fno-use-linker-plugin:%{!fno-lto" | |||
1060 | #define PLUGIN_COND_CLOSE"}" "}" | |||
1061 | #else | |||
1062 | /* The linker used has limited plugin support, use LTO plugin with explicit | |||
1063 | -fuse-linker-plugin. */ | |||
1064 | #define PLUGIN_COND"!fno-use-linker-plugin:%{!fno-lto" "fuse-linker-plugin" | |||
1065 | #define PLUGIN_COND_CLOSE"}" "" | |||
1066 | #endif | |||
1067 | #define LINK_PLUGIN_SPEC"%{" "!fno-use-linker-plugin:%{!fno-lto"": -plugin %(linker_plugin_file) -plugin-opt=%(lto_wrapper) -plugin-opt=-fresolution=%u.res " "" " %{flinker-output=*:-plugin-opt=-linker-output-known} %{!nostdlib:%{!nodefaultlibs:%:pass-through-libs(%(link_gcc_c_sequence))}} }" "}" \ | |||
1068 | "%{" PLUGIN_COND"!fno-use-linker-plugin:%{!fno-lto"": \ | |||
1069 | -plugin %(linker_plugin_file) \ | |||
1070 | -plugin-opt=%(lto_wrapper) \ | |||
1071 | -plugin-opt=-fresolution=%u.res \ | |||
1072 | " LTO_PLUGIN_SPEC"" "\ | |||
1073 | %{flinker-output=*:-plugin-opt=-linker-output-known} \ | |||
1074 | %{!nostdlib:%{!nodefaultlibs:%:pass-through-libs(%(link_gcc_c_sequence))}} \ | |||
1075 | }" PLUGIN_COND_CLOSE"}" | |||
1076 | #else | |||
1077 | /* The linker used doesn't support -plugin, reject -fuse-linker-plugin. */ | |||
1078 | #define LINK_PLUGIN_SPEC"%{" "!fno-use-linker-plugin:%{!fno-lto"": -plugin %(linker_plugin_file) -plugin-opt=%(lto_wrapper) -plugin-opt=-fresolution=%u.res " "" " %{flinker-output=*:-plugin-opt=-linker-output-known} %{!nostdlib:%{!nodefaultlibs:%:pass-through-libs(%(link_gcc_c_sequence))}} }" "}" "%{fuse-linker-plugin:\ | |||
1079 | %e-fuse-linker-plugin is not supported in this configuration}" | |||
1080 | #endif | |||
1081 | ||||
1082 | /* Linker command line options for -fsanitize= early on the command line. */ | |||
1083 | #ifndef SANITIZER_EARLY_SPEC"%{!nostdlib:%{!r:%{!nodefaultlibs:%{%:sanitize(address):" "%{!shared:libasan_preinit%O%s} " "%{static-libasan:%{!shared:" "-Bstatic" " --whole-archive -lasan --no-whole-archive " "-Bdynamic" "}}%{!static-libasan:-lasan}" "} %{%:sanitize(hwaddress):" "%{!shared:libhwasan_preinit%O%s} " "%{static-libhwasan:%{!shared:" "-Bstatic" " --whole-archive -lhwasan --no-whole-archive " "-Bdynamic" "}}%{!static-libhwasan:-lhwasan}" "} %{%:sanitize(thread):" "%{!shared:libtsan_preinit%O%s} " "%{static-libtsan:%{!shared:" "-Bstatic" " --whole-archive -ltsan --no-whole-archive " "-Bdynamic" "}}%{!static-libtsan:-ltsan}" "} %{%:sanitize(leak):" "%{!shared:liblsan_preinit%O%s} " "%{static-liblsan:%{!shared:" "-Bstatic" " --whole-archive -llsan --no-whole-archive " "-Bdynamic" "}}%{!static-liblsan:-llsan}" "}}}}" | |||
1084 | #define SANITIZER_EARLY_SPEC"%{!nostdlib:%{!r:%{!nodefaultlibs:%{%:sanitize(address):" "%{!shared:libasan_preinit%O%s} " "%{static-libasan:%{!shared:" "-Bstatic" " --whole-archive -lasan --no-whole-archive " "-Bdynamic" "}}%{!static-libasan:-lasan}" "} %{%:sanitize(hwaddress):" "%{!shared:libhwasan_preinit%O%s} " "%{static-libhwasan:%{!shared:" "-Bstatic" " --whole-archive -lhwasan --no-whole-archive " "-Bdynamic" "}}%{!static-libhwasan:-lhwasan}" "} %{%:sanitize(thread):" "%{!shared:libtsan_preinit%O%s} " "%{static-libtsan:%{!shared:" "-Bstatic" " --whole-archive -ltsan --no-whole-archive " "-Bdynamic" "}}%{!static-libtsan:-ltsan}" "} %{%:sanitize(leak):" "%{!shared:liblsan_preinit%O%s} " "%{static-liblsan:%{!shared:" "-Bstatic" " --whole-archive -llsan --no-whole-archive " "-Bdynamic" "}}%{!static-liblsan:-llsan}" "}}}}" "\ | |||
1085 | %{!nostdlib:%{!r:%{!nodefaultlibs:%{%:sanitize(address):" LIBASAN_EARLY_SPEC"%{!shared:libasan_preinit%O%s} " "%{static-libasan:%{!shared:" "-Bstatic" " --whole-archive -lasan --no-whole-archive " "-Bdynamic" "}}%{!static-libasan:-lasan}" "} \ | |||
1086 | %{%:sanitize(hwaddress):" LIBHWASAN_EARLY_SPEC"%{!shared:libhwasan_preinit%O%s} " "%{static-libhwasan:%{!shared:" "-Bstatic" " --whole-archive -lhwasan --no-whole-archive " "-Bdynamic" "}}%{!static-libhwasan:-lhwasan}" "} \ | |||
1087 | %{%:sanitize(thread):" LIBTSAN_EARLY_SPEC"%{!shared:libtsan_preinit%O%s} " "%{static-libtsan:%{!shared:" "-Bstatic" " --whole-archive -ltsan --no-whole-archive " "-Bdynamic" "}}%{!static-libtsan:-ltsan}" "} \ | |||
1088 | %{%:sanitize(leak):" LIBLSAN_EARLY_SPEC"%{!shared:liblsan_preinit%O%s} " "%{static-liblsan:%{!shared:" "-Bstatic" " --whole-archive -llsan --no-whole-archive " "-Bdynamic" "}}%{!static-liblsan:-llsan}" "}}}}" | |||
1089 | #endif | |||
1090 | ||||
1091 | /* Linker command line options for -fsanitize= late on the command line. */ | |||
1092 | #ifndef SANITIZER_SPEC"%{!nostdlib:%{!r:%{!nodefaultlibs:%{%:sanitize(address):" " %{static-libasan|static:%:include(libsanitizer.spec)%(link_libasan)}" " %{static:%ecannot specify -static with -fsanitize=address}} %{%:sanitize(hwaddress):" " %{static-libhwasan|static:%:include(libsanitizer.spec)%(link_libhwasan)}" " %{static:%ecannot specify -static with -fsanitize=hwaddress}} %{%:sanitize(thread):" " %{static-libtsan|static:%:include(libsanitizer.spec)%(link_libtsan)}" " %{static:%ecannot specify -static with -fsanitize=thread}} %{%:sanitize(undefined):" "%{static-libubsan:" "-Bstatic" "} -lubsan %{static-libubsan:" "-Bdynamic" "}" " %{static-libubsan|static:%:include(libsanitizer.spec)%(link_libubsan)}" "} %{%:sanitize(leak):" " %{static-liblsan|static:%:include(libsanitizer.spec)%(link_liblsan)}" "}}}}" | |||
1093 | #define SANITIZER_SPEC"%{!nostdlib:%{!r:%{!nodefaultlibs:%{%:sanitize(address):" " %{static-libasan|static:%:include(libsanitizer.spec)%(link_libasan)}" " %{static:%ecannot specify -static with -fsanitize=address}} %{%:sanitize(hwaddress):" " %{static-libhwasan|static:%:include(libsanitizer.spec)%(link_libhwasan)}" " %{static:%ecannot specify -static with -fsanitize=hwaddress}} %{%:sanitize(thread):" " %{static-libtsan|static:%:include(libsanitizer.spec)%(link_libtsan)}" " %{static:%ecannot specify -static with -fsanitize=thread}} %{%:sanitize(undefined):" "%{static-libubsan:" "-Bstatic" "} -lubsan %{static-libubsan:" "-Bdynamic" "}" " %{static-libubsan|static:%:include(libsanitizer.spec)%(link_libubsan)}" "} %{%:sanitize(leak):" " %{static-liblsan|static:%:include(libsanitizer.spec)%(link_liblsan)}" "}}}}" "\ | |||
1094 | %{!nostdlib:%{!r:%{!nodefaultlibs:%{%:sanitize(address):" LIBASAN_SPEC" %{static-libasan|static:%:include(libsanitizer.spec)%(link_libasan)}" "\ | |||
1095 | %{static:%ecannot specify -static with -fsanitize=address}}\ | |||
1096 | %{%:sanitize(hwaddress):" LIBHWASAN_SPEC" %{static-libhwasan|static:%:include(libsanitizer.spec)%(link_libhwasan)}" "\ | |||
1097 | %{static:%ecannot specify -static with -fsanitize=hwaddress}}\ | |||
1098 | %{%:sanitize(thread):" LIBTSAN_SPEC" %{static-libtsan|static:%:include(libsanitizer.spec)%(link_libtsan)}" "\ | |||
1099 | %{static:%ecannot specify -static with -fsanitize=thread}}\ | |||
1100 | %{%:sanitize(undefined):" LIBUBSAN_SPEC"%{static-libubsan:" "-Bstatic" "} -lubsan %{static-libubsan:" "-Bdynamic" "}" " %{static-libubsan|static:%:include(libsanitizer.spec)%(link_libubsan)}" "}\ | |||
1101 | %{%:sanitize(leak):" LIBLSAN_SPEC" %{static-liblsan|static:%:include(libsanitizer.spec)%(link_liblsan)}" "}}}}" | |||
1102 | #endif | |||
1103 | ||||
1104 | #ifndef POST_LINK_SPEC"" | |||
1105 | #define POST_LINK_SPEC"" "" | |||
1106 | #endif | |||
1107 | ||||
1108 | /* This is the spec to use, once the code for creating the vtable | |||
1109 | verification runtime library, libvtv.so, has been created. Currently | |||
1110 | the vtable verification runtime functions are in libstdc++, so we use | |||
1111 | the spec just below this one. */ | |||
1112 | #ifndef VTABLE_VERIFICATION_SPEC"%{fvtable-verify=none:} %{fvtable-verify=std: %e-fvtable-verify=std is not supported in this configuration} %{fvtable-verify=preinit: %e-fvtable-verify=preinit is not supported in this configuration}" | |||
1113 | #if ENABLE_VTABLE_VERIFY0 | |||
1114 | #define VTABLE_VERIFICATION_SPEC"%{fvtable-verify=none:} %{fvtable-verify=std: %e-fvtable-verify=std is not supported in this configuration} %{fvtable-verify=preinit: %e-fvtable-verify=preinit is not supported in this configuration}" "\ | |||
1115 | %{!nostdlib:%{!r:%{fvtable-verify=std: -lvtv -u_vtable_map_vars_start -u_vtable_map_vars_end}\ | |||
1116 | %{fvtable-verify=preinit: -lvtv -u_vtable_map_vars_start -u_vtable_map_vars_end}}}" | |||
1117 | #else | |||
1118 | #define VTABLE_VERIFICATION_SPEC"%{fvtable-verify=none:} %{fvtable-verify=std: %e-fvtable-verify=std is not supported in this configuration} %{fvtable-verify=preinit: %e-fvtable-verify=preinit is not supported in this configuration}" "\ | |||
1119 | %{fvtable-verify=none:} \ | |||
1120 | %{fvtable-verify=std: \ | |||
1121 | %e-fvtable-verify=std is not supported in this configuration} \ | |||
1122 | %{fvtable-verify=preinit: \ | |||
1123 | %e-fvtable-verify=preinit is not supported in this configuration}" | |||
1124 | #endif | |||
1125 | #endif | |||
1126 | ||||
1127 | /* -u* was put back because both BSD and SysV seem to support it. */ | |||
1128 | /* %{static|no-pie|static-pie:} simply prevents an error message: | |||
1129 | 1. If the target machine doesn't handle -static. | |||
1130 | 2. If PIE isn't enabled by default. | |||
1131 | 3. If the target machine doesn't handle -static-pie. | |||
1132 | */ | |||
1133 | /* We want %{T*} after %{L*} and %D so that it can be used to specify linker | |||
1134 | scripts which exist in user specified directories, or in standard | |||
1135 | directories. */ | |||
1136 | /* We pass any -flto flags on to the linker, which is expected | |||
1137 | to understand them. In practice, this means it had better be collect2. */ | |||
1138 | /* %{e*} includes -export-dynamic; see comment in common.opt. */ | |||
1139 | #ifndef LINK_COMMAND_SPEC"%{!fsyntax-only:%{!c:%{!M:%{!MM:%{!E:%{!S: %(linker) " "%{" "!fno-use-linker-plugin:%{!fno-lto"": -plugin %(linker_plugin_file) -plugin-opt=%(lto_wrapper) -plugin-opt=-fresolution=%u.res " "" " %{flinker-output=*:-plugin-opt=-linker-output-known} %{!nostdlib:%{!nodefaultlibs:%:pass-through-libs(%(link_gcc_c_sequence))}} }" "}" "%{flto|flto=*:%<fcompare-debug*} %{flto} %{fno-lto} %{flto=*} %l " "%{static|shared|r:;" "pie" ":" "-pie" "} " "%{fuse-ld=*:-fuse-ld=%*} " " %{gz|gz=zlib:" "--compress-debug-sections" "=zlib}" " %{gz=none:" "--compress-debug-sections" "=none}" " %{gz=zstd:" "--compress-debug-sections" "=zstd}" " %{gz=zlib-gnu:}" "%X %{o*} %{e*} %{N} %{n} %{r} %{s} %{t} %{u*} %{z} %{Z} %{!nostdlib:%{!r:%{!nostartfiles:%S}}} %{static|no-pie|static-pie:} %@{L*} %(mfwrap) %(link_libgcc) " "%{fvtable-verify=none:} %{fvtable-verify=std: %e-fvtable-verify=std is not supported in this configuration} %{fvtable-verify=preinit: %e-fvtable-verify=preinit is not supported in this configuration}" " " "%{!nostdlib:%{!r:%{!nodefaultlibs:%{%:sanitize(address):" "%{!shared:libasan_preinit%O%s} " "%{static-libasan:%{!shared:" "-Bstatic" " --whole-archive -lasan --no-whole-archive " "-Bdynamic" "}}%{!static-libasan:-lasan}" "} %{%:sanitize(hwaddress):" "%{!shared:libhwasan_preinit%O%s} " "%{static-libhwasan:%{!shared:" "-Bstatic" " --whole-archive -lhwasan --no-whole-archive " "-Bdynamic" "}}%{!static-libhwasan:-lhwasan}" "} %{%:sanitize(thread):" "%{!shared:libtsan_preinit%O%s} " "%{static-libtsan:%{!shared:" "-Bstatic" " --whole-archive -ltsan --no-whole-archive " "-Bdynamic" "}}%{!static-libtsan:-ltsan}" "} %{%:sanitize(leak):" "%{!shared:liblsan_preinit%O%s} " "%{static-liblsan:%{!shared:" "-Bstatic" " --whole-archive -llsan --no-whole-archive " "-Bdynamic" "}}%{!static-liblsan:-llsan}" "}}}}" " %o "" %{fopenacc|fopenmp|%:gt(%{ftree-parallelize-loops=*:%*} 1): %:include(libgomp.spec)%(link_gomp)} %{fgnu-tm:%:include(libitm.spec)%(link_itm)} %(mflib) " " %{fsplit-stack: --wrap=pthread_create}" " %{fprofile-arcs|fprofile-generate*|coverage:-lgcov} " "%{!nostdlib:%{!r:%{!nodefaultlibs:%{%:sanitize(address):" " %{static-libasan|static:%:include(libsanitizer.spec)%(link_libasan)}" " %{static:%ecannot specify -static with -fsanitize=address}} %{%:sanitize(hwaddress):" " %{static-libhwasan|static:%:include(libsanitizer.spec)%(link_libhwasan)}" " %{static:%ecannot specify -static with -fsanitize=hwaddress}} %{%:sanitize(thread):" " %{static-libtsan|static:%:include(libsanitizer.spec)%(link_libtsan)}" " %{static:%ecannot specify -static with -fsanitize=thread}} %{%:sanitize(undefined):" "%{static-libubsan:" "-Bstatic" "} -lubsan %{static-libubsan:" "-Bdynamic" "}" " %{static-libubsan|static:%:include(libsanitizer.spec)%(link_libubsan)}" "} %{%:sanitize(leak):" " %{static-liblsan|static:%:include(libsanitizer.spec)%(link_liblsan)}" "}}}}" " %{!nostdlib:%{!r:%{!nodefaultlibs:%(link_ssp) %(link_gcc_c_sequence)}}} %{!nostdlib:%{!r:%{!nostartfiles:%E}}} %{T*} \n%(post_link) }}}}}}" | |||
1140 | #define LINK_COMMAND_SPEC"%{!fsyntax-only:%{!c:%{!M:%{!MM:%{!E:%{!S: %(linker) " "%{" "!fno-use-linker-plugin:%{!fno-lto"": -plugin %(linker_plugin_file) -plugin-opt=%(lto_wrapper) -plugin-opt=-fresolution=%u.res " "" " %{flinker-output=*:-plugin-opt=-linker-output-known} %{!nostdlib:%{!nodefaultlibs:%:pass-through-libs(%(link_gcc_c_sequence))}} }" "}" "%{flto|flto=*:%<fcompare-debug*} %{flto} %{fno-lto} %{flto=*} %l " "%{static|shared|r:;" "pie" ":" "-pie" "} " "%{fuse-ld=*:-fuse-ld=%*} " " %{gz|gz=zlib:" "--compress-debug-sections" "=zlib}" " %{gz=none:" "--compress-debug-sections" "=none}" " %{gz=zstd:" "--compress-debug-sections" "=zstd}" " %{gz=zlib-gnu:}" "%X %{o*} %{e*} %{N} %{n} %{r} %{s} %{t} %{u*} %{z} %{Z} %{!nostdlib:%{!r:%{!nostartfiles:%S}}} %{static|no-pie|static-pie:} %@{L*} %(mfwrap) %(link_libgcc) " "%{fvtable-verify=none:} %{fvtable-verify=std: %e-fvtable-verify=std is not supported in this configuration} %{fvtable-verify=preinit: %e-fvtable-verify=preinit is not supported in this configuration}" " " "%{!nostdlib:%{!r:%{!nodefaultlibs:%{%:sanitize(address):" "%{!shared:libasan_preinit%O%s} " "%{static-libasan:%{!shared:" "-Bstatic" " --whole-archive -lasan --no-whole-archive " "-Bdynamic" "}}%{!static-libasan:-lasan}" "} %{%:sanitize(hwaddress):" "%{!shared:libhwasan_preinit%O%s} " "%{static-libhwasan:%{!shared:" "-Bstatic" " --whole-archive -lhwasan --no-whole-archive " "-Bdynamic" "}}%{!static-libhwasan:-lhwasan}" "} %{%:sanitize(thread):" "%{!shared:libtsan_preinit%O%s} " "%{static-libtsan:%{!shared:" "-Bstatic" " --whole-archive -ltsan --no-whole-archive " "-Bdynamic" "}}%{!static-libtsan:-ltsan}" "} %{%:sanitize(leak):" "%{!shared:liblsan_preinit%O%s} " "%{static-liblsan:%{!shared:" "-Bstatic" " --whole-archive -llsan --no-whole-archive " "-Bdynamic" "}}%{!static-liblsan:-llsan}" "}}}}" " %o "" %{fopenacc|fopenmp|%:gt(%{ftree-parallelize-loops=*:%*} 1): %:include(libgomp.spec)%(link_gomp)} %{fgnu-tm:%:include(libitm.spec)%(link_itm)} %(mflib) " " %{fsplit-stack: --wrap=pthread_create}" " %{fprofile-arcs|fprofile-generate*|coverage:-lgcov} " "%{!nostdlib:%{!r:%{!nodefaultlibs:%{%:sanitize(address):" " %{static-libasan|static:%:include(libsanitizer.spec)%(link_libasan)}" " %{static:%ecannot specify -static with -fsanitize=address}} %{%:sanitize(hwaddress):" " %{static-libhwasan|static:%:include(libsanitizer.spec)%(link_libhwasan)}" " %{static:%ecannot specify -static with -fsanitize=hwaddress}} %{%:sanitize(thread):" " %{static-libtsan|static:%:include(libsanitizer.spec)%(link_libtsan)}" " %{static:%ecannot specify -static with -fsanitize=thread}} %{%:sanitize(undefined):" "%{static-libubsan:" "-Bstatic" "} -lubsan %{static-libubsan:" "-Bdynamic" "}" " %{static-libubsan|static:%:include(libsanitizer.spec)%(link_libubsan)}" "} %{%:sanitize(leak):" " %{static-liblsan|static:%:include(libsanitizer.spec)%(link_liblsan)}" "}}}}" " %{!nostdlib:%{!r:%{!nodefaultlibs:%(link_ssp) %(link_gcc_c_sequence)}}} %{!nostdlib:%{!r:%{!nostartfiles:%E}}} %{T*} \n%(post_link) }}}}}}" "\ | |||
1141 | %{!fsyntax-only:%{!c:%{!M:%{!MM:%{!E:%{!S:\ | |||
1142 | %(linker) " \ | |||
1143 | LINK_PLUGIN_SPEC"%{" "!fno-use-linker-plugin:%{!fno-lto"": -plugin %(linker_plugin_file) -plugin-opt=%(lto_wrapper) -plugin-opt=-fresolution=%u.res " "" " %{flinker-output=*:-plugin-opt=-linker-output-known} %{!nostdlib:%{!nodefaultlibs:%:pass-through-libs(%(link_gcc_c_sequence))}} }" "}" \ | |||
1144 | "%{flto|flto=*:%<fcompare-debug*} \ | |||
1145 | %{flto} %{fno-lto} %{flto=*} %l " LINK_PIE_SPEC"%{static|shared|r:;" "pie" ":" "-pie" "} " \ | |||
1146 | "%{fuse-ld=*:-fuse-ld=%*} " LINK_COMPRESS_DEBUG_SPEC" %{gz|gz=zlib:" "--compress-debug-sections" "=zlib}" " %{gz=none:" "--compress-debug-sections" "=none}" " %{gz=zstd:" "--compress-debug-sections" "=zstd}" " %{gz=zlib-gnu:}" \ | |||
1147 | "%X %{o*} %{e*} %{N} %{n} %{r}\ | |||
1148 | %{s} %{t} %{u*} %{z} %{Z} %{!nostdlib:%{!r:%{!nostartfiles:%S}}} \ | |||
1149 | %{static|no-pie|static-pie:} %@{L*} %(mfwrap) %(link_libgcc) " \ | |||
1150 | VTABLE_VERIFICATION_SPEC"%{fvtable-verify=none:} %{fvtable-verify=std: %e-fvtable-verify=std is not supported in this configuration} %{fvtable-verify=preinit: %e-fvtable-verify=preinit is not supported in this configuration}" " " SANITIZER_EARLY_SPEC"%{!nostdlib:%{!r:%{!nodefaultlibs:%{%:sanitize(address):" "%{!shared:libasan_preinit%O%s} " "%{static-libasan:%{!shared:" "-Bstatic" " --whole-archive -lasan --no-whole-archive " "-Bdynamic" "}}%{!static-libasan:-lasan}" "} %{%:sanitize(hwaddress):" "%{!shared:libhwasan_preinit%O%s} " "%{static-libhwasan:%{!shared:" "-Bstatic" " --whole-archive -lhwasan --no-whole-archive " "-Bdynamic" "}}%{!static-libhwasan:-lhwasan}" "} %{%:sanitize(thread):" "%{!shared:libtsan_preinit%O%s} " "%{static-libtsan:%{!shared:" "-Bstatic" " --whole-archive -ltsan --no-whole-archive " "-Bdynamic" "}}%{!static-libtsan:-ltsan}" "} %{%:sanitize(leak):" "%{!shared:liblsan_preinit%O%s} " "%{static-liblsan:%{!shared:" "-Bstatic" " --whole-archive -llsan --no-whole-archive " "-Bdynamic" "}}%{!static-liblsan:-llsan}" "}}}}" " %o "" \ | |||
1151 | %{fopenacc|fopenmp|%:gt(%{ftree-parallelize-loops=*:%*} 1):\ | |||
1152 | %:include(libgomp.spec)%(link_gomp)}\ | |||
1153 | %{fgnu-tm:%:include(libitm.spec)%(link_itm)}\ | |||
1154 | %(mflib) " STACK_SPLIT_SPEC" %{fsplit-stack: --wrap=pthread_create}" "\ | |||
1155 | %{fprofile-arcs|fprofile-generate*|coverage:-lgcov} " SANITIZER_SPEC"%{!nostdlib:%{!r:%{!nodefaultlibs:%{%:sanitize(address):" " %{static-libasan|static:%:include(libsanitizer.spec)%(link_libasan)}" " %{static:%ecannot specify -static with -fsanitize=address}} %{%:sanitize(hwaddress):" " %{static-libhwasan|static:%:include(libsanitizer.spec)%(link_libhwasan)}" " %{static:%ecannot specify -static with -fsanitize=hwaddress}} %{%:sanitize(thread):" " %{static-libtsan|static:%:include(libsanitizer.spec)%(link_libtsan)}" " %{static:%ecannot specify -static with -fsanitize=thread}} %{%:sanitize(undefined):" "%{static-libubsan:" "-Bstatic" "} -lubsan %{static-libubsan:" "-Bdynamic" "}" " %{static-libubsan|static:%:include(libsanitizer.spec)%(link_libubsan)}" "} %{%:sanitize(leak):" " %{static-liblsan|static:%:include(libsanitizer.spec)%(link_liblsan)}" "}}}}" " \ | |||
1156 | %{!nostdlib:%{!r:%{!nodefaultlibs:%(link_ssp) %(link_gcc_c_sequence)}}}\ | |||
1157 | %{!nostdlib:%{!r:%{!nostartfiles:%E}}} %{T*} \n%(post_link) }}}}}}" | |||
1158 | #endif | |||
1159 | ||||
1160 | #ifndef LINK_LIBGCC_SPEC"%D" | |||
1161 | /* Generate -L options for startfile prefix list. */ | |||
1162 | # define LINK_LIBGCC_SPEC"%D" "%D" | |||
1163 | #endif | |||
1164 | ||||
1165 | #ifndef STARTFILE_PREFIX_SPEC"" | |||
1166 | # define STARTFILE_PREFIX_SPEC"" "" | |||
1167 | #endif | |||
1168 | ||||
1169 | #ifndef SYSROOT_SPEC"--sysroot=%R" | |||
1170 | # define SYSROOT_SPEC"--sysroot=%R" "--sysroot=%R" | |||
1171 | #endif | |||
1172 | ||||
1173 | #ifndef SYSROOT_SUFFIX_SPEC"" | |||
1174 | # define SYSROOT_SUFFIX_SPEC"" "" | |||
1175 | #endif | |||
1176 | ||||
1177 | #ifndef SYSROOT_HEADERS_SUFFIX_SPEC"" | |||
1178 | # define SYSROOT_HEADERS_SUFFIX_SPEC"" "" | |||
1179 | #endif | |||
1180 | ||||
1181 | static const char *asm_debug = ASM_DEBUG_SPEC"%{g*:%{%:debug-level-gt(0):" "" "}}" " %{ffile-prefix-map=*:--debug-prefix-map %*} %{fdebug-prefix-map=*:--debug-prefix-map %*}"; | |||
1182 | static const char *asm_debug_option = ASM_DEBUG_OPTION_SPEC"%{g*:%{%:debug-level-gt(0):" "%{%:dwarf-version-gt(4):--gdwarf-5 ;" "%:dwarf-version-gt(3):--gdwarf-4 ;" "%:dwarf-version-gt(2):--gdwarf-3 ;" ":--gdwarf2 }" "}}"; | |||
1183 | static const char *cpp_spec = CPP_SPEC"%{posix:-D_POSIX_SOURCE} %{pthread:-D_REENTRANT}"; | |||
1184 | static const char *cc1_spec = CC1_SPEC"%{" "!mandroid" "|tno-android-cc:" "%(cc1_cpu) %{profile:-p}" ";:" "%(cc1_cpu) %{profile:-p}" " " "%{!mglibc:%{!muclibc:%{!mbionic: -mbionic}}} " "%{!fno-pic:%{!fno-PIC:%{!fpic:%{!fPIC: -fPIC}}}}" "}" OS_CC1_SPEC""; | |||
1185 | static const char *cc1plus_spec = CC1PLUS_SPEC""; | |||
1186 | static const char *link_gcc_c_sequence_spec = LINK_GCC_C_SEQUENCE_SPEC"%{static|static-pie:--start-group} %G %{!nolibc:%L} %{static|static-pie:--end-group}%{!static:%{!static-pie:%G}}"; | |||
1187 | static const char *link_ssp_spec = LINK_SSP_SPEC"%{fstack-protector|fstack-protector-all" "|fstack-protector-strong|fstack-protector-explicit:}"; | |||
1188 | static const char *asm_spec = ASM_SPEC"%{" "m16|m32" ":--32} %{" "m16|m32|mx32:;" ":--64} %{" "mx32" ":--x32} %{msse2avx:%{!mavx:-msse2avx}}"; | |||
1189 | static const char *asm_final_spec = ASM_FINAL_SPEC"%{gsplit-dwarf: \n objcopy --extract-dwo %{c:%{o*:%*}%{!o*:%w%b%O}}%{!c:%U%O} %b.dwo \n objcopy --strip-dwo %{c:%{o*:%*}%{!o*:%w%b%O}}%{!c:%U%O} }"; | |||
1190 | static const char *link_spec = LINK_SPEC"%{" "!mandroid" "|tno-android-ld:" "%{" "m16|m32|mx32:;" ":-m " "elf_x86_64" "} %{" "m16|m32" ":-m " "elf_i386" "} %{" "mx32" ":-m " "elf32_x86_64" "} %{shared:-shared} %{!shared: %{!static: %{!static-pie: %{rdynamic:-export-dynamic} %{" "m16|m32" ":-dynamic-linker " "%{" "muclibc" ":" "/lib/ld-uClibc.so.0" ";:%{" "mbionic" ":" "/system/bin/linker" ";:%{" "mmusl" ":" "/lib/ld-musl-i386.so.1" ";:" "/lib/ld-linux.so.2" "}}}" "} %{" "m16|m32|mx32:;" ":-dynamic-linker " "%{" "muclibc" ":" "/lib/ld64-uClibc.so.0" ";:%{" "mbionic" ":" "/system/bin/linker64" ";:%{" "mmusl" ":" "/lib/ld-musl-x86_64.so.1" ";:" "/lib64/ld-linux-x86-64.so.2" "}}}" "} %{" "mx32" ":-dynamic-linker " "%{" "muclibc" ":" "/lib/ldx32-uClibc.so.0" ";:%{" "mbionic" ":" "/system/bin/linkerx32" ";:%{" "mmusl" ":" "/lib/ld-musl-x32.so.1" ";:" "/libx32/ld-linux-x32.so.2" "}}}" "}}} %{static:-static} %{static-pie:-static -pie --no-dynamic-linker -z text}}" ";:" "%{" "m16|m32|mx32:;" ":-m " "elf_x86_64" "} %{" "m16|m32" ":-m " "elf_i386" "} %{" "mx32" ":-m " "elf32_x86_64" "} %{shared:-shared} %{!shared: %{!static: %{!static-pie: %{rdynamic:-export-dynamic} %{" "m16|m32" ":-dynamic-linker " "%{" "muclibc" ":" "/lib/ld-uClibc.so.0" ";:%{" "mbionic" ":" "/system/bin/linker" ";:%{" "mmusl" ":" "/lib/ld-musl-i386.so.1" ";:" "/lib/ld-linux.so.2" "}}}" "} %{" "m16|m32|mx32:;" ":-dynamic-linker " "%{" "muclibc" ":" "/lib/ld64-uClibc.so.0" ";:%{" "mbionic" ":" "/system/bin/linker64" ";:%{" "mmusl" ":" "/lib/ld-musl-x86_64.so.1" ";:" "/lib64/ld-linux-x86-64.so.2" "}}}" "} %{" "mx32" ":-dynamic-linker " "%{" "muclibc" ":" "/lib/ldx32-uClibc.so.0" ";:%{" "mbionic" ":" "/system/bin/linkerx32" ";:%{" "mmusl" ":" "/lib/ld-musl-x32.so.1" ";:" "/libx32/ld-linux-x32.so.2" "}}}" "}}} %{static:-static} %{static-pie:-static -pie --no-dynamic-linker -z text}}" " " "%{shared: -Bsymbolic}" "}"; | |||
1191 | static const char *lib_spec = LIB_SPEC"%{" "!mandroid" "|tno-android-ld:" "%{pthread:-lpthread} " "%{shared:-lc} %{!shared:%{profile:-lc_p}%{!profile:-lc}}" ";:" "%{shared:-lc} %{!shared:%{profile:-lc_p}%{!profile:-lc}}" " " "%{!static: -ldl}" "}"; | |||
1192 | static const char *link_gomp_spec = ""; | |||
1193 | static const char *libgcc_spec = LIBGCC_SPEC"-lgcc"; | |||
1194 | static const char *endfile_spec = ENDFILE_SPEC"%{" "!mandroid" "|tno-android-ld:" "%{mdaz-ftz:crtfastmath.o%s;Ofast|ffast-math|funsafe-math-optimizations:%{!shared:%{!mno-daz-ftz:crtfastmath.o%s}}} %{mpc32:crtprec32.o%s} %{mpc64:crtprec64.o%s} %{mpc80:crtprec80.o%s}" " " "%{!static:%{fvtable-verify=none:%s; fvtable-verify=preinit:vtv_end_preinit.o%s; fvtable-verify=std:vtv_end.o%s}} %{static:crtend.o%s; shared|static-pie|" "pie" ":crtendS.o%s; :crtend.o%s} " "crtn.o%s" " " "" ";:" "%{mdaz-ftz:crtfastmath.o%s;Ofast|ffast-math|funsafe-math-optimizations:%{!shared:%{!mno-daz-ftz:crtfastmath.o%s}}} %{mpc32:crtprec32.o%s} %{mpc64:crtprec64.o%s} %{mpc80:crtprec80.o%s}" " " "%{shared: crtend_so%O%s;: crtend_android%O%s}" "}"; | |||
1195 | static const char *startfile_spec = STARTFILE_SPEC"%{" "!mandroid" "|tno-android-ld:" "%{shared:; pg|p|profile:%{static-pie:grcrt1.o%s;:gcrt1.o%s}; static:crt1.o%s; static-pie:rcrt1.o%s; " "pie" ":Scrt1.o%s; :crt1.o%s} " "crti.o%s" " %{static:crtbeginT.o%s; shared|static-pie|" "pie" ":crtbeginS.o%s; :crtbegin.o%s} %{fvtable-verify=none:%s; fvtable-verify=preinit:vtv_start_preinit.o%s; fvtable-verify=std:vtv_start.o%s} " "" ";:" "%{shared: crtbegin_so%O%s;:" " %{static: crtbegin_static%O%s;: crtbegin_dynamic%O%s}}" "}"; | |||
1196 | static const char *linker_name_spec = LINKER_NAME"collect2"; | |||
1197 | static const char *linker_plugin_file_spec = ""; | |||
1198 | static const char *lto_wrapper_spec = ""; | |||
1199 | static const char *lto_gcc_spec = ""; | |||
1200 | static const char *post_link_spec = POST_LINK_SPEC""; | |||
1201 | static const char *link_command_spec = LINK_COMMAND_SPEC"%{!fsyntax-only:%{!c:%{!M:%{!MM:%{!E:%{!S: %(linker) " "%{" "!fno-use-linker-plugin:%{!fno-lto"": -plugin %(linker_plugin_file) -plugin-opt=%(lto_wrapper) -plugin-opt=-fresolution=%u.res " "" " %{flinker-output=*:-plugin-opt=-linker-output-known} %{!nostdlib:%{!nodefaultlibs:%:pass-through-libs(%(link_gcc_c_sequence))}} }" "}" "%{flto|flto=*:%<fcompare-debug*} %{flto} %{fno-lto} %{flto=*} %l " "%{static|shared|r:;" "pie" ":" "-pie" "} " "%{fuse-ld=*:-fuse-ld=%*} " " %{gz|gz=zlib:" "--compress-debug-sections" "=zlib}" " %{gz=none:" "--compress-debug-sections" "=none}" " %{gz=zstd:" "--compress-debug-sections" "=zstd}" " %{gz=zlib-gnu:}" "%X %{o*} %{e*} %{N} %{n} %{r} %{s} %{t} %{u*} %{z} %{Z} %{!nostdlib:%{!r:%{!nostartfiles:%S}}} %{static|no-pie|static-pie:} %@{L*} %(mfwrap) %(link_libgcc) " "%{fvtable-verify=none:} %{fvtable-verify=std: %e-fvtable-verify=std is not supported in this configuration} %{fvtable-verify=preinit: %e-fvtable-verify=preinit is not supported in this configuration}" " " "%{!nostdlib:%{!r:%{!nodefaultlibs:%{%:sanitize(address):" "%{!shared:libasan_preinit%O%s} " "%{static-libasan:%{!shared:" "-Bstatic" " --whole-archive -lasan --no-whole-archive " "-Bdynamic" "}}%{!static-libasan:-lasan}" "} %{%:sanitize(hwaddress):" "%{!shared:libhwasan_preinit%O%s} " "%{static-libhwasan:%{!shared:" "-Bstatic" " --whole-archive -lhwasan --no-whole-archive " "-Bdynamic" "}}%{!static-libhwasan:-lhwasan}" "} %{%:sanitize(thread):" "%{!shared:libtsan_preinit%O%s} " "%{static-libtsan:%{!shared:" "-Bstatic" " --whole-archive -ltsan --no-whole-archive " "-Bdynamic" "}}%{!static-libtsan:-ltsan}" "} %{%:sanitize(leak):" "%{!shared:liblsan_preinit%O%s} " "%{static-liblsan:%{!shared:" "-Bstatic" " --whole-archive -llsan --no-whole-archive " "-Bdynamic" "}}%{!static-liblsan:-llsan}" "}}}}" " %o "" %{fopenacc|fopenmp|%:gt(%{ftree-parallelize-loops=*:%*} 1): %:include(libgomp.spec)%(link_gomp)} %{fgnu-tm:%:include(libitm.spec)%(link_itm)} %(mflib) " " %{fsplit-stack: --wrap=pthread_create}" " %{fprofile-arcs|fprofile-generate*|coverage:-lgcov} " "%{!nostdlib:%{!r:%{!nodefaultlibs:%{%:sanitize(address):" " %{static-libasan|static:%:include(libsanitizer.spec)%(link_libasan)}" " %{static:%ecannot specify -static with -fsanitize=address}} %{%:sanitize(hwaddress):" " %{static-libhwasan|static:%:include(libsanitizer.spec)%(link_libhwasan)}" " %{static:%ecannot specify -static with -fsanitize=hwaddress}} %{%:sanitize(thread):" " %{static-libtsan|static:%:include(libsanitizer.spec)%(link_libtsan)}" " %{static:%ecannot specify -static with -fsanitize=thread}} %{%:sanitize(undefined):" "%{static-libubsan:" "-Bstatic" "} -lubsan %{static-libubsan:" "-Bdynamic" "}" " %{static-libubsan|static:%:include(libsanitizer.spec)%(link_libubsan)}" "} %{%:sanitize(leak):" " %{static-liblsan|static:%:include(libsanitizer.spec)%(link_liblsan)}" "}}}}" " %{!nostdlib:%{!r:%{!nodefaultlibs:%(link_ssp) %(link_gcc_c_sequence)}}} %{!nostdlib:%{!r:%{!nostartfiles:%E}}} %{T*} \n%(post_link) }}}}}}"; | |||
1202 | static const char *link_libgcc_spec = LINK_LIBGCC_SPEC"%D"; | |||
1203 | static const char *startfile_prefix_spec = STARTFILE_PREFIX_SPEC""; | |||
1204 | static const char *sysroot_spec = SYSROOT_SPEC"--sysroot=%R"; | |||
1205 | static const char *sysroot_suffix_spec = SYSROOT_SUFFIX_SPEC""; | |||
1206 | static const char *sysroot_hdrs_suffix_spec = SYSROOT_HEADERS_SUFFIX_SPEC""; | |||
1207 | static const char *self_spec = ""; | |||
1208 | ||||
1209 | /* Standard options to cpp, cc1, and as, to reduce duplication in specs. | |||
1210 | There should be no need to override these in target dependent files, | |||
1211 | but we need to copy them to the specs file so that newer versions | |||
1212 | of the GCC driver can correctly drive older tool chains with the | |||
1213 | appropriate -B options. */ | |||
1214 | ||||
1215 | /* When cpplib handles traditional preprocessing, get rid of this, and | |||
1216 | call cc1 (or cc1obj in objc/lang-specs.h) from the main specs so | |||
1217 | that we default the front end language better. */ | |||
1218 | static const char *trad_capable_cpp = | |||
1219 | "cc1 -E %{traditional|traditional-cpp:-traditional-cpp}"; | |||
1220 | ||||
1221 | /* We don't wrap .d files in %W{} since a missing .d file, and | |||
1222 | therefore no dependency entry, confuses make into thinking a .o | |||
1223 | file that happens to exist is up-to-date. */ | |||
1224 | static const char *cpp_unique_options = | |||
1225 | "%{!Q:-quiet} %{nostdinc*} %{C} %{CC} %{v} %@{I*&F*} %{P} %I\ | |||
1226 | %{MD:-MD %{!o:%b.d}%{o*:%.d%*}}\ | |||
1227 | %{MMD:-MMD %{!o:%b.d}%{o*:%.d%*}}\ | |||
1228 | %{M} %{MM} %{MF*} %{MG} %{MP} %{MQ*} %{MT*}\ | |||
1229 | %{Mmodules} %{Mno-modules}\ | |||
1230 | %{!E:%{!M:%{!MM:%{!MT:%{!MQ:%{MD|MMD:%{o*:-MQ %*}}}}}}}\ | |||
1231 | %{remap} %{%:debug-level-gt(2):-dD}\ | |||
1232 | %{!iplugindir*:%{fplugin*:%:find-plugindir()}}\ | |||
1233 | %{H} %C %{D*&U*&A*} %{i*} %Z %i\ | |||
1234 | %{E|M|MM:%W{o*}}"; | |||
1235 | ||||
1236 | /* This contains cpp options which are common with cc1_options and are passed | |||
1237 | only when preprocessing only to avoid duplication. We pass the cc1 spec | |||
1238 | options to the preprocessor so that it the cc1 spec may manipulate | |||
1239 | options used to set target flags. Those special target flags settings may | |||
1240 | in turn cause preprocessor symbols to be defined specially. */ | |||
1241 | static const char *cpp_options = | |||
1242 | "%(cpp_unique_options) %1 %{m*} %{std*&ansi&trigraphs} %{W*&pedantic*} %{w}\ | |||
1243 | %{f*} %{g*:%{%:debug-level-gt(0):%{g*}\ | |||
1244 | %{!fno-working-directory:-fworking-directory}}} %{O*}\ | |||
1245 | %{undef} %{save-temps*:-fpch-preprocess}"; | |||
1246 | ||||
1247 | /* Pass -d* flags, possibly modifying -dumpdir, -dumpbase et al. | |||
1248 | ||||
1249 | Make it easy for a language to override the argument for the | |||
1250 | %:dumps specs function call. */ | |||
1251 | #define DUMPS_OPTIONS(EXTS)"%<dumpdir %<dumpbase %<dumpbase-ext %{d*} %:dumps(" EXTS ")" \ | |||
1252 | "%<dumpdir %<dumpbase %<dumpbase-ext %{d*} %:dumps(" EXTS ")" | |||
1253 | ||||
1254 | /* This contains cpp options which are not passed when the preprocessor | |||
1255 | output will be used by another program. */ | |||
1256 | static const char *cpp_debug_options = DUMPS_OPTIONS ("")"%<dumpdir %<dumpbase %<dumpbase-ext %{d*} %:dumps(" "" ")"; | |||
1257 | ||||
1258 | /* NB: This is shared amongst all front-ends, except for Ada. */ | |||
1259 | static const char *cc1_options = | |||
1260 | "%{pg:%{fomit-frame-pointer:%e-pg and -fomit-frame-pointer are incompatible}}\ | |||
1261 | %{!iplugindir*:%{fplugin*:%:find-plugindir()}}\ | |||
1262 | %1 %{!Q:-quiet} %(cpp_debug_options) %{m*} %{aux-info*}\ | |||
1263 | %{g*} %{O*} %{W*&pedantic*} %{w} %{std*&ansi&trigraphs}\ | |||
1264 | %{v:-version} %{pg:-p} %{p} %{f*} %{undef}\ | |||
1265 | %{Qn:-fno-ident} %{Qy:} %{-help:--help}\ | |||
1266 | %{-target-help:--target-help}\ | |||
1267 | %{-version:--version}\ | |||
1268 | %{-help=*:--help=%*}\ | |||
1269 | %{!fsyntax-only:%{S:%W{o*}%{!o*:-o %w%b.s}}}\ | |||
1270 | %{fsyntax-only:-o %j} %{-param*}\ | |||
1271 | %{coverage:-fprofile-arcs -ftest-coverage}\ | |||
1272 | %{fprofile-arcs|fprofile-generate*|coverage:\ | |||
1273 | %{!fprofile-update=single:\ | |||
1274 | %{pthread:-fprofile-update=prefer-atomic}}}"; | |||
1275 | ||||
1276 | static const char *asm_options = | |||
1277 | "%{-target-help:%:print-asm-header()} " | |||
1278 | #if HAVE_GNU_AS1 | |||
1279 | /* If GNU AS is used, then convert -w (no warnings), -I, and -v | |||
1280 | to the assembler equivalents. */ | |||
1281 | "%{v} %{w:-W} %{I*} " | |||
1282 | #endif | |||
1283 | "%(asm_debug_option)" | |||
1284 | ASM_COMPRESS_DEBUG_SPEC" %{gz|gz=zlib:" "--compress-debug-sections" "=zlib}" " %{gz=none:" "--compress-debug-sections" "=none}" " %{gz=zstd:" "--compress-debug-sections" "=zstd}" " %{gz=zlib-gnu:}" | |||
1285 | "%a %Y %{c:%W{o*}%{!o*:-o %w%b%O}}%{!c:-o %d%w%u%O}"; | |||
1286 | ||||
1287 | static const char *invoke_as = | |||
1288 | #ifdef AS_NEEDS_DASH_FOR_PIPED_INPUT | |||
1289 | "%{!fwpa*:\ | |||
1290 | %{fcompare-debug=*|fdump-final-insns=*:%:compare-debug-dump-opt()}\ | |||
1291 | %{!S:-o %|.s |\n as %(asm_options) %|.s %A }\ | |||
1292 | }"; | |||
1293 | #else | |||
1294 | "%{!fwpa*:\ | |||
1295 | %{fcompare-debug=*|fdump-final-insns=*:%:compare-debug-dump-opt()}\ | |||
1296 | %{!S:-o %|.s |\n as %(asm_options) %m.s %A }\ | |||
1297 | }"; | |||
1298 | #endif | |||
1299 | ||||
1300 | /* Some compilers have limits on line lengths, and the multilib_select | |||
1301 | and/or multilib_matches strings can be very long, so we build them at | |||
1302 | run time. */ | |||
1303 | static struct obstack multilib_obstack; | |||
1304 | static const char *multilib_select; | |||
1305 | static const char *multilib_matches; | |||
1306 | static const char *multilib_defaults; | |||
1307 | static const char *multilib_exclusions; | |||
1308 | static const char *multilib_reuse; | |||
1309 | ||||
1310 | /* Check whether a particular argument is a default argument. */ | |||
1311 | ||||
1312 | #ifndef MULTILIB_DEFAULTS{ "m64" } | |||
1313 | #define MULTILIB_DEFAULTS{ "m64" } { "" } | |||
1314 | #endif | |||
1315 | ||||
1316 | static const char *const multilib_defaults_raw[] = MULTILIB_DEFAULTS{ "m64" }; | |||
1317 | ||||
1318 | #ifndef DRIVER_SELF_SPECS"" | |||
1319 | #define DRIVER_SELF_SPECS"" "" | |||
1320 | #endif | |||
1321 | ||||
1322 | /* Linking to libgomp implies pthreads. This is particularly important | |||
1323 | for targets that use different start files and suchlike. */ | |||
1324 | #ifndef GOMP_SELF_SPECS"%{fopenacc|fopenmp|%:gt(%{ftree-parallelize-loops=*:%*} 1): " "-pthread}" | |||
1325 | #define GOMP_SELF_SPECS"%{fopenacc|fopenmp|%:gt(%{ftree-parallelize-loops=*:%*} 1): " "-pthread}" \ | |||
1326 | "%{fopenacc|fopenmp|%:gt(%{ftree-parallelize-loops=*:%*} 1): " \ | |||
1327 | "-pthread}" | |||
1328 | #endif | |||
1329 | ||||
1330 | /* Likewise for -fgnu-tm. */ | |||
1331 | #ifndef GTM_SELF_SPECS"%{fgnu-tm: -pthread}" | |||
1332 | #define GTM_SELF_SPECS"%{fgnu-tm: -pthread}" "%{fgnu-tm: -pthread}" | |||
1333 | #endif | |||
1334 | ||||
1335 | static const char *const driver_self_specs[] = { | |||
1336 | "%{fdump-final-insns:-fdump-final-insns=.} %<fdump-final-insns", | |||
1337 | DRIVER_SELF_SPECS"", CONFIGURE_SPECS"", GOMP_SELF_SPECS"%{fopenacc|fopenmp|%:gt(%{ftree-parallelize-loops=*:%*} 1): " "-pthread}", GTM_SELF_SPECS"%{fgnu-tm: -pthread}", | |||
1338 | /* This discards -fmultiflags at the end of self specs processing in the | |||
1339 | driver, so that it is effectively Ignored, without actually marking it as | |||
1340 | Ignored, which would get it discarded before self specs could remap it. */ | |||
1341 | "%<fmultiflags" | |||
1342 | }; | |||
1343 | ||||
1344 | #ifndef OPTION_DEFAULT_SPECS{"tune", "%{!mtune=*:%{!mcpu=*:%{!march=*:-mtune=%(VALUE)}}}" }, {"tune_32", "%{" "m32" ":%{!mtune=*:%{!mcpu=*:%{!march=*:-mtune=%(VALUE)}}}}" }, {"tune_64", "%{" "!m32" ":%{!mtune=*:%{!mcpu=*:%{!march=*:-mtune=%(VALUE)}}}}" }, {"cpu", "%{!mtune=*:%{!mcpu=*:%{!march=*:-mtune=%(VALUE)}}}" }, {"cpu_32", "%{" "m32" ":%{!mtune=*:%{!mcpu=*:%{!march=*:-mtune=%(VALUE)}}}}" }, {"cpu_64", "%{" "!m32" ":%{!mtune=*:%{!mcpu=*:%{!march=*:-mtune=%(VALUE)}}}}" }, {"arch", "%{!march=*:-march=%(VALUE)}"}, {"arch_32", "%{" "m32" ":%{!march=*:-march=%(VALUE)}}"}, {"arch_64", "%{" "!m32" ":%{!march=*:-march=%(VALUE)}}"}, | |||
1345 | #define OPTION_DEFAULT_SPECS{"tune", "%{!mtune=*:%{!mcpu=*:%{!march=*:-mtune=%(VALUE)}}}" }, {"tune_32", "%{" "m32" ":%{!mtune=*:%{!mcpu=*:%{!march=*:-mtune=%(VALUE)}}}}" }, {"tune_64", "%{" "!m32" ":%{!mtune=*:%{!mcpu=*:%{!march=*:-mtune=%(VALUE)}}}}" }, {"cpu", "%{!mtune=*:%{!mcpu=*:%{!march=*:-mtune=%(VALUE)}}}" }, {"cpu_32", "%{" "m32" ":%{!mtune=*:%{!mcpu=*:%{!march=*:-mtune=%(VALUE)}}}}" }, {"cpu_64", "%{" "!m32" ":%{!mtune=*:%{!mcpu=*:%{!march=*:-mtune=%(VALUE)}}}}" }, {"arch", "%{!march=*:-march=%(VALUE)}"}, {"arch_32", "%{" "m32" ":%{!march=*:-march=%(VALUE)}}"}, {"arch_64", "%{" "!m32" ":%{!march=*:-march=%(VALUE)}}"}, { "", "" } | |||
1346 | #endif | |||
1347 | ||||
1348 | struct default_spec | |||
1349 | { | |||
1350 | const char *name; | |||
1351 | const char *spec; | |||
1352 | }; | |||
1353 | ||||
1354 | static const struct default_spec | |||
1355 | option_default_specs[] = { OPTION_DEFAULT_SPECS{"tune", "%{!mtune=*:%{!mcpu=*:%{!march=*:-mtune=%(VALUE)}}}" }, {"tune_32", "%{" "m32" ":%{!mtune=*:%{!mcpu=*:%{!march=*:-mtune=%(VALUE)}}}}" }, {"tune_64", "%{" "!m32" ":%{!mtune=*:%{!mcpu=*:%{!march=*:-mtune=%(VALUE)}}}}" }, {"cpu", "%{!mtune=*:%{!mcpu=*:%{!march=*:-mtune=%(VALUE)}}}" }, {"cpu_32", "%{" "m32" ":%{!mtune=*:%{!mcpu=*:%{!march=*:-mtune=%(VALUE)}}}}" }, {"cpu_64", "%{" "!m32" ":%{!mtune=*:%{!mcpu=*:%{!march=*:-mtune=%(VALUE)}}}}" }, {"arch", "%{!march=*:-march=%(VALUE)}"}, {"arch_32", "%{" "m32" ":%{!march=*:-march=%(VALUE)}}"}, {"arch_64", "%{" "!m32" ":%{!march=*:-march=%(VALUE)}}"}, }; | |||
1356 | ||||
1357 | struct user_specs | |||
1358 | { | |||
1359 | struct user_specs *next; | |||
1360 | const char *filename; | |||
1361 | }; | |||
1362 | ||||
1363 | static struct user_specs *user_specs_head, *user_specs_tail; | |||
1364 | ||||
1365 | ||||
1366 | /* Record the mapping from file suffixes for compilation specs. */ | |||
1367 | ||||
1368 | struct compiler | |||
1369 | { | |||
1370 | const char *suffix; /* Use this compiler for input files | |||
1371 | whose names end in this suffix. */ | |||
1372 | ||||
1373 | const char *spec; /* To use this compiler, run this spec. */ | |||
1374 | ||||
1375 | const char *cpp_spec; /* If non-NULL, substitute this spec | |||
1376 | for `%C', rather than the usual | |||
1377 | cpp_spec. */ | |||
1378 | int combinable; /* If nonzero, compiler can deal with | |||
1379 | multiple source files at once (IMA). */ | |||
1380 | int needs_preprocessing; /* If nonzero, source files need to | |||
1381 | be run through a preprocessor. */ | |||
1382 | }; | |||
1383 | ||||
1384 | /* Pointer to a vector of `struct compiler' that gives the spec for | |||
1385 | compiling a file, based on its suffix. | |||
1386 | A file that does not end in any of these suffixes will be passed | |||
1387 | unchanged to the loader and nothing else will be done to it. | |||
1388 | ||||
1389 | An entry containing two 0s is used to terminate the vector. | |||
1390 | ||||
1391 | If multiple entries match a file, the last matching one is used. */ | |||
1392 | ||||
1393 | static struct compiler *compilers; | |||
1394 | ||||
1395 | /* Number of entries in `compilers', not counting the null terminator. */ | |||
1396 | ||||
1397 | static int n_compilers; | |||
1398 | ||||
1399 | /* The default list of file name suffixes and their compilation specs. */ | |||
1400 | ||||
1401 | static const struct compiler default_compilers[] = | |||
1402 | { | |||
1403 | /* Add lists of suffixes of known languages here. If those languages | |||
1404 | were not present when we built the driver, we will hit these copies | |||
1405 | and be given a more meaningful error than "file not used since | |||
1406 | linking is not done". */ | |||
1407 | {".m", "#Objective-C", 0, 0, 0}, {".mi", "#Objective-C", 0, 0, 0}, | |||
1408 | {".mm", "#Objective-C++", 0, 0, 0}, {".M", "#Objective-C++", 0, 0, 0}, | |||
1409 | {".mii", "#Objective-C++", 0, 0, 0}, | |||
1410 | {".cc", "#C++", 0, 0, 0}, {".cxx", "#C++", 0, 0, 0}, | |||
1411 | {".cpp", "#C++", 0, 0, 0}, {".cp", "#C++", 0, 0, 0}, | |||
1412 | {".c++", "#C++", 0, 0, 0}, {".C", "#C++", 0, 0, 0}, | |||
1413 | {".CPP", "#C++", 0, 0, 0}, {".ii", "#C++", 0, 0, 0}, | |||
1414 | {".ads", "#Ada", 0, 0, 0}, {".adb", "#Ada", 0, 0, 0}, | |||
1415 | {".f", "#Fortran", 0, 0, 0}, {".F", "#Fortran", 0, 0, 0}, | |||
1416 | {".for", "#Fortran", 0, 0, 0}, {".FOR", "#Fortran", 0, 0, 0}, | |||
1417 | {".ftn", "#Fortran", 0, 0, 0}, {".FTN", "#Fortran", 0, 0, 0}, | |||
1418 | {".fpp", "#Fortran", 0, 0, 0}, {".FPP", "#Fortran", 0, 0, 0}, | |||
1419 | {".f90", "#Fortran", 0, 0, 0}, {".F90", "#Fortran", 0, 0, 0}, | |||
1420 | {".f95", "#Fortran", 0, 0, 0}, {".F95", "#Fortran", 0, 0, 0}, | |||
1421 | {".f03", "#Fortran", 0, 0, 0}, {".F03", "#Fortran", 0, 0, 0}, | |||
1422 | {".f08", "#Fortran", 0, 0, 0}, {".F08", "#Fortran", 0, 0, 0}, | |||
1423 | {".r", "#Ratfor", 0, 0, 0}, | |||
1424 | {".go", "#Go", 0, 1, 0}, | |||
1425 | {".d", "#D", 0, 1, 0}, {".dd", "#D", 0, 1, 0}, {".di", "#D", 0, 1, 0}, | |||
1426 | {".mod", "#Modula-2", 0, 0, 0}, {".m2i", "#Modula-2", 0, 0, 0}, | |||
1427 | /* Next come the entries for C. */ | |||
1428 | {".c", "@c", 0, 0, 1}, | |||
1429 | {"@c", | |||
1430 | /* cc1 has an integrated ISO C preprocessor. We should invoke the | |||
1431 | external preprocessor if -save-temps is given. */ | |||
1432 | "%{E|M|MM:%(trad_capable_cpp) %(cpp_options) %(cpp_debug_options)}\ | |||
1433 | %{!E:%{!M:%{!MM:\ | |||
1434 | %{traditional:\ | |||
1435 | %eGNU C no longer supports -traditional without -E}\ | |||
1436 | %{save-temps*|traditional-cpp|no-integrated-cpp:%(trad_capable_cpp) \ | |||
1437 | %(cpp_options) -o %{save-temps*:%b.i} %{!save-temps*:%g.i} \n\ | |||
1438 | cc1 -fpreprocessed %{save-temps*:%b.i} %{!save-temps*:%g.i} \ | |||
1439 | %(cc1_options)}\ | |||
1440 | %{!save-temps*:%{!traditional-cpp:%{!no-integrated-cpp:\ | |||
1441 | cc1 %(cpp_unique_options) %(cc1_options)}}}\ | |||
1442 | %{!fsyntax-only:%(invoke_as)}}}}", 0, 0, 1}, | |||
1443 | {"-", | |||
1444 | "%{!E:%e-E or -x required when input is from standard input}\ | |||
1445 | %(trad_capable_cpp) %(cpp_options) %(cpp_debug_options)", 0, 0, 0}, | |||
1446 | {".h", "@c-header", 0, 0, 0}, | |||
1447 | {"@c-header", | |||
1448 | /* cc1 has an integrated ISO C preprocessor. We should invoke the | |||
1449 | external preprocessor if -save-temps is given. */ | |||
1450 | "%{E|M|MM:%(trad_capable_cpp) %(cpp_options) %(cpp_debug_options)}\ | |||
1451 | %{!E:%{!M:%{!MM:\ | |||
1452 | %{save-temps*|traditional-cpp|no-integrated-cpp:%(trad_capable_cpp) \ | |||
1453 | %(cpp_options) -o %{save-temps*:%b.i} %{!save-temps*:%g.i} \n\ | |||
1454 | cc1 -fpreprocessed %{save-temps*:%b.i} %{!save-temps*:%g.i} \ | |||
1455 | %(cc1_options)\ | |||
1456 | %{!fsyntax-only:%{!S:-o %g.s} \ | |||
1457 | %{!fdump-ada-spec*:%{!o*:--output-pch %i.gch}\ | |||
1458 | %W{o*:--output-pch %*}}%V}}\ | |||
1459 | %{!save-temps*:%{!traditional-cpp:%{!no-integrated-cpp:\ | |||
1460 | cc1 %(cpp_unique_options) %(cc1_options)\ | |||
1461 | %{!fsyntax-only:%{!S:-o %g.s} \ | |||
1462 | %{!fdump-ada-spec*:%{!o*:--output-pch %i.gch}\ | |||
1463 | %W{o*:--output-pch %*}}%V}}}}}}}", 0, 0, 0}, | |||
1464 | {".i", "@cpp-output", 0, 0, 0}, | |||
1465 | {"@cpp-output", | |||
1466 | "%{!M:%{!MM:%{!E:cc1 -fpreprocessed %i %(cc1_options) %{!fsyntax-only:%(invoke_as)}}}}", 0, 0, 0}, | |||
1467 | {".s", "@assembler", 0, 0, 0}, | |||
1468 | {"@assembler", | |||
1469 | "%{!M:%{!MM:%{!E:%{!S:as %(asm_debug) %(asm_options) %i %A }}}}", 0, 0, 0}, | |||
1470 | {".sx", "@assembler-with-cpp", 0, 0, 0}, | |||
1471 | {".S", "@assembler-with-cpp", 0, 0, 0}, | |||
1472 | {"@assembler-with-cpp", | |||
1473 | #ifdef AS_NEEDS_DASH_FOR_PIPED_INPUT | |||
1474 | "%(trad_capable_cpp) -lang-asm %(cpp_options) -fno-directives-only\ | |||
1475 | %{E|M|MM:%(cpp_debug_options)}\ | |||
1476 | %{!M:%{!MM:%{!E:%{!S:-o %|.s |\n\ | |||
1477 | as %(asm_debug) %(asm_options) %|.s %A }}}}" | |||
1478 | #else | |||
1479 | "%(trad_capable_cpp) -lang-asm %(cpp_options) -fno-directives-only\ | |||
1480 | %{E|M|MM:%(cpp_debug_options)}\ | |||
1481 | %{!M:%{!MM:%{!E:%{!S:-o %|.s |\n\ | |||
1482 | as %(asm_debug) %(asm_options) %m.s %A }}}}" | |||
1483 | #endif | |||
1484 | , 0, 0, 0}, | |||
1485 | ||||
1486 | #include "specs.h" | |||
1487 | /* Mark end of table. */ | |||
1488 | {0, 0, 0, 0, 0} | |||
1489 | }; | |||
1490 | ||||
1491 | /* Number of elements in default_compilers, not counting the terminator. */ | |||
1492 | ||||
1493 | static const int n_default_compilers = ARRAY_SIZE (default_compilers)(sizeof (default_compilers) / sizeof ((default_compilers)[0]) ) - 1; | |||
1494 | ||||
1495 | typedef char *char_p; /* For DEF_VEC_P. */ | |||
1496 | ||||
1497 | /* A vector of options to give to the linker. | |||
1498 | These options are accumulated by %x, | |||
1499 | and substituted into the linker command with %X. */ | |||
1500 | static vec<char_p> linker_options; | |||
1501 | ||||
1502 | /* A vector of options to give to the assembler. | |||
1503 | These options are accumulated by -Wa, | |||
1504 | and substituted into the assembler command with %Y. */ | |||
1505 | static vec<char_p> assembler_options; | |||
1506 | ||||
1507 | /* A vector of options to give to the preprocessor. | |||
1508 | These options are accumulated by -Wp, | |||
1509 | and substituted into the preprocessor command with %Z. */ | |||
1510 | static vec<char_p> preprocessor_options; | |||
1511 | ||||
1512 | static char * | |||
1513 | skip_whitespace (char *p) | |||
1514 | { | |||
1515 | while (1) | |||
1516 | { | |||
1517 | /* A fully-blank line is a delimiter in the SPEC file and shouldn't | |||
1518 | be considered whitespace. */ | |||
1519 | if (p[0] == '\n' && p[1] == '\n' && p[2] == '\n') | |||
1520 | return p + 1; | |||
1521 | else if (*p == '\n' || *p == ' ' || *p == '\t') | |||
1522 | p++; | |||
1523 | else if (*p == '#') | |||
1524 | { | |||
1525 | while (*p != '\n') | |||
1526 | p++; | |||
1527 | p++; | |||
1528 | } | |||
1529 | else | |||
1530 | break; | |||
1531 | } | |||
1532 | ||||
1533 | return p; | |||
1534 | } | |||
1535 | /* Structures to keep track of prefixes to try when looking for files. */ | |||
1536 | ||||
1537 | struct prefix_list | |||
1538 | { | |||
1539 | const char *prefix; /* String to prepend to the path. */ | |||
1540 | struct prefix_list *next; /* Next in linked list. */ | |||
1541 | int require_machine_suffix; /* Don't use without machine_suffix. */ | |||
1542 | /* 2 means try both machine_suffix and just_machine_suffix. */ | |||
1543 | int priority; /* Sort key - priority within list. */ | |||
1544 | int os_multilib; /* 1 if OS multilib scheme should be used, | |||
1545 | 0 for GCC multilib scheme. */ | |||
1546 | }; | |||
1547 | ||||
1548 | struct path_prefix | |||
1549 | { | |||
1550 | struct prefix_list *plist; /* List of prefixes to try */ | |||
1551 | int max_len; /* Max length of a prefix in PLIST */ | |||
1552 | const char *name; /* Name of this list (used in config stuff) */ | |||
1553 | }; | |||
1554 | ||||
1555 | /* List of prefixes to try when looking for executables. */ | |||
1556 | ||||
1557 | static struct path_prefix exec_prefixes = { 0, 0, "exec" }; | |||
1558 | ||||
1559 | /* List of prefixes to try when looking for startup (crt0) files. */ | |||
1560 | ||||
1561 | static struct path_prefix startfile_prefixes = { 0, 0, "startfile" }; | |||
1562 | ||||
1563 | /* List of prefixes to try when looking for include files. */ | |||
1564 | ||||
1565 | static struct path_prefix include_prefixes = { 0, 0, "include" }; | |||
1566 | ||||
1567 | /* Suffix to attach to directories searched for commands. | |||
1568 | This looks like `MACHINE/VERSION/'. */ | |||
1569 | ||||
1570 | static const char *machine_suffix = 0; | |||
1571 | ||||
1572 | /* Suffix to attach to directories searched for commands. | |||
1573 | This is just `MACHINE/'. */ | |||
1574 | ||||
1575 | static const char *just_machine_suffix = 0; | |||
1576 | ||||
1577 | /* Adjusted value of GCC_EXEC_PREFIX envvar. */ | |||
1578 | ||||
1579 | static const char *gcc_exec_prefix; | |||
1580 | ||||
1581 | /* Adjusted value of standard_libexec_prefix. */ | |||
1582 | ||||
1583 | static const char *gcc_libexec_prefix; | |||
1584 | ||||
1585 | /* Default prefixes to attach to command names. */ | |||
1586 | ||||
1587 | #ifndef STANDARD_STARTFILE_PREFIX_1"/lib/" | |||
1588 | #define STANDARD_STARTFILE_PREFIX_1"/lib/" "/lib/" | |||
1589 | #endif | |||
1590 | #ifndef STANDARD_STARTFILE_PREFIX_2"/usr/lib/" | |||
1591 | #define STANDARD_STARTFILE_PREFIX_2"/usr/lib/" "/usr/lib/" | |||
1592 | #endif | |||
1593 | ||||
1594 | #ifdef CROSS_DIRECTORY_STRUCTURE /* Don't use these prefixes for a cross compiler. */ | |||
1595 | #undef MD_EXEC_PREFIX"" | |||
1596 | #undef MD_STARTFILE_PREFIX"" | |||
1597 | #undef MD_STARTFILE_PREFIX_1"" | |||
1598 | #endif | |||
1599 | ||||
1600 | /* If no prefixes defined, use the null string, which will disable them. */ | |||
1601 | #ifndef MD_EXEC_PREFIX"" | |||
1602 | #define MD_EXEC_PREFIX"" "" | |||
1603 | #endif | |||
1604 | #ifndef MD_STARTFILE_PREFIX"" | |||
1605 | #define MD_STARTFILE_PREFIX"" "" | |||
1606 | #endif | |||
1607 | #ifndef MD_STARTFILE_PREFIX_1"" | |||
1608 | #define MD_STARTFILE_PREFIX_1"" "" | |||
1609 | #endif | |||
1610 | ||||
1611 | /* These directories are locations set at configure-time based on the | |||
1612 | --prefix option provided to configure. Their initializers are | |||
1613 | defined in Makefile.in. These paths are not *directly* used when | |||
1614 | gcc_exec_prefix is set because, in that case, we know where the | |||
1615 | compiler has been installed, and use paths relative to that | |||
1616 | location instead. */ | |||
1617 | static const char *const standard_exec_prefix = STANDARD_EXEC_PREFIX"/usr/local/lib/gcc/"; | |||
1618 | static const char *const standard_libexec_prefix = STANDARD_LIBEXEC_PREFIX"/usr/local/libexec/gcc/"; | |||
1619 | static const char *const standard_bindir_prefix = STANDARD_BINDIR_PREFIX"/usr/local/bin/"; | |||
1620 | static const char *const standard_startfile_prefix = STANDARD_STARTFILE_PREFIX"../../../"; | |||
1621 | ||||
1622 | /* For native compilers, these are well-known paths containing | |||
1623 | components that may be provided by the system. For cross | |||
1624 | compilers, these paths are not used. */ | |||
1625 | static const char *md_exec_prefix = MD_EXEC_PREFIX""; | |||
1626 | static const char *md_startfile_prefix = MD_STARTFILE_PREFIX""; | |||
1627 | static const char *md_startfile_prefix_1 = MD_STARTFILE_PREFIX_1""; | |||
1628 | static const char *const standard_startfile_prefix_1 | |||
1629 | = STANDARD_STARTFILE_PREFIX_1"/lib/"; | |||
1630 | static const char *const standard_startfile_prefix_2 | |||
1631 | = STANDARD_STARTFILE_PREFIX_2"/usr/lib/"; | |||
1632 | ||||
1633 | /* A relative path to be used in finding the location of tools | |||
1634 | relative to the driver. */ | |||
1635 | static const char *const tooldir_base_prefix = TOOLDIR_BASE_PREFIX"../../../../"; | |||
1636 | ||||
1637 | /* A prefix to be used when this is an accelerator compiler. */ | |||
1638 | static const char *const accel_dir_suffix = ACCEL_DIR_SUFFIX""; | |||
1639 | ||||
1640 | /* Subdirectory to use for locating libraries. Set by | |||
1641 | set_multilib_dir based on the compilation options. */ | |||
1642 | ||||
1643 | static const char *multilib_dir; | |||
1644 | ||||
1645 | /* Subdirectory to use for locating libraries in OS conventions. Set by | |||
1646 | set_multilib_dir based on the compilation options. */ | |||
1647 | ||||
1648 | static const char *multilib_os_dir; | |||
1649 | ||||
1650 | /* Subdirectory to use for locating libraries in multiarch conventions. Set by | |||
1651 | set_multilib_dir based on the compilation options. */ | |||
1652 | ||||
1653 | static const char *multiarch_dir; | |||
1654 | ||||
1655 | /* Structure to keep track of the specs that have been defined so far. | |||
1656 | These are accessed using %(specname) in a compiler or link | |||
1657 | spec. */ | |||
1658 | ||||
1659 | struct spec_list | |||
1660 | { | |||
1661 | /* The following 2 fields must be first */ | |||
1662 | /* to allow EXTRA_SPECS to be initialized */ | |||
1663 | const char *name; /* name of the spec. */ | |||
1664 | const char *ptr; /* available ptr if no static pointer */ | |||
1665 | ||||
1666 | /* The following fields are not initialized */ | |||
1667 | /* by EXTRA_SPECS */ | |||
1668 | const char **ptr_spec; /* pointer to the spec itself. */ | |||
1669 | struct spec_list *next; /* Next spec in linked list. */ | |||
1670 | int name_len; /* length of the name */ | |||
1671 | bool user_p; /* whether string come from file spec. */ | |||
1672 | bool alloc_p; /* whether string was allocated */ | |||
1673 | const char *default_ptr; /* The default value of *ptr_spec. */ | |||
1674 | }; | |||
1675 | ||||
1676 | #define INIT_STATIC_SPEC(NAME,PTR){ NAME, nullptr, PTR, (struct spec_list *) 0, sizeof (NAME) - 1, false, false, *PTR } \ | |||
1677 | { NAME, NULLnullptr, PTR, (struct spec_list *) 0, sizeof (NAME) - 1, false, false, \ | |||
1678 | *PTR } | |||
1679 | ||||
1680 | /* List of statically defined specs. */ | |||
1681 | static struct spec_list static_specs[] = | |||
1682 | { | |||
1683 | INIT_STATIC_SPEC ("asm", &asm_spec){ "asm", nullptr, &asm_spec, (struct spec_list *) 0, sizeof ("asm") - 1, false, false, *&asm_spec }, | |||
1684 | INIT_STATIC_SPEC ("asm_debug", &asm_debug){ "asm_debug", nullptr, &asm_debug, (struct spec_list *) 0 , sizeof ("asm_debug") - 1, false, false, *&asm_debug }, | |||
1685 | INIT_STATIC_SPEC ("asm_debug_option", &asm_debug_option){ "asm_debug_option", nullptr, &asm_debug_option, (struct spec_list *) 0, sizeof ("asm_debug_option") - 1, false, false , *&asm_debug_option }, | |||
1686 | INIT_STATIC_SPEC ("asm_final", &asm_final_spec){ "asm_final", nullptr, &asm_final_spec, (struct spec_list *) 0, sizeof ("asm_final") - 1, false, false, *&asm_final_spec }, | |||
1687 | INIT_STATIC_SPEC ("asm_options", &asm_options){ "asm_options", nullptr, &asm_options, (struct spec_list *) 0, sizeof ("asm_options") - 1, false, false, *&asm_options }, | |||
1688 | INIT_STATIC_SPEC ("invoke_as", &invoke_as){ "invoke_as", nullptr, &invoke_as, (struct spec_list *) 0 , sizeof ("invoke_as") - 1, false, false, *&invoke_as }, | |||
1689 | INIT_STATIC_SPEC ("cpp", &cpp_spec){ "cpp", nullptr, &cpp_spec, (struct spec_list *) 0, sizeof ("cpp") - 1, false, false, *&cpp_spec }, | |||
1690 | INIT_STATIC_SPEC ("cpp_options", &cpp_options){ "cpp_options", nullptr, &cpp_options, (struct spec_list *) 0, sizeof ("cpp_options") - 1, false, false, *&cpp_options }, | |||
1691 | INIT_STATIC_SPEC ("cpp_debug_options", &cpp_debug_options){ "cpp_debug_options", nullptr, &cpp_debug_options, (struct spec_list *) 0, sizeof ("cpp_debug_options") - 1, false, false , *&cpp_debug_options }, | |||
1692 | INIT_STATIC_SPEC ("cpp_unique_options", &cpp_unique_options){ "cpp_unique_options", nullptr, &cpp_unique_options, (struct spec_list *) 0, sizeof ("cpp_unique_options") - 1, false, false , *&cpp_unique_options }, | |||
1693 | INIT_STATIC_SPEC ("trad_capable_cpp", &trad_capable_cpp){ "trad_capable_cpp", nullptr, &trad_capable_cpp, (struct spec_list *) 0, sizeof ("trad_capable_cpp") - 1, false, false , *&trad_capable_cpp }, | |||
1694 | INIT_STATIC_SPEC ("cc1", &cc1_spec){ "cc1", nullptr, &cc1_spec, (struct spec_list *) 0, sizeof ("cc1") - 1, false, false, *&cc1_spec }, | |||
1695 | INIT_STATIC_SPEC ("cc1_options", &cc1_options){ "cc1_options", nullptr, &cc1_options, (struct spec_list *) 0, sizeof ("cc1_options") - 1, false, false, *&cc1_options }, | |||
1696 | INIT_STATIC_SPEC ("cc1plus", &cc1plus_spec){ "cc1plus", nullptr, &cc1plus_spec, (struct spec_list *) 0, sizeof ("cc1plus") - 1, false, false, *&cc1plus_spec }, | |||
1697 | INIT_STATIC_SPEC ("link_gcc_c_sequence", &link_gcc_c_sequence_spec){ "link_gcc_c_sequence", nullptr, &link_gcc_c_sequence_spec , (struct spec_list *) 0, sizeof ("link_gcc_c_sequence") - 1, false, false, *&link_gcc_c_sequence_spec }, | |||
1698 | INIT_STATIC_SPEC ("link_ssp", &link_ssp_spec){ "link_ssp", nullptr, &link_ssp_spec, (struct spec_list * ) 0, sizeof ("link_ssp") - 1, false, false, *&link_ssp_spec }, | |||
1699 | INIT_STATIC_SPEC ("endfile", &endfile_spec){ "endfile", nullptr, &endfile_spec, (struct spec_list *) 0, sizeof ("endfile") - 1, false, false, *&endfile_spec }, | |||
1700 | INIT_STATIC_SPEC ("link", &link_spec){ "link", nullptr, &link_spec, (struct spec_list *) 0, sizeof ("link") - 1, false, false, *&link_spec }, | |||
1701 | INIT_STATIC_SPEC ("lib", &lib_spec){ "lib", nullptr, &lib_spec, (struct spec_list *) 0, sizeof ("lib") - 1, false, false, *&lib_spec }, | |||
1702 | INIT_STATIC_SPEC ("link_gomp", &link_gomp_spec){ "link_gomp", nullptr, &link_gomp_spec, (struct spec_list *) 0, sizeof ("link_gomp") - 1, false, false, *&link_gomp_spec }, | |||
1703 | INIT_STATIC_SPEC ("libgcc", &libgcc_spec){ "libgcc", nullptr, &libgcc_spec, (struct spec_list *) 0 , sizeof ("libgcc") - 1, false, false, *&libgcc_spec }, | |||
1704 | INIT_STATIC_SPEC ("startfile", &startfile_spec){ "startfile", nullptr, &startfile_spec, (struct spec_list *) 0, sizeof ("startfile") - 1, false, false, *&startfile_spec }, | |||
1705 | INIT_STATIC_SPEC ("cross_compile", &cross_compile){ "cross_compile", nullptr, &cross_compile, (struct spec_list *) 0, sizeof ("cross_compile") - 1, false, false, *&cross_compile }, | |||
1706 | INIT_STATIC_SPEC ("version", &compiler_version){ "version", nullptr, &compiler_version, (struct spec_list *) 0, sizeof ("version") - 1, false, false, *&compiler_version }, | |||
1707 | INIT_STATIC_SPEC ("multilib", &multilib_select){ "multilib", nullptr, &multilib_select, (struct spec_list *) 0, sizeof ("multilib") - 1, false, false, *&multilib_select }, | |||
1708 | INIT_STATIC_SPEC ("multilib_defaults", &multilib_defaults){ "multilib_defaults", nullptr, &multilib_defaults, (struct spec_list *) 0, sizeof ("multilib_defaults") - 1, false, false , *&multilib_defaults }, | |||
1709 | INIT_STATIC_SPEC ("multilib_extra", &multilib_extra){ "multilib_extra", nullptr, &multilib_extra, (struct spec_list *) 0, sizeof ("multilib_extra") - 1, false, false, *&multilib_extra }, | |||
1710 | INIT_STATIC_SPEC ("multilib_matches", &multilib_matches){ "multilib_matches", nullptr, &multilib_matches, (struct spec_list *) 0, sizeof ("multilib_matches") - 1, false, false , *&multilib_matches }, | |||
1711 | INIT_STATIC_SPEC ("multilib_exclusions", &multilib_exclusions){ "multilib_exclusions", nullptr, &multilib_exclusions, ( struct spec_list *) 0, sizeof ("multilib_exclusions") - 1, false , false, *&multilib_exclusions }, | |||
1712 | INIT_STATIC_SPEC ("multilib_options", &multilib_options){ "multilib_options", nullptr, &multilib_options, (struct spec_list *) 0, sizeof ("multilib_options") - 1, false, false , *&multilib_options }, | |||
1713 | INIT_STATIC_SPEC ("multilib_reuse", &multilib_reuse){ "multilib_reuse", nullptr, &multilib_reuse, (struct spec_list *) 0, sizeof ("multilib_reuse") - 1, false, false, *&multilib_reuse }, | |||
1714 | INIT_STATIC_SPEC ("linker", &linker_name_spec){ "linker", nullptr, &linker_name_spec, (struct spec_list *) 0, sizeof ("linker") - 1, false, false, *&linker_name_spec }, | |||
1715 | INIT_STATIC_SPEC ("linker_plugin_file", &linker_plugin_file_spec){ "linker_plugin_file", nullptr, &linker_plugin_file_spec , (struct spec_list *) 0, sizeof ("linker_plugin_file") - 1, false , false, *&linker_plugin_file_spec }, | |||
1716 | INIT_STATIC_SPEC ("lto_wrapper", <o_wrapper_spec){ "lto_wrapper", nullptr, <o_wrapper_spec, (struct spec_list *) 0, sizeof ("lto_wrapper") - 1, false, false, *<o_wrapper_spec }, | |||
1717 | INIT_STATIC_SPEC ("lto_gcc", <o_gcc_spec){ "lto_gcc", nullptr, <o_gcc_spec, (struct spec_list *) 0, sizeof ("lto_gcc") - 1, false, false, *<o_gcc_spec }, | |||
1718 | INIT_STATIC_SPEC ("post_link", &post_link_spec){ "post_link", nullptr, &post_link_spec, (struct spec_list *) 0, sizeof ("post_link") - 1, false, false, *&post_link_spec }, | |||
1719 | INIT_STATIC_SPEC ("link_libgcc", &link_libgcc_spec){ "link_libgcc", nullptr, &link_libgcc_spec, (struct spec_list *) 0, sizeof ("link_libgcc") - 1, false, false, *&link_libgcc_spec }, | |||
1720 | INIT_STATIC_SPEC ("md_exec_prefix", &md_exec_prefix){ "md_exec_prefix", nullptr, &md_exec_prefix, (struct spec_list *) 0, sizeof ("md_exec_prefix") - 1, false, false, *&md_exec_prefix }, | |||
1721 | INIT_STATIC_SPEC ("md_startfile_prefix", &md_startfile_prefix){ "md_startfile_prefix", nullptr, &md_startfile_prefix, ( struct spec_list *) 0, sizeof ("md_startfile_prefix") - 1, false , false, *&md_startfile_prefix }, | |||
1722 | INIT_STATIC_SPEC ("md_startfile_prefix_1", &md_startfile_prefix_1){ "md_startfile_prefix_1", nullptr, &md_startfile_prefix_1 , (struct spec_list *) 0, sizeof ("md_startfile_prefix_1") - 1 , false, false, *&md_startfile_prefix_1 }, | |||
1723 | INIT_STATIC_SPEC ("startfile_prefix_spec", &startfile_prefix_spec){ "startfile_prefix_spec", nullptr, &startfile_prefix_spec , (struct spec_list *) 0, sizeof ("startfile_prefix_spec") - 1 , false, false, *&startfile_prefix_spec }, | |||
1724 | INIT_STATIC_SPEC ("sysroot_spec", &sysroot_spec){ "sysroot_spec", nullptr, &sysroot_spec, (struct spec_list *) 0, sizeof ("sysroot_spec") - 1, false, false, *&sysroot_spec }, | |||
1725 | INIT_STATIC_SPEC ("sysroot_suffix_spec", &sysroot_suffix_spec){ "sysroot_suffix_spec", nullptr, &sysroot_suffix_spec, ( struct spec_list *) 0, sizeof ("sysroot_suffix_spec") - 1, false , false, *&sysroot_suffix_spec }, | |||
1726 | INIT_STATIC_SPEC ("sysroot_hdrs_suffix_spec", &sysroot_hdrs_suffix_spec){ "sysroot_hdrs_suffix_spec", nullptr, &sysroot_hdrs_suffix_spec , (struct spec_list *) 0, sizeof ("sysroot_hdrs_suffix_spec") - 1, false, false, *&sysroot_hdrs_suffix_spec }, | |||
1727 | INIT_STATIC_SPEC ("self_spec", &self_spec){ "self_spec", nullptr, &self_spec, (struct spec_list *) 0 , sizeof ("self_spec") - 1, false, false, *&self_spec }, | |||
1728 | }; | |||
1729 | ||||
1730 | #ifdef EXTRA_SPECS{ "cc1_cpu", "" "%{march=native:%>march=native %:local_cpu_detect(arch " "%{" "!m32" ":64;:32}" ") %{!mtune=*:%>mtune=native %:local_cpu_detect(tune " "%{" "!m32" ":64;:32}" ")}} %{mtune=native:%>mtune=native %:local_cpu_detect(tune " "%{" "!m32" ":64;:32}" ")}" }, /* additional specs needed */ | |||
1731 | /* Structure to keep track of just the first two args of a spec_list. | |||
1732 | That is all that the EXTRA_SPECS macro gives us. */ | |||
1733 | struct spec_list_1 | |||
1734 | { | |||
1735 | const char *const name; | |||
1736 | const char *const ptr; | |||
1737 | }; | |||
1738 | ||||
1739 | static const struct spec_list_1 extra_specs_1[] = { EXTRA_SPECS{ "cc1_cpu", "" "%{march=native:%>march=native %:local_cpu_detect(arch " "%{" "!m32" ":64;:32}" ") %{!mtune=*:%>mtune=native %:local_cpu_detect(tune " "%{" "!m32" ":64;:32}" ")}} %{mtune=native:%>mtune=native %:local_cpu_detect(tune " "%{" "!m32" ":64;:32}" ")}" }, }; | |||
1740 | static struct spec_list *extra_specs = (struct spec_list *) 0; | |||
1741 | #endif | |||
1742 | ||||
1743 | /* List of dynamically allocates specs that have been defined so far. */ | |||
1744 | ||||
1745 | static struct spec_list *specs = (struct spec_list *) 0; | |||
1746 | ||||
1747 | /* List of static spec functions. */ | |||
1748 | ||||
1749 | static const struct spec_function static_spec_functions[] = | |||
1750 | { | |||
1751 | { "getenv", getenv_spec_function }, | |||
1752 | { "if-exists", if_exists_spec_function }, | |||
1753 | { "if-exists-else", if_exists_else_spec_function }, | |||
1754 | { "if-exists-then-else", if_exists_then_else_spec_function }, | |||
1755 | { "sanitize", sanitize_spec_function }, | |||
1756 | { "replace-outfile", replace_outfile_spec_function }, | |||
1757 | { "remove-outfile", remove_outfile_spec_function }, | |||
1758 | { "version-compare", version_compare_spec_function }, | |||
1759 | { "include", include_spec_function }, | |||
1760 | { "find-file", find_file_spec_function }, | |||
1761 | { "find-plugindir", find_plugindir_spec_function }, | |||
1762 | { "print-asm-header", print_asm_header_spec_function }, | |||
1763 | { "compare-debug-dump-opt", compare_debug_dump_opt_spec_function }, | |||
1764 | { "compare-debug-self-opt", compare_debug_self_opt_spec_function }, | |||
1765 | { "pass-through-libs", pass_through_libs_spec_func }, | |||
1766 | { "dumps", dumps_spec_func }, | |||
1767 | { "gt", greater_than_spec_func }, | |||
1768 | { "debug-level-gt", debug_level_greater_than_spec_func }, | |||
1769 | { "dwarf-version-gt", dwarf_version_greater_than_spec_func }, | |||
1770 | { "fortran-preinclude-file", find_fortran_preinclude_file}, | |||
1771 | #ifdef EXTRA_SPEC_FUNCTIONS{ "local_cpu_detect", host_detect_local_cpu }, | |||
1772 | EXTRA_SPEC_FUNCTIONS{ "local_cpu_detect", host_detect_local_cpu }, | |||
1773 | #endif | |||
1774 | { 0, 0 } | |||
1775 | }; | |||
1776 | ||||
1777 | static int processing_spec_function; | |||
1778 | ||||
1779 | /* Add appropriate libgcc specs to OBSTACK, taking into account | |||
1780 | various permutations of -shared-libgcc, -shared, and such. */ | |||
1781 | ||||
1782 | #if defined(ENABLE_SHARED_LIBGCC1) && !defined(REAL_LIBGCC_SPEC) | |||
1783 | ||||
1784 | #ifndef USE_LD_AS_NEEDED1 | |||
1785 | #define USE_LD_AS_NEEDED1 0 | |||
1786 | #endif | |||
1787 | ||||
1788 | static void | |||
1789 | init_gcc_specs (struct obstack *obstack, const char *shared_name, | |||
1790 | const char *static_name, const char *eh_name) | |||
1791 | { | |||
1792 | char *buf; | |||
1793 | ||||
1794 | #if USE_LD_AS_NEEDED1 | |||
1795 | buf = concat ("%{static|static-libgcc|static-pie:", static_name, " ", eh_name, "}" | |||
1796 | "%{!static:%{!static-libgcc:%{!static-pie:" | |||
1797 | "%{!shared-libgcc:", | |||
1798 | static_name, " " LD_AS_NEEDED_OPTION"--push-state --as-needed" " ", | |||
1799 | shared_name, " " LD_NO_AS_NEEDED_OPTION"--pop-state" | |||
1800 | "}" | |||
1801 | "%{shared-libgcc:", | |||
1802 | shared_name, "%{!shared: ", static_name, "}" | |||
1803 | "}}" | |||
1804 | #else | |||
1805 | buf = concat ("%{static|static-libgcc:", static_name, " ", eh_name, "}" | |||
1806 | "%{!static:%{!static-libgcc:" | |||
1807 | "%{!shared:" | |||
1808 | "%{!shared-libgcc:", static_name, " ", eh_name, "}" | |||
1809 | "%{shared-libgcc:", shared_name, " ", static_name, "}" | |||
1810 | "}" | |||
1811 | #ifdef LINK_EH_SPEC"%{!static|static-pie:--eh-frame-hdr} " | |||
1812 | "%{shared:" | |||
1813 | "%{shared-libgcc:", shared_name, "}" | |||
1814 | "%{!shared-libgcc:", static_name, "}" | |||
1815 | "}" | |||
1816 | #else | |||
1817 | "%{shared:", shared_name, "}" | |||
1818 | #endif | |||
1819 | #endif | |||
1820 | "}}", NULLnullptr); | |||
1821 | ||||
1822 | obstack_grow (obstack, buf, strlen (buf))__extension__ ({ struct obstack *__o = (obstack); size_t __len = (strlen (buf)); if (__extension__ ({ struct obstack const * __o1 = (__o); (size_t) (__o1->chunk_limit - __o1->next_free ); }) < __len) _obstack_newchunk (__o, __len); memcpy (__o ->next_free, buf, __len); __o->next_free += __len; (void ) 0; }); | |||
1823 | free (buf); | |||
1824 | } | |||
1825 | #endif /* ENABLE_SHARED_LIBGCC */ | |||
1826 | ||||
1827 | /* Initialize the specs lookup routines. */ | |||
1828 | ||||
1829 | static void | |||
1830 | init_spec (void) | |||
1831 | { | |||
1832 | struct spec_list *next = (struct spec_list *) 0; | |||
1833 | struct spec_list *sl = (struct spec_list *) 0; | |||
1834 | int i; | |||
1835 | ||||
1836 | if (specs) | |||
1837 | return; /* Already initialized. */ | |||
1838 | ||||
1839 | if (verbose_flagglobal_options.x_verbose_flag) | |||
1840 | fnotice (stderrstderr, "Using built-in specs.\n"); | |||
1841 | ||||
1842 | #ifdef EXTRA_SPECS{ "cc1_cpu", "" "%{march=native:%>march=native %:local_cpu_detect(arch " "%{" "!m32" ":64;:32}" ") %{!mtune=*:%>mtune=native %:local_cpu_detect(tune " "%{" "!m32" ":64;:32}" ")}} %{mtune=native:%>mtune=native %:local_cpu_detect(tune " "%{" "!m32" ":64;:32}" ")}" }, | |||
1843 | extra_specs = XCNEWVEC (struct spec_list, ARRAY_SIZE (extra_specs_1))((struct spec_list *) xcalloc (((sizeof (extra_specs_1) / sizeof ((extra_specs_1)[0]))), sizeof (struct spec_list))); | |||
1844 | ||||
1845 | for (i = ARRAY_SIZE (extra_specs_1)(sizeof (extra_specs_1) / sizeof ((extra_specs_1)[0])) - 1; i >= 0; i--) | |||
1846 | { | |||
1847 | sl = &extra_specs[i]; | |||
1848 | sl->name = extra_specs_1[i].name; | |||
1849 | sl->ptr = extra_specs_1[i].ptr; | |||
1850 | sl->next = next; | |||
1851 | sl->name_len = strlen (sl->name); | |||
1852 | sl->ptr_spec = &sl->ptr; | |||
1853 | gcc_assert (sl->ptr_spec != NULL)((void)(!(sl->ptr_spec != nullptr) ? fancy_abort ("/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/gcc.cc" , 1853, __FUNCTION__), 0 : 0)); | |||
1854 | sl->default_ptr = sl->ptr; | |||
1855 | next = sl; | |||
1856 | } | |||
1857 | #endif | |||
1858 | ||||
1859 | for (i = ARRAY_SIZE (static_specs)(sizeof (static_specs) / sizeof ((static_specs)[0])) - 1; i >= 0; i--) | |||
1860 | { | |||
1861 | sl = &static_specs[i]; | |||
1862 | sl->next = next; | |||
1863 | next = sl; | |||
1864 | } | |||
1865 | ||||
1866 | #if defined(ENABLE_SHARED_LIBGCC1) && !defined(REAL_LIBGCC_SPEC) | |||
1867 | /* ??? If neither -shared-libgcc nor --static-libgcc was | |||
1868 | seen, then we should be making an educated guess. Some proposed | |||
1869 | heuristics for ELF include: | |||
1870 | ||||
1871 | (1) If "-Wl,--export-dynamic", then it's a fair bet that the | |||
1872 | program will be doing dynamic loading, which will likely | |||
1873 | need the shared libgcc. | |||
1874 | ||||
1875 | (2) If "-ldl", then it's also a fair bet that we're doing | |||
1876 | dynamic loading. | |||
1877 | ||||
1878 | (3) For each ET_DYN we're linking against (either through -lfoo | |||
1879 | or /some/path/foo.so), check to see whether it or one of | |||
1880 | its dependencies depends on a shared libgcc. | |||
1881 | ||||
1882 | (4) If "-shared" | |||
1883 | ||||
1884 | If the runtime is fixed to look for program headers instead | |||
1885 | of calling __register_frame_info at all, for each object, | |||
1886 | use the shared libgcc if any EH symbol referenced. | |||
1887 | ||||
1888 | If crtstuff is fixed to not invoke __register_frame_info | |||
1889 | automatically, for each object, use the shared libgcc if | |||
1890 | any non-empty unwind section found. | |||
1891 | ||||
1892 | Doing any of this probably requires invoking an external program to | |||
1893 | do the actual object file scanning. */ | |||
1894 | { | |||
1895 | const char *p = libgcc_spec; | |||
1896 | int in_sep = 1; | |||
1897 | ||||
1898 | /* Transform the extant libgcc_spec into one that uses the shared libgcc | |||
1899 | when given the proper command line arguments. */ | |||
1900 | while (*p) | |||
1901 | { | |||
1902 | if (in_sep && *p == '-' && startswith (p, "-lgcc")) | |||
1903 | { | |||
1904 | init_gcc_specs (&obstack, | |||
1905 | "-lgcc_s" | |||
1906 | #ifdef USE_LIBUNWIND_EXCEPTIONS | |||
1907 | " -lunwind" | |||
1908 | #endif | |||
1909 | , | |||
1910 | "-lgcc", | |||
1911 | "-lgcc_eh" | |||
1912 | #ifdef USE_LIBUNWIND_EXCEPTIONS | |||
1913 | # ifdef HAVE_LD_STATIC_DYNAMIC1 | |||
1914 | " %{!static:%{!static-pie:" LD_STATIC_OPTION"-Bstatic" "}} -lunwind" | |||
1915 | " %{!static:%{!static-pie:" LD_DYNAMIC_OPTION"-Bdynamic" "}}" | |||
1916 | # else | |||
1917 | " -lunwind" | |||
1918 | # endif | |||
1919 | #endif | |||
1920 | ); | |||
1921 | ||||
1922 | p += 5; | |||
1923 | in_sep = 0; | |||
1924 | } | |||
1925 | else if (in_sep && *p == 'l' && startswith (p, "libgcc.a%s")) | |||
1926 | { | |||
1927 | /* Ug. We don't know shared library extensions. Hope that | |||
1928 | systems that use this form don't do shared libraries. */ | |||
1929 | init_gcc_specs (&obstack, | |||
1930 | "-lgcc_s", | |||
1931 | "libgcc.a%s", | |||
1932 | "libgcc_eh.a%s" | |||
1933 | #ifdef USE_LIBUNWIND_EXCEPTIONS | |||
1934 | " -lunwind" | |||
1935 | #endif | |||
1936 | ); | |||
1937 | p += 10; | |||
1938 | in_sep = 0; | |||
1939 | } | |||
1940 | else | |||
1941 | { | |||
1942 | obstack_1grow (&obstack, *p)__extension__ ({ struct obstack *__o = (&obstack); if (__extension__ ({ struct obstack const *__o1 = (__o); (size_t) (__o1->chunk_limit - __o1->next_free); }) < 1) _obstack_newchunk (__o, 1) ; ((void) (*((__o)->next_free)++ = (*p))); }); | |||
1943 | in_sep = (*p == ' '); | |||
1944 | p += 1; | |||
1945 | } | |||
1946 | } | |||
1947 | ||||
1948 | obstack_1grow (&obstack, '\0')__extension__ ({ struct obstack *__o = (&obstack); if (__extension__ ({ struct obstack const *__o1 = (__o); (size_t) (__o1->chunk_limit - __o1->next_free); }) < 1) _obstack_newchunk (__o, 1) ; ((void) (*((__o)->next_free)++ = ('\0'))); }); | |||
1949 | libgcc_spec = XOBFINISH (&obstack, const char *)((const char *) __extension__ ({ struct obstack *__o1 = ((& obstack)); void *__value = (void *) __o1->object_base; if ( __o1->next_free == __value) __o1->maybe_empty_object = 1 ; __o1->next_free = (sizeof (ptrdiff_t) < sizeof (void * ) ? ((__o1->object_base) + (((__o1->next_free) - (__o1-> object_base) + (__o1->alignment_mask)) & ~(__o1->alignment_mask ))) : (char *) (((ptrdiff_t) (__o1->next_free) + (__o1-> alignment_mask)) & ~(__o1->alignment_mask))); if ((size_t ) (__o1->next_free - (char *) __o1->chunk) > (size_t ) (__o1->chunk_limit - (char *) __o1->chunk)) __o1-> next_free = __o1->chunk_limit; __o1->object_base = __o1 ->next_free; __value; })); | |||
1950 | } | |||
1951 | #endif | |||
1952 | #ifdef USE_AS_TRADITIONAL_FORMAT | |||
1953 | /* Prepend "--traditional-format" to whatever asm_spec we had before. */ | |||
1954 | { | |||
1955 | static const char tf[] = "--traditional-format "; | |||
1956 | obstack_grow (&obstack, tf, sizeof (tf) - 1)__extension__ ({ struct obstack *__o = (&obstack); size_t __len = (sizeof (tf) - 1); if (__extension__ ({ struct obstack const *__o1 = (__o); (size_t) (__o1->chunk_limit - __o1-> next_free); }) < __len) _obstack_newchunk (__o, __len); memcpy (__o->next_free, tf, __len); __o->next_free += __len; ( void) 0; }); | |||
1957 | obstack_grow0 (&obstack, asm_spec, strlen (asm_spec))__extension__ ({ struct obstack *__o = (&obstack); size_t __len = (strlen (asm_spec)); if (__extension__ ({ struct obstack const *__o1 = (__o); (size_t) (__o1->chunk_limit - __o1-> next_free); }) < __len + 1) _obstack_newchunk (__o, __len + 1); memcpy (__o->next_free, asm_spec, __len); __o->next_free += __len; *(__o->next_free)++ = 0; (void) 0; }); | |||
1958 | asm_spec = XOBFINISH (&obstack, const char *)((const char *) __extension__ ({ struct obstack *__o1 = ((& obstack)); void *__value = (void *) __o1->object_base; if ( __o1->next_free == __value) __o1->maybe_empty_object = 1 ; __o1->next_free = (sizeof (ptrdiff_t) < sizeof (void * ) ? ((__o1->object_base) + (((__o1->next_free) - (__o1-> object_base) + (__o1->alignment_mask)) & ~(__o1->alignment_mask ))) : (char *) (((ptrdiff_t) (__o1->next_free) + (__o1-> alignment_mask)) & ~(__o1->alignment_mask))); if ((size_t ) (__o1->next_free - (char *) __o1->chunk) > (size_t ) (__o1->chunk_limit - (char *) __o1->chunk)) __o1-> next_free = __o1->chunk_limit; __o1->object_base = __o1 ->next_free; __value; })); | |||
1959 | } | |||
1960 | #endif | |||
1961 | ||||
1962 | #if defined LINK_EH_SPEC"%{!static|static-pie:--eh-frame-hdr} " || defined LINK_BUILDID_SPEC || \ | |||
1963 | defined LINKER_HASH_STYLE | |||
1964 | # ifdef LINK_BUILDID_SPEC | |||
1965 | /* Prepend LINK_BUILDID_SPEC to whatever link_spec we had before. */ | |||
1966 | obstack_grow (&obstack, LINK_BUILDID_SPEC, sizeof (LINK_BUILDID_SPEC) - 1)__extension__ ({ struct obstack *__o = (&obstack); size_t __len = (sizeof (LINK_BUILDID_SPEC) - 1); if (__extension__ ( { struct obstack const *__o1 = (__o); (size_t) (__o1->chunk_limit - __o1->next_free); }) < __len) _obstack_newchunk (__o , __len); memcpy (__o->next_free, LINK_BUILDID_SPEC, __len ); __o->next_free += __len; (void) 0; }); | |||
1967 | # endif | |||
1968 | # ifdef LINK_EH_SPEC"%{!static|static-pie:--eh-frame-hdr} " | |||
1969 | /* Prepend LINK_EH_SPEC to whatever link_spec we had before. */ | |||
1970 | obstack_grow (&obstack, LINK_EH_SPEC, sizeof (LINK_EH_SPEC) - 1)__extension__ ({ struct obstack *__o = (&obstack); size_t __len = (sizeof ("%{!static|static-pie:--eh-frame-hdr} ") - 1 ); if (__extension__ ({ struct obstack const *__o1 = (__o); ( size_t) (__o1->chunk_limit - __o1->next_free); }) < __len ) _obstack_newchunk (__o, __len); memcpy (__o->next_free, "%{!static|static-pie:--eh-frame-hdr} " , __len); __o->next_free += __len; (void) 0; }); | |||
1971 | # endif | |||
1972 | # ifdef LINKER_HASH_STYLE | |||
1973 | /* Prepend --hash-style=LINKER_HASH_STYLE to whatever link_spec we had | |||
1974 | before. */ | |||
1975 | { | |||
1976 | static const char hash_style[] = "--hash-style="; | |||
1977 | obstack_grow (&obstack, hash_style, sizeof (hash_style) - 1)__extension__ ({ struct obstack *__o = (&obstack); size_t __len = (sizeof (hash_style) - 1); if (__extension__ ({ struct obstack const *__o1 = (__o); (size_t) (__o1->chunk_limit - __o1->next_free); }) < __len) _obstack_newchunk (__o, __len ); memcpy (__o->next_free, hash_style, __len); __o->next_free += __len; (void) 0; }); | |||
1978 | obstack_grow (&obstack, LINKER_HASH_STYLE, sizeof (LINKER_HASH_STYLE) - 1)__extension__ ({ struct obstack *__o = (&obstack); size_t __len = (sizeof (LINKER_HASH_STYLE) - 1); if (__extension__ ( { struct obstack const *__o1 = (__o); (size_t) (__o1->chunk_limit - __o1->next_free); }) < __len) _obstack_newchunk (__o , __len); memcpy (__o->next_free, LINKER_HASH_STYLE, __len ); __o->next_free += __len; (void) 0; }); | |||
1979 | obstack_1grow (&obstack, ' ')__extension__ ({ struct obstack *__o = (&obstack); if (__extension__ ({ struct obstack const *__o1 = (__o); (size_t) (__o1->chunk_limit - __o1->next_free); }) < 1) _obstack_newchunk (__o, 1) ; ((void) (*((__o)->next_free)++ = (' '))); }); | |||
1980 | } | |||
1981 | # endif | |||
1982 | obstack_grow0 (&obstack, link_spec, strlen (link_spec))__extension__ ({ struct obstack *__o = (&obstack); size_t __len = (strlen (link_spec)); if (__extension__ ({ struct obstack const *__o1 = (__o); (size_t) (__o1->chunk_limit - __o1-> next_free); }) < __len + 1) _obstack_newchunk (__o, __len + 1); memcpy (__o->next_free, link_spec, __len); __o->next_free += __len; *(__o->next_free)++ = 0; (void) 0; }); | |||
1983 | link_spec = XOBFINISH (&obstack, const char *)((const char *) __extension__ ({ struct obstack *__o1 = ((& obstack)); void *__value = (void *) __o1->object_base; if ( __o1->next_free == __value) __o1->maybe_empty_object = 1 ; __o1->next_free = (sizeof (ptrdiff_t) < sizeof (void * ) ? ((__o1->object_base) + (((__o1->next_free) - (__o1-> object_base) + (__o1->alignment_mask)) & ~(__o1->alignment_mask ))) : (char *) (((ptrdiff_t) (__o1->next_free) + (__o1-> alignment_mask)) & ~(__o1->alignment_mask))); if ((size_t ) (__o1->next_free - (char *) __o1->chunk) > (size_t ) (__o1->chunk_limit - (char *) __o1->chunk)) __o1-> next_free = __o1->chunk_limit; __o1->object_base = __o1 ->next_free; __value; })); | |||
1984 | #endif | |||
1985 | ||||
1986 | specs = sl; | |||
1987 | } | |||
1988 | ||||
1989 | /* Update the entry for SPEC in the static_specs table to point to VALUE, | |||
1990 | ensuring that we free the previous value if necessary. Set alloc_p for the | |||
1991 | entry to ALLOC_P: this determines whether we take ownership of VALUE (i.e. | |||
1992 | whether we need to free it later on). */ | |||
1993 | static void | |||
1994 | set_static_spec (const char **spec, const char *value, bool alloc_p) | |||
1995 | { | |||
1996 | struct spec_list *sl = NULLnullptr; | |||
1997 | ||||
1998 | for (unsigned i = 0; i < ARRAY_SIZE (static_specs)(sizeof (static_specs) / sizeof ((static_specs)[0])); i++) | |||
1999 | { | |||
2000 | if (static_specs[i].ptr_spec == spec) | |||
2001 | { | |||
2002 | sl = static_specs + i; | |||
2003 | break; | |||
2004 | } | |||
2005 | } | |||
2006 | ||||
2007 | gcc_assert (sl)((void)(!(sl) ? fancy_abort ("/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/gcc.cc" , 2007, __FUNCTION__), 0 : 0)); | |||
2008 | ||||
2009 | if (sl->alloc_p) | |||
2010 | { | |||
2011 | const char *old = *spec; | |||
2012 | free (const_cast <char *> (old)); | |||
2013 | } | |||
2014 | ||||
2015 | *spec = value; | |||
2016 | sl->alloc_p = alloc_p; | |||
2017 | } | |||
2018 | ||||
2019 | /* Update a static spec to a new string, taking ownership of that | |||
2020 | string's memory. */ | |||
2021 | static void set_static_spec_owned (const char **spec, const char *val) | |||
2022 | { | |||
2023 | return set_static_spec (spec, val, true); | |||
2024 | } | |||
2025 | ||||
2026 | /* Update a static spec to point to a new value, but don't take | |||
2027 | ownership of (i.e. don't free) that string. */ | |||
2028 | static void set_static_spec_shared (const char **spec, const char *val) | |||
2029 | { | |||
2030 | return set_static_spec (spec, val, false); | |||
2031 | } | |||
2032 | ||||
2033 | ||||
2034 | /* Change the value of spec NAME to SPEC. If SPEC is empty, then the spec is | |||
2035 | removed; If the spec starts with a + then SPEC is added to the end of the | |||
2036 | current spec. */ | |||
2037 | ||||
2038 | static void | |||
2039 | set_spec (const char *name, const char *spec, bool user_p) | |||
2040 | { | |||
2041 | struct spec_list *sl; | |||
2042 | const char *old_spec; | |||
2043 | int name_len = strlen (name); | |||
2044 | int i; | |||
2045 | ||||
2046 | /* If this is the first call, initialize the statically allocated specs. */ | |||
2047 | if (!specs) | |||
2048 | { | |||
2049 | struct spec_list *next = (struct spec_list *) 0; | |||
2050 | for (i = ARRAY_SIZE (static_specs)(sizeof (static_specs) / sizeof ((static_specs)[0])) - 1; i >= 0; i--) | |||
2051 | { | |||
2052 | sl = &static_specs[i]; | |||
2053 | sl->next = next; | |||
2054 | next = sl; | |||
2055 | } | |||
2056 | specs = sl; | |||
2057 | } | |||
2058 | ||||
2059 | /* See if the spec already exists. */ | |||
2060 | for (sl = specs; sl; sl = sl->next) | |||
2061 | if (name_len == sl->name_len && !strcmp (sl->name, name)) | |||
2062 | break; | |||
2063 | ||||
2064 | if (!sl) | |||
2065 | { | |||
2066 | /* Not found - make it. */ | |||
2067 | sl = XNEW (struct spec_list)((struct spec_list *) xmalloc (sizeof (struct spec_list))); | |||
2068 | sl->name = xstrdup (name); | |||
2069 | sl->name_len = name_len; | |||
2070 | sl->ptr_spec = &sl->ptr; | |||
2071 | sl->alloc_p = 0; | |||
2072 | *(sl->ptr_spec) = ""; | |||
2073 | sl->next = specs; | |||
2074 | sl->default_ptr = NULLnullptr; | |||
2075 | specs = sl; | |||
2076 | } | |||
2077 | ||||
2078 | old_spec = *(sl->ptr_spec); | |||
2079 | *(sl->ptr_spec) = ((spec[0] == '+' && ISSPACE ((unsigned char)spec[1])(_sch_istable[((unsigned char)spec[1]) & 0xff] & (unsigned short)(_sch_isspace))) | |||
2080 | ? concat (old_spec, spec + 1, NULLnullptr) | |||
2081 | : xstrdup (spec)); | |||
2082 | ||||
2083 | #ifdef DEBUG_SPECS | |||
2084 | if (verbose_flagglobal_options.x_verbose_flag) | |||
2085 | fnotice (stderrstderr, "Setting spec %s to '%s'\n\n", name, *(sl->ptr_spec)); | |||
2086 | #endif | |||
2087 | ||||
2088 | /* Free the old spec. */ | |||
2089 | if (old_spec && sl->alloc_p) | |||
2090 | free (CONST_CAST (char *, old_spec)(const_cast<char *> ((old_spec)))); | |||
2091 | ||||
2092 | sl->user_p = user_p; | |||
2093 | sl->alloc_p = true; | |||
2094 | } | |||
2095 | ||||
2096 | /* Accumulate a command (program name and args), and run it. */ | |||
2097 | ||||
2098 | typedef const char *const_char_p; /* For DEF_VEC_P. */ | |||
2099 | ||||
2100 | /* Vector of pointers to arguments in the current line of specifications. */ | |||
2101 | static vec<const_char_p> argbuf; | |||
2102 | ||||
2103 | /* Likewise, but for the current @file. */ | |||
2104 | static vec<const_char_p> at_file_argbuf; | |||
2105 | ||||
2106 | /* Whether an @file is currently open. */ | |||
2107 | static bool in_at_file = false; | |||
2108 | ||||
2109 | /* Were the options -c, -S or -E passed. */ | |||
2110 | static int have_c = 0; | |||
2111 | ||||
2112 | /* Was the option -o passed. */ | |||
2113 | static int have_o = 0; | |||
2114 | ||||
2115 | /* Was the option -E passed. */ | |||
2116 | static int have_E = 0; | |||
2117 | ||||
2118 | /* Pointer to output file name passed in with -o. */ | |||
2119 | static const char *output_file = 0; | |||
2120 | ||||
2121 | /* This is the list of suffixes and codes (%g/%u/%U/%j) and the associated | |||
2122 | temp file. If the HOST_BIT_BUCKET is used for %j, no entry is made for | |||
2123 | it here. */ | |||
2124 | ||||
2125 | static struct temp_name { | |||
2126 | const char *suffix; /* suffix associated with the code. */ | |||
2127 | int length; /* strlen (suffix). */ | |||
2128 | int unique; /* Indicates whether %g or %u/%U was used. */ | |||
2129 | const char *filename; /* associated filename. */ | |||
2130 | int filename_length; /* strlen (filename). */ | |||
2131 | struct temp_name *next; | |||
2132 | } *temp_names; | |||
2133 | ||||
2134 | /* Number of commands executed so far. */ | |||
2135 | ||||
2136 | static int execution_count; | |||
2137 | ||||
2138 | /* Number of commands that exited with a signal. */ | |||
2139 | ||||
2140 | static int signal_count; | |||
2141 | ||||
2142 | /* Allocate the argument vector. */ | |||
2143 | ||||
2144 | static void | |||
2145 | alloc_args (void) | |||
2146 | { | |||
2147 | argbuf.create (10); | |||
2148 | at_file_argbuf.create (10); | |||
2149 | } | |||
2150 | ||||
2151 | /* Clear out the vector of arguments (after a command is executed). */ | |||
2152 | ||||
2153 | static void | |||
2154 | clear_args (void) | |||
2155 | { | |||
2156 | argbuf.truncate (0); | |||
2157 | at_file_argbuf.truncate (0); | |||
2158 | } | |||
2159 | ||||
2160 | /* Add one argument to the vector at the end. | |||
2161 | This is done when a space is seen or at the end of the line. | |||
2162 | If DELETE_ALWAYS is nonzero, the arg is a filename | |||
2163 | and the file should be deleted eventually. | |||
2164 | If DELETE_FAILURE is nonzero, the arg is a filename | |||
2165 | and the file should be deleted if this compilation fails. */ | |||
2166 | ||||
2167 | static void | |||
2168 | store_arg (const char *arg, int delete_always, int delete_failure) | |||
2169 | { | |||
2170 | if (in_at_file) | |||
2171 | at_file_argbuf.safe_push (arg); | |||
2172 | else | |||
2173 | argbuf.safe_push (arg); | |||
2174 | ||||
2175 | if (delete_always || delete_failure) | |||
2176 | { | |||
2177 | const char *p; | |||
2178 | /* If the temporary file we should delete is specified as | |||
2179 | part of a joined argument extract the filename. */ | |||
2180 | if (arg[0] == '-' | |||
2181 | && (p = strrchr (arg, '='))) | |||
2182 | arg = p + 1; | |||
2183 | record_temp_file (arg, delete_always, delete_failure); | |||
2184 | } | |||
2185 | } | |||
2186 | ||||
2187 | /* Open a temporary @file into which subsequent arguments will be stored. */ | |||
2188 | ||||
2189 | static void | |||
2190 | open_at_file (void) | |||
2191 | { | |||
2192 | if (in_at_file) | |||
2193 | fatal_error (input_location, "cannot open nested response file"); | |||
2194 | else | |||
2195 | in_at_file = true; | |||
2196 | } | |||
2197 | ||||
2198 | /* Create a temporary @file name. */ | |||
2199 | ||||
2200 | static char *make_at_file (void) | |||
2201 | { | |||
2202 | static int fileno = 0; | |||
2203 | char filename[20]; | |||
2204 | const char *base, *ext; | |||
2205 | ||||
2206 | if (!save_temps_flag) | |||
2207 | return make_temp_file (""); | |||
2208 | ||||
2209 | base = dumpbase; | |||
2210 | if (!(base && *base)) | |||
2211 | base = dumpdir; | |||
2212 | if (!(base && *base)) | |||
2213 | base = "a"; | |||
2214 | ||||
2215 | sprintf (filename, ".args.%d", fileno++); | |||
2216 | ext = filename; | |||
2217 | ||||
2218 | if (base == dumpdir && dumpdir_trailing_dash_added) | |||
2219 | ext++; | |||
2220 | ||||
2221 | return concat (base, ext, NULLnullptr); | |||
2222 | } | |||
2223 | ||||
2224 | /* Close the temporary @file and add @file to the argument list. */ | |||
2225 | ||||
2226 | static void | |||
2227 | close_at_file (void) | |||
2228 | { | |||
2229 | if (!in_at_file) | |||
2230 | fatal_error (input_location, "cannot close nonexistent response file"); | |||
2231 | ||||
2232 | in_at_file = false; | |||
2233 | ||||
2234 | const unsigned int n_args = at_file_argbuf.length (); | |||
2235 | if (n_args == 0) | |||
2236 | return; | |||
2237 | ||||
2238 | char **argv = XALLOCAVEC (char *, n_args + 1)((char * *) __builtin_alloca(sizeof (char *) * (n_args + 1))); | |||
2239 | char *temp_file = make_at_file (); | |||
2240 | char *at_argument = concat ("@", temp_file, NULLnullptr); | |||
2241 | FILE *f = fopen (temp_file, "w"); | |||
2242 | int status; | |||
2243 | unsigned int i; | |||
2244 | ||||
2245 | /* Copy the strings over. */ | |||
2246 | for (i = 0; i < n_args; i++) | |||
2247 | argv[i] = CONST_CAST (char *, at_file_argbuf[i])(const_cast<char *> ((at_file_argbuf[i]))); | |||
2248 | argv[i] = NULLnullptr; | |||
2249 | ||||
2250 | at_file_argbuf.truncate (0); | |||
2251 | ||||
2252 | if (f == NULLnullptr) | |||
2253 | fatal_error (input_location, "could not open temporary response file %s", | |||
2254 | temp_file); | |||
2255 | ||||
2256 | status = writeargv (argv, f); | |||
2257 | ||||
2258 | if (status) | |||
2259 | fatal_error (input_location, | |||
2260 | "could not write to temporary response file %s", | |||
2261 | temp_file); | |||
2262 | ||||
2263 | status = fclose (f); | |||
2264 | ||||
2265 | if (status == EOF(-1)) | |||
2266 | fatal_error (input_location, "could not close temporary response file %s", | |||
2267 | temp_file); | |||
2268 | ||||
2269 | store_arg (at_argument, 0, 0); | |||
2270 | ||||
2271 | record_temp_file (temp_file, !save_temps_flag, !save_temps_flag); | |||
2272 | } | |||
2273 | ||||
2274 | /* Load specs from a file name named FILENAME, replacing occurrences of | |||
2275 | various different types of line-endings, \r\n, \n\r and just \r, with | |||
2276 | a single \n. */ | |||
2277 | ||||
2278 | static char * | |||
2279 | load_specs (const char *filename) | |||
2280 | { | |||
2281 | int desc; | |||
2282 | int readlen; | |||
2283 | struct stat statbuf; | |||
2284 | char *buffer; | |||
2285 | char *buffer_p; | |||
2286 | char *specs; | |||
2287 | char *specs_p; | |||
2288 | ||||
2289 | if (verbose_flagglobal_options.x_verbose_flag) | |||
2290 | fnotice (stderrstderr, "Reading specs from %s\n", filename); | |||
2291 | ||||
2292 | /* Open and stat the file. */ | |||
2293 | desc = open (filename, O_RDONLY00, 0); | |||
2294 | if (desc < 0) | |||
2295 | { | |||
2296 | failed: | |||
2297 | /* This leaves DESC open, but the OS will save us. */ | |||
2298 | fatal_error (input_location, "cannot read spec file %qs: %m", filename); | |||
2299 | } | |||
2300 | ||||
2301 | if (stat (filename, &statbuf) < 0) | |||
2302 | goto failed; | |||
2303 | ||||
2304 | /* Read contents of file into BUFFER. */ | |||
2305 | buffer = XNEWVEC (char, statbuf.st_size + 1)((char *) xmalloc (sizeof (char) * (statbuf.st_size + 1))); | |||
2306 | readlen = read (desc, buffer, (unsigned) statbuf.st_size); | |||
2307 | if (readlen < 0) | |||
2308 | goto failed; | |||
2309 | buffer[readlen] = 0; | |||
2310 | close (desc); | |||
2311 | ||||
2312 | specs = XNEWVEC (char, readlen + 1)((char *) xmalloc (sizeof (char) * (readlen + 1))); | |||
2313 | specs_p = specs; | |||
2314 | for (buffer_p = buffer; buffer_p && *buffer_p; buffer_p++) | |||
2315 | { | |||
2316 | int skip = 0; | |||
2317 | char c = *buffer_p; | |||
2318 | if (c == '\r') | |||
2319 | { | |||
2320 | if (buffer_p > buffer && *(buffer_p - 1) == '\n') /* \n\r */ | |||
2321 | skip = 1; | |||
2322 | else if (*(buffer_p + 1) == '\n') /* \r\n */ | |||
2323 | skip = 1; | |||
2324 | else /* \r */ | |||
2325 | c = '\n'; | |||
2326 | } | |||
2327 | if (! skip) | |||
2328 | *specs_p++ = c; | |||
2329 | } | |||
2330 | *specs_p = '\0'; | |||
2331 | ||||
2332 | free (buffer); | |||
2333 | return (specs); | |||
2334 | } | |||
2335 | ||||
2336 | /* Read compilation specs from a file named FILENAME, | |||
2337 | replacing the default ones. | |||
2338 | ||||
2339 | A suffix which starts with `*' is a definition for | |||
2340 | one of the machine-specific sub-specs. The "suffix" should be | |||
2341 | *asm, *cc1, *cpp, *link, *startfile, etc. | |||
2342 | The corresponding spec is stored in asm_spec, etc., | |||
2343 | rather than in the `compilers' vector. | |||
2344 | ||||
2345 | Anything invalid in the file is a fatal error. */ | |||
2346 | ||||
2347 | static void | |||
2348 | read_specs (const char *filename, bool main_p, bool user_p) | |||
2349 | { | |||
2350 | char *buffer; | |||
2351 | char *p; | |||
2352 | ||||
2353 | buffer = load_specs (filename); | |||
2354 | ||||
2355 | /* Scan BUFFER for specs, putting them in the vector. */ | |||
2356 | p = buffer; | |||
2357 | while (1) | |||
2358 | { | |||
2359 | char *suffix; | |||
2360 | char *spec; | |||
2361 | char *in, *out, *p1, *p2, *p3; | |||
2362 | ||||
2363 | /* Advance P in BUFFER to the next nonblank nocomment line. */ | |||
2364 | p = skip_whitespace (p); | |||
2365 | if (*p == 0) | |||
2366 | break; | |||
2367 | ||||
2368 | /* Is this a special command that starts with '%'? */ | |||
2369 | /* Don't allow this for the main specs file, since it would | |||
2370 | encourage people to overwrite it. */ | |||
2371 | if (*p == '%' && !main_p) | |||
2372 | { | |||
2373 | p1 = p; | |||
2374 | while (*p && *p != '\n') | |||
2375 | p++; | |||
2376 | ||||
2377 | /* Skip '\n'. */ | |||
2378 | p++; | |||
2379 | ||||
2380 | if (startswith (p1, "%include") | |||
2381 | && (p1[sizeof "%include" - 1] == ' ' | |||
2382 | || p1[sizeof "%include" - 1] == '\t')) | |||
2383 | { | |||
2384 | char *new_filename; | |||
2385 | ||||
2386 | p1 += sizeof ("%include"); | |||
2387 | while (*p1 == ' ' || *p1 == '\t') | |||
2388 | p1++; | |||
2389 | ||||
2390 | if (*p1++ != '<' || p[-2] != '>') | |||
2391 | fatal_error (input_location, | |||
2392 | "specs %%include syntax malformed after " | |||
2393 | "%ld characters", | |||
2394 | (long) (p1 - buffer + 1)); | |||
2395 | ||||
2396 | p[-2] = '\0'; | |||
2397 | new_filename = find_a_file (&startfile_prefixes, p1, R_OK4, true); | |||
2398 | read_specs (new_filename ? new_filename : p1, false, user_p); | |||
2399 | continue; | |||
2400 | } | |||
2401 | else if (startswith (p1, "%include_noerr") | |||
2402 | && (p1[sizeof "%include_noerr" - 1] == ' ' | |||
2403 | || p1[sizeof "%include_noerr" - 1] == '\t')) | |||
2404 | { | |||
2405 | char *new_filename; | |||
2406 | ||||
2407 | p1 += sizeof "%include_noerr"; | |||
2408 | while (*p1 == ' ' || *p1 == '\t') | |||
2409 | p1++; | |||
2410 | ||||
2411 | if (*p1++ != '<' || p[-2] != '>') | |||
2412 | fatal_error (input_location, | |||
2413 | "specs %%include syntax malformed after " | |||
2414 | "%ld characters", | |||
2415 | (long) (p1 - buffer + 1)); | |||
2416 | ||||
2417 | p[-2] = '\0'; | |||
2418 | new_filename = find_a_file (&startfile_prefixes, p1, R_OK4, true); | |||
2419 | if (new_filename) | |||
2420 | read_specs (new_filename, false, user_p); | |||
2421 | else if (verbose_flagglobal_options.x_verbose_flag) | |||
2422 | fnotice (stderrstderr, "could not find specs file %s\n", p1); | |||
2423 | continue; | |||
2424 | } | |||
2425 | else if (startswith (p1, "%rename") | |||
2426 | && (p1[sizeof "%rename" - 1] == ' ' | |||
2427 | || p1[sizeof "%rename" - 1] == '\t')) | |||
2428 | { | |||
2429 | int name_len; | |||
2430 | struct spec_list *sl; | |||
2431 | struct spec_list *newsl; | |||
2432 | ||||
2433 | /* Get original name. */ | |||
2434 | p1 += sizeof "%rename"; | |||
2435 | while (*p1 == ' ' || *p1 == '\t') | |||
2436 | p1++; | |||
2437 | ||||
2438 | if (! ISALPHA ((unsigned char) *p1)(_sch_istable[((unsigned char) *p1) & 0xff] & (unsigned short)(_sch_isalpha))) | |||
2439 | fatal_error (input_location, | |||
2440 | "specs %%rename syntax malformed after " | |||
2441 | "%ld characters", | |||
2442 | (long) (p1 - buffer)); | |||
2443 | ||||
2444 | p2 = p1; | |||
2445 | while (*p2 && !ISSPACE ((unsigned char) *p2)(_sch_istable[((unsigned char) *p2) & 0xff] & (unsigned short)(_sch_isspace))) | |||
2446 | p2++; | |||
2447 | ||||
2448 | if (*p2 != ' ' && *p2 != '\t') | |||
2449 | fatal_error (input_location, | |||
2450 | "specs %%rename syntax malformed after " | |||
2451 | "%ld characters", | |||
2452 | (long) (p2 - buffer)); | |||
2453 | ||||
2454 | name_len = p2 - p1; | |||
2455 | *p2++ = '\0'; | |||
2456 | while (*p2 == ' ' || *p2 == '\t') | |||
2457 | p2++; | |||
2458 | ||||
2459 | if (! ISALPHA ((unsigned char) *p2)(_sch_istable[((unsigned char) *p2) & 0xff] & (unsigned short)(_sch_isalpha))) | |||
2460 | fatal_error (input_location, | |||
2461 | "specs %%rename syntax malformed after " | |||
2462 | "%ld characters", | |||
2463 | (long) (p2 - buffer)); | |||
2464 | ||||
2465 | /* Get new spec name. */ | |||
2466 | p3 = p2; | |||
2467 | while (*p3 && !ISSPACE ((unsigned char) *p3)(_sch_istable[((unsigned char) *p3) & 0xff] & (unsigned short)(_sch_isspace))) | |||
2468 | p3++; | |||
2469 | ||||
2470 | if (p3 != p - 1) | |||
2471 | fatal_error (input_location, | |||
2472 | "specs %%rename syntax malformed after " | |||
2473 | "%ld characters", | |||
2474 | (long) (p3 - buffer)); | |||
2475 | *p3 = '\0'; | |||
2476 | ||||
2477 | for (sl = specs; sl; sl = sl->next) | |||
2478 | if (name_len == sl->name_len && !strcmp (sl->name, p1)) | |||
2479 | break; | |||
2480 | ||||
2481 | if (!sl) | |||
2482 | fatal_error (input_location, | |||
2483 | "specs %s spec was not found to be renamed", p1); | |||
2484 | ||||
2485 | if (strcmp (p1, p2) == 0) | |||
2486 | continue; | |||
2487 | ||||
2488 | for (newsl = specs; newsl; newsl = newsl->next) | |||
2489 | if (strcmp (newsl->name, p2) == 0) | |||
2490 | fatal_error (input_location, | |||
2491 | "%s: attempt to rename spec %qs to " | |||
2492 | "already defined spec %qs", | |||
2493 | filename, p1, p2); | |||
2494 | ||||
2495 | if (verbose_flagglobal_options.x_verbose_flag) | |||
2496 | { | |||
2497 | fnotice (stderrstderr, "rename spec %s to %s\n", p1, p2); | |||
2498 | #ifdef DEBUG_SPECS | |||
2499 | fnotice (stderrstderr, "spec is '%s'\n\n", *(sl->ptr_spec)); | |||
2500 | #endif | |||
2501 | } | |||
2502 | ||||
2503 | set_spec (p2, *(sl->ptr_spec), user_p); | |||
2504 | if (sl->alloc_p) | |||
2505 | free (CONST_CAST (char *, *(sl->ptr_spec))(const_cast<char *> ((*(sl->ptr_spec))))); | |||
2506 | ||||
2507 | *(sl->ptr_spec) = ""; | |||
2508 | sl->alloc_p = 0; | |||
2509 | continue; | |||
2510 | } | |||
2511 | else | |||
2512 | fatal_error (input_location, | |||
2513 | "specs unknown %% command after %ld characters", | |||
2514 | (long) (p1 - buffer)); | |||
2515 | } | |||
2516 | ||||
2517 | /* Find the colon that should end the suffix. */ | |||
2518 | p1 = p; | |||
2519 | while (*p1 && *p1 != ':' && *p1 != '\n') | |||
2520 | p1++; | |||
2521 | ||||
2522 | /* The colon shouldn't be missing. */ | |||
2523 | if (*p1 != ':') | |||
2524 | fatal_error (input_location, | |||
2525 | "specs file malformed after %ld characters", | |||
2526 | (long) (p1 - buffer)); | |||
2527 | ||||
2528 | /* Skip back over trailing whitespace. */ | |||
2529 | p2 = p1; | |||
2530 | while (p2 > buffer && (p2[-1] == ' ' || p2[-1] == '\t')) | |||
2531 | p2--; | |||
2532 | ||||
2533 | /* Copy the suffix to a string. */ | |||
2534 | suffix = save_string (p, p2 - p); | |||
2535 | /* Find the next line. */ | |||
2536 | p = skip_whitespace (p1 + 1); | |||
2537 | if (p[1] == 0) | |||
2538 | fatal_error (input_location, | |||
2539 | "specs file malformed after %ld characters", | |||
2540 | (long) (p - buffer)); | |||
2541 | ||||
2542 | p1 = p; | |||
2543 | /* Find next blank line or end of string. */ | |||
2544 | while (*p1 && !(*p1 == '\n' && (p1[1] == '\n' || p1[1] == '\0'))) | |||
2545 | p1++; | |||
2546 | ||||
2547 | /* Specs end at the blank line and do not include the newline. */ | |||
2548 | spec = save_string (p, p1 - p); | |||
2549 | p = p1; | |||
2550 | ||||
2551 | /* Delete backslash-newline sequences from the spec. */ | |||
2552 | in = spec; | |||
2553 | out = spec; | |||
2554 | while (*in != 0) | |||
2555 | { | |||
2556 | if (in[0] == '\\' && in[1] == '\n') | |||
2557 | in += 2; | |||
2558 | else if (in[0] == '#') | |||
2559 | while (*in && *in != '\n') | |||
2560 | in++; | |||
2561 | ||||
2562 | else | |||
2563 | *out++ = *in++; | |||
2564 | } | |||
2565 | *out = 0; | |||
2566 | ||||
2567 | if (suffix[0] == '*') | |||
2568 | { | |||
2569 | if (! strcmp (suffix, "*link_command")) | |||
2570 | link_command_spec = spec; | |||
2571 | else | |||
2572 | { | |||
2573 | set_spec (suffix + 1, spec, user_p); | |||
2574 | free (spec); | |||
2575 | } | |||
2576 | } | |||
2577 | else | |||
2578 | { | |||
2579 | /* Add this pair to the vector. */ | |||
2580 | compilers | |||
2581 | = XRESIZEVEC (struct compiler, compilers, n_compilers + 2)((struct compiler *) xrealloc ((void *) (compilers), sizeof ( struct compiler) * (n_compilers + 2))); | |||
2582 | ||||
2583 | compilers[n_compilers].suffix = suffix; | |||
2584 | compilers[n_compilers].spec = spec; | |||
2585 | n_compilers++; | |||
2586 | memset (&compilers[n_compilers], 0, sizeof compilers[n_compilers]); | |||
2587 | } | |||
2588 | ||||
2589 | if (*suffix == 0) | |||
2590 | link_command_spec = spec; | |||
2591 | } | |||
2592 | ||||
2593 | if (link_command_spec == 0) | |||
2594 | fatal_error (input_location, "spec file has no spec for linking"); | |||
2595 | ||||
2596 | XDELETEVEC (buffer)free ((void*) (buffer)); | |||
2597 | } | |||
2598 | ||||
2599 | /* Record the names of temporary files we tell compilers to write, | |||
2600 | and delete them at the end of the run. */ | |||
2601 | ||||
2602 | /* This is the common prefix we use to make temp file names. | |||
2603 | It is chosen once for each run of this program. | |||
2604 | It is substituted into a spec by %g or %j. | |||
2605 | Thus, all temp file names contain this prefix. | |||
2606 | In practice, all temp file names start with this prefix. | |||
2607 | ||||
2608 | This prefix comes from the envvar TMPDIR if it is defined; | |||
2609 | otherwise, from the P_tmpdir macro if that is defined; | |||
2610 | otherwise, in /usr/tmp or /tmp; | |||
2611 | or finally the current directory if all else fails. */ | |||
2612 | ||||
2613 | static const char *temp_filename; | |||
2614 | ||||
2615 | /* Length of the prefix. */ | |||
2616 | ||||
2617 | static int temp_filename_length; | |||
2618 | ||||
2619 | /* Define the list of temporary files to delete. */ | |||
2620 | ||||
2621 | struct temp_file | |||
2622 | { | |||
2623 | const char *name; | |||
2624 | struct temp_file *next; | |||
2625 | }; | |||
2626 | ||||
2627 | /* Queue of files to delete on success or failure of compilation. */ | |||
2628 | static struct temp_file *always_delete_queue; | |||
2629 | /* Queue of files to delete on failure of compilation. */ | |||
2630 | static struct temp_file *failure_delete_queue; | |||
2631 | ||||
2632 | /* Record FILENAME as a file to be deleted automatically. | |||
2633 | ALWAYS_DELETE nonzero means delete it if all compilation succeeds; | |||
2634 | otherwise delete it in any case. | |||
2635 | FAIL_DELETE nonzero means delete it if a compilation step fails; | |||
2636 | otherwise delete it in any case. */ | |||
2637 | ||||
2638 | void | |||
2639 | record_temp_file (const char *filename, int always_delete, int fail_delete) | |||
2640 | { | |||
2641 | char *const name = xstrdup (filename); | |||
2642 | ||||
2643 | if (always_delete) | |||
2644 | { | |||
2645 | struct temp_file *temp; | |||
2646 | for (temp = always_delete_queue; temp; temp = temp->next) | |||
2647 | if (! filename_cmp (name, temp->name)) | |||
2648 | { | |||
2649 | free (name); | |||
2650 | goto already1; | |||
2651 | } | |||
2652 | ||||
2653 | temp = XNEW (struct temp_file)((struct temp_file *) xmalloc (sizeof (struct temp_file))); | |||
2654 | temp->next = always_delete_queue; | |||
2655 | temp->name = name; | |||
2656 | always_delete_queue = temp; | |||
2657 | ||||
2658 | already1:; | |||
2659 | } | |||
2660 | ||||
2661 | if (fail_delete) | |||
2662 | { | |||
2663 | struct temp_file *temp; | |||
2664 | for (temp = failure_delete_queue; temp; temp = temp->next) | |||
2665 | if (! filename_cmp (name, temp->name)) | |||
2666 | { | |||
2667 | free (name); | |||
2668 | goto already2; | |||
2669 | } | |||
2670 | ||||
2671 | temp = XNEW (struct temp_file)((struct temp_file *) xmalloc (sizeof (struct temp_file))); | |||
2672 | temp->next = failure_delete_queue; | |||
2673 | temp->name = name; | |||
2674 | failure_delete_queue = temp; | |||
2675 | ||||
2676 | already2:; | |||
2677 | } | |||
2678 | } | |||
2679 | ||||
2680 | /* Delete all the temporary files whose names we previously recorded. */ | |||
2681 | ||||
2682 | #ifndef DELETE_IF_ORDINARY | |||
2683 | #define DELETE_IF_ORDINARY(NAME,ST,VERBOSE_FLAG)do { if (stat (NAME, &ST) >= 0 && ((((ST.st_mode )) & 0170000) == (0100000))) if (unlink (NAME) < 0) if (VERBOSE_FLAG) error ("%s: %m", (NAME)); } while (0) \ | |||
2684 | do \ | |||
2685 | { \ | |||
2686 | if (stat (NAME, &ST) >= 0 && S_ISREG (ST.st_mode)((((ST.st_mode)) & 0170000) == (0100000))) \ | |||
2687 | if (unlink (NAME) < 0) \ | |||
2688 | if (VERBOSE_FLAG) \ | |||
2689 | error ("%s: %m", (NAME)); \ | |||
2690 | } while (0) | |||
2691 | #endif | |||
2692 | ||||
2693 | static void | |||
2694 | delete_if_ordinary (const char *name) | |||
2695 | { | |||
2696 | struct stat st; | |||
2697 | #ifdef DEBUG | |||
2698 | int i, c; | |||
2699 | ||||
2700 | printf ("Delete %s? (y or n) ", name); | |||
2701 | fflush (stdoutstdout); | |||
2702 | i = getchar (); | |||
2703 | if (i != '\n') | |||
2704 | while ((c = getchar ()) != '\n' && c != EOF(-1)) | |||
2705 | ; | |||
2706 | ||||
2707 | if (i == 'y' || i == 'Y') | |||
2708 | #endif /* DEBUG */ | |||
2709 | DELETE_IF_ORDINARY (name, st, verbose_flag)do { if (stat (name, &st) >= 0 && ((((st.st_mode )) & 0170000) == (0100000))) if (unlink (name) < 0) if (global_options.x_verbose_flag) error ("%s: %m", (name)); } while (0); | |||
2710 | } | |||
2711 | ||||
2712 | static void | |||
2713 | delete_temp_files (void) | |||
2714 | { | |||
2715 | struct temp_file *temp; | |||
2716 | ||||
2717 | for (temp = always_delete_queue; temp; temp = temp->next) | |||
2718 | delete_if_ordinary (temp->name); | |||
2719 | always_delete_queue = 0; | |||
2720 | } | |||
2721 | ||||
2722 | /* Delete all the files to be deleted on error. */ | |||
2723 | ||||
2724 | static void | |||
2725 | delete_failure_queue (void) | |||
2726 | { | |||
2727 | struct temp_file *temp; | |||
2728 | ||||
2729 | for (temp = failure_delete_queue; temp; temp = temp->next) | |||
2730 | delete_if_ordinary (temp->name); | |||
2731 | } | |||
2732 | ||||
2733 | static void | |||
2734 | clear_failure_queue (void) | |||
2735 | { | |||
2736 | failure_delete_queue = 0; | |||
2737 | } | |||
2738 | ||||
2739 | /* Call CALLBACK for each path in PATHS, breaking out early if CALLBACK | |||
2740 | returns non-NULL. | |||
2741 | If DO_MULTI is true iterate over the paths twice, first with multilib | |||
2742 | suffix then without, otherwise iterate over the paths once without | |||
2743 | adding a multilib suffix. When DO_MULTI is true, some attempt is made | |||
2744 | to avoid visiting the same path twice, but we could do better. For | |||
2745 | instance, /usr/lib/../lib is considered different from /usr/lib. | |||
2746 | At least EXTRA_SPACE chars past the end of the path passed to | |||
2747 | CALLBACK are available for use by the callback. | |||
2748 | CALLBACK_INFO allows extra parameters to be passed to CALLBACK. | |||
2749 | ||||
2750 | Returns the value returned by CALLBACK. */ | |||
2751 | ||||
2752 | static void * | |||
2753 | for_each_path (const struct path_prefix *paths, | |||
2754 | bool do_multi, | |||
2755 | size_t extra_space, | |||
2756 | void *(*callback) (char *, void *), | |||
2757 | void *callback_info) | |||
2758 | { | |||
2759 | struct prefix_list *pl; | |||
2760 | const char *multi_dir = NULLnullptr; | |||
2761 | const char *multi_os_dir = NULLnullptr; | |||
2762 | const char *multiarch_suffix = NULLnullptr; | |||
2763 | const char *multi_suffix; | |||
2764 | const char *just_multi_suffix; | |||
2765 | char *path = NULLnullptr; | |||
2766 | void *ret = NULLnullptr; | |||
2767 | bool skip_multi_dir = false; | |||
2768 | bool skip_multi_os_dir = false; | |||
2769 | ||||
2770 | multi_suffix = machine_suffix; | |||
2771 | just_multi_suffix = just_machine_suffix; | |||
2772 | if (do_multi
| |||
2773 | { | |||
2774 | multi_dir = concat (multilib_dir, dir_separator_str, NULLnullptr); | |||
2775 | multi_suffix = concat (multi_suffix, multi_dir, NULLnullptr); | |||
2776 | just_multi_suffix = concat (just_multi_suffix, multi_dir, NULLnullptr); | |||
2777 | } | |||
2778 | if (do_multi
| |||
2779 | multi_os_dir = concat (multilib_os_dir, dir_separator_str, NULLnullptr); | |||
2780 | if (multiarch_dir) | |||
2781 | multiarch_suffix = concat (multiarch_dir, dir_separator_str, NULLnullptr); | |||
2782 | ||||
2783 | while (1) | |||
2784 | { | |||
2785 | size_t multi_dir_len = 0; | |||
2786 | size_t multi_os_dir_len = 0; | |||
2787 | size_t multiarch_len = 0; | |||
2788 | size_t suffix_len; | |||
2789 | size_t just_suffix_len; | |||
2790 | size_t len; | |||
2791 | ||||
2792 | if (multi_dir
| |||
2793 | multi_dir_len = strlen (multi_dir); | |||
2794 | if (multi_os_dir
| |||
2795 | multi_os_dir_len = strlen (multi_os_dir); | |||
2796 | if (multiarch_suffix
| |||
2797 | multiarch_len = strlen (multiarch_suffix); | |||
2798 | suffix_len = strlen (multi_suffix); | |||
2799 | just_suffix_len = strlen (just_multi_suffix); | |||
2800 | ||||
2801 | if (path == NULLnullptr) | |||
2802 | { | |||
2803 | len = paths->max_len + extra_space + 1; | |||
2804 | len += MAX (MAX (suffix_len, multi_os_dir_len), multiarch_len)((((suffix_len) > (multi_os_dir_len) ? (suffix_len) : (multi_os_dir_len ))) > (multiarch_len) ? (((suffix_len) > (multi_os_dir_len ) ? (suffix_len) : (multi_os_dir_len))) : (multiarch_len)); | |||
2805 | path = XNEWVEC (char, len)((char *) xmalloc (sizeof (char) * (len))); | |||
2806 | } | |||
2807 | ||||
2808 | for (pl = paths->plist; pl != 0; pl = pl->next) | |||
2809 | { | |||
2810 | len = strlen (pl->prefix); | |||
2811 | memcpy (path, pl->prefix, len); | |||
2812 | ||||
2813 | /* Look first in MACHINE/VERSION subdirectory. */ | |||
2814 | if (!skip_multi_dir
| |||
2815 | { | |||
2816 | memcpy (path + len, multi_suffix, suffix_len + 1); | |||
2817 | ret = callback (path, callback_info); | |||
2818 | if (ret
| |||
2819 | break; | |||
2820 | } | |||
2821 | ||||
2822 | /* Some paths are tried with just the machine (ie. target) | |||
2823 | subdir. This is used for finding as, ld, etc. */ | |||
2824 | if (!skip_multi_dir |
30.2 | 'skip_multi_dir' is false |
31.1 | 'skip_multi_dir' is false |
35 | Null pointer passed to 2nd parameter expecting 'nonnull' |