File: | build/gcc/gcc.cc |
Warning: | line 2665, column 8 Use of memory after it is freed |
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 && multilib_dir && strcmp (multilib_dir, ".") != 0) | |||
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 && multilib_os_dir && strcmp (multilib_os_dir, ".") != 0) | |||
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 | |||
2825 | && pl->require_machine_suffix == 2) | |||
2826 | { | |||
2827 | memcpy (path + len, just_multi_suffix, just_suffix_len + 1); | |||
2828 | ret = callback (path, callback_info); | |||
2829 | if (ret) | |||
2830 | break; | |||
2831 | } | |||
2832 | ||||
2833 | /* Now try the multiarch path. */ | |||
2834 | if (!skip_multi_dir | |||
2835 | && !pl->require_machine_suffix && multiarch_dir) | |||
2836 | { | |||
2837 | memcpy (path + len, multiarch_suffix, multiarch_len + 1); | |||
2838 | ret = callback (path, callback_info); | |||
2839 | if (ret) | |||
2840 | break; | |||
2841 | } | |||
2842 | ||||
2843 | /* Now try the base path. */ | |||
2844 | if (!pl->require_machine_suffix | |||
2845 | && !(pl->os_multilib ? skip_multi_os_dir : skip_multi_dir)) | |||
2846 | { | |||
2847 | const char *this_multi; | |||
2848 | size_t this_multi_len; | |||
2849 | ||||
2850 | if (pl->os_multilib) | |||
2851 | { | |||
2852 | this_multi = multi_os_dir; | |||
2853 | this_multi_len = multi_os_dir_len; | |||
2854 | } | |||
2855 | else | |||
2856 | { | |||
2857 | this_multi = multi_dir; | |||
2858 | this_multi_len = multi_dir_len; | |||
2859 | } | |||
2860 | ||||
2861 | if (this_multi_len) | |||
2862 | memcpy (path + len, this_multi, this_multi_len + 1); | |||
2863 | else | |||
2864 | path[len] = '\0'; | |||
2865 | ||||
2866 | ret = callback (path, callback_info); | |||
2867 | if (ret) | |||
2868 | break; | |||
2869 | } | |||
2870 | } | |||
2871 | if (pl) | |||
2872 | break; | |||
2873 | ||||
2874 | if (multi_dir == NULLnullptr && multi_os_dir == NULLnullptr) | |||
2875 | break; | |||
2876 | ||||
2877 | /* Run through the paths again, this time without multilibs. | |||
2878 | Don't repeat any we have already seen. */ | |||
2879 | if (multi_dir) | |||
2880 | { | |||
2881 | free (CONST_CAST (char *, multi_dir)(const_cast<char *> ((multi_dir)))); | |||
2882 | multi_dir = NULLnullptr; | |||
2883 | free (CONST_CAST (char *, multi_suffix)(const_cast<char *> ((multi_suffix)))); | |||
2884 | multi_suffix = machine_suffix; | |||
2885 | free (CONST_CAST (char *, just_multi_suffix)(const_cast<char *> ((just_multi_suffix)))); | |||
2886 | just_multi_suffix = just_machine_suffix; | |||
2887 | } | |||
2888 | else | |||
2889 | skip_multi_dir = true; | |||
2890 | if (multi_os_dir) | |||
2891 | { | |||
2892 | free (CONST_CAST (char *, multi_os_dir)(const_cast<char *> ((multi_os_dir)))); | |||
2893 | multi_os_dir = NULLnullptr; | |||
2894 | } | |||
2895 | else | |||
2896 | skip_multi_os_dir = true; | |||
2897 | } | |||
2898 | ||||
2899 | if (multi_dir) | |||
2900 | { | |||
2901 | free (CONST_CAST (char *, multi_dir)(const_cast<char *> ((multi_dir)))); | |||
2902 | free (CONST_CAST (char *, multi_suffix)(const_cast<char *> ((multi_suffix)))); | |||
2903 | free (CONST_CAST (char *, just_multi_suffix)(const_cast<char *> ((just_multi_suffix)))); | |||
2904 | } | |||
2905 | if (multi_os_dir) | |||
2906 | free (CONST_CAST (char *, multi_os_dir)(const_cast<char *> ((multi_os_dir)))); | |||
2907 | if (ret != path) | |||
2908 | free (path); | |||
2909 | return ret; | |||
2910 | } | |||
2911 | ||||
2912 | /* Callback for build_search_list. Adds path to obstack being built. */ | |||
2913 | ||||
2914 | struct add_to_obstack_info { | |||
2915 | struct obstack *ob; | |||
2916 | bool check_dir; | |||
2917 | bool first_time; | |||
2918 | }; | |||
2919 | ||||
2920 | static void * | |||
2921 | add_to_obstack (char *path, void *data) | |||
2922 | { | |||
2923 | struct add_to_obstack_info *info = (struct add_to_obstack_info *) data; | |||
2924 | ||||
2925 | if (info->check_dir && !is_directory (path, false)) | |||
2926 | return NULLnullptr; | |||
2927 | ||||
2928 | if (!info->first_time) | |||
2929 | obstack_1grow (info->ob, PATH_SEPARATOR)__extension__ ({ struct obstack *__o = (info->ob); if (__extension__ ({ struct obstack const *__o1 = (__o); (size_t) (__o1->chunk_limit - __o1->next_free); }) < 1) _obstack_newchunk (__o, 1) ; ((void) (*((__o)->next_free)++ = (':'))); }); | |||
2930 | ||||
2931 | obstack_grow (info->ob, path, strlen (path))__extension__ ({ struct obstack *__o = (info->ob); size_t __len = (strlen (path)); if (__extension__ ({ struct obstack const *__o1 = (__o); (size_t) (__o1->chunk_limit - __o1->next_free ); }) < __len) _obstack_newchunk (__o, __len); memcpy (__o ->next_free, path, __len); __o->next_free += __len; (void ) 0; }); | |||
2932 | ||||
2933 | info->first_time = false; | |||
2934 | return NULLnullptr; | |||
2935 | } | |||
2936 | ||||
2937 | /* Add or change the value of an environment variable, outputting the | |||
2938 | change to standard error if in verbose mode. */ | |||
2939 | static void | |||
2940 | xputenv (const char *string) | |||
2941 | { | |||
2942 | env.xput (string); | |||
2943 | } | |||
2944 | ||||
2945 | /* Build a list of search directories from PATHS. | |||
2946 | PREFIX is a string to prepend to the list. | |||
2947 | If CHECK_DIR_P is true we ensure the directory exists. | |||
2948 | If DO_MULTI is true, multilib paths are output first, then | |||
2949 | non-multilib paths. | |||
2950 | This is used mostly by putenv_from_prefixes so we use `collect_obstack'. | |||
2951 | It is also used by the --print-search-dirs flag. */ | |||
2952 | ||||
2953 | static char * | |||
2954 | build_search_list (const struct path_prefix *paths, const char *prefix, | |||
2955 | bool check_dir, bool do_multi) | |||
2956 | { | |||
2957 | struct add_to_obstack_info info; | |||
2958 | ||||
2959 | info.ob = &collect_obstack; | |||
2960 | info.check_dir = check_dir; | |||
2961 | info.first_time = true; | |||
2962 | ||||
2963 | obstack_grow (&collect_obstack, prefix, strlen (prefix))__extension__ ({ struct obstack *__o = (&collect_obstack) ; size_t __len = (strlen (prefix)); if (__extension__ ({ struct obstack const *__o1 = (__o); (size_t) (__o1->chunk_limit - __o1->next_free); }) < __len) _obstack_newchunk (__o, __len ); memcpy (__o->next_free, prefix, __len); __o->next_free += __len; (void) 0; }); | |||
2964 | obstack_1grow (&collect_obstack, '=')__extension__ ({ struct obstack *__o = (&collect_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)++ = ('='))); }); | |||
2965 | ||||
2966 | for_each_path (paths, do_multi, 0, add_to_obstack, &info); | |||
2967 | ||||
2968 | obstack_1grow (&collect_obstack, '\0')__extension__ ({ struct obstack *__o = (&collect_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'))); }); | |||
2969 | return XOBFINISH (&collect_obstack, char *)((char *) __extension__ ({ struct obstack *__o1 = ((&collect_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; })); | |||
2970 | } | |||
2971 | ||||
2972 | /* Rebuild the COMPILER_PATH and LIBRARY_PATH environment variables | |||
2973 | for collect. */ | |||
2974 | ||||
2975 | static void | |||
2976 | putenv_from_prefixes (const struct path_prefix *paths, const char *env_var, | |||
2977 | bool do_multi) | |||
2978 | { | |||
2979 | xputenv (build_search_list (paths, env_var, true, do_multi)); | |||
2980 | } | |||
2981 | ||||
2982 | /* Check whether NAME can be accessed in MODE. This is like access, | |||
2983 | except that it never considers directories to be executable. */ | |||
2984 | ||||
2985 | static int | |||
2986 | access_check (const char *name, int mode) | |||
2987 | { | |||
2988 | if (mode == X_OK1) | |||
2989 | { | |||
2990 | struct stat st; | |||
2991 | ||||
2992 | if (stat (name, &st) < 0 | |||
2993 | || S_ISDIR (st.st_mode)((((st.st_mode)) & 0170000) == (0040000))) | |||
2994 | return -1; | |||
2995 | } | |||
2996 | ||||
2997 | return access (name, mode); | |||
2998 | } | |||
2999 | ||||
3000 | /* Callback for find_a_file. Appends the file name to the directory | |||
3001 | path. If the resulting file exists in the right mode, return the | |||
3002 | full pathname to the file. */ | |||
3003 | ||||
3004 | struct file_at_path_info { | |||
3005 | const char *name; | |||
3006 | const char *suffix; | |||
3007 | int name_len; | |||
3008 | int suffix_len; | |||
3009 | int mode; | |||
3010 | }; | |||
3011 | ||||
3012 | static void * | |||
3013 | file_at_path (char *path, void *data) | |||
3014 | { | |||
3015 | struct file_at_path_info *info = (struct file_at_path_info *) data; | |||
3016 | size_t len = strlen (path); | |||
3017 | ||||
3018 | memcpy (path + len, info->name, info->name_len); | |||
3019 | len += info->name_len; | |||
3020 | ||||
3021 | /* Some systems have a suffix for executable files. | |||
3022 | So try appending that first. */ | |||
3023 | if (info->suffix_len) | |||
3024 | { | |||
3025 | memcpy (path + len, info->suffix, info->suffix_len + 1); | |||
3026 | if (access_check (path, info->mode) == 0) | |||
3027 | return path; | |||
3028 | } | |||
3029 | ||||
3030 | path[len] = '\0'; | |||
3031 | if (access_check (path, info->mode) == 0) | |||
3032 | return path; | |||
3033 | ||||
3034 | return NULLnullptr; | |||
3035 | } | |||
3036 | ||||
3037 | /* Search for NAME using the prefix list PREFIXES. MODE is passed to | |||
3038 | access to check permissions. If DO_MULTI is true, search multilib | |||
3039 | paths then non-multilib paths, otherwise do not search multilib paths. | |||
3040 | Return 0 if not found, otherwise return its name, allocated with malloc. */ | |||
3041 | ||||
3042 | static char * | |||
3043 | find_a_file (const struct path_prefix *pprefix, const char *name, int mode, | |||
3044 | bool do_multi) | |||
3045 | { | |||
3046 | struct file_at_path_info info; | |||
3047 | ||||
3048 | /* Find the filename in question (special case for absolute paths). */ | |||
3049 | ||||
3050 | if (IS_ABSOLUTE_PATH (name)(((((name)[0]) == '/') || ((((name)[0]) == '\\') && ( 0))) || ((name)[0] && ((name)[1] == ':') && ( 0)))) | |||
3051 | { | |||
3052 | if (access (name, mode) == 0) | |||
3053 | return xstrdup (name); | |||
3054 | ||||
3055 | return NULLnullptr; | |||
3056 | } | |||
3057 | ||||
3058 | info.name = name; | |||
3059 | info.suffix = (mode & X_OK1) != 0 ? HOST_EXECUTABLE_SUFFIX"" : ""; | |||
3060 | info.name_len = strlen (info.name); | |||
3061 | info.suffix_len = strlen (info.suffix); | |||
3062 | info.mode = mode; | |||
3063 | ||||
3064 | return (char*) for_each_path (pprefix, do_multi, | |||
3065 | info.name_len + info.suffix_len, | |||
3066 | file_at_path, &info); | |||
3067 | } | |||
3068 | ||||
3069 | /* Specialization of find_a_file for programs that also takes into account | |||
3070 | configure-specified default programs. */ | |||
3071 | ||||
3072 | static char* | |||
3073 | find_a_program (const char *name) | |||
3074 | { | |||
3075 | /* Do not search if default matches query. */ | |||
3076 | ||||
3077 | #ifdef DEFAULT_ASSEMBLER | |||
3078 | if (! strcmp (name, "as") && access (DEFAULT_ASSEMBLER, X_OK1) == 0) | |||
3079 | return xstrdup (DEFAULT_ASSEMBLER); | |||
3080 | #endif | |||
3081 | ||||
3082 | #ifdef DEFAULT_LINKER | |||
3083 | if (! strcmp (name, "ld") && access (DEFAULT_LINKER, X_OK1) == 0) | |||
3084 | return xstrdup (DEFAULT_LINKER); | |||
3085 | #endif | |||
3086 | ||||
3087 | #ifdef DEFAULT_DSYMUTIL | |||
3088 | if (! strcmp (name, "dsymutil") && access (DEFAULT_DSYMUTIL, X_OK1) == 0) | |||
3089 | return xstrdup (DEFAULT_DSYMUTIL); | |||
3090 | #endif | |||
3091 | ||||
3092 | return find_a_file (&exec_prefixes, name, X_OK1, false); | |||
3093 | } | |||
3094 | ||||
3095 | /* Ranking of prefixes in the sort list. -B prefixes are put before | |||
3096 | all others. */ | |||
3097 | ||||
3098 | enum path_prefix_priority | |||
3099 | { | |||
3100 | PREFIX_PRIORITY_B_OPT, | |||
3101 | PREFIX_PRIORITY_LAST | |||
3102 | }; | |||
3103 | ||||
3104 | /* Add an entry for PREFIX in PLIST. The PLIST is kept in ascending | |||
3105 | order according to PRIORITY. Within each PRIORITY, new entries are | |||
3106 | appended. | |||
3107 | ||||
3108 | If WARN is nonzero, we will warn if no file is found | |||
3109 | through this prefix. WARN should point to an int | |||
3110 | which will be set to 1 if this entry is used. | |||
3111 | ||||
3112 | COMPONENT is the value to be passed to update_path. | |||
3113 | ||||
3114 | REQUIRE_MACHINE_SUFFIX is 1 if this prefix can't be used without | |||
3115 | the complete value of machine_suffix. | |||
3116 | 2 means try both machine_suffix and just_machine_suffix. */ | |||
3117 | ||||
3118 | static void | |||
3119 | add_prefix (struct path_prefix *pprefix, const char *prefix, | |||
3120 | const char *component, /* enum prefix_priority */ int priority, | |||
3121 | int require_machine_suffix, int os_multilib) | |||
3122 | { | |||
3123 | struct prefix_list *pl, **prev; | |||
3124 | int len; | |||
3125 | ||||
3126 | for (prev = &pprefix->plist; | |||
3127 | (*prev) != NULLnullptr && (*prev)->priority <= priority; | |||
3128 | prev = &(*prev)->next) | |||
3129 | ; | |||
3130 | ||||
3131 | /* Keep track of the longest prefix. */ | |||
3132 | ||||
3133 | prefix = update_path (prefix, component); | |||
3134 | len = strlen (prefix); | |||
3135 | if (len > pprefix->max_len) | |||
3136 | pprefix->max_len = len; | |||
3137 | ||||
3138 | pl = XNEW (struct prefix_list)((struct prefix_list *) xmalloc (sizeof (struct prefix_list)) ); | |||
3139 | pl->prefix = prefix; | |||
3140 | pl->require_machine_suffix = require_machine_suffix; | |||
3141 | pl->priority = priority; | |||
3142 | pl->os_multilib = os_multilib; | |||
3143 | ||||
3144 | /* Insert after PREV. */ | |||
3145 | pl->next = (*prev); | |||
3146 | (*prev) = pl; | |||
3147 | } | |||
3148 | ||||
3149 | /* Same as add_prefix, but prepending target_system_root to prefix. */ | |||
3150 | /* The target_system_root prefix has been relocated by gcc_exec_prefix. */ | |||
3151 | static void | |||
3152 | add_sysrooted_prefix (struct path_prefix *pprefix, const char *prefix, | |||
3153 | const char *component, | |||
3154 | /* enum prefix_priority */ int priority, | |||
3155 | int require_machine_suffix, int os_multilib) | |||
3156 | { | |||
3157 | if (!IS_ABSOLUTE_PATH (prefix)(((((prefix)[0]) == '/') || ((((prefix)[0]) == '\\') && (0))) || ((prefix)[0] && ((prefix)[1] == ':') && (0)))) | |||
3158 | fatal_error (input_location, "system path %qs is not absolute", prefix); | |||
3159 | ||||
3160 | if (target_system_root) | |||
3161 | { | |||
3162 | char *sysroot_no_trailing_dir_separator = xstrdup (target_system_root); | |||
3163 | size_t sysroot_len = strlen (target_system_root); | |||
3164 | ||||
3165 | if (sysroot_len > 0 | |||
3166 | && target_system_root[sysroot_len - 1] == DIR_SEPARATOR'/') | |||
3167 | sysroot_no_trailing_dir_separator[sysroot_len - 1] = '\0'; | |||
3168 | ||||
3169 | if (target_sysroot_suffix) | |||
3170 | prefix = concat (sysroot_no_trailing_dir_separator, | |||
3171 | target_sysroot_suffix, prefix, NULLnullptr); | |||
3172 | else | |||
3173 | prefix = concat (sysroot_no_trailing_dir_separator, prefix, NULLnullptr); | |||
3174 | ||||
3175 | free (sysroot_no_trailing_dir_separator); | |||
3176 | ||||
3177 | /* We have to override this because GCC's notion of sysroot | |||
3178 | moves along with GCC. */ | |||
3179 | component = "GCC"; | |||
3180 | } | |||
3181 | ||||
3182 | add_prefix (pprefix, prefix, component, priority, | |||
3183 | require_machine_suffix, os_multilib); | |||
3184 | } | |||
3185 | ||||
3186 | /* Same as add_prefix, but prepending target_sysroot_hdrs_suffix to prefix. */ | |||
3187 | ||||
3188 | static void | |||
3189 | add_sysrooted_hdrs_prefix (struct path_prefix *pprefix, const char *prefix, | |||
3190 | const char *component, | |||
3191 | /* enum prefix_priority */ int priority, | |||
3192 | int require_machine_suffix, int os_multilib) | |||
3193 | { | |||
3194 | if (!IS_ABSOLUTE_PATH (prefix)(((((prefix)[0]) == '/') || ((((prefix)[0]) == '\\') && (0))) || ((prefix)[0] && ((prefix)[1] == ':') && (0)))) | |||
3195 | fatal_error (input_location, "system path %qs is not absolute", prefix); | |||
3196 | ||||
3197 | if (target_system_root) | |||
3198 | { | |||
3199 | char *sysroot_no_trailing_dir_separator = xstrdup (target_system_root); | |||
3200 | size_t sysroot_len = strlen (target_system_root); | |||
3201 | ||||
3202 | if (sysroot_len > 0 | |||
3203 | && target_system_root[sysroot_len - 1] == DIR_SEPARATOR'/') | |||
3204 | sysroot_no_trailing_dir_separator[sysroot_len - 1] = '\0'; | |||
3205 | ||||
3206 | if (target_sysroot_hdrs_suffix) | |||
3207 | prefix = concat (sysroot_no_trailing_dir_separator, | |||
3208 | target_sysroot_hdrs_suffix, prefix, NULLnullptr); | |||
3209 | else | |||
3210 | prefix = concat (sysroot_no_trailing_dir_separator, prefix, NULLnullptr); | |||
3211 | ||||
3212 | free (sysroot_no_trailing_dir_separator); | |||
3213 | ||||
3214 | /* We have to override this because GCC's notion of sysroot | |||
3215 | moves along with GCC. */ | |||
3216 | component = "GCC"; | |||
3217 | } | |||
3218 | ||||
3219 | add_prefix (pprefix, prefix, component, priority, | |||
3220 | require_machine_suffix, os_multilib); | |||
3221 | } | |||
3222 | ||||
3223 | ||||
3224 | /* Execute the command specified by the arguments on the current line of spec. | |||
3225 | When using pipes, this includes several piped-together commands | |||
3226 | with `|' between them. | |||
3227 | ||||
3228 | Return 0 if successful, -1 if failed. */ | |||
3229 | ||||
3230 | static int | |||
3231 | execute (void) | |||
3232 | { | |||
3233 | int i; | |||
3234 | int n_commands; /* # of command. */ | |||
3235 | char *string; | |||
3236 | struct pex_obj *pex; | |||
3237 | struct command | |||
3238 | { | |||
3239 | const char *prog; /* program name. */ | |||
3240 | const char **argv; /* vector of args. */ | |||
3241 | }; | |||
3242 | const char *arg; | |||
3243 | ||||
3244 | struct command *commands; /* each command buffer with above info. */ | |||
3245 | ||||
3246 | gcc_assert (!processing_spec_function)((void)(!(!processing_spec_function) ? fancy_abort ("/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/gcc.cc" , 3246, __FUNCTION__), 0 : 0)); | |||
3247 | ||||
3248 | if (wrapper_stringglobal_options.x_wrapper_string) | |||
3249 | { | |||
3250 | string = find_a_program (argbuf[0]); | |||
3251 | if (string) | |||
3252 | argbuf[0] = string; | |||
3253 | insert_wrapper (wrapper_stringglobal_options.x_wrapper_string); | |||
3254 | } | |||
3255 | ||||
3256 | /* Count # of piped commands. */ | |||
3257 | for (n_commands = 1, i = 0; argbuf.iterate (i, &arg); i++) | |||
3258 | if (strcmp (arg, "|") == 0) | |||
3259 | n_commands++; | |||
3260 | ||||
3261 | /* Get storage for each command. */ | |||
3262 | commands = XALLOCAVEC (struct command, n_commands)((struct command *) __builtin_alloca(sizeof (struct command) * (n_commands))); | |||
3263 | ||||
3264 | /* Split argbuf into its separate piped processes, | |||
3265 | and record info about each one. | |||
3266 | Also search for the programs that are to be run. */ | |||
3267 | ||||
3268 | argbuf.safe_push (0); | |||
3269 | ||||
3270 | commands[0].prog = argbuf[0]; /* first command. */ | |||
3271 | commands[0].argv = argbuf.address (); | |||
3272 | ||||
3273 | if (!wrapper_stringglobal_options.x_wrapper_string) | |||
3274 | { | |||
3275 | string = find_a_program(commands[0].prog); | |||
3276 | if (string) | |||
3277 | commands[0].argv[0] = string; | |||
3278 | } | |||
3279 | ||||
3280 | for (n_commands = 1, i = 0; argbuf.iterate (i, &arg); i++) | |||
3281 | if (arg && strcmp (arg, "|") == 0) | |||
3282 | { /* each command. */ | |||
3283 | #if defined (__MSDOS__) || defined (OS2) || defined (VMS) | |||
3284 | fatal_error (input_location, "%<-pipe%> not supported"); | |||
3285 | #endif | |||
3286 | argbuf[i] = 0; /* Termination of command args. */ | |||
3287 | commands[n_commands].prog = argbuf[i + 1]; | |||
3288 | commands[n_commands].argv | |||
3289 | = &(argbuf.address ())[i + 1]; | |||
3290 | string = find_a_program(commands[n_commands].prog); | |||
3291 | if (string) | |||
3292 | commands[n_commands].argv[0] = string; | |||
3293 | n_commands++; | |||
3294 | } | |||
3295 | ||||
3296 | /* If -v, print what we are about to do, and maybe query. */ | |||
3297 | ||||
3298 | if (verbose_flagglobal_options.x_verbose_flag) | |||
3299 | { | |||
3300 | /* For help listings, put a blank line between sub-processes. */ | |||
3301 | if (print_help_list) | |||
3302 | fputc ('\n', stderrstderr); | |||
3303 | ||||
3304 | /* Print each piped command as a separate line. */ | |||
3305 | for (i = 0; i < n_commands; i++) | |||
3306 | { | |||
3307 | const char *const *j; | |||
3308 | ||||
3309 | if (verbose_only_flag) | |||
3310 | { | |||
3311 | for (j = commands[i].argv; *j; j++) | |||
3312 | { | |||
3313 | const char *p; | |||
3314 | for (p = *j; *p; ++p) | |||
3315 | if (!ISALNUM ((unsigned char) *p)(_sch_istable[((unsigned char) *p) & 0xff] & (unsigned short)(_sch_isalnum)) | |||
3316 | && *p != '_' && *p != '/' && *p != '-' && *p != '.') | |||
3317 | break; | |||
3318 | if (*p || !*j) | |||
3319 | { | |||
3320 | fprintf (stderrstderr, " \""); | |||
3321 | for (p = *j; *p; ++p) | |||
3322 | { | |||
3323 | if (*p == '"' || *p == '\\' || *p == '$') | |||
3324 | fputc ('\\', stderrstderr); | |||
3325 | fputc (*p, stderrstderr); | |||
3326 | } | |||
3327 | fputc ('"', stderrstderr); | |||
3328 | } | |||
3329 | /* If it's empty, print "". */ | |||
3330 | else if (!**j) | |||
3331 | fprintf (stderrstderr, " \"\""); | |||
3332 | else | |||
3333 | fprintf (stderrstderr, " %s", *j); | |||
3334 | } | |||
3335 | } | |||
3336 | else | |||
3337 | for (j = commands[i].argv; *j; j++) | |||
3338 | /* If it's empty, print "". */ | |||
3339 | if (!**j) | |||
3340 | fprintf (stderrstderr, " \"\""); | |||
3341 | else | |||
3342 | fprintf (stderrstderr, " %s", *j); | |||
3343 | ||||
3344 | /* Print a pipe symbol after all but the last command. */ | |||
3345 | if (i + 1 != n_commands) | |||
3346 | fprintf (stderrstderr, " |"); | |||
3347 | fprintf (stderrstderr, "\n"); | |||
3348 | } | |||
3349 | fflush (stderrstderr); | |||
3350 | if (verbose_only_flag != 0) | |||
3351 | { | |||
3352 | /* verbose_only_flag should act as if the spec was | |||
3353 | executed, so increment execution_count before | |||
3354 | returning. This prevents spurious warnings about | |||
3355 | unused linker input files, etc. */ | |||
3356 | execution_count++; | |||
3357 | return 0; | |||
3358 | } | |||
3359 | #ifdef DEBUG | |||
3360 | fnotice (stderrstderr, "\nGo ahead? (y or n) "); | |||
3361 | fflush (stderrstderr); | |||
3362 | i = getchar (); | |||
3363 | if (i != '\n') | |||
3364 | while (getchar () != '\n') | |||
3365 | ; | |||
3366 | ||||
3367 | if (i != 'y' && i != 'Y') | |||
3368 | return 0; | |||
3369 | #endif /* DEBUG */ | |||
3370 | } | |||
3371 | ||||
3372 | #ifdef ENABLE_VALGRIND_CHECKING | |||
3373 | /* Run the each command through valgrind. To simplify prepending the | |||
3374 | path to valgrind and the option "-q" (for quiet operation unless | |||
3375 | something triggers), we allocate a separate argv array. */ | |||
3376 | ||||
3377 | for (i = 0; i < n_commands; i++) | |||
3378 | { | |||
3379 | const char **argv; | |||
3380 | int argc; | |||
3381 | int j; | |||
3382 | ||||
3383 | for (argc = 0; commands[i].argv[argc] != NULLnullptr; argc++) | |||
3384 | ; | |||
3385 | ||||
3386 | argv = XALLOCAVEC (const char *, argc + 3)((const char * *) __builtin_alloca(sizeof (const char *) * (argc + 3))); | |||
3387 | ||||
3388 | argv[0] = VALGRIND_PATH; | |||
3389 | argv[1] = "-q"; | |||
3390 | for (j = 2; j < argc + 2; j++) | |||
3391 | argv[j] = commands[i].argv[j - 2]; | |||
3392 | argv[j] = NULLnullptr; | |||
3393 | ||||
3394 | commands[i].argv = argv; | |||
3395 | commands[i].prog = argv[0]; | |||
3396 | } | |||
3397 | #endif | |||
3398 | ||||
3399 | /* Run each piped subprocess. */ | |||
3400 | ||||
3401 | pex = pex_init (PEX_USE_PIPES0x2 | ((report_timesglobal_options.x_report_times || report_times_to_file) | |||
3402 | ? PEX_RECORD_TIMES0x1 : 0), | |||
3403 | progname, temp_filename); | |||
3404 | if (pex == NULLnullptr) | |||
3405 | fatal_error (input_location, "%<pex_init%> failed: %m"); | |||
3406 | ||||
3407 | for (i = 0; i < n_commands; i++) | |||
3408 | { | |||
3409 | const char *errmsg; | |||
3410 | int err; | |||
3411 | const char *string = commands[i].argv[0]; | |||
3412 | ||||
3413 | errmsg = pex_run (pex, | |||
3414 | ((i + 1 == n_commands ? PEX_LAST0x1 : 0) | |||
3415 | | (string == commands[i].prog ? PEX_SEARCH0x2 : 0)), | |||
3416 | string, CONST_CAST (char **, commands[i].argv)(const_cast<char **> ((commands[i].argv))), | |||
3417 | NULLnullptr, NULLnullptr, &err); | |||
3418 | if (errmsg != NULLnullptr) | |||
3419 | { | |||
3420 | errno(*__errno_location ()) = err; | |||
3421 | fatal_error (input_location, | |||
3422 | err ? G_("cannot execute %qs: %s: %m")"cannot execute %qs: %s: %m" | |||
3423 | : G_("cannot execute %qs: %s")"cannot execute %qs: %s", | |||
3424 | string, errmsg); | |||
3425 | } | |||
3426 | ||||
3427 | if (i && string != commands[i].prog) | |||
3428 | free (CONST_CAST (char *, string)(const_cast<char *> ((string)))); | |||
3429 | } | |||
3430 | ||||
3431 | execution_count++; | |||
3432 | ||||
3433 | /* Wait for all the subprocesses to finish. */ | |||
3434 | ||||
3435 | { | |||
3436 | int *statuses; | |||
3437 | struct pex_time *times = NULLnullptr; | |||
3438 | int ret_code = 0; | |||
3439 | ||||
3440 | statuses = XALLOCAVEC (int, n_commands)((int *) __builtin_alloca(sizeof (int) * (n_commands))); | |||
3441 | if (!pex_get_status (pex, n_commands, statuses)) | |||
3442 | fatal_error (input_location, "failed to get exit status: %m"); | |||
3443 | ||||
3444 | if (report_timesglobal_options.x_report_times || report_times_to_file) | |||
3445 | { | |||
3446 | times = XALLOCAVEC (struct pex_time, n_commands)((struct pex_time *) __builtin_alloca(sizeof (struct pex_time ) * (n_commands))); | |||
3447 | if (!pex_get_times (pex, n_commands, times)) | |||
3448 | fatal_error (input_location, "failed to get process times: %m"); | |||
3449 | } | |||
3450 | ||||
3451 | pex_free (pex); | |||
3452 | ||||
3453 | for (i = 0; i < n_commands; ++i) | |||
3454 | { | |||
3455 | int status = statuses[i]; | |||
3456 | ||||
3457 | if (WIFSIGNALED (status)(((signed char) (((status) & 0x7f) + 1) >> 1) > 0 )) | |||
3458 | switch (WTERMSIG (status)((status) & 0x7f)) | |||
3459 | { | |||
3460 | case SIGINT2: | |||
3461 | case SIGTERM15: | |||
3462 | /* SIGQUIT and SIGKILL are not available on MinGW. */ | |||
3463 | #ifdef SIGQUIT3 | |||
3464 | case SIGQUIT3: | |||
3465 | #endif | |||
3466 | #ifdef SIGKILL9 | |||
3467 | case SIGKILL9: | |||
3468 | #endif | |||
3469 | /* The user (or environment) did something to the | |||
3470 | inferior. Making this an ICE confuses the user into | |||
3471 | thinking there's a compiler bug. Much more likely is | |||
3472 | the user or OOM killer nuked it. */ | |||
3473 | fatal_error (input_location, | |||
3474 | "%s signal terminated program %s", | |||
3475 | strsignal (WTERMSIG (status)((status) & 0x7f)), | |||
3476 | commands[i].prog); | |||
3477 | break; | |||
3478 | ||||
3479 | #ifdef SIGPIPE13 | |||
3480 | case SIGPIPE13: | |||
3481 | /* SIGPIPE is a special case. It happens in -pipe mode | |||
3482 | when the compiler dies before the preprocessor is | |||
3483 | done, or the assembler dies before the compiler is | |||
3484 | done. There's generally been an error already, and | |||
3485 | this is just fallout. So don't generate another | |||
3486 | error unless we would otherwise have succeeded. */ | |||
3487 | if (signal_count || greatest_status >= MIN_FATAL_STATUS1) | |||
3488 | { | |||
3489 | signal_count++; | |||
3490 | ret_code = -1; | |||
3491 | break; | |||
3492 | } | |||
3493 | #endif | |||
3494 | /* FALLTHROUGH */ | |||
3495 | ||||
3496 | default: | |||
3497 | /* The inferior failed to catch the signal. */ | |||
3498 | internal_error_no_backtrace ("%s signal terminated program %s", | |||
3499 | strsignal (WTERMSIG (status)((status) & 0x7f)), | |||
3500 | commands[i].prog); | |||
3501 | } | |||
3502 | else if (WIFEXITED (status)(((status) & 0x7f) == 0) | |||
3503 | && WEXITSTATUS (status)(((status) & 0xff00) >> 8) >= MIN_FATAL_STATUS1) | |||
3504 | { | |||
3505 | /* For ICEs in cc1, cc1obj, cc1plus see if it is | |||
3506 | reproducible or not. */ | |||
3507 | const char *p; | |||
3508 | if (flag_report_bugglobal_options.x_flag_report_bug | |||
3509 | && WEXITSTATUS (status)(((status) & 0xff00) >> 8) == ICE_EXIT_CODE4 | |||
3510 | && i == 0 | |||
3511 | && (p = strrchr (commands[0].argv[0], DIR_SEPARATOR'/')) | |||
3512 | && startswith (p + 1, "cc1")) | |||
3513 | try_generate_repro (commands[0].argv); | |||
3514 | if (WEXITSTATUS (status)(((status) & 0xff00) >> 8) > greatest_status) | |||
3515 | greatest_status = WEXITSTATUS (status)(((status) & 0xff00) >> 8); | |||
3516 | ret_code = -1; | |||
3517 | } | |||
3518 | ||||
3519 | if (report_timesglobal_options.x_report_times || report_times_to_file) | |||
3520 | { | |||
3521 | struct pex_time *pt = ×[i]; | |||
3522 | double ut, st; | |||
3523 | ||||
3524 | ut = ((double) pt->user_seconds | |||
3525 | + (double) pt->user_microseconds / 1.0e6); | |||
3526 | st = ((double) pt->system_seconds | |||
3527 | + (double) pt->system_microseconds / 1.0e6); | |||
3528 | ||||
3529 | if (ut + st != 0) | |||
3530 | { | |||
3531 | if (report_timesglobal_options.x_report_times) | |||
3532 | fnotice (stderrstderr, "# %s %.2f %.2f\n", | |||
3533 | commands[i].prog, ut, st); | |||
3534 | ||||
3535 | if (report_times_to_file) | |||
3536 | { | |||
3537 | int c = 0; | |||
3538 | const char *const *j; | |||
3539 | ||||
3540 | fprintf (report_times_to_file, "%g %g", ut, st); | |||
3541 | ||||
3542 | for (j = &commands[i].prog; *j; j = &commands[i].argv[++c]) | |||
3543 | { | |||
3544 | const char *p; | |||
3545 | for (p = *j; *p; ++p) | |||
3546 | if (*p == '"' || *p == '\\' || *p == '$' | |||
3547 | || ISSPACE (*p)(_sch_istable[(*p) & 0xff] & (unsigned short)(_sch_isspace ))) | |||
3548 | break; | |||
3549 | ||||
3550 | if (*p) | |||
3551 | { | |||
3552 | fprintf (report_times_to_file, " \""); | |||
3553 | for (p = *j; *p; ++p) | |||
3554 | { | |||
3555 | if (*p == '"' || *p == '\\' || *p == '$') | |||
3556 | fputc ('\\', report_times_to_file); | |||
3557 | fputc (*p, report_times_to_file); | |||
3558 | } | |||
3559 | fputc ('"', report_times_to_file); | |||
3560 | } | |||
3561 | else | |||
3562 | fprintf (report_times_to_file, " %s", *j); | |||
3563 | } | |||
3564 | ||||
3565 | fputc ('\n', report_times_to_file); | |||
3566 | } | |||
3567 | } | |||
3568 | } | |||
3569 | } | |||
3570 | ||||
3571 | if (commands[0].argv[0] != commands[0].prog) | |||
3572 | free (CONST_CAST (char *, commands[0].argv[0])(const_cast<char *> ((commands[0].argv[0])))); | |||
3573 | ||||
3574 | return ret_code; | |||
3575 | } | |||
3576 | } | |||
3577 | ||||
3578 | static struct switchstr *switches; | |||
3579 | ||||
3580 | static int n_switches; | |||
3581 | ||||
3582 | static int n_switches_alloc; | |||
3583 | ||||
3584 | /* Set to zero if -fcompare-debug is disabled, positive if it's | |||
3585 | enabled and we're running the first compilation, negative if it's | |||
3586 | enabled and we're running the second compilation. For most of the | |||
3587 | time, it's in the range -1..1, but it can be temporarily set to 2 | |||
3588 | or 3 to indicate that the -fcompare-debug flags didn't come from | |||
3589 | the command-line, but rather from the GCC_COMPARE_DEBUG environment | |||
3590 | variable, until a synthesized -fcompare-debug flag is added to the | |||
3591 | command line. */ | |||
3592 | int compare_debug; | |||
3593 | ||||
3594 | /* Set to nonzero if we've seen the -fcompare-debug-second flag. */ | |||
3595 | int compare_debug_second; | |||
3596 | ||||
3597 | /* Set to the flags that should be passed to the second compilation in | |||
3598 | a -fcompare-debug compilation. */ | |||
3599 | const char *compare_debug_opt; | |||
3600 | ||||
3601 | static struct switchstr *switches_debug_check[2]; | |||
3602 | ||||
3603 | static int n_switches_debug_check[2]; | |||
3604 | ||||
3605 | static int n_switches_alloc_debug_check[2]; | |||
3606 | ||||
3607 | static char *debug_check_temp_file[2]; | |||
3608 | ||||
3609 | /* Language is one of three things: | |||
3610 | ||||
3611 | 1) The name of a real programming language. | |||
3612 | 2) NULL, indicating that no one has figured out | |||
3613 | what it is yet. | |||
3614 | 3) '*', indicating that the file should be passed | |||
3615 | to the linker. */ | |||
3616 | struct infile | |||
3617 | { | |||
3618 | const char *name; | |||
3619 | const char *language; | |||
3620 | struct compiler *incompiler; | |||
3621 | bool compiled; | |||
3622 | bool preprocessed; | |||
3623 | }; | |||
3624 | ||||
3625 | /* Also a vector of input files specified. */ | |||
3626 | ||||
3627 | static struct infile *infiles; | |||
3628 | ||||
3629 | int n_infiles; | |||
3630 | ||||
3631 | static int n_infiles_alloc; | |||
3632 | ||||
3633 | /* True if undefined environment variables encountered during spec processing | |||
3634 | are ok to ignore, typically when we're running for --help or --version. */ | |||
3635 | ||||
3636 | static bool spec_undefvar_allowed; | |||
3637 | ||||
3638 | /* True if multiple input files are being compiled to a single | |||
3639 | assembly file. */ | |||
3640 | ||||
3641 | static bool combine_inputs; | |||
3642 | ||||
3643 | /* This counts the number of libraries added by lang_specific_driver, so that | |||
3644 | we can tell if there were any user supplied any files or libraries. */ | |||
3645 | ||||
3646 | static int added_libraries; | |||
3647 | ||||
3648 | /* And a vector of corresponding output files is made up later. */ | |||
3649 | ||||
3650 | const char **outfiles; | |||
3651 | ||||
3652 | #if defined(HAVE_TARGET_OBJECT_SUFFIX) || defined(HAVE_TARGET_EXECUTABLE_SUFFIX) | |||
3653 | ||||
3654 | /* Convert NAME to a new name if it is the standard suffix. DO_EXE | |||
3655 | is true if we should look for an executable suffix. DO_OBJ | |||
3656 | is true if we should look for an object suffix. */ | |||
3657 | ||||
3658 | static const char * | |||
3659 | convert_filename (const char *name, int do_exe ATTRIBUTE_UNUSED__attribute__ ((__unused__)), | |||
3660 | int do_obj ATTRIBUTE_UNUSED__attribute__ ((__unused__))) | |||
3661 | { | |||
3662 | #if defined(HAVE_TARGET_EXECUTABLE_SUFFIX) | |||
3663 | int i; | |||
3664 | #endif | |||
3665 | int len; | |||
3666 | ||||
3667 | if (name == NULLnullptr) | |||
3668 | return NULLnullptr; | |||
3669 | ||||
3670 | len = strlen (name); | |||
3671 | ||||
3672 | #ifdef HAVE_TARGET_OBJECT_SUFFIX | |||
3673 | /* Convert x.o to x.obj if TARGET_OBJECT_SUFFIX is ".obj". */ | |||
3674 | if (do_obj && len > 2 | |||
3675 | && name[len - 2] == '.' | |||
3676 | && name[len - 1] == 'o') | |||
3677 | { | |||
3678 | obstack_grow (&obstack, name, len - 2)__extension__ ({ struct obstack *__o = (&obstack); size_t __len = (len - 2); if (__extension__ ({ struct obstack const *__o1 = (__o); (size_t) (__o1->chunk_limit - __o1->next_free ); }) < __len) _obstack_newchunk (__o, __len); memcpy (__o ->next_free, name, __len); __o->next_free += __len; (void ) 0; }); | |||
3679 | obstack_grow0 (&obstack, TARGET_OBJECT_SUFFIX, strlen (TARGET_OBJECT_SUFFIX))__extension__ ({ struct obstack *__o = (&obstack); size_t __len = (strlen (".o")); 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, ".o", __len); __o->next_free += __len; *(__o->next_free)++ = 0; (void) 0; }); | |||
3680 | name = 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; })); | |||
3681 | } | |||
3682 | #endif | |||
3683 | ||||
3684 | #if defined(HAVE_TARGET_EXECUTABLE_SUFFIX) | |||
3685 | /* If there is no filetype, make it the executable suffix (which includes | |||
3686 | the "."). But don't get confused if we have just "-o". */ | |||
3687 | if (! do_exe || TARGET_EXECUTABLE_SUFFIX""[0] == 0 || not_actual_file_p (name)) | |||
3688 | return name; | |||
3689 | ||||
3690 | for (i = len - 1; i >= 0; i--) | |||
3691 | if (IS_DIR_SEPARATOR (name[i])(((name[i]) == '/') || (((name[i]) == '\\') && (0)))) | |||
3692 | break; | |||
3693 | ||||
3694 | for (i++; i < len; i++) | |||
3695 | if (name[i] == '.') | |||
3696 | return name; | |||
3697 | ||||
3698 | obstack_grow (&obstack, name, len)__extension__ ({ struct obstack *__o = (&obstack); size_t __len = (len); if (__extension__ ({ struct obstack const *__o1 = (__o); (size_t) (__o1->chunk_limit - __o1->next_free ); }) < __len) _obstack_newchunk (__o, __len); memcpy (__o ->next_free, name, __len); __o->next_free += __len; (void ) 0; }); | |||
3699 | obstack_grow0 (&obstack, TARGET_EXECUTABLE_SUFFIX,__extension__ ({ struct obstack *__o = (&obstack); size_t __len = (strlen ("")); 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, "", __len); __o->next_free += __len; * (__o->next_free)++ = 0; (void) 0; }) | |||
3700 | strlen (TARGET_EXECUTABLE_SUFFIX))__extension__ ({ struct obstack *__o = (&obstack); size_t __len = (strlen ("")); 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, "", __len); __o->next_free += __len; * (__o->next_free)++ = 0; (void) 0; }); | |||
3701 | name = 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; })); | |||
3702 | #endif | |||
3703 | ||||
3704 | return name; | |||
3705 | } | |||
3706 | #endif | |||
3707 | ||||
3708 | /* Display the command line switches accepted by gcc. */ | |||
3709 | static void | |||
3710 | display_help (void) | |||
3711 | { | |||
3712 | printf (_("Usage: %s [options] file...\n")gettext ("Usage: %s [options] file...\n"), progname); | |||
3713 | fputs (_("Options:\n")gettext ("Options:\n"), stdoutstdout); | |||
3714 | ||||
3715 | fputs (_(" -pass-exit-codes Exit with highest error code from a phase.\n")gettext (" -pass-exit-codes Exit with highest error code from a phase.\n" ), stdoutstdout); | |||
3716 | fputs (_(" --help Display this information.\n")gettext (" --help Display this information.\n" ), stdoutstdout); | |||
3717 | fputs (_(" --target-help Display target specific command line options "gettext (" --target-help Display target specific command line options " "(including assembler and linker options).\n") | |||
3718 | "(including assembler and linker options).\n")gettext (" --target-help Display target specific command line options " "(including assembler and linker options).\n"), stdoutstdout); | |||
3719 | fputs (_(" --help={common|optimizers|params|target|warnings|[^]{joined|separate|undocumented}}[,...].\n")gettext (" --help={common|optimizers|params|target|warnings|[^]{joined|separate|undocumented}}[,...].\n" ), stdoutstdout); | |||
3720 | fputs (_(" Display specific types of command line options.\n")gettext (" Display specific types of command line options.\n" ), stdoutstdout); | |||
3721 | if (! verbose_flagglobal_options.x_verbose_flag) | |||
3722 | fputs (_(" (Use '-v --help' to display command line options of sub-processes).\n")gettext (" (Use '-v --help' to display command line options of sub-processes).\n" ), stdoutstdout); | |||
3723 | fputs (_(" --version Display compiler version information.\n")gettext (" --version Display compiler version information.\n" ), stdoutstdout); | |||
3724 | fputs (_(" -dumpspecs Display all of the built in spec strings.\n")gettext (" -dumpspecs Display all of the built in spec strings.\n" ), stdoutstdout); | |||
3725 | fputs (_(" -dumpversion Display the version of the compiler.\n")gettext (" -dumpversion Display the version of the compiler.\n" ), stdoutstdout); | |||
3726 | fputs (_(" -dumpmachine Display the compiler's target processor.\n")gettext (" -dumpmachine Display the compiler's target processor.\n" ), stdoutstdout); | |||
3727 | fputs (_(" -foffload=<targets> Specify offloading targets.\n")gettext (" -foffload=<targets> Specify offloading targets.\n" ), stdoutstdout); | |||
3728 | fputs (_(" -print-search-dirs Display the directories in the compiler's search path.\n")gettext (" -print-search-dirs Display the directories in the compiler's search path.\n" ), stdoutstdout); | |||
3729 | fputs (_(" -print-libgcc-file-name Display the name of the compiler's companion library.\n")gettext (" -print-libgcc-file-name Display the name of the compiler's companion library.\n" ), stdoutstdout); | |||
3730 | fputs (_(" -print-file-name=<lib> Display the full path to library <lib>.\n")gettext (" -print-file-name=<lib> Display the full path to library <lib>.\n" ), stdoutstdout); | |||
3731 | fputs (_(" -print-prog-name=<prog> Display the full path to compiler component <prog>.\n")gettext (" -print-prog-name=<prog> Display the full path to compiler component <prog>.\n" ), stdoutstdout); | |||
3732 | fputs (_("\gettext (" -print-multiarch Display the target's normalized GNU triplet, used as\n a component in the library path.\n" ) | |||
3733 | -print-multiarch Display the target's normalized GNU triplet, used as\n\gettext (" -print-multiarch Display the target's normalized GNU triplet, used as\n a component in the library path.\n" ) | |||
3734 | a component in the library path.\n")gettext (" -print-multiarch Display the target's normalized GNU triplet, used as\n a component in the library path.\n" ), stdoutstdout); | |||
3735 | fputs (_(" -print-multi-directory Display the root directory for versions of libgcc.\n")gettext (" -print-multi-directory Display the root directory for versions of libgcc.\n" ), stdoutstdout); | |||
3736 | fputs (_("\gettext (" -print-multi-lib Display the mapping between command line options and\n multiple library search directories.\n" ) | |||
3737 | -print-multi-lib Display the mapping between command line options and\n\gettext (" -print-multi-lib Display the mapping between command line options and\n multiple library search directories.\n" ) | |||
3738 | multiple library search directories.\n")gettext (" -print-multi-lib Display the mapping between command line options and\n multiple library search directories.\n" ), stdoutstdout); | |||
3739 | fputs (_(" -print-multi-os-directory Display the relative path to OS libraries.\n")gettext (" -print-multi-os-directory Display the relative path to OS libraries.\n" ), stdoutstdout); | |||
3740 | fputs (_(" -print-sysroot Display the target libraries directory.\n")gettext (" -print-sysroot Display the target libraries directory.\n" ), stdoutstdout); | |||
3741 | fputs (_(" -print-sysroot-headers-suffix Display the sysroot suffix used to find headers.\n")gettext (" -print-sysroot-headers-suffix Display the sysroot suffix used to find headers.\n" ), stdoutstdout); | |||
3742 | fputs (_(" -Wa,<options> Pass comma-separated <options> on to the assembler.\n")gettext (" -Wa,<options> Pass comma-separated <options> on to the assembler.\n" ), stdoutstdout); | |||
3743 | fputs (_(" -Wp,<options> Pass comma-separated <options> on to the preprocessor.\n")gettext (" -Wp,<options> Pass comma-separated <options> on to the preprocessor.\n" ), stdoutstdout); | |||
3744 | fputs (_(" -Wl,<options> Pass comma-separated <options> on to the linker.\n")gettext (" -Wl,<options> Pass comma-separated <options> on to the linker.\n" ), stdoutstdout); | |||
3745 | fputs (_(" -Xassembler <arg> Pass <arg> on to the assembler.\n")gettext (" -Xassembler <arg> Pass <arg> on to the assembler.\n" ), stdoutstdout); | |||
3746 | fputs (_(" -Xpreprocessor <arg> Pass <arg> on to the preprocessor.\n")gettext (" -Xpreprocessor <arg> Pass <arg> on to the preprocessor.\n" ), stdoutstdout); | |||
3747 | fputs (_(" -Xlinker <arg> Pass <arg> on to the linker.\n")gettext (" -Xlinker <arg> Pass <arg> on to the linker.\n" ), stdoutstdout); | |||
3748 | fputs (_(" -save-temps Do not delete intermediate files.\n")gettext (" -save-temps Do not delete intermediate files.\n" ), stdoutstdout); | |||
3749 | fputs (_(" -save-temps=<arg> Do not delete intermediate files.\n")gettext (" -save-temps=<arg> Do not delete intermediate files.\n" ), stdoutstdout); | |||
3750 | fputs (_("\gettext (" -no-canonical-prefixes Do not canonicalize paths when building relative\n prefixes to other gcc components.\n" ) | |||
3751 | -no-canonical-prefixes Do not canonicalize paths when building relative\n\gettext (" -no-canonical-prefixes Do not canonicalize paths when building relative\n prefixes to other gcc components.\n" ) | |||
3752 | prefixes to other gcc components.\n")gettext (" -no-canonical-prefixes Do not canonicalize paths when building relative\n prefixes to other gcc components.\n" ), stdoutstdout); | |||
3753 | fputs (_(" -pipe Use pipes rather than intermediate files.\n")gettext (" -pipe Use pipes rather than intermediate files.\n" ), stdoutstdout); | |||
3754 | fputs (_(" -time Time the execution of each subprocess.\n")gettext (" -time Time the execution of each subprocess.\n" ), stdoutstdout); | |||
3755 | fputs (_(" -specs=<file> Override built-in specs with the contents of <file>.\n")gettext (" -specs=<file> Override built-in specs with the contents of <file>.\n" ), stdoutstdout); | |||
3756 | fputs (_(" -std=<standard> Assume that the input sources are for <standard>.\n")gettext (" -std=<standard> Assume that the input sources are for <standard>.\n" ), stdoutstdout); | |||
3757 | fputs (_("\gettext (" --sysroot=<directory> Use <directory> as the root directory for headers\n and libraries.\n" ) | |||
3758 | --sysroot=<directory> Use <directory> as the root directory for headers\n\gettext (" --sysroot=<directory> Use <directory> as the root directory for headers\n and libraries.\n" ) | |||
3759 | and libraries.\n")gettext (" --sysroot=<directory> Use <directory> as the root directory for headers\n and libraries.\n" ), stdoutstdout); | |||
3760 | fputs (_(" -B <directory> Add <directory> to the compiler's search paths.\n")gettext (" -B <directory> Add <directory> to the compiler's search paths.\n" ), stdoutstdout); | |||
3761 | fputs (_(" -v Display the programs invoked by the compiler.\n")gettext (" -v Display the programs invoked by the compiler.\n" ), stdoutstdout); | |||
3762 | fputs (_(" -### Like -v but options quoted and commands not executed.\n")gettext (" -### Like -v but options quoted and commands not executed.\n" ), stdoutstdout); | |||
3763 | fputs (_(" -E Preprocess only; do not compile, assemble or link.\n")gettext (" -E Preprocess only; do not compile, assemble or link.\n" ), stdoutstdout); | |||
3764 | fputs (_(" -S Compile only; do not assemble or link.\n")gettext (" -S Compile only; do not assemble or link.\n" ), stdoutstdout); | |||
3765 | fputs (_(" -c Compile and assemble, but do not link.\n")gettext (" -c Compile and assemble, but do not link.\n" ), stdoutstdout); | |||
3766 | fputs (_(" -o <file> Place the output into <file>.\n")gettext (" -o <file> Place the output into <file>.\n" ), stdoutstdout); | |||
3767 | fputs (_(" -pie Create a dynamically linked position independent\n\gettext (" -pie Create a dynamically linked position independent\n executable.\n" ) | |||
3768 | executable.\n")gettext (" -pie Create a dynamically linked position independent\n executable.\n" ), stdoutstdout); | |||
3769 | fputs (_(" -shared Create a shared library.\n")gettext (" -shared Create a shared library.\n" ), stdoutstdout); | |||
3770 | fputs (_("\gettext (" -x <language> Specify the language of the following input files.\n Permissible languages include: c c++ assembler none\n 'none' means revert to the default behavior of\n guessing the language based on the file's extension.\n" ) | |||
3771 | -x <language> Specify the language of the following input files.\n\gettext (" -x <language> Specify the language of the following input files.\n Permissible languages include: c c++ assembler none\n 'none' means revert to the default behavior of\n guessing the language based on the file's extension.\n" ) | |||
3772 | Permissible languages include: c c++ assembler none\n\gettext (" -x <language> Specify the language of the following input files.\n Permissible languages include: c c++ assembler none\n 'none' means revert to the default behavior of\n guessing the language based on the file's extension.\n" ) | |||
3773 | 'none' means revert to the default behavior of\n\gettext (" -x <language> Specify the language of the following input files.\n Permissible languages include: c c++ assembler none\n 'none' means revert to the default behavior of\n guessing the language based on the file's extension.\n" ) | |||
3774 | guessing the language based on the file's extension.\n\gettext (" -x <language> Specify the language of the following input files.\n Permissible languages include: c c++ assembler none\n 'none' means revert to the default behavior of\n guessing the language based on the file's extension.\n" ) | |||
3775 | ")gettext (" -x <language> Specify the language of the following input files.\n Permissible languages include: c c++ assembler none\n 'none' means revert to the default behavior of\n guessing the language based on the file's extension.\n" ), stdoutstdout); | |||
3776 | ||||
3777 | printf (_("\gettext ("\nOptions starting with -g, -f, -m, -O, -W, or --param are automatically\n passed on to the various sub-processes invoked by %s. In order to pass\n other options on to these processes the -W<letter> options must be used.\n" ) | |||
3778 | \nOptions starting with -g, -f, -m, -O, -W, or --param are automatically\n\gettext ("\nOptions starting with -g, -f, -m, -O, -W, or --param are automatically\n passed on to the various sub-processes invoked by %s. In order to pass\n other options on to these processes the -W<letter> options must be used.\n" ) | |||
3779 | passed on to the various sub-processes invoked by %s. In order to pass\n\gettext ("\nOptions starting with -g, -f, -m, -O, -W, or --param are automatically\n passed on to the various sub-processes invoked by %s. In order to pass\n other options on to these processes the -W<letter> options must be used.\n" ) | |||
3780 | other options on to these processes the -W<letter> options must be used.\n\gettext ("\nOptions starting with -g, -f, -m, -O, -W, or --param are automatically\n passed on to the various sub-processes invoked by %s. In order to pass\n other options on to these processes the -W<letter> options must be used.\n" ) | |||
3781 | ")gettext ("\nOptions starting with -g, -f, -m, -O, -W, or --param are automatically\n passed on to the various sub-processes invoked by %s. In order to pass\n other options on to these processes the -W<letter> options must be used.\n" ), progname); | |||
3782 | ||||
3783 | /* The rest of the options are displayed by invocations of the various | |||
3784 | sub-processes. */ | |||
3785 | } | |||
3786 | ||||
3787 | static void | |||
3788 | add_preprocessor_option (const char *option, int len) | |||
3789 | { | |||
3790 | preprocessor_options.safe_push (save_string (option, len)); | |||
3791 | } | |||
3792 | ||||
3793 | static void | |||
3794 | add_assembler_option (const char *option, int len) | |||
3795 | { | |||
3796 | assembler_options.safe_push (save_string (option, len)); | |||
3797 | } | |||
3798 | ||||
3799 | static void | |||
3800 | add_linker_option (const char *option, int len) | |||
3801 | { | |||
3802 | linker_options.safe_push (save_string (option, len)); | |||
3803 | } | |||
3804 | ||||
3805 | /* Allocate space for an input file in infiles. */ | |||
3806 | ||||
3807 | static void | |||
3808 | alloc_infile (void) | |||
3809 | { | |||
3810 | if (n_infiles_alloc == 0) | |||
3811 | { | |||
3812 | n_infiles_alloc = 16; | |||
3813 | infiles = XNEWVEC (struct infile, n_infiles_alloc)((struct infile *) xmalloc (sizeof (struct infile) * (n_infiles_alloc ))); | |||
3814 | } | |||
3815 | else if (n_infiles_alloc == n_infiles) | |||
3816 | { | |||
3817 | n_infiles_alloc *= 2; | |||
3818 | infiles = XRESIZEVEC (struct infile, infiles, n_infiles_alloc)((struct infile *) xrealloc ((void *) (infiles), sizeof (struct infile) * (n_infiles_alloc))); | |||
3819 | } | |||
3820 | } | |||
3821 | ||||
3822 | /* Store an input file with the given NAME and LANGUAGE in | |||
3823 | infiles. */ | |||
3824 | ||||
3825 | static void | |||
3826 | add_infile (const char *name, const char *language) | |||
3827 | { | |||
3828 | alloc_infile (); | |||
3829 | infiles[n_infiles].name = name; | |||
3830 | infiles[n_infiles++].language = language; | |||
3831 | } | |||
3832 | ||||
3833 | /* Allocate space for a switch in switches. */ | |||
3834 | ||||
3835 | static void | |||
3836 | alloc_switch (void) | |||
3837 | { | |||
3838 | if (n_switches_alloc == 0) | |||
3839 | { | |||
3840 | n_switches_alloc = 16; | |||
3841 | switches = XNEWVEC (struct switchstr, n_switches_alloc)((struct switchstr *) xmalloc (sizeof (struct switchstr) * (n_switches_alloc ))); | |||
3842 | } | |||
3843 | else if (n_switches_alloc == n_switches) | |||
3844 | { | |||
3845 | n_switches_alloc *= 2; | |||
3846 | switches = XRESIZEVEC (struct switchstr, switches, n_switches_alloc)((struct switchstr *) xrealloc ((void *) (switches), sizeof ( struct switchstr) * (n_switches_alloc))); | |||
3847 | } | |||
3848 | } | |||
3849 | ||||
3850 | /* Save an option OPT with N_ARGS arguments in array ARGS, marking it | |||
3851 | as validated if VALIDATED and KNOWN if it is an internal switch. */ | |||
3852 | ||||
3853 | static void | |||
3854 | save_switch (const char *opt, size_t n_args, const char *const *args, | |||
3855 | bool validated, bool known) | |||
3856 | { | |||
3857 | alloc_switch (); | |||
3858 | switches[n_switches].part1 = opt + 1; | |||
3859 | if (n_args == 0) | |||
3860 | switches[n_switches].args = 0; | |||
3861 | else | |||
3862 | { | |||
3863 | switches[n_switches].args = XNEWVEC (const char *, n_args + 1)((const char * *) xmalloc (sizeof (const char *) * (n_args + 1 ))); | |||
3864 | memcpy (switches[n_switches].args, args, n_args * sizeof (const char *)); | |||
3865 | switches[n_switches].args[n_args] = NULLnullptr; | |||
3866 | } | |||
3867 | ||||
3868 | switches[n_switches].live_cond = 0; | |||
3869 | switches[n_switches].validated = validated; | |||
3870 | switches[n_switches].known = known; | |||
3871 | switches[n_switches].ordering = 0; | |||
3872 | n_switches++; | |||
3873 | } | |||
3874 | ||||
3875 | /* Set the SOURCE_DATE_EPOCH environment variable to the current time if it is | |||
3876 | not set already. */ | |||
3877 | ||||
3878 | static void | |||
3879 | set_source_date_epoch_envvar () | |||
3880 | { | |||
3881 | /* Array size is 21 = ceil(log_10(2^64)) + 1 to hold string representations | |||
3882 | of 64 bit integers. */ | |||
3883 | char source_date_epoch[21]; | |||
3884 | time_t tt; | |||
3885 | ||||
3886 | errno(*__errno_location ()) = 0; | |||
3887 | tt = time (NULLnullptr); | |||
3888 | if (tt < (time_t) 0 || errno(*__errno_location ()) != 0) | |||
3889 | tt = (time_t) 0; | |||
3890 | ||||
3891 | snprintf (source_date_epoch, 21, "%llu", (unsigned long long) tt); | |||
3892 | /* Using setenv instead of xputenv because we want the variable to remain | |||
3893 | after finalizing so that it's still set in the second run when using | |||
3894 | -fcompare-debug. */ | |||
3895 | setenv ("SOURCE_DATE_EPOCH", source_date_epoch, 0); | |||
3896 | } | |||
3897 | ||||
3898 | /* Handle an option DECODED that is unknown to the option-processing | |||
3899 | machinery. */ | |||
3900 | ||||
3901 | static bool | |||
3902 | driver_unknown_option_callback (const struct cl_decoded_option *decoded) | |||
3903 | { | |||
3904 | const char *opt = decoded->arg; | |||
3905 | if (opt[1] == 'W' && opt[2] == 'n' && opt[3] == 'o' && opt[4] == '-' | |||
3906 | && !(decoded->errors & CL_ERR_NEGATIVE(1 << 6))) | |||
3907 | { | |||
3908 | /* Leave unknown -Wno-* options for the compiler proper, to be | |||
3909 | diagnosed only if there are warnings. */ | |||
3910 | save_switch (decoded->canonical_option[0], | |||
3911 | decoded->canonical_option_num_elements - 1, | |||
3912 | &decoded->canonical_option[1], false, true); | |||
3913 | return false; | |||
3914 | } | |||
3915 | if (decoded->opt_index == OPT_SPECIAL_unknown) | |||
3916 | { | |||
3917 | /* Give it a chance to define it a spec file. */ | |||
3918 | save_switch (decoded->canonical_option[0], | |||
3919 | decoded->canonical_option_num_elements - 1, | |||
3920 | &decoded->canonical_option[1], false, false); | |||
3921 | return false; | |||
3922 | } | |||
3923 | else | |||
3924 | return true; | |||
3925 | } | |||
3926 | ||||
3927 | /* Handle an option DECODED that is not marked as CL_DRIVER. | |||
3928 | LANG_MASK will always be CL_DRIVER. */ | |||
3929 | ||||
3930 | static void | |||
3931 | driver_wrong_lang_callback (const struct cl_decoded_option *decoded, | |||
3932 | unsigned int lang_mask ATTRIBUTE_UNUSED__attribute__ ((__unused__))) | |||
3933 | { | |||
3934 | /* At this point, non-driver options are accepted (and expected to | |||
3935 | be passed down by specs) unless marked to be rejected by the | |||
3936 | driver. Options to be rejected by the driver but accepted by the | |||
3937 | compilers proper are treated just like completely unknown | |||
3938 | options. */ | |||
3939 | const struct cl_option *option = &cl_options[decoded->opt_index]; | |||
3940 | ||||
3941 | if (option->cl_reject_driver) | |||
3942 | error ("unrecognized command-line option %qs", | |||
3943 | decoded->orig_option_with_args_text); | |||
3944 | else | |||
3945 | save_switch (decoded->canonical_option[0], | |||
3946 | decoded->canonical_option_num_elements - 1, | |||
3947 | &decoded->canonical_option[1], false, true); | |||
3948 | } | |||
3949 | ||||
3950 | static const char *spec_lang = 0; | |||
3951 | static int last_language_n_infiles; | |||
3952 | ||||
3953 | ||||
3954 | /* Check that GCC is configured to support the offload target. */ | |||
3955 | ||||
3956 | static bool | |||
3957 | check_offload_target_name (const char *target, ptrdiff_t len) | |||
3958 | { | |||
3959 | const char *n, *c = OFFLOAD_TARGETS""; | |||
3960 | while (c) | |||
3961 | { | |||
3962 | n = strchr (c, ','); | |||
3963 | if (n == NULLnullptr) | |||
3964 | n = strchr (c, '\0'); | |||
3965 | if (len == n - c && strncmp (target, c, n - c) == 0) | |||
3966 | break; | |||
3967 | c = *n ? n + 1 : NULLnullptr; | |||
3968 | } | |||
3969 | if (!c) | |||
3970 | { | |||
3971 | auto_vec<const char*> candidates; | |||
3972 | size_t olen = strlen (OFFLOAD_TARGETS"") + 1; | |||
3973 | char *cand = XALLOCAVEC (char, olen)((char *) __builtin_alloca(sizeof (char) * (olen))); | |||
3974 | memcpy (cand, OFFLOAD_TARGETS"", olen); | |||
3975 | for (c = strtok (cand, ","); c; c = strtok (NULLnullptr, ",")) | |||
3976 | candidates.safe_push (c); | |||
3977 | candidates.safe_push ("default"); | |||
3978 | candidates.safe_push ("disable"); | |||
3979 | ||||
3980 | char *target2 = XALLOCAVEC (char, len + 1)((char *) __builtin_alloca(sizeof (char) * (len + 1))); | |||
3981 | memcpy (target2, target, len); | |||
3982 | target2[len] = '\0'; | |||
3983 | ||||
3984 | error ("GCC is not configured to support %qs as %<-foffload=%> argument", | |||
3985 | target2); | |||
3986 | ||||
3987 | char *s; | |||
3988 | const char *hint = candidates_list_and_hint (target2, s, candidates); | |||
3989 | if (hint) | |||
3990 | inform (UNKNOWN_LOCATION((location_t) 0), | |||
3991 | "valid %<-foffload=%> arguments are: %s; " | |||
3992 | "did you mean %qs?", s, hint); | |||
3993 | else | |||
3994 | inform (UNKNOWN_LOCATION((location_t) 0), "valid %<-foffload=%> arguments are: %s", s); | |||
3995 | XDELETEVEC (s)free ((void*) (s)); | |||
3996 | return false; | |||
3997 | } | |||
3998 | return true; | |||
3999 | } | |||
4000 | ||||
4001 | /* Sanity check for -foffload-options. */ | |||
4002 | ||||
4003 | static void | |||
4004 | check_foffload_target_names (const char *arg) | |||
4005 | { | |||
4006 | const char *cur, *next, *end; | |||
4007 | /* If option argument starts with '-' then no target is specified and we | |||
4008 | do not need to parse it. */ | |||
4009 | if (arg[0] == '-') | |||
4010 | return; | |||
4011 | end = strchr (arg, '='); | |||
4012 | if (end == NULLnullptr) | |||
4013 | { | |||
4014 | error ("%<=%>options missing after %<-foffload-options=%>target"); | |||
4015 | return; | |||
4016 | } | |||
4017 | ||||
4018 | cur = arg; | |||
4019 | while (cur < end) | |||
4020 | { | |||
4021 | next = strchr (cur, ','); | |||
4022 | if (next == NULLnullptr) | |||
4023 | next = end; | |||
4024 | next = (next > end) ? end : next; | |||
4025 | ||||
4026 | /* Retain non-supported targets after printing an error as those will not | |||
4027 | be processed; each enabled target only processes its triplet. */ | |||
4028 | check_offload_target_name (cur, next - cur); | |||
4029 | cur = next + 1; | |||
4030 | } | |||
4031 | } | |||
4032 | ||||
4033 | /* Parse -foffload option argument. */ | |||
4034 | ||||
4035 | static void | |||
4036 | handle_foffload_option (const char *arg) | |||
4037 | { | |||
4038 | const char *c, *cur, *n, *next, *end; | |||
4039 | char *target; | |||
4040 | ||||
4041 | /* If option argument starts with '-' then no target is specified and we | |||
4042 | do not need to parse it. */ | |||
4043 | if (arg[0] == '-') | |||
4044 | return; | |||
4045 | ||||
4046 | end = strchr (arg, '='); | |||
4047 | if (end == NULLnullptr) | |||
4048 | end = strchr (arg, '\0'); | |||
4049 | cur = arg; | |||
4050 | ||||
4051 | while (cur < end) | |||
4052 | { | |||
4053 | next = strchr (cur, ','); | |||
4054 | if (next == NULLnullptr) | |||
4055 | next = end; | |||
4056 | next = (next > end) ? end : next; | |||
4057 | ||||
4058 | target = XNEWVEC (char, next - cur + 1)((char *) xmalloc (sizeof (char) * (next - cur + 1))); | |||
4059 | memcpy (target, cur, next - cur); | |||
4060 | target[next - cur] = '\0'; | |||
4061 | ||||
4062 | /* Reset offloading list and continue. */ | |||
4063 | if (strcmp (target, "default") == 0) | |||
4064 | { | |||
4065 | free (offload_targets); | |||
4066 | offload_targets = NULLnullptr; | |||
4067 | goto next_item; | |||
4068 | } | |||
4069 | ||||
4070 | /* If 'disable' is passed to the option, clean the list of | |||
4071 | offload targets and return, even if more targets follow. | |||
4072 | Likewise if GCC is not configured to support that offload target. */ | |||
4073 | if (strcmp (target, "disable") == 0 | |||
4074 | || !check_offload_target_name (target, next - cur)) | |||
4075 | { | |||
4076 | free (offload_targets); | |||
4077 | offload_targets = xstrdup (""); | |||
4078 | return; | |||
4079 | } | |||
4080 | ||||
4081 | if (!offload_targets) | |||
4082 | { | |||
4083 | offload_targets = target; | |||
4084 | target = NULLnullptr; | |||
4085 | } | |||
4086 | else | |||
4087 | { | |||
4088 | /* Check that the target hasn't already presented in the list. */ | |||
4089 | c = offload_targets; | |||
4090 | do | |||
4091 | { | |||
4092 | n = strchr (c, ':'); | |||
4093 | if (n == NULLnullptr) | |||
4094 | n = strchr (c, '\0'); | |||
4095 | ||||
4096 | if (next - cur == n - c && strncmp (c, target, n - c) == 0) | |||
4097 | break; | |||
4098 | ||||
4099 | c = n + 1; | |||
4100 | } | |||
4101 | while (*n); | |||
4102 | ||||
4103 | /* If duplicate is not found, append the target to the list. */ | |||
4104 | if (c > n) | |||
4105 | { | |||
4106 | size_t offload_targets_len = strlen (offload_targets); | |||
4107 | offload_targets | |||
4108 | = XRESIZEVEC (char, offload_targets,((char *) xrealloc ((void *) (offload_targets), sizeof (char) * (offload_targets_len + 1 + next - cur + 1))) | |||
4109 | offload_targets_len + 1 + next - cur + 1)((char *) xrealloc ((void *) (offload_targets), sizeof (char) * (offload_targets_len + 1 + next - cur + 1))); | |||
4110 | offload_targets[offload_targets_len++] = ':'; | |||
4111 | memcpy (offload_targets + offload_targets_len, target, next - cur + 1); | |||
4112 | } | |||
4113 | } | |||
4114 | next_item: | |||
4115 | cur = next + 1; | |||
4116 | XDELETEVEC (target)free ((void*) (target)); | |||
4117 | } | |||
4118 | } | |||
4119 | ||||
4120 | /* Handle a driver option; arguments and return value as for | |||
4121 | handle_option. */ | |||
4122 | ||||
4123 | static bool | |||
4124 | driver_handle_option (struct gcc_options *opts, | |||
4125 | struct gcc_options *opts_set, | |||
4126 | const struct cl_decoded_option *decoded, | |||
4127 | unsigned int lang_mask ATTRIBUTE_UNUSED__attribute__ ((__unused__)), int kind, | |||
4128 | location_t loc, | |||
4129 | const struct cl_option_handlers *handlers ATTRIBUTE_UNUSED__attribute__ ((__unused__)), | |||
4130 | diagnostic_context *dc, | |||
4131 | void (*) (void)) | |||
4132 | { | |||
4133 | size_t opt_index = decoded->opt_index; | |||
4134 | const char *arg = decoded->arg; | |||
4135 | const char *compare_debug_replacement_opt; | |||
4136 | int value = decoded->value; | |||
4137 | bool validated = false; | |||
4138 | bool do_save = true; | |||
4139 | ||||
4140 | gcc_assert (opts == &global_options)((void)(!(opts == &global_options) ? fancy_abort ("/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/gcc.cc" , 4140, __FUNCTION__), 0 : 0)); | |||
4141 | gcc_assert (opts_set == &global_options_set)((void)(!(opts_set == &global_options_set) ? fancy_abort ( "/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/gcc.cc" , 4141, __FUNCTION__), 0 : 0)); | |||
4142 | gcc_assert (kind == DK_UNSPECIFIED)((void)(!(kind == DK_UNSPECIFIED) ? fancy_abort ("/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/gcc.cc" , 4142, __FUNCTION__), 0 : 0)); | |||
4143 | gcc_assert (loc == UNKNOWN_LOCATION)((void)(!(loc == ((location_t) 0)) ? fancy_abort ("/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/gcc.cc" , 4143, __FUNCTION__), 0 : 0)); | |||
4144 | gcc_assert (dc == global_dc)((void)(!(dc == global_dc) ? fancy_abort ("/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/gcc.cc" , 4144, __FUNCTION__), 0 : 0)); | |||
4145 | ||||
4146 | switch (opt_index) | |||
4147 | { | |||
4148 | case OPT_dumpspecs: | |||
4149 | { | |||
4150 | struct spec_list *sl; | |||
4151 | init_spec (); | |||
4152 | for (sl = specs; sl; sl = sl->next) | |||
4153 | printf ("*%s:\n%s\n\n", sl->name, *(sl->ptr_spec)); | |||
4154 | if (link_command_spec) | |||
4155 | printf ("*link_command:\n%s\n\n", link_command_spec); | |||
4156 | exit (0); | |||
4157 | } | |||
4158 | ||||
4159 | case OPT_dumpversion: | |||
4160 | printf ("%s\n", spec_version); | |||
4161 | exit (0); | |||
4162 | ||||
4163 | case OPT_dumpmachine: | |||
4164 | printf ("%s\n", spec_machine); | |||
4165 | exit (0); | |||
4166 | ||||
4167 | case OPT_dumpfullversion: | |||
4168 | printf ("%s\n", BASEVER"13.0.1"); | |||
4169 | exit (0); | |||
4170 | ||||
4171 | case OPT__version: | |||
4172 | print_version = 1; | |||
4173 | ||||
4174 | /* CPP driver cannot obtain switch from cc1_options. */ | |||
4175 | if (is_cpp_driver) | |||
4176 | add_preprocessor_option ("--version", strlen ("--version")); | |||
4177 | add_assembler_option ("--version", strlen ("--version")); | |||
4178 | add_linker_option ("--version", strlen ("--version")); | |||
4179 | break; | |||
4180 | ||||
4181 | case OPT__completion_: | |||
4182 | validated = true; | |||
4183 | completion = decoded->arg; | |||
4184 | break; | |||
4185 | ||||
4186 | case OPT__help: | |||
4187 | print_help_list = 1; | |||
4188 | ||||
4189 | /* CPP driver cannot obtain switch from cc1_options. */ | |||
4190 | if (is_cpp_driver) | |||
4191 | add_preprocessor_option ("--help", 6); | |||
4192 | add_assembler_option ("--help", 6); | |||
4193 | add_linker_option ("--help", 6); | |||
4194 | break; | |||
4195 | ||||
4196 | case OPT__help_: | |||
4197 | print_subprocess_help = 2; | |||
4198 | break; | |||
4199 | ||||
4200 | case OPT__target_help: | |||
4201 | print_subprocess_help = 1; | |||
4202 | ||||
4203 | /* CPP driver cannot obtain switch from cc1_options. */ | |||
4204 | if (is_cpp_driver) | |||
4205 | add_preprocessor_option ("--target-help", 13); | |||
4206 | add_assembler_option ("--target-help", 13); | |||
4207 | add_linker_option ("--target-help", 13); | |||
4208 | break; | |||
4209 | ||||
4210 | case OPT__no_sysroot_suffix: | |||
4211 | case OPT_pass_exit_codes: | |||
4212 | case OPT_print_search_dirs: | |||
4213 | case OPT_print_file_name_: | |||
4214 | case OPT_print_prog_name_: | |||
4215 | case OPT_print_multi_lib: | |||
4216 | case OPT_print_multi_directory: | |||
4217 | case OPT_print_sysroot: | |||
4218 | case OPT_print_multi_os_directory: | |||
4219 | case OPT_print_multiarch: | |||
4220 | case OPT_print_sysroot_headers_suffix: | |||
4221 | case OPT_time: | |||
4222 | case OPT_wrapper: | |||
4223 | /* These options set the variables specified in common.opt | |||
4224 | automatically, and do not need to be saved for spec | |||
4225 | processing. */ | |||
4226 | do_save = false; | |||
4227 | break; | |||
4228 | ||||
4229 | case OPT_print_libgcc_file_name: | |||
4230 | print_file_nameglobal_options.x_print_file_name = "libgcc.a"; | |||
4231 | do_save = false; | |||
4232 | break; | |||
4233 | ||||
4234 | case OPT_fuse_ld_bfd: | |||
4235 | use_ld = ".bfd"; | |||
4236 | break; | |||
4237 | ||||
4238 | case OPT_fuse_ld_gold: | |||
4239 | use_ld = ".gold"; | |||
4240 | break; | |||
4241 | ||||
4242 | case OPT_fuse_ld_mold: | |||
4243 | use_ld = ".mold"; | |||
4244 | break; | |||
4245 | ||||
4246 | case OPT_fcompare_debug_second: | |||
4247 | compare_debug_second = 1; | |||
4248 | break; | |||
4249 | ||||
4250 | case OPT_fcompare_debug: | |||
4251 | switch (value) | |||
4252 | { | |||
4253 | case 0: | |||
4254 | compare_debug_replacement_opt = "-fcompare-debug="; | |||
4255 | arg = ""; | |||
4256 | goto compare_debug_with_arg; | |||
4257 | ||||
4258 | case 1: | |||
4259 | compare_debug_replacement_opt = "-fcompare-debug=-gtoggle"; | |||
4260 | arg = "-gtoggle"; | |||
4261 | goto compare_debug_with_arg; | |||
4262 | ||||
4263 | default: | |||
4264 | gcc_unreachable ()(fancy_abort ("/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/gcc.cc" , 4264, __FUNCTION__)); | |||
4265 | } | |||
4266 | break; | |||
4267 | ||||
4268 | case OPT_fcompare_debug_: | |||
4269 | compare_debug_replacement_opt = decoded->canonical_option[0]; | |||
4270 | compare_debug_with_arg: | |||
4271 | gcc_assert (decoded->canonical_option_num_elements == 1)((void)(!(decoded->canonical_option_num_elements == 1) ? fancy_abort ("/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/gcc.cc" , 4271, __FUNCTION__), 0 : 0)); | |||
4272 | gcc_assert (arg != NULL)((void)(!(arg != nullptr) ? fancy_abort ("/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/gcc.cc" , 4272, __FUNCTION__), 0 : 0)); | |||
4273 | if (*arg) | |||
4274 | compare_debug = 1; | |||
4275 | else | |||
4276 | compare_debug = -1; | |||
4277 | if (compare_debug < 0) | |||
4278 | compare_debug_opt = NULLnullptr; | |||
4279 | else | |||
4280 | compare_debug_opt = arg; | |||
4281 | save_switch (compare_debug_replacement_opt, 0, NULLnullptr, validated, true); | |||
4282 | set_source_date_epoch_envvar (); | |||
4283 | return true; | |||
4284 | ||||
4285 | case OPT_fdiagnostics_color_: | |||
4286 | diagnostic_color_init (dc, value); | |||
4287 | break; | |||
4288 | ||||
4289 | case OPT_fdiagnostics_urls_: | |||
4290 | diagnostic_urls_init (dc, value); | |||
4291 | break; | |||
4292 | ||||
4293 | case OPT_fdiagnostics_format_: | |||
4294 | { | |||
4295 | const char *basename = (opts->x_dump_base_name ? opts->x_dump_base_name | |||
4296 | : opts->x_main_input_basename); | |||
4297 | diagnostic_output_format_init (dc, basename, | |||
4298 | (enum diagnostics_output_format)value); | |||
4299 | break; | |||
4300 | } | |||
4301 | ||||
4302 | case OPT_Wa_: | |||
4303 | { | |||
4304 | int prev, j; | |||
4305 | /* Pass the rest of this option to the assembler. */ | |||
4306 | ||||
4307 | /* Split the argument at commas. */ | |||
4308 | prev = 0; | |||
4309 | for (j = 0; arg[j]; j++) | |||
4310 | if (arg[j] == ',') | |||
4311 | { | |||
4312 | add_assembler_option (arg + prev, j - prev); | |||
4313 | prev = j + 1; | |||
4314 | } | |||
4315 | ||||
4316 | /* Record the part after the last comma. */ | |||
4317 | add_assembler_option (arg + prev, j - prev); | |||
4318 | } | |||
4319 | do_save = false; | |||
4320 | break; | |||
4321 | ||||
4322 | case OPT_Wp_: | |||
4323 | { | |||
4324 | int prev, j; | |||
4325 | /* Pass the rest of this option to the preprocessor. */ | |||
4326 | ||||
4327 | /* Split the argument at commas. */ | |||
4328 | prev = 0; | |||
4329 | for (j = 0; arg[j]; j++) | |||
4330 | if (arg[j] == ',') | |||
4331 | { | |||
4332 | add_preprocessor_option (arg + prev, j - prev); | |||
4333 | prev = j + 1; | |||
4334 | } | |||
4335 | ||||
4336 | /* Record the part after the last comma. */ | |||
4337 | add_preprocessor_option (arg + prev, j - prev); | |||
4338 | } | |||
4339 | do_save = false; | |||
4340 | break; | |||
4341 | ||||
4342 | case OPT_Wl_: | |||
4343 | { | |||
4344 | int prev, j; | |||
4345 | /* Split the argument at commas. */ | |||
4346 | prev = 0; | |||
4347 | for (j = 0; arg[j]; j++) | |||
4348 | if (arg[j] == ',') | |||
4349 | { | |||
4350 | add_infile (save_string (arg + prev, j - prev), "*"); | |||
4351 | prev = j + 1; | |||
4352 | } | |||
4353 | /* Record the part after the last comma. */ | |||
4354 | add_infile (arg + prev, "*"); | |||
4355 | } | |||
4356 | do_save = false; | |||
4357 | break; | |||
4358 | ||||
4359 | case OPT_Xlinker: | |||
4360 | add_infile (arg, "*"); | |||
4361 | do_save = false; | |||
4362 | break; | |||
4363 | ||||
4364 | case OPT_Xpreprocessor: | |||
4365 | add_preprocessor_option (arg, strlen (arg)); | |||
4366 | do_save = false; | |||
4367 | break; | |||
4368 | ||||
4369 | case OPT_Xassembler: | |||
4370 | add_assembler_option (arg, strlen (arg)); | |||
4371 | do_save = false; | |||
4372 | break; | |||
4373 | ||||
4374 | case OPT_l: | |||
4375 | /* POSIX allows separation of -l and the lib arg; canonicalize | |||
4376 | by concatenating -l with its arg */ | |||
4377 | add_infile (concat ("-l", arg, NULLnullptr), "*"); | |||
4378 | do_save = false; | |||
4379 | break; | |||
4380 | ||||
4381 | case OPT_L: | |||
4382 | /* Similarly, canonicalize -L for linkers that may not accept | |||
4383 | separate arguments. */ | |||
4384 | save_switch (concat ("-L", arg, NULLnullptr), 0, NULLnullptr, validated, true); | |||
4385 | return true; | |||
4386 | ||||
4387 | case OPT_F: | |||
4388 | /* Likewise -F. */ | |||
4389 | save_switch (concat ("-F", arg, NULLnullptr), 0, NULLnullptr, validated, true); | |||
4390 | return true; | |||
4391 | ||||
4392 | case OPT_save_temps: | |||
4393 | if (!save_temps_flag) | |||
4394 | save_temps_flag = SAVE_TEMPS_DUMP; | |||
4395 | validated = true; | |||
4396 | break; | |||
4397 | ||||
4398 | case OPT_save_temps_: | |||
4399 | if (strcmp (arg, "cwd") == 0) | |||
4400 | save_temps_flag = SAVE_TEMPS_CWD; | |||
4401 | else if (strcmp (arg, "obj") == 0 | |||
4402 | || strcmp (arg, "object") == 0) | |||
4403 | save_temps_flag = SAVE_TEMPS_OBJ; | |||
4404 | else | |||
4405 | fatal_error (input_location, "%qs is an unknown %<-save-temps%> option", | |||
4406 | decoded->orig_option_with_args_text); | |||
4407 | save_temps_overrides_dumpdir = true; | |||
4408 | break; | |||
4409 | ||||
4410 | case OPT_dumpdir: | |||
4411 | free (dumpdir); | |||
4412 | dumpdir = xstrdup (arg); | |||
4413 | save_temps_overrides_dumpdir = false; | |||
4414 | break; | |||
4415 | ||||
4416 | case OPT_dumpbase: | |||
4417 | free (dumpbase); | |||
4418 | dumpbase = xstrdup (arg); | |||
4419 | break; | |||
4420 | ||||
4421 | case OPT_dumpbase_ext: | |||
4422 | free (dumpbase_ext); | |||
4423 | dumpbase_ext = xstrdup (arg); | |||
4424 | break; | |||
4425 | ||||
4426 | case OPT_no_canonical_prefixes: | |||
4427 | /* Already handled as a special case, so ignored here. */ | |||
4428 | do_save = false; | |||
4429 | break; | |||
4430 | ||||
4431 | case OPT_pipe: | |||
4432 | validated = true; | |||
4433 | /* These options set the variables specified in common.opt | |||
4434 | automatically, but do need to be saved for spec | |||
4435 | processing. */ | |||
4436 | break; | |||
4437 | ||||
4438 | case OPT_specs_: | |||
4439 | { | |||
4440 | struct user_specs *user = XNEW (struct user_specs)((struct user_specs *) xmalloc (sizeof (struct user_specs))); | |||
4441 | ||||
4442 | user->next = (struct user_specs *) 0; | |||
4443 | user->filename = arg; | |||
4444 | if (user_specs_tail) | |||
4445 | user_specs_tail->next = user; | |||
4446 | else | |||
4447 | user_specs_head = user; | |||
4448 | user_specs_tail = user; | |||
4449 | } | |||
4450 | validated = true; | |||
4451 | break; | |||
4452 | ||||
4453 | case OPT__sysroot_: | |||
4454 | target_system_root = arg; | |||
4455 | target_system_root_changed = 1; | |||
4456 | /* Saving this option is useful to let self-specs decide to | |||
4457 | provide a default one. */ | |||
4458 | do_save = true; | |||
4459 | validated = true; | |||
4460 | break; | |||
4461 | ||||
4462 | case OPT_time_: | |||
4463 | if (report_times_to_file) | |||
4464 | fclose (report_times_to_file); | |||
4465 | report_times_to_file = fopen (arg, "a"); | |||
4466 | do_save = false; | |||
4467 | break; | |||
4468 | ||||
4469 | case OPT____: | |||
4470 | /* "-###" | |||
4471 | This is similar to -v except that there is no execution | |||
4472 | of the commands and the echoed arguments are quoted. It | |||
4473 | is intended for use in shell scripts to capture the | |||
4474 | driver-generated command line. */ | |||
4475 | verbose_only_flag++; | |||
4476 | verbose_flagglobal_options.x_verbose_flag = 1; | |||
4477 | do_save = false; | |||
4478 | break; | |||
4479 | ||||
4480 | case OPT_B: | |||
4481 | { | |||
4482 | size_t len = strlen (arg); | |||
4483 | ||||
4484 | /* Catch the case where the user has forgotten to append a | |||
4485 | directory separator to the path. Note, they may be using | |||
4486 | -B to add an executable name prefix, eg "i386-elf-", in | |||
4487 | order to distinguish between multiple installations of | |||
4488 | GCC in the same directory. Hence we must check to see | |||
4489 | if appending a directory separator actually makes a | |||
4490 | valid directory name. */ | |||
4491 | if (!IS_DIR_SEPARATOR (arg[len - 1])(((arg[len - 1]) == '/') || (((arg[len - 1]) == '\\') && (0))) | |||
4492 | && is_directory (arg, false)) | |||
4493 | { | |||
4494 | char *tmp = XNEWVEC (char, len + 2)((char *) xmalloc (sizeof (char) * (len + 2))); | |||
4495 | strcpy (tmp, arg); | |||
4496 | tmp[len] = DIR_SEPARATOR'/'; | |||
4497 | tmp[++len] = 0; | |||
4498 | arg = tmp; | |||
4499 | } | |||
4500 | ||||
4501 | add_prefix (&exec_prefixes, arg, NULLnullptr, | |||
4502 | PREFIX_PRIORITY_B_OPT, 0, 0); | |||
4503 | add_prefix (&startfile_prefixes, arg, NULLnullptr, | |||
4504 | PREFIX_PRIORITY_B_OPT, 0, 0); | |||
4505 | add_prefix (&include_prefixes, arg, NULLnullptr, | |||
4506 | PREFIX_PRIORITY_B_OPT, 0, 0); | |||
4507 | } | |||
4508 | validated = true; | |||
4509 | break; | |||
4510 | ||||
4511 | case OPT_E: | |||
4512 | have_E = true; | |||
4513 | break; | |||
4514 | ||||
4515 | case OPT_x: | |||
4516 | spec_lang = arg; | |||
4517 | if (!strcmp (spec_lang, "none")) | |||
4518 | /* Suppress the warning if -xnone comes after the last input | |||
4519 | file, because alternate command interfaces like g++ might | |||
4520 | find it useful to place -xnone after each input file. */ | |||
4521 | spec_lang = 0; | |||
4522 | else | |||
4523 | last_language_n_infiles = n_infiles; | |||
4524 | do_save = false; | |||
4525 | break; | |||
4526 | ||||
4527 | case OPT_o: | |||
4528 | have_o = 1; | |||
4529 | #if defined(HAVE_TARGET_EXECUTABLE_SUFFIX) || defined(HAVE_TARGET_OBJECT_SUFFIX) | |||
4530 | arg = convert_filename (arg, ! have_c, 0); | |||
4531 | #endif | |||
4532 | output_file = arg; | |||
4533 | /* On some systems, ld cannot handle "-o" without a space. So | |||
4534 | split the option from its argument. */ | |||
4535 | save_switch ("-o", 1, &arg, validated, true); | |||
4536 | return true; | |||
4537 | ||||
4538 | #ifdef ENABLE_DEFAULT_PIE | |||
4539 | case OPT_pie: | |||
4540 | /* -pie is turned on by default. */ | |||
4541 | #endif | |||
4542 | ||||
4543 | case OPT_static_libgcc: | |||
4544 | case OPT_shared_libgcc: | |||
4545 | case OPT_static_libgfortran: | |||
4546 | case OPT_static_libquadmath: | |||
4547 | case OPT_static_libphobos: | |||
4548 | case OPT_static_libgm2: | |||
4549 | case OPT_static_libstdc__: | |||
4550 | /* These are always valid; gcc.cc itself understands the first two | |||
4551 | gfortranspec.cc understands -static-libgfortran, | |||
4552 | libgfortran.spec handles -static-libquadmath, | |||
4553 | d-spec.cc understands -static-libphobos, | |||
4554 | gm2spec.cc understands -static-libgm2, | |||
4555 | and g++spec.cc understands -static-libstdc++. */ | |||
4556 | validated = true; | |||
4557 | break; | |||
4558 | ||||
4559 | case OPT_fwpa: | |||
4560 | flag_wpaglobal_options.x_flag_wpa = ""; | |||
4561 | break; | |||
4562 | ||||
4563 | case OPT_foffload_options_: | |||
4564 | check_foffload_target_names (arg); | |||
4565 | break; | |||
4566 | ||||
4567 | case OPT_foffload_: | |||
4568 | handle_foffload_option (arg); | |||
4569 | if (arg[0] == '-' || NULLnullptr != strchr (arg, '=')) | |||
4570 | save_switch (concat ("-foffload-options=", arg, NULLnullptr), | |||
4571 | 0, NULLnullptr, validated, true); | |||
4572 | do_save = false; | |||
4573 | break; | |||
4574 | ||||
4575 | default: | |||
4576 | /* Various driver options need no special processing at this | |||
4577 | point, having been handled in a prescan above or being | |||
4578 | handled by specs. */ | |||
4579 | break; | |||
4580 | } | |||
4581 | ||||
4582 | if (do_save) | |||
4583 | save_switch (decoded->canonical_option[0], | |||
4584 | decoded->canonical_option_num_elements - 1, | |||
4585 | &decoded->canonical_option[1], validated, true); | |||
4586 | return true; | |||
4587 | } | |||
4588 | ||||
4589 | /* Return true if F2 is F1 followed by a single suffix, i.e., by a | |||
4590 | period and additional characters other than a period. */ | |||
4591 | ||||
4592 | static inline bool | |||
4593 | adds_single_suffix_p (const char *f2, const char *f1) | |||
4594 | { | |||
4595 | size_t len = strlen (f1); | |||
4596 | ||||
4597 | return (strncmp (f1, f2, len) == 0 | |||
4598 | && f2[len] == '.' | |||
4599 | && strchr (f2 + len + 1, '.') == NULLnullptr); | |||
4600 | } | |||
4601 | ||||
4602 | /* Put the driver's standard set of option handlers in *HANDLERS. */ | |||
4603 | ||||
4604 | static void | |||
4605 | set_option_handlers (struct cl_option_handlers *handlers) | |||
4606 | { | |||
4607 | handlers->unknown_option_callback = driver_unknown_option_callback; | |||
4608 | handlers->wrong_lang_callback = driver_wrong_lang_callback; | |||
4609 | handlers->num_handlers = 3; | |||
4610 | handlers->handlers[0].handler = driver_handle_option; | |||
4611 | handlers->handlers[0].mask = CL_DRIVER(1U << 19); | |||
4612 | handlers->handlers[1].handler = common_handle_option; | |||
4613 | handlers->handlers[1].mask = CL_COMMON(1U << 21); | |||
4614 | handlers->handlers[2].handler = target_handle_option; | |||
4615 | handlers->handlers[2].mask = CL_TARGET(1U << 20); | |||
4616 | } | |||
4617 | ||||
4618 | ||||
4619 | /* Return the index into infiles for the single non-library | |||
4620 | non-lto-wpa input file, -1 if there isn't any, or -2 if there is | |||
4621 | more than one. */ | |||
4622 | static inline int | |||
4623 | single_input_file_index () | |||
4624 | { | |||
4625 | int ret = -1; | |||
4626 | ||||
4627 | for (int i = 0; i < n_infiles; i++) | |||
4628 | { | |||
4629 | if (infiles[i].language | |||
4630 | && (infiles[i].language[0] == '*' | |||
4631 | || (flag_wpaglobal_options.x_flag_wpa | |||
4632 | && strcmp (infiles[i].language, "lto") == 0))) | |||
4633 | continue; | |||
4634 | ||||
4635 | if (ret != -1) | |||
4636 | return -2; | |||
4637 | ||||
4638 | ret = i; | |||
4639 | } | |||
4640 | ||||
4641 | return ret; | |||
4642 | } | |||
4643 | ||||
4644 | /* Create the vector `switches' and its contents. | |||
4645 | Store its length in `n_switches'. */ | |||
4646 | ||||
4647 | static void | |||
4648 | process_command (unsigned int decoded_options_count, | |||
4649 | struct cl_decoded_option *decoded_options) | |||
4650 | { | |||
4651 | const char *temp; | |||
4652 | char *temp1; | |||
4653 | char *tooldir_prefix, *tooldir_prefix2; | |||
4654 | char *(*get_relative_prefix) (const char *, const char *, | |||
4655 | const char *) = NULLnullptr; | |||
4656 | struct cl_option_handlers handlers; | |||
4657 | unsigned int j; | |||
4658 | ||||
4659 | gcc_exec_prefix = env.get ("GCC_EXEC_PREFIX"); | |||
4660 | ||||
4661 | n_switches = 0; | |||
4662 | n_infiles = 0; | |||
4663 | added_libraries = 0; | |||
4664 | ||||
4665 | /* Figure compiler version from version string. */ | |||
4666 | ||||
4667 | compiler_version = temp1 = xstrdup (version_string"13.0.1 20230327 (experimental)"); | |||
4668 | ||||
4669 | for (; *temp1; ++temp1) | |||
4670 | { | |||
4671 | if (*temp1 == ' ') | |||
4672 | { | |||
4673 | *temp1 = '\0'; | |||
4674 | break; | |||
4675 | } | |||
4676 | } | |||
4677 | ||||
4678 | /* Handle any -no-canonical-prefixes flag early, to assign the function | |||
4679 | that builds relative prefixes. This function creates default search | |||
4680 | paths that are needed later in normal option handling. */ | |||
4681 | ||||
4682 | for (j = 1; j < decoded_options_count; j++) | |||
4683 | { | |||
4684 | if (decoded_options[j].opt_index == OPT_no_canonical_prefixes) | |||
4685 | { | |||
4686 | get_relative_prefix = make_relative_prefix_ignore_links; | |||
4687 | break; | |||
4688 | } | |||
4689 | } | |||
4690 | if (! get_relative_prefix) | |||
4691 | get_relative_prefix = make_relative_prefix; | |||
4692 | ||||
4693 | /* Set up the default search paths. If there is no GCC_EXEC_PREFIX, | |||
4694 | see if we can create it from the pathname specified in | |||
4695 | decoded_options[0].arg. */ | |||
4696 | ||||
4697 | gcc_libexec_prefix = standard_libexec_prefix; | |||
4698 | #ifndef VMS | |||
4699 | /* FIXME: make_relative_prefix doesn't yet work for VMS. */ | |||
4700 | if (!gcc_exec_prefix) | |||
4701 | { | |||
4702 | gcc_exec_prefix = get_relative_prefix (decoded_options[0].arg, | |||
4703 | standard_bindir_prefix, | |||
4704 | standard_exec_prefix); | |||
4705 | gcc_libexec_prefix = get_relative_prefix (decoded_options[0].arg, | |||
4706 | standard_bindir_prefix, | |||
4707 | standard_libexec_prefix); | |||
4708 | if (gcc_exec_prefix) | |||
4709 | xputenv (concat ("GCC_EXEC_PREFIX=", gcc_exec_prefix, NULLnullptr)); | |||
4710 | } | |||
4711 | else | |||
4712 | { | |||
4713 | /* make_relative_prefix requires a program name, but | |||
4714 | GCC_EXEC_PREFIX is typically a directory name with a trailing | |||
4715 | / (which is ignored by make_relative_prefix), so append a | |||
4716 | program name. */ | |||
4717 | char *tmp_prefix = concat (gcc_exec_prefix, "gcc", NULLnullptr); | |||
4718 | gcc_libexec_prefix = get_relative_prefix (tmp_prefix, | |||
4719 | standard_exec_prefix, | |||
4720 | standard_libexec_prefix); | |||
4721 | ||||
4722 | /* The path is unrelocated, so fallback to the original setting. */ | |||
4723 | if (!gcc_libexec_prefix) | |||
4724 | gcc_libexec_prefix = standard_libexec_prefix; | |||
4725 | ||||
4726 | free (tmp_prefix); | |||
4727 | } | |||
4728 | #else | |||
4729 | #endif | |||
4730 | /* From this point onward, gcc_exec_prefix is non-null if the toolchain | |||
4731 | is relocated. The toolchain was either relocated using GCC_EXEC_PREFIX | |||
4732 | or an automatically created GCC_EXEC_PREFIX from | |||
4733 | decoded_options[0].arg. */ | |||
4734 | ||||
4735 | /* Do language-specific adjustment/addition of flags. */ | |||
4736 | lang_specific_driver (&decoded_options, &decoded_options_count, | |||
4737 | &added_libraries); | |||
4738 | ||||
4739 | if (gcc_exec_prefix) | |||
4740 | { | |||
4741 | int len = strlen (gcc_exec_prefix); | |||
4742 | ||||
4743 | if (len > (int) sizeof ("/lib/gcc/") - 1 | |||
4744 | && (IS_DIR_SEPARATOR (gcc_exec_prefix[len-1])(((gcc_exec_prefix[len-1]) == '/') || (((gcc_exec_prefix[len- 1]) == '\\') && (0))))) | |||
4745 | { | |||
4746 | temp = gcc_exec_prefix + len - sizeof ("/lib/gcc/") + 1; | |||
4747 | if (IS_DIR_SEPARATOR (*temp)(((*temp) == '/') || (((*temp) == '\\') && (0))) | |||
4748 | && filename_ncmp (temp + 1, "lib", 3) == 0 | |||
4749 | && IS_DIR_SEPARATOR (temp[4])(((temp[4]) == '/') || (((temp[4]) == '\\') && (0))) | |||
4750 | && filename_ncmp (temp + 5, "gcc", 3) == 0) | |||
4751 | len -= sizeof ("/lib/gcc/") - 1; | |||
4752 | } | |||
4753 | ||||
4754 | set_std_prefix (gcc_exec_prefix, len); | |||
4755 | add_prefix (&exec_prefixes, gcc_libexec_prefix, "GCC", | |||
4756 | PREFIX_PRIORITY_LAST, 0, 0); | |||
4757 | add_prefix (&startfile_prefixes, gcc_exec_prefix, "GCC", | |||
4758 | PREFIX_PRIORITY_LAST, 0, 0); | |||
4759 | } | |||
4760 | ||||
4761 | /* COMPILER_PATH and LIBRARY_PATH have values | |||
4762 | that are lists of directory names with colons. */ | |||
4763 | ||||
4764 | temp = env.get ("COMPILER_PATH"); | |||
4765 | if (temp) | |||
4766 | { | |||
4767 | const char *startp, *endp; | |||
4768 | char *nstore = (char *) alloca (strlen (temp) + 3)__builtin_alloca(strlen (temp) + 3); | |||
4769 | ||||
4770 | startp = endp = temp; | |||
4771 | while (1) | |||
4772 | { | |||
4773 | if (*endp == PATH_SEPARATOR':' || *endp == 0) | |||
4774 | { | |||
4775 | strncpy (nstore, startp, endp - startp); | |||
4776 | if (endp == startp) | |||
4777 | strcpy (nstore, concat (".", dir_separator_str, NULLnullptr)); | |||
4778 | else if (!IS_DIR_SEPARATOR (endp[-1])(((endp[-1]) == '/') || (((endp[-1]) == '\\') && (0)) )) | |||
4779 | { | |||
4780 | nstore[endp - startp] = DIR_SEPARATOR'/'; | |||
4781 | nstore[endp - startp + 1] = 0; | |||
4782 | } | |||
4783 | else | |||
4784 | nstore[endp - startp] = 0; | |||
4785 | add_prefix (&exec_prefixes, nstore, 0, | |||
4786 | PREFIX_PRIORITY_LAST, 0, 0); | |||
4787 | add_prefix (&include_prefixes, nstore, 0, | |||
4788 | PREFIX_PRIORITY_LAST, 0, 0); | |||
4789 | if (*endp == 0) | |||
4790 | break; | |||
4791 | endp = startp = endp + 1; | |||
4792 | } | |||
4793 | else | |||
4794 | endp++; | |||
4795 | } | |||
4796 | } | |||
4797 | ||||
4798 | temp = env.get (LIBRARY_PATH_ENV"LIBRARY_PATH"); | |||
4799 | if (temp && *cross_compile == '0') | |||
4800 | { | |||
4801 | const char *startp, *endp; | |||
4802 | char *nstore = (char *) alloca (strlen (temp) + 3)__builtin_alloca(strlen (temp) + 3); | |||
4803 | ||||
4804 | startp = endp = temp; | |||
4805 | while (1) | |||
4806 | { | |||
4807 | if (*endp == PATH_SEPARATOR':' || *endp == 0) | |||
4808 | { | |||
4809 | strncpy (nstore, startp, endp - startp); | |||
4810 | if (endp == startp) | |||
4811 | strcpy (nstore, concat (".", dir_separator_str, NULLnullptr)); | |||
4812 | else if (!IS_DIR_SEPARATOR (endp[-1])(((endp[-1]) == '/') || (((endp[-1]) == '\\') && (0)) )) | |||
4813 | { | |||
4814 | nstore[endp - startp] = DIR_SEPARATOR'/'; | |||
4815 | nstore[endp - startp + 1] = 0; | |||
4816 | } | |||
4817 | else | |||
4818 | nstore[endp - startp] = 0; | |||
4819 | add_prefix (&startfile_prefixes, nstore, NULLnullptr, | |||
4820 | PREFIX_PRIORITY_LAST, 0, 1); | |||
4821 | if (*endp == 0) | |||
4822 | break; | |||
4823 | endp = startp = endp + 1; | |||
4824 | } | |||
4825 | else | |||
4826 | endp++; | |||
4827 | } | |||
4828 | } | |||
4829 | ||||
4830 | /* Use LPATH like LIBRARY_PATH (for the CMU build program). */ | |||
4831 | temp = env.get ("LPATH"); | |||
4832 | if (temp && *cross_compile == '0') | |||
4833 | { | |||
4834 | const char *startp, *endp; | |||
4835 | char *nstore = (char *) alloca (strlen (temp) + 3)__builtin_alloca(strlen (temp) + 3); | |||
4836 | ||||
4837 | startp = endp = temp; | |||
4838 | while (1) | |||
4839 | { | |||
4840 | if (*endp == PATH_SEPARATOR':' || *endp == 0) | |||
4841 | { | |||
4842 | strncpy (nstore, startp, endp - startp); | |||
4843 | if (endp == startp) | |||
4844 | strcpy (nstore, concat (".", dir_separator_str, NULLnullptr)); | |||
4845 | else if (!IS_DIR_SEPARATOR (endp[-1])(((endp[-1]) == '/') || (((endp[-1]) == '\\') && (0)) )) | |||
4846 | { | |||
4847 | nstore[endp - startp] = DIR_SEPARATOR'/'; | |||
4848 | nstore[endp - startp + 1] = 0; | |||
4849 | } | |||
4850 | else | |||
4851 | nstore[endp - startp] = 0; | |||
4852 | add_prefix (&startfile_prefixes, nstore, NULLnullptr, | |||
4853 | PREFIX_PRIORITY_LAST, 0, 1); | |||
4854 | if (*endp == 0) | |||
4855 | break; | |||
4856 | endp = startp = endp + 1; | |||
4857 | } | |||
4858 | else | |||
4859 | endp++; | |||
4860 | } | |||
4861 | } | |||
4862 | ||||
4863 | /* Process the options and store input files and switches in their | |||
4864 | vectors. */ | |||
4865 | ||||
4866 | last_language_n_infiles = -1; | |||
4867 | ||||
4868 | set_option_handlers (&handlers); | |||
4869 | ||||
4870 | for (j = 1; j < decoded_options_count; j++) | |||
4871 | { | |||
4872 | switch (decoded_options[j].opt_index) | |||
4873 | { | |||
4874 | case OPT_S: | |||
4875 | case OPT_c: | |||
4876 | case OPT_E: | |||
4877 | have_c = 1; | |||
4878 | break; | |||
4879 | } | |||
4880 | if (have_c) | |||
4881 | break; | |||
4882 | } | |||
4883 | ||||
4884 | for (j = 1; j < decoded_options_count; j++) | |||
4885 | { | |||
4886 | if (decoded_options[j].opt_index == OPT_SPECIAL_input_file) | |||
4887 | { | |||
4888 | const char *arg = decoded_options[j].arg; | |||
4889 | ||||
4890 | #ifdef HAVE_TARGET_OBJECT_SUFFIX | |||
4891 | arg = convert_filename (arg, 0, access (arg, F_OK0)); | |||
4892 | #endif | |||
4893 | add_infile (arg, spec_lang); | |||
4894 | ||||
4895 | continue; | |||
4896 | } | |||
4897 | ||||
4898 | read_cmdline_option (&global_options, &global_options_set, | |||
4899 | decoded_options + j, UNKNOWN_LOCATION((location_t) 0), | |||
4900 | CL_DRIVER(1U << 19), &handlers, global_dc); | |||
4901 | } | |||
4902 | ||||
4903 | /* If the user didn't specify any, default to all configured offload | |||
4904 | targets. */ | |||
4905 | if (ENABLE_OFFLOADING0 && offload_targets == NULLnullptr) | |||
4906 | { | |||
4907 | handle_foffload_option (OFFLOAD_TARGETS""); | |||
4908 | #if OFFLOAD_DEFAULTED | |||
4909 | offload_targets_default = true; | |||
4910 | #endif | |||
4911 | } | |||
4912 | ||||
4913 | /* Handle -gtoggle as it would later in toplev.cc:process_options to | |||
4914 | make the debug-level-gt spec function work as expected. */ | |||
4915 | if (flag_gtoggleglobal_options.x_flag_gtoggle) | |||
4916 | { | |||
4917 | if (debug_info_levelglobal_options.x_debug_info_level == DINFO_LEVEL_NONE) | |||
4918 | debug_info_levelglobal_options.x_debug_info_level = DINFO_LEVEL_NORMAL; | |||
4919 | else | |||
4920 | debug_info_levelglobal_options.x_debug_info_level = DINFO_LEVEL_NONE; | |||
4921 | } | |||
4922 | ||||
4923 | if (output_file | |||
4924 | && strcmp (output_file, "-") != 0 | |||
4925 | && strcmp (output_file, HOST_BIT_BUCKET"/dev/null") != 0) | |||
4926 | { | |||
4927 | int i; | |||
4928 | for (i = 0; i < n_infiles; i++) | |||
4929 | if ((!infiles[i].language || infiles[i].language[0] != '*') | |||
4930 | && canonical_filename_eq (infiles[i].name, output_file)) | |||
4931 | fatal_error (input_location, | |||
4932 | "input file %qs is the same as output file", | |||
4933 | output_file); | |||
4934 | } | |||
4935 | ||||
4936 | if (output_file != NULLnullptr && output_file[0] == '\0') | |||
4937 | fatal_error (input_location, "output filename may not be empty"); | |||
4938 | ||||
4939 | /* -dumpdir and -save-temps=* both specify the location of aux/dump | |||
4940 | outputs; the one that appears last prevails. When compiling | |||
4941 | multiple sources, an explicit dumpbase (minus -ext) may be | |||
4942 | combined with an explicit or implicit dumpdir, whereas when | |||
4943 | linking, a specified or implied link output name (minus | |||
4944 | extension) may be combined with a prevailing -save-temps=* or an | |||
4945 | otherwise implied dumpdir, but not override a prevailing | |||
4946 | -dumpdir. Primary outputs (e.g., linker output when linking | |||
4947 | without -o, or .i, .s or .o outputs when processing multiple | |||
4948 | inputs with -E, -S or -c, respectively) are NOT affected by these | |||
4949 | -save-temps=/-dump* options, always landing in the current | |||
4950 | directory and with the same basename as the input when an output | |||
4951 | name is not given, but when they're intermediate outputs, they | |||
4952 | are named like other aux outputs, so the options affect their | |||
4953 | location and name. | |||
4954 | ||||
4955 | Here are some examples. There are several more in the | |||
4956 | documentation of -o and -dump*, and some quite exhaustive tests | |||
4957 | in gcc.misc-tests/outputs.exp. | |||
4958 | ||||
4959 | When compiling any number of sources, no -dump* nor | |||
4960 | -save-temps=*, all outputs in cwd without prefix: | |||
4961 | ||||
4962 | # gcc -c b.c -gsplit-dwarf | |||
4963 | -> cc1 [-dumpdir ./] -dumpbase b.c -dumpbase-ext .c # b.o b.dwo | |||
4964 | ||||
4965 | # gcc -c b.c d.c -gsplit-dwarf | |||
4966 | -> cc1 [-dumpdir ./] -dumpbase b.c -dumpbase-ext .c # b.o b.dwo | |||
4967 | && cc1 [-dumpdir ./] -dumpbase d.c -dumpbase-ext .c # d.o d.dwo | |||
4968 | ||||
4969 | When compiling and linking, no -dump* nor -save-temps=*, .o | |||
4970 | outputs are temporary, aux outputs land in the dir of the output, | |||
4971 | prefixed with the basename of the linker output: | |||
4972 | ||||
4973 | # gcc b.c d.c -o ab -gsplit-dwarf | |||
4974 | -> cc1 -dumpdir ab- -dumpbase b.c -dumpbase-ext .c # ab-b.dwo | |||
4975 | && cc1 -dumpdir ab- -dumpbase d.c -dumpbase-ext .c # ab-d.dwo | |||
4976 | && link ... -o ab | |||
4977 | ||||
4978 | # gcc b.c d.c [-o a.out] -gsplit-dwarf | |||
4979 | -> cc1 -dumpdir a- -dumpbase b.c -dumpbase-ext .c # a-b.dwo | |||
4980 | && cc1 -dumpdir a- -dumpbase d.c -dumpbase-ext .c # a-d.dwo | |||
4981 | && link ... [-o a.out] | |||
4982 | ||||
4983 | When compiling and linking, a prevailing -dumpdir fully overrides | |||
4984 | the prefix of aux outputs given by the output name: | |||
4985 | ||||
4986 | # gcc -dumpdir f b.c d.c -gsplit-dwarf [-o [dir/]whatever] | |||
4987 | -> cc1 -dumpdir f -dumpbase b.c -dumpbase-ext .c # fb.dwo | |||
4988 | && cc1 -dumpdir f -dumpbase d.c -dumpbase-ext .c # fd.dwo | |||
4989 | && link ... [-o whatever] | |||
4990 | ||||
4991 | When compiling multiple inputs, an explicit -dumpbase is combined | |||
4992 | with -dumpdir, affecting aux outputs, but not the .o outputs: | |||
4993 | ||||
4994 | # gcc -dumpdir f -dumpbase g- b.c d.c -gsplit-dwarf -c | |||
4995 | -> cc1 -dumpdir fg- -dumpbase b.c -dumpbase-ext .c # b.o fg-b.dwo | |||
4996 | && cc1 -dumpdir fg- -dumpbase d.c -dumpbase-ext .c # d.o fg-d.dwo | |||
4997 | ||||
4998 | When compiling and linking with -save-temps, the .o outputs that | |||
4999 | would have been temporary become aux outputs, so they get | |||
5000 | affected by -dump* flags: | |||
5001 | ||||
5002 | # gcc -dumpdir f -dumpbase g- -save-temps b.c d.c | |||
5003 | -> cc1 -dumpdir fg- -dumpbase b.c -dumpbase-ext .c # fg-b.o | |||
5004 | && cc1 -dumpdir fg- -dumpbase d.c -dumpbase-ext .c # fg-d.o | |||
5005 | && link | |||
5006 | ||||
5007 | If -save-temps=* prevails over -dumpdir, however, the explicit | |||
5008 | -dumpdir is discarded, as if it wasn't there. The basename of | |||
5009 | the implicit linker output, a.out or a.exe, becomes a- as the aux | |||
5010 | output prefix for all compilations: | |||
5011 | ||||
5012 | # gcc [-dumpdir f] -save-temps=cwd b.c d.c | |||
5013 | -> cc1 -dumpdir a- -dumpbase b.c -dumpbase-ext .c # a-b.o | |||
5014 | && cc1 -dumpdir a- -dumpbase d.c -dumpbase-ext .c # a-d.o | |||
5015 | && link | |||
5016 | ||||
5017 | A single -dumpbase, applying to multiple inputs, overrides the | |||
5018 | linker output name, implied or explicit, as the aux output prefix: | |||
5019 | ||||
5020 | # gcc [-dumpdir f] -dumpbase g- -save-temps=cwd b.c d.c | |||
5021 | -> cc1 -dumpdir g- -dumpbase b.c -dumpbase-ext .c # g-b.o | |||
5022 | && cc1 -dumpdir g- -dumpbase d.c -dumpbase-ext .c # g-d.o | |||
5023 | && link | |||
5024 | ||||
5025 | # gcc [-dumpdir f] -dumpbase g- -save-temps=cwd b.c d.c -o dir/h.out | |||
5026 | -> cc1 -dumpdir g- -dumpbase b.c -dumpbase-ext .c # g-b.o | |||
5027 | && cc1 -dumpdir g- -dumpbase d.c -dumpbase-ext .c # g-d.o | |||
5028 | && link -o dir/h.out | |||
5029 | ||||
5030 | Now, if the linker output is NOT overridden as a prefix, but | |||
5031 | -save-temps=* overrides implicit or explicit -dumpdir, the | |||
5032 | effective dump dir combines the dir selected by the -save-temps=* | |||
5033 | option with the basename of the specified or implied link output: | |||
5034 | ||||
5035 | # gcc [-dumpdir f] -save-temps=cwd b.c d.c -o dir/h.out | |||
5036 | -> cc1 -dumpdir h- -dumpbase b.c -dumpbase-ext .c # h-b.o | |||
5037 | && cc1 -dumpdir h- -dumpbase d.c -dumpbase-ext .c # h-d.o | |||
5038 | && link -o dir/h.out | |||
5039 | ||||
5040 | # gcc [-dumpdir f] -save-temps=obj b.c d.c -o dir/h.out | |||
5041 | -> cc1 -dumpdir dir/h- -dumpbase b.c -dumpbase-ext .c # dir/h-b.o | |||
5042 | && cc1 -dumpdir dir/h- -dumpbase d.c -dumpbase-ext .c # dir/h-d.o | |||
5043 | && link -o dir/h.out | |||
5044 | ||||
5045 | But then again, a single -dumpbase applying to multiple inputs | |||
5046 | gets used instead of the linker output basename in the combined | |||
5047 | dumpdir: | |||
5048 | ||||
5049 | # gcc [-dumpdir f] -dumpbase g- -save-temps=obj b.c d.c -o dir/h.out | |||
5050 | -> cc1 -dumpdir dir/g- -dumpbase b.c -dumpbase-ext .c # dir/g-b.o | |||
5051 | && cc1 -dumpdir dir/g- -dumpbase d.c -dumpbase-ext .c # dir/g-d.o | |||
5052 | && link -o dir/h.out | |||
5053 | ||||
5054 | With a single input being compiled, the output basename does NOT | |||
5055 | affect the dumpdir prefix. | |||
5056 | ||||
5057 | # gcc -save-temps=obj b.c -gsplit-dwarf -c -o dir/b.o | |||
5058 | -> cc1 -dumpdir dir/ -dumpbase b.c -dumpbase-ext .c # dir/b.o dir/b.dwo | |||
5059 | ||||
5060 | but when compiling and linking even a single file, it does: | |||
5061 | ||||
5062 | # gcc -save-temps=obj b.c -o dir/h.out | |||
5063 | -> cc1 -dumpdir dir/h- -dumpbase b.c -dumpbase-ext .c # dir/h-b.o | |||
5064 | ||||
5065 | unless an explicit -dumpdir prevails: | |||
5066 | ||||
5067 | # gcc -save-temps[=obj] -dumpdir g- b.c -o dir/h.out | |||
5068 | -> cc1 -dumpdir g- -dumpbase b.c -dumpbase-ext .c # g-b.o | |||
5069 | ||||
5070 | */ | |||
5071 | ||||
5072 | bool explicit_dumpdir = dumpdir; | |||
5073 | ||||
5074 | if ((!save_temps_overrides_dumpdir && explicit_dumpdir) | |||
5075 | || (output_file && not_actual_file_p (output_file))) | |||
5076 | { | |||
5077 | /* Do nothing. */ | |||
5078 | } | |||
5079 | ||||
5080 | /* If -save-temps=obj and -o name, create the prefix to use for %b. | |||
5081 | Otherwise just make -save-temps=obj the same as -save-temps=cwd. */ | |||
5082 | else if (save_temps_flag != SAVE_TEMPS_CWD && output_file != NULLnullptr) | |||
5083 | { | |||
5084 | free (dumpdir); | |||
5085 | dumpdir = NULLnullptr; | |||
5086 | temp = lbasename (output_file); | |||
5087 | if (temp != output_file) | |||
5088 | dumpdir = xstrndup (output_file, | |||
5089 | strlen (output_file) - strlen (temp)); | |||
5090 | } | |||
5091 | else if (dumpdir) | |||
5092 | { | |||
5093 | free (dumpdir); | |||
5094 | dumpdir = NULLnullptr; | |||
5095 | } | |||
5096 | ||||
5097 | if (save_temps_flag) | |||
5098 | save_temps_flag = SAVE_TEMPS_DUMP; | |||
5099 | ||||
5100 | /* If there is any pathname component in an explicit -dumpbase, it | |||
5101 | overrides dumpdir entirely, so discard it right away. Although | |||
5102 | the presence of an explicit -dumpdir matters for the driver, it | |||
5103 | shouldn't matter for other processes, that get all that's needed | |||
5104 | from the -dumpdir and -dumpbase always passed to them. */ | |||
5105 | if (dumpdir && dumpbase && lbasename (dumpbase) != dumpbase) | |||
5106 | { | |||
5107 | free (dumpdir); | |||
5108 | dumpdir = NULLnullptr; | |||
5109 | } | |||
5110 | ||||
5111 | /* Check that dumpbase_ext matches the end of dumpbase, drop it | |||
5112 | otherwise. */ | |||
5113 | if (dumpbase_ext && dumpbase && *dumpbase) | |||
5114 | { | |||
5115 | int lendb = strlen (dumpbase); | |||
5116 | int lendbx = strlen (dumpbase_ext); | |||
5117 | ||||
5118 | /* -dumpbase-ext must be a suffix proper; discard it if it | |||
5119 | matches all of -dumpbase, as that would make for an empty | |||
5120 | basename. */ | |||
5121 | if (lendbx >= lendb | |||
5122 | || strcmp (dumpbase + lendb - lendbx, dumpbase_ext) != 0) | |||
5123 | { | |||
5124 | free (dumpbase_ext); | |||
5125 | dumpbase_ext = NULLnullptr; | |||
5126 | } | |||
5127 | } | |||
5128 | ||||
5129 | /* -dumpbase with multiple sources goes into dumpdir. With a single | |||
5130 | source, it does only if linking and if dumpdir was not explicitly | |||
5131 | specified. */ | |||
5132 | if (dumpbase && *dumpbase | |||
5133 | && (single_input_file_index () == -2 | |||
5134 | || (!have_c && !explicit_dumpdir))) | |||
5135 | { | |||
5136 | char *prefix; | |||
5137 | ||||
5138 | if (dumpbase_ext) | |||
5139 | /* We checked that they match above. */ | |||
5140 | dumpbase[strlen (dumpbase) - strlen (dumpbase_ext)] = '\0'; | |||
5141 | ||||
5142 | if (dumpdir) | |||
5143 | prefix = concat (dumpdir, dumpbase, "-", NULLnullptr); | |||
5144 | else | |||
5145 | prefix = concat (dumpbase, "-", NULLnullptr); | |||
5146 | ||||
5147 | free (dumpdir); | |||
5148 | free (dumpbase); | |||
5149 | free (dumpbase_ext); | |||
5150 | dumpbase = dumpbase_ext = NULLnullptr; | |||
5151 | dumpdir = prefix; | |||
5152 | dumpdir_trailing_dash_added = true; | |||
5153 | } | |||
5154 | ||||
5155 | /* If dumpbase was not brought into dumpdir but we're linking, bring | |||
5156 | output_file into dumpdir unless dumpdir was explicitly specified. | |||
5157 | The test for !explicit_dumpdir is further below, because we want | |||
5158 | to use the obase computation for a ghost outbase, passed to | |||
5159 | GCC_COLLECT_OPTIONS. */ | |||
5160 | else if (!have_c && (!explicit_dumpdir || (dumpbase && !*dumpbase))) | |||
5161 | { | |||
5162 | /* If we get here, we know dumpbase was not specified, or it was | |||
5163 | specified as an empty string. If it was anything else, it | |||
5164 | would have combined with dumpdir above, because the condition | |||
5165 | for dumpbase to be used when present is broader than the | |||
5166 | condition that gets us here. */ | |||
5167 | gcc_assert (!dumpbase || !*dumpbase)((void)(!(!dumpbase || !*dumpbase) ? fancy_abort ("/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/gcc.cc" , 5167, __FUNCTION__), 0 : 0)); | |||
5168 | ||||
5169 | const char *obase; | |||
5170 | char *tofree = NULLnullptr; | |||
5171 | if (!output_file || not_actual_file_p (output_file)) | |||
5172 | obase = "a"; | |||
5173 | else | |||
5174 | { | |||
5175 | obase = lbasename (output_file); | |||
5176 | size_t blen = strlen (obase), xlen; | |||
5177 | /* Drop the suffix if it's dumpbase_ext, if given, | |||
5178 | otherwise .exe or the target executable suffix, or if the | |||
5179 | output was explicitly named a.out, but not otherwise. */ | |||
5180 | if (dumpbase_ext | |||
5181 | ? (blen > (xlen = strlen (dumpbase_ext)) | |||
5182 | && strcmp ((temp = (obase + blen - xlen)), | |||
5183 | dumpbase_ext) == 0) | |||
5184 | : ((temp = strrchr (obase + 1, '.')) | |||
5185 | && (xlen = strlen (temp)) | |||
5186 | && (strcmp (temp, ".exe") == 0 | |||
5187 | #if defined(HAVE_TARGET_EXECUTABLE_SUFFIX) | |||
5188 | || strcmp (temp, TARGET_EXECUTABLE_SUFFIX"") == 0 | |||
5189 | #endif | |||
5190 | || strcmp (obase, "a.out") == 0))) | |||
5191 | { | |||
5192 | tofree = xstrndup (obase, blen - xlen); | |||
5193 | obase = tofree; | |||
5194 | } | |||
5195 | } | |||
5196 | ||||
5197 | /* We wish to save this basename to the -dumpdir passed through | |||
5198 | GCC_COLLECT_OPTIONS within maybe_run_linker, for e.g. LTO, | |||
5199 | but we do NOT wish to add it to e.g. %b, so we keep | |||
5200 | outbase_length as zero. */ | |||
5201 | gcc_assert (!outbase)((void)(!(!outbase) ? fancy_abort ("/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/gcc.cc" , 5201, __FUNCTION__), 0 : 0)); | |||
5202 | outbase_length = 0; | |||
5203 | ||||
5204 | /* If we're building [dir1/]foo[.exe] out of a single input | |||
5205 | [dir2/]foo.c that shares the same basename, dump to | |||
5206 | [dir2/]foo.c.* rather than duplicating the basename into | |||
5207 | [dir2/]foo-foo.c.*. */ | |||
5208 | int idxin; | |||
5209 | if (dumpbase | |||
5210 | || ((idxin = single_input_file_index ()) >= 0 | |||
5211 | && adds_single_suffix_p (lbasename (infiles[idxin].name), | |||
5212 | obase))) | |||
5213 | { | |||
5214 | if (obase == tofree) | |||
5215 | outbase = tofree; | |||
5216 | else | |||
5217 | { | |||
5218 | outbase = xstrdup (obase); | |||
5219 | free (tofree); | |||
5220 | } | |||
5221 | obase = tofree = NULLnullptr; | |||
5222 | } | |||
5223 | else | |||
5224 | { | |||
5225 | if (dumpdir) | |||
5226 | { | |||
5227 | char *p = concat (dumpdir, obase, "-", NULLnullptr); | |||
5228 | free (dumpdir); | |||
5229 | dumpdir = p; | |||
5230 | } | |||
5231 | else | |||
5232 | dumpdir = concat (obase, "-", NULLnullptr); | |||
5233 | ||||
5234 | dumpdir_trailing_dash_added = true; | |||
5235 | ||||
5236 | free (tofree); | |||
5237 | obase = tofree = NULLnullptr; | |||
5238 | } | |||
5239 | ||||
5240 | if (!explicit_dumpdir || dumpbase) | |||
5241 | { | |||
5242 | /* Absent -dumpbase and present -dumpbase-ext have been applied | |||
5243 | to the linker output name, so compute fresh defaults for each | |||
5244 | compilation. */ | |||
5245 | free (dumpbase_ext); | |||
5246 | dumpbase_ext = NULLnullptr; | |||
5247 | } | |||
5248 | } | |||
5249 | ||||
5250 | /* Now, if we're compiling, or if we haven't used the dumpbase | |||
5251 | above, then outbase (%B) is derived from dumpbase, if given, or | |||
5252 | from the output name, given or implied. We can't precompute | |||
5253 | implied output names, but that's ok, since they're derived from | |||
5254 | input names. Just make sure we skip this if dumpbase is the | |||
5255 | empty string: we want to use input names then, so don't set | |||
5256 | outbase. */ | |||
5257 | if ((dumpbase || have_c) | |||
5258 | && !(dumpbase && !*dumpbase)) | |||
5259 | { | |||
5260 | gcc_assert (!outbase)((void)(!(!outbase) ? fancy_abort ("/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/gcc.cc" , 5260, __FUNCTION__), 0 : 0)); | |||
5261 | ||||
5262 | if (dumpbase) | |||
5263 | { | |||
5264 | gcc_assert (single_input_file_index () != -2)((void)(!(single_input_file_index () != -2) ? fancy_abort ("/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/gcc.cc" , 5264, __FUNCTION__), 0 : 0)); | |||
5265 | /* We do not want lbasename here; dumpbase with dirnames | |||
5266 | overrides dumpdir entirely, even if dumpdir is | |||
5267 | specified. */ | |||
5268 | if (dumpbase_ext) | |||
5269 | /* We've already checked above that the suffix matches. */ | |||
5270 | outbase = xstrndup (dumpbase, | |||
5271 | strlen (dumpbase) - strlen (dumpbase_ext)); | |||
5272 | else | |||
5273 | outbase = xstrdup (dumpbase); | |||
5274 | } | |||
5275 | else if (output_file && !not_actual_file_p (output_file)) | |||
5276 | { | |||
5277 | outbase = xstrdup (lbasename (output_file)); | |||
5278 | char *p = strrchr (outbase + 1, '.'); | |||
5279 | if (p) | |||
5280 | *p = '\0'; | |||
5281 | } | |||
5282 | ||||
5283 | if (outbase) | |||
5284 | outbase_length = strlen (outbase); | |||
5285 | } | |||
5286 | ||||
5287 | /* If there is any pathname component in an explicit -dumpbase, do | |||
5288 | not use dumpdir, but retain it to pass it on to the compiler. */ | |||
5289 | if (dumpdir) | |||
5290 | dumpdir_length = strlen (dumpdir); | |||
5291 | else | |||
5292 | dumpdir_length = 0; | |||
5293 | ||||
5294 | /* Check that dumpbase_ext, if still present, still matches the end | |||
5295 | of dumpbase, if present, and drop it otherwise. We only retained | |||
5296 | it above when dumpbase was absent to maybe use it to drop the | |||
5297 | extension from output_name before combining it with dumpdir. We | |||
5298 | won't deal with -dumpbase-ext when -dumpbase is not explicitly | |||
5299 | given, even if just to activate backward-compatible dumpbase: | |||
5300 | dropping it on the floor is correct, expected and documented | |||
5301 | behavior. Attempting to deal with a -dumpbase-ext that might | |||
5302 | match the end of some input filename, or of the combination of | |||
5303 | the output basename with the suffix of the input filename, | |||
5304 | possible with an intermediate .gk extension for -fcompare-debug, | |||
5305 | is just calling for trouble. */ | |||
5306 | if (dumpbase_ext) | |||
5307 | { | |||
5308 | if (!dumpbase || !*dumpbase) | |||
5309 | { | |||
5310 | free (dumpbase_ext); | |||
5311 | dumpbase_ext = NULLnullptr; | |||