Mercurial > hg > CbC > CbC_gcc
comparison gcc/gcc.c @ 69:1b10fe6932e1
merge 69
author | Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Sun, 21 Aug 2011 07:53:12 +0900 |
parents | 326d9e06c2e3 f6334be47118 |
children | b81903832de2 |
comparison
equal
deleted
inserted
replaced
66:b362627d71ba | 69:1b10fe6932e1 |
---|---|
1 /* Compiler driver program that can handle many languages. | 1 /* Compiler driver program that can handle many languages. |
2 Copyright (C) 1987, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998, | 2 Copyright (C) 1987, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998, |
3 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 | 3 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, |
4 2010, 2011 | |
4 Free Software Foundation, Inc. | 5 Free Software Foundation, Inc. |
5 | 6 |
6 This file is part of GCC. | 7 This file is part of GCC. |
7 | 8 |
8 GCC is free software; you can redistribute it and/or modify it under | 9 GCC is free software; you can redistribute it and/or modify it under |
27 | 28 |
28 CC recognizes how to compile each input file by suffixes in the file names. | 29 CC recognizes how to compile each input file by suffixes in the file names. |
29 Once it knows which kind of compilation to perform, the procedure for | 30 Once it knows which kind of compilation to perform, the procedure for |
30 compilation is specified by a string called a "spec". */ | 31 compilation is specified by a string called a "spec". */ |
31 | 32 |
32 /* A Short Introduction to Adding a Command-Line Option. | |
33 | |
34 Before adding a command-line option, consider if it is really | |
35 necessary. Each additional command-line option adds complexity and | |
36 is difficult to remove in subsequent versions. | |
37 | |
38 In the following, consider adding the command-line argument | |
39 `--bar'. | |
40 | |
41 1. Each command-line option is specified in the specs file. The | |
42 notation is described below in the comment entitled "The Specs | |
43 Language". Read it. | |
44 | |
45 2. In this file, add an entry to "option_map" equating the long | |
46 `--' argument version and any shorter, single letter version. Read | |
47 the comments in the declaration of "struct option_map" for an | |
48 explanation. Do not omit the first `-'. | |
49 | |
50 3. Look in the "specs" file to determine which program or option | |
51 list should be given the argument, e.g., "cc1_options". Add the | |
52 appropriate syntax for the shorter option version to the | |
53 corresponding "const char *" entry in this file. Omit the first | |
54 `-' from the option. For example, use `-bar', rather than `--bar'. | |
55 | |
56 4. If the argument takes an argument, e.g., `--baz argument1', | |
57 modify either DEFAULT_SWITCH_TAKES_ARG or | |
58 DEFAULT_WORD_SWITCH_TAKES_ARG in gcc.h. Omit the first `-' | |
59 from `--baz'. | |
60 | |
61 5. Document the option in this file's display_help(). If the | |
62 option is passed to a subprogram, modify its corresponding | |
63 function, e.g., cppinit.c:print_help() or toplev.c:display_help(), | |
64 instead. | |
65 | |
66 6. Compile and test. Make sure that your new specs file is being | |
67 read. For example, use a debugger to investigate the value of | |
68 "specs_file" in main(). */ | |
69 | |
70 #include "config.h" | 33 #include "config.h" |
71 #include "system.h" | 34 #include "system.h" |
72 #include "coretypes.h" | 35 #include "coretypes.h" |
73 #include "multilib.h" /* before tm.h */ | 36 #include "multilib.h" /* before tm.h */ |
74 #include "tm.h" | 37 #include "tm.h" |
75 #include <signal.h> | |
76 #if ! defined( SIGCHLD ) && defined( SIGCLD ) | |
77 # define SIGCHLD SIGCLD | |
78 #endif | |
79 #include "xregex.h" | 38 #include "xregex.h" |
80 #include "obstack.h" | 39 #include "obstack.h" |
81 #include "intl.h" | 40 #include "intl.h" |
82 #include "prefix.h" | 41 #include "prefix.h" |
83 #include "gcc.h" | 42 #include "gcc.h" |
43 #include "diagnostic.h" | |
84 #include "flags.h" | 44 #include "flags.h" |
85 #include "opts.h" | 45 #include "opts.h" |
86 | 46 #include "vec.h" |
87 #ifdef HAVE_MMAP_FILE | |
88 # include <sys/mman.h> | |
89 # ifdef HAVE_MINCORE | |
90 /* This is on Solaris. */ | |
91 # include <sys/types.h> | |
92 # endif | |
93 #endif | |
94 | |
95 #ifndef MAP_FAILED | |
96 # define MAP_FAILED ((void *)-1) | |
97 #endif | |
98 | 47 |
99 /* By default there is no special suffix for target executables. */ | 48 /* By default there is no special suffix for target executables. */ |
100 /* FIXME: when autoconf is fixed, remove the host check - dj */ | 49 /* FIXME: when autoconf is fixed, remove the host check - dj */ |
101 #if defined(TARGET_EXECUTABLE_SUFFIX) && defined(HOST_EXECUTABLE_SUFFIX) | 50 #if defined(TARGET_EXECUTABLE_SUFFIX) && defined(HOST_EXECUTABLE_SUFFIX) |
102 #define HAVE_TARGET_EXECUTABLE_SUFFIX | 51 #define HAVE_TARGET_EXECUTABLE_SUFFIX |
121 /* Most every one is fine with LIBRARY_PATH. For some, it conflicts. */ | 70 /* Most every one is fine with LIBRARY_PATH. For some, it conflicts. */ |
122 #ifndef LIBRARY_PATH_ENV | 71 #ifndef LIBRARY_PATH_ENV |
123 #define LIBRARY_PATH_ENV "LIBRARY_PATH" | 72 #define LIBRARY_PATH_ENV "LIBRARY_PATH" |
124 #endif | 73 #endif |
125 | 74 |
126 #ifndef HAVE_KILL | |
127 #define kill(p,s) raise(s) | |
128 #endif | |
129 | |
130 /* If a stage of compilation returns an exit status >= 1, | 75 /* If a stage of compilation returns an exit status >= 1, |
131 compilation of that file ceases. */ | 76 compilation of that file ceases. */ |
132 | 77 |
133 #define MIN_FATAL_STATUS 1 | 78 #define MIN_FATAL_STATUS 1 |
134 | 79 |
136 int is_cpp_driver; | 81 int is_cpp_driver; |
137 | 82 |
138 /* Flag set to nonzero if an @file argument has been supplied to gcc. */ | 83 /* Flag set to nonzero if an @file argument has been supplied to gcc. */ |
139 static bool at_file_supplied; | 84 static bool at_file_supplied; |
140 | 85 |
141 /* Flag saying to pass the greatest exit code returned by a sub-process | |
142 to the calling program. */ | |
143 static int pass_exit_codes; | |
144 | |
145 /* Definition of string containing the arguments given to configure. */ | 86 /* Definition of string containing the arguments given to configure. */ |
146 #include "configargs.h" | 87 #include "configargs.h" |
147 | 88 |
148 /* Flag saying to print the directories gcc will search through looking for | |
149 programs, libraries, etc. */ | |
150 | |
151 static int print_search_dirs; | |
152 | |
153 /* Flag saying to print the full filename of this file | |
154 as found through our usual search mechanism. */ | |
155 | |
156 static const char *print_file_name = NULL; | |
157 | |
158 /* As print_file_name, but search for executable file. */ | |
159 | |
160 static const char *print_prog_name = NULL; | |
161 | |
162 /* Flag saying to print the relative path we'd use to | |
163 find libgcc.a given the current compiler flags. */ | |
164 | |
165 static int print_multi_directory; | |
166 | |
167 static int print_sysroot; | |
168 | |
169 /* Flag saying to print the relative path we'd use to | |
170 find OS libraries given the current compiler flags. */ | |
171 | |
172 static int print_multi_os_directory; | |
173 | |
174 /* Flag saying to print the list of subdirectories and | |
175 compiler flags used to select them in a standard form. */ | |
176 | |
177 static int print_multi_lib; | |
178 | |
179 /* Flag saying to print the command line options understood by gcc and its | 89 /* Flag saying to print the command line options understood by gcc and its |
180 sub-processes. */ | 90 sub-processes. */ |
181 | 91 |
182 static int print_help_list; | 92 static int print_help_list; |
183 | 93 |
184 /* Flag saying to print the version of gcc and its sub-processes. */ | 94 /* Flag saying to print the version of gcc and its sub-processes. */ |
185 | 95 |
186 static int print_version; | 96 static int print_version; |
187 | |
188 /* Flag saying to print the sysroot suffix used for searching for | |
189 headers. */ | |
190 | |
191 static int print_sysroot_headers_suffix; | |
192 | |
193 /* Flag indicating whether we should print the command and arguments */ | |
194 | |
195 static int verbose_flag; | |
196 | 97 |
197 /* Flag indicating whether we should ONLY print the command and | 98 /* Flag indicating whether we should ONLY print the command and |
198 arguments (like verbose_flag) without executing the command. | 99 arguments (like verbose_flag) without executing the command. |
199 Displayed arguments are quoted so that the generated command | 100 Displayed arguments are quoted so that the generated command |
200 line is suitable for execution. This is intended for use in | 101 line is suitable for execution. This is intended for use in |
203 | 104 |
204 /* Flag indicating how to print command line options of sub-processes. */ | 105 /* Flag indicating how to print command line options of sub-processes. */ |
205 | 106 |
206 static int print_subprocess_help; | 107 static int print_subprocess_help; |
207 | 108 |
208 /* Flag indicating whether we should report subprocess execution times | |
209 (if this is supported by the system - see pexecute.c). */ | |
210 | |
211 static int report_times; | |
212 | |
213 /* Whether we should report subprocess execution times to a file. */ | 109 /* Whether we should report subprocess execution times to a file. */ |
214 | 110 |
215 FILE *report_times_to_file = NULL; | 111 FILE *report_times_to_file = NULL; |
216 | 112 |
217 /* Nonzero means place this string before uses of /, so that include | 113 /* Nonzero means place this string before uses of /, so that include |
246 | 142 |
247 /* Output file to use to get the object directory for -save-temps=obj */ | 143 /* Output file to use to get the object directory for -save-temps=obj */ |
248 static char *save_temps_prefix = 0; | 144 static char *save_temps_prefix = 0; |
249 static size_t save_temps_length = 0; | 145 static size_t save_temps_length = 0; |
250 | 146 |
251 /* Nonzero means pass multiple source files to the compiler at one time. */ | |
252 | |
253 static int combine_flag = 0; | |
254 | |
255 /* Nonzero means use pipes to communicate between subprocesses. | |
256 Overridden by either of the above two flags. */ | |
257 | |
258 static int use_pipes; | |
259 | |
260 /* The compiler version. */ | 147 /* The compiler version. */ |
261 | 148 |
262 static const char *compiler_version; | 149 static const char *compiler_version; |
263 | 150 |
264 /* The target version specified with -V */ | 151 /* The target version. */ |
265 | 152 |
266 static const char *const spec_version = DEFAULT_TARGET_VERSION; | 153 static const char *const spec_version = DEFAULT_TARGET_VERSION; |
267 | 154 |
268 /* The target machine specified with -b. */ | 155 /* The target machine. */ |
269 | 156 |
270 static const char *spec_machine = DEFAULT_TARGET_MACHINE; | 157 static const char *spec_machine = DEFAULT_TARGET_MACHINE; |
271 | 158 |
272 /* Nonzero if cross-compiling. | 159 /* Nonzero if cross-compiling. |
273 When -b is used, the value comes from the `specs' file. */ | 160 When -b is used, the value comes from the `specs' file. */ |
276 static const char *cross_compile = "1"; | 163 static const char *cross_compile = "1"; |
277 #else | 164 #else |
278 static const char *cross_compile = "0"; | 165 static const char *cross_compile = "0"; |
279 #endif | 166 #endif |
280 | 167 |
281 #ifdef MODIFY_TARGET_NAME | |
282 | |
283 /* Information on how to alter the target name based on a command-line | |
284 switch. The only case we support now is simply appending or deleting a | |
285 string to or from the end of the first part of the configuration name. */ | |
286 | |
287 enum add_del {ADD, DELETE}; | |
288 | |
289 static const struct modify_target | |
290 { | |
291 const char *const sw; | |
292 const enum add_del add_del; | |
293 const char *const str; | |
294 } | |
295 modify_target[] = MODIFY_TARGET_NAME; | |
296 #endif | |
297 | |
298 /* The number of errors that have occurred; the link phase will not be | |
299 run if this is nonzero. */ | |
300 static int error_count = 0; | |
301 | |
302 /* Greatest exit code of sub-processes that has been encountered up to | 168 /* Greatest exit code of sub-processes that has been encountered up to |
303 now. */ | 169 now. */ |
304 static int greatest_status = 1; | 170 static int greatest_status = 1; |
305 | 171 |
306 /* This is the obstack which we use to allocate many strings. */ | 172 /* This is the obstack which we use to allocate many strings. */ |
311 collect2 that describes all of the relevant switches of what to | 177 collect2 that describes all of the relevant switches of what to |
312 pass the compiler in building the list of pointers to constructors | 178 pass the compiler in building the list of pointers to constructors |
313 and destructors. */ | 179 and destructors. */ |
314 | 180 |
315 static struct obstack collect_obstack; | 181 static struct obstack collect_obstack; |
316 | |
317 /* This is a list of a wrapper program and its arguments. | |
318 e.g. wrapper_string of "strace,-c" | |
319 will cause all programs to run as | |
320 strace -c program arguments | |
321 instead of just | |
322 program arguments */ | |
323 static const char *wrapper_string; | |
324 | 182 |
325 /* Forward declaration for prototypes. */ | 183 /* Forward declaration for prototypes. */ |
326 struct path_prefix; | 184 struct path_prefix; |
327 struct prefix_list; | 185 struct prefix_list; |
328 | 186 |
342 static char *find_a_file (const struct path_prefix *, const char *, int, bool); | 200 static char *find_a_file (const struct path_prefix *, const char *, int, bool); |
343 static void add_prefix (struct path_prefix *, const char *, const char *, | 201 static void add_prefix (struct path_prefix *, const char *, const char *, |
344 int, int, int); | 202 int, int, int); |
345 static void add_sysrooted_prefix (struct path_prefix *, const char *, | 203 static void add_sysrooted_prefix (struct path_prefix *, const char *, |
346 const char *, int, int, int); | 204 const char *, int, int, int); |
347 static void translate_options (int *, const char *const **); | |
348 static char *skip_whitespace (char *); | 205 static char *skip_whitespace (char *); |
349 static void delete_if_ordinary (const char *); | 206 static void delete_if_ordinary (const char *); |
350 static void delete_temp_files (void); | 207 static void delete_temp_files (void); |
351 static void delete_failure_queue (void); | 208 static void delete_failure_queue (void); |
352 static void clear_failure_queue (void); | 209 static void clear_failure_queue (void); |
375 static int used_arg (const char *, int); | 232 static int used_arg (const char *, int); |
376 static int default_arg (const char *, int); | 233 static int default_arg (const char *, int); |
377 static void set_multilib_dir (void); | 234 static void set_multilib_dir (void); |
378 static void print_multilib_info (void); | 235 static void print_multilib_info (void); |
379 static void perror_with_name (const char *); | 236 static void perror_with_name (const char *); |
380 static void fatal_ice (const char *, ...) ATTRIBUTE_PRINTF_1 ATTRIBUTE_NORETURN; | |
381 static void notice (const char *, ...) ATTRIBUTE_PRINTF_1; | |
382 static void display_help (void); | 237 static void display_help (void); |
383 static void add_preprocessor_option (const char *, int); | 238 static void add_preprocessor_option (const char *, int); |
384 static void add_assembler_option (const char *, int); | 239 static void add_assembler_option (const char *, int); |
385 static void add_linker_option (const char *, int); | 240 static void add_linker_option (const char *, int); |
386 static void process_command (int, const char **); | 241 static void process_command (unsigned int, struct cl_decoded_option *); |
387 static int execute (void); | 242 static int execute (void); |
388 static void alloc_args (void); | 243 static void alloc_args (void); |
389 static void clear_args (void); | 244 static void clear_args (void); |
390 static void fatal_error (int); | 245 static void fatal_signal (int); |
391 #if defined(ENABLE_SHARED_LIBGCC) && !defined(REAL_LIBGCC_SPEC) | 246 #if defined(ENABLE_SHARED_LIBGCC) && !defined(REAL_LIBGCC_SPEC) |
392 static void init_gcc_specs (struct obstack *, const char *, const char *, | 247 static void init_gcc_specs (struct obstack *, const char *, const char *, |
393 const char *); | 248 const char *); |
394 #endif | 249 #endif |
395 #if defined(HAVE_TARGET_OBJECT_SUFFIX) || defined(HAVE_TARGET_EXECUTABLE_SUFFIX) | 250 #if defined(HAVE_TARGET_OBJECT_SUFFIX) || defined(HAVE_TARGET_EXECUTABLE_SUFFIX) |
398 | 253 |
399 static const char *getenv_spec_function (int, const char **); | 254 static const char *getenv_spec_function (int, const char **); |
400 static const char *if_exists_spec_function (int, const char **); | 255 static const char *if_exists_spec_function (int, const char **); |
401 static const char *if_exists_else_spec_function (int, const char **); | 256 static const char *if_exists_else_spec_function (int, const char **); |
402 static const char *replace_outfile_spec_function (int, const char **); | 257 static const char *replace_outfile_spec_function (int, const char **); |
258 static const char *remove_outfile_spec_function (int, const char **); | |
403 static const char *version_compare_spec_function (int, const char **); | 259 static const char *version_compare_spec_function (int, const char **); |
404 static const char *include_spec_function (int, const char **); | 260 static const char *include_spec_function (int, const char **); |
261 static const char *find_file_spec_function (int, const char **); | |
262 static const char *find_plugindir_spec_function (int, const char **); | |
405 static const char *print_asm_header_spec_function (int, const char **); | 263 static const char *print_asm_header_spec_function (int, const char **); |
406 static const char *compare_debug_dump_opt_spec_function (int, const char **); | 264 static const char *compare_debug_dump_opt_spec_function (int, const char **); |
407 static const char *compare_debug_self_opt_spec_function (int, const char **); | 265 static const char *compare_debug_self_opt_spec_function (int, const char **); |
408 static const char *compare_debug_auxbase_opt_spec_function (int, const char **); | 266 static const char *compare_debug_auxbase_opt_spec_function (int, const char **); |
267 static const char *pass_through_libs_spec_func (int, const char **); | |
409 | 268 |
410 /* The Specs Language | 269 /* The Specs Language |
411 | 270 |
412 Specs are strings containing lines, each of which (if not blank) | 271 Specs are strings containing lines, each of which (if not blank) |
413 is made up of a program name, and arguments separated by spaces. | 272 is made up of a program name, and arguments separated by spaces. |
529 a single space. | 388 a single space. |
530 %<S remove all occurrences of -S from the command line. | 389 %<S remove all occurrences of -S from the command line. |
531 Note - this command is position dependent. % commands in the | 390 Note - this command is position dependent. % commands in the |
532 spec string before this one will see -S, % commands in the | 391 spec string before this one will see -S, % commands in the |
533 spec string after this one will not. | 392 spec string after this one will not. |
393 %>S Similar to "%<S", but keep it in the GCC command line. | |
534 %<S* remove all occurrences of all switches beginning with -S from the | 394 %<S* remove all occurrences of all switches beginning with -S from the |
535 command line. | 395 command line. |
536 %:function(args) | 396 %:function(args) |
537 Call the named function FUNCTION, passing it ARGS. ARGS is | 397 Call the named function FUNCTION, passing it ARGS. ARGS is |
538 first processed as a nested spec string, then split into an | 398 first processed as a nested spec string, then split into an |
662 #endif | 522 #endif |
663 #ifndef MFLIB_SPEC | 523 #ifndef MFLIB_SPEC |
664 #define MFLIB_SPEC "%{fmudflap|fmudflapth: -export-dynamic}" | 524 #define MFLIB_SPEC "%{fmudflap|fmudflapth: -export-dynamic}" |
665 #endif | 525 #endif |
666 | 526 |
527 /* When using -fsplit-stack we need to wrap pthread_create, in order | |
528 to initialize the stack guard. We always use wrapping, rather than | |
529 shared library ordering, and we keep the wrapper function in | |
530 libgcc. This is not yet a real spec, though it could become one; | |
531 it is currently just stuffed into LINK_SPEC. FIXME: This wrapping | |
532 only works with GNU ld and gold. FIXME: This is incompatible with | |
533 -fmudflap when linking statically, which wants to do its own | |
534 wrapping. */ | |
535 #define STACK_SPLIT_SPEC " %{fsplit-stack: --wrap=pthread_create}" | |
536 | |
667 /* config.h can define LIBGCC_SPEC to override how and when libgcc.a is | 537 /* config.h can define LIBGCC_SPEC to override how and when libgcc.a is |
668 included. */ | 538 included. */ |
669 #ifndef LIBGCC_SPEC | 539 #ifndef LIBGCC_SPEC |
670 #if defined(REAL_LIBGCC_SPEC) | 540 #if defined(REAL_LIBGCC_SPEC) |
671 #define LIBGCC_SPEC REAL_LIBGCC_SPEC | 541 #define LIBGCC_SPEC REAL_LIBGCC_SPEC |
679 | 549 |
680 /* config.h can define STARTFILE_SPEC to override the default crt0 files. */ | 550 /* config.h can define STARTFILE_SPEC to override the default crt0 files. */ |
681 #ifndef STARTFILE_SPEC | 551 #ifndef STARTFILE_SPEC |
682 #define STARTFILE_SPEC \ | 552 #define STARTFILE_SPEC \ |
683 "%{!shared:%{pg:gcrt0%O%s}%{!pg:%{p:mcrt0%O%s}%{!p:crt0%O%s}}}" | 553 "%{!shared:%{pg:gcrt0%O%s}%{!pg:%{p:mcrt0%O%s}%{!p:crt0%O%s}}}" |
684 #endif | |
685 | |
686 /* config.h can define SWITCHES_NEED_SPACES to control which options | |
687 require spaces between the option and the argument. | |
688 | |
689 We define SWITCHES_NEED_SPACES to include "o" by default. This | |
690 causes "-ofoo.o" to be split into "-o foo.o" during the initial | |
691 processing of the command-line, before being seen by the specs | |
692 machinery. This makes sure we record "foo.o" as the temporary file | |
693 to be deleted in the case of error, rather than "-ofoo.o". */ | |
694 #ifndef SWITCHES_NEED_SPACES | |
695 #define SWITCHES_NEED_SPACES "o" | |
696 #endif | 554 #endif |
697 | 555 |
698 /* config.h can define ENDFILE_SPEC to override the default crtn files. */ | 556 /* config.h can define ENDFILE_SPEC to override the default crtn files. */ |
699 #ifndef ENDFILE_SPEC | 557 #ifndef ENDFILE_SPEC |
700 #define ENDFILE_SPEC "" | 558 #define ENDFILE_SPEC "" |
761 # if defined(HAVE_LD_BUILDID) && defined(ENABLE_LD_BUILDID) | 619 # if defined(HAVE_LD_BUILDID) && defined(ENABLE_LD_BUILDID) |
762 # define LINK_BUILDID_SPEC "%{!r:--build-id} " | 620 # define LINK_BUILDID_SPEC "%{!r:--build-id} " |
763 # endif | 621 # endif |
764 #endif | 622 #endif |
765 | 623 |
624 /* Conditional to test whether plugin is used or not. | |
625 FIXME: For slim LTO we will need to enable plugin unconditionally. This | |
626 still cause problems with PLUGIN_LD != LD and when plugin is built but | |
627 not useable. For GCC 4.6 we don't support slim LTO and thus we can enable | |
628 plugin only when LTO is enabled. We still honor explicit | |
629 -fuse-linker-plugin. */ | |
630 #ifdef HAVE_LTO_PLUGIN | |
631 #define PLUGIN_COND "!fno-use-linker-plugin:%{flto|flto=*|fuse-linker-plugin" | |
632 #define PLUGIN_COND_CLOSE "}" | |
633 #else | |
634 #define PLUGIN_COND "fuse-linker-plugin" | |
635 #define PLUGIN_COND_CLOSE "" | |
636 #endif | |
637 | |
766 | 638 |
767 /* -u* was put back because both BSD and SysV seem to support it. */ | 639 /* -u* was put back because both BSD and SysV seem to support it. */ |
768 /* %{static:} simply prevents an error message if the target machine | 640 /* %{static:} simply prevents an error message if the target machine |
769 doesn't handle -static. */ | 641 doesn't handle -static. */ |
770 /* We want %{T*} after %{L*} and %D so that it can be used to specify linker | 642 /* We want %{T*} after %{L*} and %D so that it can be used to specify linker |
771 scripts which exist in user specified directories, or in standard | 643 scripts which exist in user specified directories, or in standard |
772 directories. */ | 644 directories. */ |
773 /* We pass any -flto and -fwhopr flags on to the linker, which is expected | 645 /* We pass any -flto flags on to the linker, which is expected |
774 to understand them. In practice, this means it had better be collect2. */ | 646 to understand them. In practice, this means it had better be collect2. */ |
647 /* %{e*} includes -export-dynamic; see comment in common.opt. */ | |
775 #ifndef LINK_COMMAND_SPEC | 648 #ifndef LINK_COMMAND_SPEC |
776 #define LINK_COMMAND_SPEC "\ | 649 #define LINK_COMMAND_SPEC "\ |
777 %{!fsyntax-only:%{!c:%{!M:%{!MM:%{!E:%{!S:\ | 650 %{!fsyntax-only:%{!c:%{!M:%{!MM:%{!E:%{!S:\ |
778 %(linker) \ | 651 %(linker) \ |
779 %{fuse-linker-plugin: \ | 652 %{"PLUGIN_COND": \ |
780 -plugin %(linker_plugin_file) \ | 653 -plugin %(linker_plugin_file) \ |
781 -plugin-opt=%(lto_wrapper) \ | 654 -plugin-opt=%(lto_wrapper) \ |
782 -plugin-opt=%(lto_gcc) \ | 655 -plugin-opt=-fresolution=%u.res \ |
783 %{static|static-libgcc:-plugin-opt=-pass-through=%(lto_libgcc)} \ | 656 %{!nostdlib:%{!nodefaultlibs:%:pass-through-libs(%(link_gcc_c_sequence))}} \ |
784 %{static:-plugin-opt=-pass-through=-lc} \ | 657 }"PLUGIN_COND_CLOSE" \ |
785 %{O*:-plugin-opt=-O%*} \ | 658 %{flto|flto=*:%<fcompare-debug*} \ |
786 %{w:-plugin-opt=-w} \ | 659 %{flto} %{flto=*} %l " LINK_PIE_SPEC \ |
787 %{f*:-plugin-opt=-f%*} \ | 660 "%X %{o*} %{e*} %{N} %{n} %{r}\ |
788 } \ | 661 %{s} %{t} %{u*} %{z} %{Z} %{!nostdlib:%{!nostartfiles:%S}}\ |
789 %{flto} %{fwhopr} %l " LINK_PIE_SPEC \ | |
790 "%X %{o*} %{A} %{d} %{e*} %{m} %{N} %{n} %{r}\ | |
791 %{s} %{t} %{u*} %{x} %{z} %{Z} %{!A:%{!nostdlib:%{!nostartfiles:%S}}}\ | |
792 %{static:} %{L*} %(mfwrap) %(link_libgcc) %o\ | 662 %{static:} %{L*} %(mfwrap) %(link_libgcc) %o\ |
793 %{fopenmp|ftree-parallelize-loops=*:%:include(libgomp.spec)%(link_gomp)} %(mflib)\ | 663 %{fopenmp|ftree-parallelize-loops=*:%:include(libgomp.spec)%(link_gomp)}\ |
664 %(mflib) " STACK_SPLIT_SPEC "\ | |
794 %{fprofile-arcs|fprofile-generate*|coverage:-lgcov}\ | 665 %{fprofile-arcs|fprofile-generate*|coverage:-lgcov}\ |
795 %{!nostdlib:%{!nodefaultlibs:%(link_ssp) %(link_gcc_c_sequence)}}\ | 666 %{!nostdlib:%{!nodefaultlibs:%(link_ssp) %(link_gcc_c_sequence)}}\ |
796 %{!A:%{!nostdlib:%{!nostartfiles:%E}}} %{T*} }}}}}}" | 667 %{!nostdlib:%{!nostartfiles:%E}} %{T*} }}}}}}" |
797 #endif | 668 #endif |
798 | 669 |
799 #ifndef LINK_LIBGCC_SPEC | 670 #ifndef LINK_LIBGCC_SPEC |
800 /* Generate -L options for startfile prefix list. */ | 671 /* Generate -L options for startfile prefix list. */ |
801 # define LINK_LIBGCC_SPEC "%D" | 672 # define LINK_LIBGCC_SPEC "%D" |
831 static const char *mflib_spec = MFLIB_SPEC; | 702 static const char *mflib_spec = MFLIB_SPEC; |
832 static const char *link_gomp_spec = ""; | 703 static const char *link_gomp_spec = ""; |
833 static const char *libgcc_spec = LIBGCC_SPEC; | 704 static const char *libgcc_spec = LIBGCC_SPEC; |
834 static const char *endfile_spec = ENDFILE_SPEC; | 705 static const char *endfile_spec = ENDFILE_SPEC; |
835 static const char *startfile_spec = STARTFILE_SPEC; | 706 static const char *startfile_spec = STARTFILE_SPEC; |
836 static const char *switches_need_spaces = SWITCHES_NEED_SPACES; | |
837 static const char *linker_name_spec = LINKER_NAME; | 707 static const char *linker_name_spec = LINKER_NAME; |
838 static const char *linker_plugin_file_spec = ""; | 708 static const char *linker_plugin_file_spec = ""; |
839 static const char *lto_wrapper_spec = ""; | 709 static const char *lto_wrapper_spec = ""; |
840 static const char *lto_gcc_spec = ""; | 710 static const char *lto_gcc_spec = ""; |
841 static const char *lto_libgcc_spec = ""; | |
842 static const char *link_command_spec = LINK_COMMAND_SPEC; | 711 static const char *link_command_spec = LINK_COMMAND_SPEC; |
843 static const char *link_libgcc_spec = LINK_LIBGCC_SPEC; | 712 static const char *link_libgcc_spec = LINK_LIBGCC_SPEC; |
844 static const char *startfile_prefix_spec = STARTFILE_PREFIX_SPEC; | 713 static const char *startfile_prefix_spec = STARTFILE_PREFIX_SPEC; |
845 static const char *sysroot_spec = SYSROOT_SPEC; | 714 static const char *sysroot_spec = SYSROOT_SPEC; |
846 static const char *sysroot_suffix_spec = SYSROOT_SUFFIX_SPEC; | 715 static const char *sysroot_suffix_spec = SYSROOT_SUFFIX_SPEC; |
854 | 723 |
855 /* When cpplib handles traditional preprocessing, get rid of this, and | 724 /* When cpplib handles traditional preprocessing, get rid of this, and |
856 call cc1 (or cc1obj in objc/lang-specs.h) from the main specs so | 725 call cc1 (or cc1obj in objc/lang-specs.h) from the main specs so |
857 that we default the front end language better. */ | 726 that we default the front end language better. */ |
858 static const char *trad_capable_cpp = | 727 static const char *trad_capable_cpp = |
859 "cc1 -E %{traditional|ftraditional|traditional-cpp:-traditional-cpp}"; | 728 "cc1 -E %{traditional|traditional-cpp:-traditional-cpp}"; |
860 | 729 |
861 /* We don't wrap .d files in %W{} since a missing .d file, and | 730 /* We don't wrap .d files in %W{} since a missing .d file, and |
862 therefore no dependency entry, confuses make into thinking a .o | 731 therefore no dependency entry, confuses make into thinking a .o |
863 file that happens to exist is up-to-date. */ | 732 file that happens to exist is up-to-date. */ |
864 static const char *cpp_unique_options = | 733 static const char *cpp_unique_options = |
865 "%{C|CC:%{!E:%eGCC does not support -C or -CC without -E}}\ | 734 "%{!Q:-quiet} %{nostdinc*} %{C} %{CC} %{v} %{I*&F*} %{P} %I\ |
866 %{!Q:-quiet} %{nostdinc*} %{C} %{CC} %{v} %{I*&F*} %{P} %I\ | |
867 %{MD:-MD %{!o:%b.d}%{o*:%.d%*}}\ | 735 %{MD:-MD %{!o:%b.d}%{o*:%.d%*}}\ |
868 %{MMD:-MMD %{!o:%b.d}%{o*:%.d%*}}\ | 736 %{MMD:-MMD %{!o:%b.d}%{o*:%.d%*}}\ |
869 %{M} %{MM} %{MF*} %{MG} %{MP} %{MQ*} %{MT*}\ | 737 %{M} %{MM} %{MF*} %{MG} %{MP} %{MQ*} %{MT*}\ |
870 %{!E:%{!M:%{!MM:%{!MT:%{!MQ:%{MD|MMD:%{o*:-MQ %*}}}}}}}\ | 738 %{!E:%{!M:%{!MM:%{!MT:%{!MQ:%{MD|MMD:%{o*:-MQ %*}}}}}}}\ |
871 %{remap} %{g3|ggdb3|gstabs3|gcoff3|gxcoff3|gvms3:-dD}\ | 739 %{remap} %{g3|ggdb3|gstabs3|gcoff3|gxcoff3|gvms3:-dD}\ |
740 %{!iplugindir*:%{fplugin*:%:find-plugindir()}}\ | |
872 %{H} %C %{D*&U*&A*} %{i*} %Z %i\ | 741 %{H} %C %{D*&U*&A*} %{i*} %Z %i\ |
873 %{fmudflap:-D_MUDFLAP -include mf-runtime.h}\ | 742 %{fmudflap:-D_MUDFLAP -include mf-runtime.h}\ |
874 %{fmudflapth:-D_MUDFLAP -D_MUDFLAPTH -include mf-runtime.h}\ | 743 %{fmudflapth:-D_MUDFLAP -D_MUDFLAPTH -include mf-runtime.h}\ |
875 %{E|M|MM:%W{o*}}"; | 744 %{E|M|MM:%W{o*}}"; |
876 | 745 |
889 static const char *cpp_debug_options = "%{d*}"; | 758 static const char *cpp_debug_options = "%{d*}"; |
890 | 759 |
891 /* NB: This is shared amongst all front-ends, except for Ada. */ | 760 /* NB: This is shared amongst all front-ends, except for Ada. */ |
892 static const char *cc1_options = | 761 static const char *cc1_options = |
893 "%{pg:%{fomit-frame-pointer:%e-pg and -fomit-frame-pointer are incompatible}}\ | 762 "%{pg:%{fomit-frame-pointer:%e-pg and -fomit-frame-pointer are incompatible}}\ |
894 %1 %{!Q:-quiet} -dumpbase %B %{d*} %{m*} %{a*}\ | 763 %{!iplugindir*:%{fplugin*:%:find-plugindir()}}\ |
764 %1 %{!Q:-quiet} %{!dumpbase:-dumpbase %B} %{d*} %{m*} %{aux-info*}\ | |
895 %{fcompare-debug-second:%:compare-debug-auxbase-opt(%b)} \ | 765 %{fcompare-debug-second:%:compare-debug-auxbase-opt(%b)} \ |
896 %{!fcompare-debug-second:%{c|S:%{o*:-auxbase-strip %*}%{!o*:-auxbase %b}}}%{!c:%{!S:-auxbase %b}} \ | 766 %{!fcompare-debug-second:%{c|S:%{o*:-auxbase-strip %*}%{!o*:-auxbase %b}}}%{!c:%{!S:-auxbase %b}} \ |
897 %{g*} %{O*} %{W*&pedantic*} %{w} %{std*&ansi&trigraphs}\ | 767 %{g*} %{O*} %{W*&pedantic*} %{w} %{std*&ansi&trigraphs}\ |
898 %{v:-version} %{pg:-p} %{p} %{f*} %{undef}\ | 768 %{v:-version} %{pg:-p} %{p} %{f*} %{undef}\ |
899 %{Qn:-fno-ident} %{--help:--help}\ | 769 %{Qn:-fno-ident} %{Qy:} %{-help:--help}\ |
900 %{--target-help:--target-help}\ | 770 %{-target-help:--target-help}\ |
901 %{--help=*:--help=%(VALUE)}\ | 771 %{-version:--version}\ |
772 %{-help=*:--help=%*}\ | |
902 %{!fsyntax-only:%{S:%W{o*}%{!o*:-o %b.s}}}\ | 773 %{!fsyntax-only:%{S:%W{o*}%{!o*:-o %b.s}}}\ |
903 %{fsyntax-only:-o %j} %{-param*}\ | 774 %{fsyntax-only:-o %j} %{-param*}\ |
904 %{fmudflap|fmudflapth:-fno-builtin -fno-merge-constants}\ | 775 %{fmudflap|fmudflapth:-fno-builtin -fno-merge-constants}\ |
905 %{coverage:-fprofile-arcs -ftest-coverage}"; | 776 %{coverage:-fprofile-arcs -ftest-coverage}"; |
906 | 777 |
907 static const char *asm_options = | 778 static const char *asm_options = |
908 "%{--target-help:%:print-asm-header()} " | 779 "%{-target-help:%:print-asm-header()} " |
909 #if HAVE_GNU_AS | 780 #if HAVE_GNU_AS |
910 /* If GNU AS is used, then convert -w (no warnings), -I, and -v | 781 /* If GNU AS is used, then convert -w (no warnings), -I, and -v |
911 to the assembler equivalents. */ | 782 to the assembler equivalents. */ |
912 "%{v} %{w:-W} %{I*} " | 783 "%{v} %{w:-W} %{I*} " |
913 #endif | 784 #endif |
977 const char *filename; | 848 const char *filename; |
978 }; | 849 }; |
979 | 850 |
980 static struct user_specs *user_specs_head, *user_specs_tail; | 851 static struct user_specs *user_specs_head, *user_specs_tail; |
981 | 852 |
982 #ifndef SWITCH_TAKES_ARG | |
983 #define SWITCH_TAKES_ARG(CHAR) DEFAULT_SWITCH_TAKES_ARG(CHAR) | |
984 #endif | |
985 | |
986 #ifndef WORD_SWITCH_TAKES_ARG | |
987 #define WORD_SWITCH_TAKES_ARG(STR) DEFAULT_WORD_SWITCH_TAKES_ARG (STR) | |
988 #endif | |
989 | 853 |
990 #ifdef HAVE_TARGET_EXECUTABLE_SUFFIX | |
991 /* This defines which switches stop a full compilation. */ | |
992 #define DEFAULT_SWITCH_CURTAILS_COMPILATION(CHAR) \ | |
993 ((CHAR) == 'c' || (CHAR) == 'S' || (CHAR) == 'E') | |
994 | |
995 #ifndef SWITCH_CURTAILS_COMPILATION | |
996 #define SWITCH_CURTAILS_COMPILATION(CHAR) \ | |
997 DEFAULT_SWITCH_CURTAILS_COMPILATION(CHAR) | |
998 #endif | |
999 #endif | |
1000 | |
1001 /* Record the mapping from file suffixes for compilation specs. */ | 854 /* Record the mapping from file suffixes for compilation specs. */ |
1002 | 855 |
1003 struct compiler | 856 struct compiler |
1004 { | 857 { |
1005 const char *suffix; /* Use this compiler for input files | 858 const char *suffix; /* Use this compiler for input files |
1057 {".f08", "#Fortran", 0, 0, 0}, {".F08", "#Fortran", 0, 0, 0}, | 910 {".f08", "#Fortran", 0, 0, 0}, {".F08", "#Fortran", 0, 0, 0}, |
1058 {".r", "#Ratfor", 0, 0, 0}, | 911 {".r", "#Ratfor", 0, 0, 0}, |
1059 {".p", "#Pascal", 0, 0, 0}, {".pas", "#Pascal", 0, 0, 0}, | 912 {".p", "#Pascal", 0, 0, 0}, {".pas", "#Pascal", 0, 0, 0}, |
1060 {".java", "#Java", 0, 0, 0}, {".class", "#Java", 0, 0, 0}, | 913 {".java", "#Java", 0, 0, 0}, {".class", "#Java", 0, 0, 0}, |
1061 {".zip", "#Java", 0, 0, 0}, {".jar", "#Java", 0, 0, 0}, | 914 {".zip", "#Java", 0, 0, 0}, {".jar", "#Java", 0, 0, 0}, |
915 {".go", "#Go", 0, 1, 0}, | |
1062 /* Next come the entries for C. */ | 916 /* Next come the entries for C. */ |
1063 {".c", "@c", 0, 1, 1}, | |
1064 #ifndef noCbC | 917 #ifndef noCbC |
1065 {".cbc", "@c", 0, 1, 1}, | 918 {".cbc", "@c", 0, 1, 1}, |
1066 #endif | 919 #endif |
920 {".c", "@c", 0, 0, 1}, | |
1067 {"@c", | 921 {"@c", |
1068 /* cc1 has an integrated ISO C preprocessor. We should invoke the | 922 /* cc1 has an integrated ISO C preprocessor. We should invoke the |
1069 external preprocessor if -save-temps is given. */ | 923 external preprocessor if -save-temps is given. */ |
1070 "%{E|M|MM:%(trad_capable_cpp) %(cpp_options) %(cpp_debug_options)}\ | 924 "%{E|M|MM:%(trad_capable_cpp) %(cpp_options) %(cpp_debug_options)}\ |
1071 %{!E:%{!M:%{!MM:\ | 925 %{!E:%{!M:%{!MM:\ |
1072 %{traditional|ftraditional:\ | 926 %{traditional:\ |
1073 %eGNU C no longer supports -traditional without -E}\ | 927 %eGNU C no longer supports -traditional without -E}\ |
1074 %{!combine:\ | 928 %{save-temps*|traditional-cpp|no-integrated-cpp:%(trad_capable_cpp) \ |
1075 %{save-temps*|traditional-cpp|no-integrated-cpp:%(trad_capable_cpp) \ | 929 %(cpp_options) -o %{save-temps*:%b.i} %{!save-temps*:%g.i} \n\ |
1076 %(cpp_options) -o %{save-temps*:%b.i} %{!save-temps*:%g.i} \n\ | 930 cc1 -fpreprocessed %{save-temps*:%b.i} %{!save-temps*:%g.i} \ |
1077 cc1 -fpreprocessed %{save-temps*:%b.i} %{!save-temps*:%g.i} \ | 931 %(cc1_options)}\ |
1078 %(cc1_options)}\ | 932 %{!save-temps*:%{!traditional-cpp:%{!no-integrated-cpp:\ |
1079 %{!save-temps*:%{!traditional-cpp:%{!no-integrated-cpp:\ | 933 cc1 %(cpp_unique_options) %(cc1_options)}}}\ |
1080 cc1 %(cpp_unique_options) %(cc1_options)}}}\ | 934 %{!fsyntax-only:%(invoke_as)}}}}", 0, 0, 1}, |
1081 %{!fsyntax-only:%(invoke_as)}} \ | |
1082 %{combine:\ | |
1083 %{save-temps*|traditional-cpp|no-integrated-cpp:%(trad_capable_cpp) \ | |
1084 %(cpp_options) -o %{save-temps*:%b.i} %{!save-temps*:%g.i}}\ | |
1085 %{!save-temps*:%{!traditional-cpp:%{!no-integrated-cpp:\ | |
1086 cc1 %(cpp_unique_options) %(cc1_options)}}\ | |
1087 %{!fsyntax-only:%(invoke_as)}}}}}}", 0, 1, 1}, | |
1088 {"-", | 935 {"-", |
1089 "%{!E:%e-E or -x required when input is from standard input}\ | 936 "%{!E:%e-E or -x required when input is from standard input}\ |
1090 %(trad_capable_cpp) %(cpp_options) %(cpp_debug_options)", 0, 0, 0}, | 937 %(trad_capable_cpp) %(cpp_options) %(cpp_debug_options)", 0, 0, 0}, |
1091 {".h", "@c-header", 0, 0, 0}, | 938 {".h", "@c-header", 0, 0, 0}, |
1092 {"@c-header", | 939 {"@c-header", |
1096 %{!E:%{!M:%{!MM:\ | 943 %{!E:%{!M:%{!MM:\ |
1097 %{save-temps*|traditional-cpp|no-integrated-cpp:%(trad_capable_cpp) \ | 944 %{save-temps*|traditional-cpp|no-integrated-cpp:%(trad_capable_cpp) \ |
1098 %(cpp_options) -o %{save-temps*:%b.i} %{!save-temps*:%g.i} \n\ | 945 %(cpp_options) -o %{save-temps*:%b.i} %{!save-temps*:%g.i} \n\ |
1099 cc1 -fpreprocessed %{save-temps*:%b.i} %{!save-temps*:%g.i} \ | 946 cc1 -fpreprocessed %{save-temps*:%b.i} %{!save-temps*:%g.i} \ |
1100 %(cc1_options)\ | 947 %(cc1_options)\ |
1101 -o %g.s %{!o*:--output-pch=%i.gch}\ | 948 %{!fdump-ada-spec*:-o %g.s %{!o*:--output-pch=%i.gch}\ |
1102 %W{o*:--output-pch=%*}%V}\ | 949 %W{o*:--output-pch=%*}}%V}\ |
1103 %{!save-temps*:%{!traditional-cpp:%{!no-integrated-cpp:\ | 950 %{!save-temps*:%{!traditional-cpp:%{!no-integrated-cpp:\ |
1104 cc1 %(cpp_unique_options) %(cc1_options)\ | 951 cc1 %(cpp_unique_options) %(cc1_options)\ |
1105 -o %g.s %{!o*:--output-pch=%i.gch}\ | 952 %{!fdump-ada-spec*:-o %g.s %{!o*:--output-pch=%i.gch}\ |
1106 %W{o*:--output-pch=%*}%V}}}}}}", 0, 0, 0}, | 953 %W{o*:--output-pch=%*}}%V}}}}}}", 0, 0, 0}, |
1107 {".i", "@cpp-output", 0, 1, 0}, | 954 {".i", "@cpp-output", 0, 0, 0}, |
1108 {"@cpp-output", | 955 {"@cpp-output", |
1109 "%{!M:%{!MM:%{!E:cc1 -fpreprocessed %i %(cc1_options) %{!fsyntax-only:%(invoke_as)}}}}", 0, 1, 0}, | 956 "%{!M:%{!MM:%{!E:cc1 -fpreprocessed %i %(cc1_options) %{!fsyntax-only:%(invoke_as)}}}}", 0, 0, 0}, |
1110 {".s", "@assembler", 0, 1, 0}, | 957 {".s", "@assembler", 0, 0, 0}, |
1111 {"@assembler", | 958 {"@assembler", |
1112 "%{!M:%{!MM:%{!E:%{!S:as %(asm_debug) %(asm_options) %i %A }}}}", 0, 1, 0}, | 959 "%{!M:%{!MM:%{!E:%{!S:as %(asm_debug) %(asm_options) %i %A }}}}", 0, 0, 0}, |
1113 {".sx", "@assembler-with-cpp", 0, 1, 0}, | 960 {".sx", "@assembler-with-cpp", 0, 0, 0}, |
1114 {".S", "@assembler-with-cpp", 0, 1, 0}, | 961 {".S", "@assembler-with-cpp", 0, 0, 0}, |
1115 {"@assembler-with-cpp", | 962 {"@assembler-with-cpp", |
1116 #ifdef AS_NEEDS_DASH_FOR_PIPED_INPUT | 963 #ifdef AS_NEEDS_DASH_FOR_PIPED_INPUT |
1117 "%(trad_capable_cpp) -lang-asm %(cpp_options) -fno-directives-only\ | 964 "%(trad_capable_cpp) -lang-asm %(cpp_options) -fno-directives-only\ |
1118 %{E|M|MM:%(cpp_debug_options)}\ | 965 %{E|M|MM:%(cpp_debug_options)}\ |
1119 %{!M:%{!MM:%{!E:%{!S:-o %|.s |\n\ | 966 %{!M:%{!MM:%{!E:%{!S:-o %|.s |\n\ |
1122 "%(trad_capable_cpp) -lang-asm %(cpp_options) -fno-directives-only\ | 969 "%(trad_capable_cpp) -lang-asm %(cpp_options) -fno-directives-only\ |
1123 %{E|M|MM:%(cpp_debug_options)}\ | 970 %{E|M|MM:%(cpp_debug_options)}\ |
1124 %{!M:%{!MM:%{!E:%{!S:-o %|.s |\n\ | 971 %{!M:%{!MM:%{!E:%{!S:-o %|.s |\n\ |
1125 as %(asm_debug) %(asm_options) %m.s %A }}}}" | 972 as %(asm_debug) %(asm_options) %m.s %A }}}}" |
1126 #endif | 973 #endif |
1127 , 0, 1, 0}, | 974 , 0, 0, 0}, |
1128 | 975 |
1129 #include "specs.h" | 976 #include "specs.h" |
1130 /* Mark end of table. */ | 977 /* Mark end of table. */ |
1131 {0, 0, 0, 0, 0} | 978 {0, 0, 0, 0, 0} |
1132 }; | 979 }; |
1133 | 980 |
1134 /* Number of elements in default_compilers, not counting the terminator. */ | 981 /* Number of elements in default_compilers, not counting the terminator. */ |
1135 | 982 |
1136 static const int n_default_compilers = ARRAY_SIZE (default_compilers) - 1; | 983 static const int n_default_compilers = ARRAY_SIZE (default_compilers) - 1; |
1137 | 984 |
985 typedef char *char_p; /* For DEF_VEC_P. */ | |
986 DEF_VEC_P(char_p); | |
987 DEF_VEC_ALLOC_P(char_p,heap); | |
988 | |
1138 /* A vector of options to give to the linker. | 989 /* A vector of options to give to the linker. |
1139 These options are accumulated by %x, | 990 These options are accumulated by %x, |
1140 and substituted into the linker command with %X. */ | 991 and substituted into the linker command with %X. */ |
1141 static int n_linker_options; | 992 static VEC(char_p,heap) *linker_options; |
1142 static char **linker_options; | |
1143 | 993 |
1144 /* A vector of options to give to the assembler. | 994 /* A vector of options to give to the assembler. |
1145 These options are accumulated by -Wa, | 995 These options are accumulated by -Wa, |
1146 and substituted into the assembler command with %Y. */ | 996 and substituted into the assembler command with %Y. */ |
1147 static int n_assembler_options; | 997 static VEC(char_p,heap) *assembler_options; |
1148 static char **assembler_options; | |
1149 | 998 |
1150 /* A vector of options to give to the preprocessor. | 999 /* A vector of options to give to the preprocessor. |
1151 These options are accumulated by -Wp, | 1000 These options are accumulated by -Wp, |
1152 and substituted into the preprocessor command with %Z. */ | 1001 and substituted into the preprocessor command with %Z. */ |
1153 static int n_preprocessor_options; | 1002 static VEC(char_p,heap) *preprocessor_options; |
1154 static char **preprocessor_options; | |
1155 | |
1156 /* Define how to map long options into short ones. */ | |
1157 | |
1158 /* This structure describes one mapping. */ | |
1159 struct option_map | |
1160 { | |
1161 /* The long option's name. */ | |
1162 const char *const name; | |
1163 /* The equivalent short option. */ | |
1164 const char *const equivalent; | |
1165 /* Argument info. A string of flag chars; NULL equals no options. | |
1166 a => argument required. | |
1167 o => argument optional. | |
1168 j => join argument to equivalent, making one word. | |
1169 * => require other text after NAME as an argument. */ | |
1170 const char *const arg_info; | |
1171 }; | |
1172 | |
1173 /* This is the table of mappings. Mappings are tried sequentially | |
1174 for each option encountered; the first one that matches, wins. */ | |
1175 | |
1176 static const struct option_map option_map[] = | |
1177 { | |
1178 {"--all-warnings", "-Wall", 0}, | |
1179 {"--ansi", "-ansi", 0}, | |
1180 {"--assemble", "-S", 0}, | |
1181 {"--assert", "-A", "a"}, | |
1182 {"--classpath", "-fclasspath=", "aj"}, | |
1183 {"--bootclasspath", "-fbootclasspath=", "aj"}, | |
1184 {"--CLASSPATH", "-fclasspath=", "aj"}, | |
1185 {"--combine", "-combine", 0}, | |
1186 {"--comments", "-C", 0}, | |
1187 {"--comments-in-macros", "-CC", 0}, | |
1188 {"--compile", "-c", 0}, | |
1189 {"--debug", "-g", "oj"}, | |
1190 {"--define-macro", "-D", "aj"}, | |
1191 {"--dependencies", "-M", 0}, | |
1192 {"--dump", "-d", "a"}, | |
1193 {"--dumpbase", "-dumpbase", "a"}, | |
1194 {"--encoding", "-fencoding=", "aj"}, | |
1195 {"--entry", "-e", 0}, | |
1196 {"--extra-warnings", "-W", 0}, | |
1197 {"--extdirs", "-fextdirs=", "aj"}, | |
1198 {"--for-assembler", "-Wa", "a"}, | |
1199 {"--for-linker", "-Xlinker", "a"}, | |
1200 {"--force-link", "-u", "a"}, | |
1201 {"--coverage", "-coverage", 0}, | |
1202 {"--imacros", "-imacros", "a"}, | |
1203 {"--include", "-include", "a"}, | |
1204 {"--include-barrier", "-I-", 0}, | |
1205 {"--include-directory", "-I", "aj"}, | |
1206 {"--include-directory-after", "-idirafter", "a"}, | |
1207 {"--include-prefix", "-iprefix", "a"}, | |
1208 {"--include-with-prefix", "-iwithprefix", "a"}, | |
1209 {"--include-with-prefix-before", "-iwithprefixbefore", "a"}, | |
1210 {"--include-with-prefix-after", "-iwithprefix", "a"}, | |
1211 {"--language", "-x", "a"}, | |
1212 {"--library-directory", "-L", "a"}, | |
1213 {"--machine", "-m", "aj"}, | |
1214 {"--machine-", "-m", "*j"}, | |
1215 {"--no-canonical-prefixes", "-no-canonical-prefixes", 0}, | |
1216 {"--no-integrated-cpp", "-no-integrated-cpp", 0}, | |
1217 {"--no-line-commands", "-P", 0}, | |
1218 {"--no-precompiled-includes", "-noprecomp", 0}, | |
1219 {"--no-standard-includes", "-nostdinc", 0}, | |
1220 {"--no-standard-libraries", "-nostdlib", 0}, | |
1221 {"--no-warnings", "-w", 0}, | |
1222 {"--optimize", "-O", "oj"}, | |
1223 {"--output", "-o", "a"}, | |
1224 {"--output-class-directory", "-foutput-class-dir=", "ja"}, | |
1225 {"--param", "--param", "a"}, | |
1226 {"--pass-exit-codes", "-pass-exit-codes", 0}, | |
1227 {"--pedantic", "-pedantic", 0}, | |
1228 {"--pedantic-errors", "-pedantic-errors", 0}, | |
1229 {"--pie", "-pie", 0}, | |
1230 {"--pipe", "-pipe", 0}, | |
1231 {"--prefix", "-B", "a"}, | |
1232 {"--preprocess", "-E", 0}, | |
1233 {"--print-search-dirs", "-print-search-dirs", 0}, | |
1234 {"--print-file-name", "-print-file-name=", "aj"}, | |
1235 {"--print-libgcc-file-name", "-print-libgcc-file-name", 0}, | |
1236 {"--print-missing-file-dependencies", "-MG", 0}, | |
1237 {"--print-multi-lib", "-print-multi-lib", 0}, | |
1238 {"--print-multi-directory", "-print-multi-directory", 0}, | |
1239 {"--print-multi-os-directory", "-print-multi-os-directory", 0}, | |
1240 {"--print-prog-name", "-print-prog-name=", "aj"}, | |
1241 {"--print-sysroot", "-print-sysroot", 0}, | |
1242 {"--print-sysroot-headers-suffix", "-print-sysroot-headers-suffix", 0}, | |
1243 {"--profile", "-p", 0}, | |
1244 {"--profile-blocks", "-a", 0}, | |
1245 {"--quiet", "-q", 0}, | |
1246 {"--resource", "-fcompile-resource=", "aj"}, | |
1247 {"--save-temps", "-save-temps", 0}, | |
1248 {"--shared", "-shared", 0}, | |
1249 {"--silent", "-q", 0}, | |
1250 {"--specs", "-specs=", "aj"}, | |
1251 {"--static", "-static", 0}, | |
1252 {"--std", "-std=", "aj"}, | |
1253 {"--symbolic", "-symbolic", 0}, | |
1254 {"--sysroot", "--sysroot=", "aj"}, | |
1255 {"--time", "-time", 0}, | |
1256 {"--trace-includes", "-H", 0}, | |
1257 {"--traditional", "-traditional", 0}, | |
1258 {"--traditional-cpp", "-traditional-cpp", 0}, | |
1259 {"--trigraphs", "-trigraphs", 0}, | |
1260 {"--undefine-macro", "-U", "aj"}, | |
1261 {"--user-dependencies", "-MM", 0}, | |
1262 {"--verbose", "-v", 0}, | |
1263 {"--warn-", "-W", "*j"}, | |
1264 {"--write-dependencies", "-MD", 0}, | |
1265 {"--write-user-dependencies", "-MMD", 0}, | |
1266 {"--", "-f", "*j"} | |
1267 }; | |
1268 | |
1269 | |
1270 #ifdef TARGET_OPTION_TRANSLATE_TABLE | |
1271 static const struct { | |
1272 const char *const option_found; | |
1273 const char *const replacements; | |
1274 } target_option_translations[] = | |
1275 { | |
1276 TARGET_OPTION_TRANSLATE_TABLE, | |
1277 { 0, 0 } | |
1278 }; | |
1279 #endif | |
1280 | |
1281 /* Translate the options described by *ARGCP and *ARGVP. | |
1282 Make a new vector and store it back in *ARGVP, | |
1283 and store its length in *ARGCP. */ | |
1284 | |
1285 static void | |
1286 translate_options (int *argcp, const char *const **argvp) | |
1287 { | |
1288 int i; | |
1289 int argc = *argcp; | |
1290 const char *const *argv = *argvp; | |
1291 int newvsize = (argc + 2) * 2 * sizeof (const char *); | |
1292 const char **newv = XNEWVAR (const char *, newvsize); | |
1293 int newindex = 0; | |
1294 | |
1295 i = 0; | |
1296 newv[newindex++] = argv[i++]; | |
1297 | |
1298 while (i < argc) | |
1299 { | |
1300 #ifdef TARGET_OPTION_TRANSLATE_TABLE | |
1301 int tott_idx; | |
1302 | |
1303 for (tott_idx = 0; | |
1304 target_option_translations[tott_idx].option_found; | |
1305 tott_idx++) | |
1306 { | |
1307 if (strcmp (target_option_translations[tott_idx].option_found, | |
1308 argv[i]) == 0) | |
1309 { | |
1310 int spaces = 1; | |
1311 const char *sp; | |
1312 char *np; | |
1313 | |
1314 for (sp = target_option_translations[tott_idx].replacements; | |
1315 *sp; sp++) | |
1316 { | |
1317 if (*sp == ' ') | |
1318 spaces ++; | |
1319 } | |
1320 | |
1321 newvsize += spaces * sizeof (const char *); | |
1322 newv = XRESIZEVAR (const char *, newv, newvsize); | |
1323 | |
1324 sp = target_option_translations[tott_idx].replacements; | |
1325 np = xstrdup (sp); | |
1326 | |
1327 while (1) | |
1328 { | |
1329 while (*np == ' ') | |
1330 np++; | |
1331 if (*np == 0) | |
1332 break; | |
1333 newv[newindex++] = np; | |
1334 while (*np != ' ' && *np) | |
1335 np++; | |
1336 if (*np == 0) | |
1337 break; | |
1338 *np++ = 0; | |
1339 } | |
1340 | |
1341 i ++; | |
1342 break; | |
1343 } | |
1344 } | |
1345 if (target_option_translations[tott_idx].option_found) | |
1346 continue; | |
1347 #endif | |
1348 | |
1349 /* Translate -- options. */ | |
1350 if (argv[i][0] == '-' && argv[i][1] == '-') | |
1351 { | |
1352 size_t j; | |
1353 /* Find a mapping that applies to this option. */ | |
1354 for (j = 0; j < ARRAY_SIZE (option_map); j++) | |
1355 { | |
1356 size_t optlen = strlen (option_map[j].name); | |
1357 size_t arglen = strlen (argv[i]); | |
1358 size_t complen = arglen > optlen ? optlen : arglen; | |
1359 const char *arginfo = option_map[j].arg_info; | |
1360 | |
1361 if (arginfo == 0) | |
1362 arginfo = ""; | |
1363 | |
1364 if (!strncmp (argv[i], option_map[j].name, complen)) | |
1365 { | |
1366 const char *arg = 0; | |
1367 | |
1368 if (arglen < optlen) | |
1369 { | |
1370 size_t k; | |
1371 for (k = j + 1; k < ARRAY_SIZE (option_map); k++) | |
1372 if (strlen (option_map[k].name) >= arglen | |
1373 && !strncmp (argv[i], option_map[k].name, arglen)) | |
1374 { | |
1375 error ("ambiguous abbreviation %s", argv[i]); | |
1376 break; | |
1377 } | |
1378 | |
1379 if (k != ARRAY_SIZE (option_map)) | |
1380 break; | |
1381 } | |
1382 | |
1383 if (arglen > optlen) | |
1384 { | |
1385 /* If the option has an argument, accept that. */ | |
1386 if (argv[i][optlen] == '=') | |
1387 arg = argv[i] + optlen + 1; | |
1388 | |
1389 /* If this mapping requires extra text at end of name, | |
1390 accept that as "argument". */ | |
1391 else if (strchr (arginfo, '*') != 0) | |
1392 arg = argv[i] + optlen; | |
1393 | |
1394 /* Otherwise, extra text at end means mismatch. | |
1395 Try other mappings. */ | |
1396 else | |
1397 continue; | |
1398 } | |
1399 | |
1400 else if (strchr (arginfo, '*') != 0) | |
1401 { | |
1402 error ("incomplete '%s' option", option_map[j].name); | |
1403 break; | |
1404 } | |
1405 | |
1406 /* Handle arguments. */ | |
1407 if (strchr (arginfo, 'a') != 0) | |
1408 { | |
1409 if (arg == 0) | |
1410 { | |
1411 if (i + 1 == argc) | |
1412 { | |
1413 error ("missing argument to '%s' option", | |
1414 option_map[j].name); | |
1415 break; | |
1416 } | |
1417 | |
1418 arg = argv[++i]; | |
1419 } | |
1420 } | |
1421 else if (strchr (arginfo, '*') != 0) | |
1422 ; | |
1423 else if (strchr (arginfo, 'o') == 0) | |
1424 { | |
1425 if (arg != 0) | |
1426 error ("extraneous argument to '%s' option", | |
1427 option_map[j].name); | |
1428 arg = 0; | |
1429 } | |
1430 | |
1431 /* Store the translation as one argv elt or as two. */ | |
1432 if (arg != 0 && strchr (arginfo, 'j') != 0) | |
1433 newv[newindex++] = concat (option_map[j].equivalent, arg, | |
1434 NULL); | |
1435 else if (arg != 0) | |
1436 { | |
1437 newv[newindex++] = option_map[j].equivalent; | |
1438 newv[newindex++] = arg; | |
1439 } | |
1440 else | |
1441 newv[newindex++] = option_map[j].equivalent; | |
1442 | |
1443 break; | |
1444 } | |
1445 } | |
1446 i++; | |
1447 } | |
1448 | |
1449 /* Handle old-fashioned options--just copy them through, | |
1450 with their arguments. */ | |
1451 else if (argv[i][0] == '-') | |
1452 { | |
1453 const char *p = argv[i] + 1; | |
1454 int c = *p; | |
1455 int nskip = 1; | |
1456 | |
1457 if (SWITCH_TAKES_ARG (c) > (p[1] != 0)) | |
1458 nskip += SWITCH_TAKES_ARG (c) - (p[1] != 0); | |
1459 else if (WORD_SWITCH_TAKES_ARG (p)) | |
1460 nskip += WORD_SWITCH_TAKES_ARG (p); | |
1461 else if ((c == 'B' || c == 'b' || c == 'x') | |
1462 && p[1] == 0) | |
1463 nskip += 1; | |
1464 else if (! strcmp (p, "Xlinker")) | |
1465 nskip += 1; | |
1466 else if (! strcmp (p, "Xpreprocessor")) | |
1467 nskip += 1; | |
1468 else if (! strcmp (p, "Xassembler")) | |
1469 nskip += 1; | |
1470 | |
1471 /* Watch out for an option at the end of the command line that | |
1472 is missing arguments, and avoid skipping past the end of the | |
1473 command line. */ | |
1474 if (nskip + i > argc) | |
1475 nskip = argc - i; | |
1476 | |
1477 while (nskip > 0) | |
1478 { | |
1479 newv[newindex++] = argv[i++]; | |
1480 nskip--; | |
1481 } | |
1482 } | |
1483 else | |
1484 /* Ordinary operands, or +e options. */ | |
1485 newv[newindex++] = argv[i++]; | |
1486 } | |
1487 | |
1488 newv[newindex] = 0; | |
1489 | |
1490 *argvp = newv; | |
1491 *argcp = newindex; | |
1492 } | |
1493 | 1003 |
1494 static char * | 1004 static char * |
1495 skip_whitespace (char *p) | 1005 skip_whitespace (char *p) |
1496 { | 1006 { |
1497 while (1) | 1007 while (1) |
1672 INIT_STATIC_SPEC ("mfwrap", &mfwrap_spec), | 1182 INIT_STATIC_SPEC ("mfwrap", &mfwrap_spec), |
1673 INIT_STATIC_SPEC ("mflib", &mflib_spec), | 1183 INIT_STATIC_SPEC ("mflib", &mflib_spec), |
1674 INIT_STATIC_SPEC ("link_gomp", &link_gomp_spec), | 1184 INIT_STATIC_SPEC ("link_gomp", &link_gomp_spec), |
1675 INIT_STATIC_SPEC ("libgcc", &libgcc_spec), | 1185 INIT_STATIC_SPEC ("libgcc", &libgcc_spec), |
1676 INIT_STATIC_SPEC ("startfile", &startfile_spec), | 1186 INIT_STATIC_SPEC ("startfile", &startfile_spec), |
1677 INIT_STATIC_SPEC ("switches_need_spaces", &switches_need_spaces), | |
1678 INIT_STATIC_SPEC ("cross_compile", &cross_compile), | 1187 INIT_STATIC_SPEC ("cross_compile", &cross_compile), |
1679 INIT_STATIC_SPEC ("version", &compiler_version), | 1188 INIT_STATIC_SPEC ("version", &compiler_version), |
1680 INIT_STATIC_SPEC ("multilib", &multilib_select), | 1189 INIT_STATIC_SPEC ("multilib", &multilib_select), |
1681 INIT_STATIC_SPEC ("multilib_defaults", &multilib_defaults), | 1190 INIT_STATIC_SPEC ("multilib_defaults", &multilib_defaults), |
1682 INIT_STATIC_SPEC ("multilib_extra", &multilib_extra), | 1191 INIT_STATIC_SPEC ("multilib_extra", &multilib_extra), |
1685 INIT_STATIC_SPEC ("multilib_options", &multilib_options), | 1194 INIT_STATIC_SPEC ("multilib_options", &multilib_options), |
1686 INIT_STATIC_SPEC ("linker", &linker_name_spec), | 1195 INIT_STATIC_SPEC ("linker", &linker_name_spec), |
1687 INIT_STATIC_SPEC ("linker_plugin_file", &linker_plugin_file_spec), | 1196 INIT_STATIC_SPEC ("linker_plugin_file", &linker_plugin_file_spec), |
1688 INIT_STATIC_SPEC ("lto_wrapper", <o_wrapper_spec), | 1197 INIT_STATIC_SPEC ("lto_wrapper", <o_wrapper_spec), |
1689 INIT_STATIC_SPEC ("lto_gcc", <o_gcc_spec), | 1198 INIT_STATIC_SPEC ("lto_gcc", <o_gcc_spec), |
1690 INIT_STATIC_SPEC ("lto_libgcc", <o_libgcc_spec), | |
1691 INIT_STATIC_SPEC ("link_libgcc", &link_libgcc_spec), | 1199 INIT_STATIC_SPEC ("link_libgcc", &link_libgcc_spec), |
1692 INIT_STATIC_SPEC ("md_exec_prefix", &md_exec_prefix), | 1200 INIT_STATIC_SPEC ("md_exec_prefix", &md_exec_prefix), |
1693 INIT_STATIC_SPEC ("md_startfile_prefix", &md_startfile_prefix), | 1201 INIT_STATIC_SPEC ("md_startfile_prefix", &md_startfile_prefix), |
1694 INIT_STATIC_SPEC ("md_startfile_prefix_1", &md_startfile_prefix_1), | 1202 INIT_STATIC_SPEC ("md_startfile_prefix_1", &md_startfile_prefix_1), |
1695 INIT_STATIC_SPEC ("startfile_prefix_spec", &startfile_prefix_spec), | 1203 INIT_STATIC_SPEC ("startfile_prefix_spec", &startfile_prefix_spec), |
1721 { | 1229 { |
1722 { "getenv", getenv_spec_function }, | 1230 { "getenv", getenv_spec_function }, |
1723 { "if-exists", if_exists_spec_function }, | 1231 { "if-exists", if_exists_spec_function }, |
1724 { "if-exists-else", if_exists_else_spec_function }, | 1232 { "if-exists-else", if_exists_else_spec_function }, |
1725 { "replace-outfile", replace_outfile_spec_function }, | 1233 { "replace-outfile", replace_outfile_spec_function }, |
1234 { "remove-outfile", remove_outfile_spec_function }, | |
1726 { "version-compare", version_compare_spec_function }, | 1235 { "version-compare", version_compare_spec_function }, |
1727 { "include", include_spec_function }, | 1236 { "include", include_spec_function }, |
1237 { "find-file", find_file_spec_function }, | |
1238 { "find-plugindir", find_plugindir_spec_function }, | |
1728 { "print-asm-header", print_asm_header_spec_function }, | 1239 { "print-asm-header", print_asm_header_spec_function }, |
1729 { "compare-debug-dump-opt", compare_debug_dump_opt_spec_function }, | 1240 { "compare-debug-dump-opt", compare_debug_dump_opt_spec_function }, |
1730 { "compare-debug-self-opt", compare_debug_self_opt_spec_function }, | 1241 { "compare-debug-self-opt", compare_debug_self_opt_spec_function }, |
1731 { "compare-debug-auxbase-opt", compare_debug_auxbase_opt_spec_function }, | 1242 { "compare-debug-auxbase-opt", compare_debug_auxbase_opt_spec_function }, |
1243 { "pass-through-libs", pass_through_libs_spec_func }, | |
1732 #ifdef EXTRA_SPEC_FUNCTIONS | 1244 #ifdef EXTRA_SPEC_FUNCTIONS |
1733 EXTRA_SPEC_FUNCTIONS | 1245 EXTRA_SPEC_FUNCTIONS |
1734 #endif | 1246 #endif |
1735 { 0, 0 } | 1247 { 0, 0 } |
1736 }; | 1248 }; |
1793 | 1305 |
1794 if (specs) | 1306 if (specs) |
1795 return; /* Already initialized. */ | 1307 return; /* Already initialized. */ |
1796 | 1308 |
1797 if (verbose_flag) | 1309 if (verbose_flag) |
1798 notice ("Using built-in specs.\n"); | 1310 fnotice (stderr, "Using built-in specs.\n"); |
1799 | 1311 |
1800 #ifdef EXTRA_SPECS | 1312 #ifdef EXTRA_SPECS |
1801 extra_specs = XCNEWVEC (struct spec_list, ARRAY_SIZE (extra_specs_1)); | 1313 extra_specs = XCNEWVEC (struct spec_list, ARRAY_SIZE (extra_specs_1)); |
1802 | 1314 |
1803 for (i = ARRAY_SIZE (extra_specs_1) - 1; i >= 0; i--) | 1315 for (i = ARRAY_SIZE (extra_specs_1) - 1; i >= 0; i--) |
1865 , | 1377 , |
1866 "-lgcc", | 1378 "-lgcc", |
1867 "-lgcc_eh" | 1379 "-lgcc_eh" |
1868 #ifdef USE_LIBUNWIND_EXCEPTIONS | 1380 #ifdef USE_LIBUNWIND_EXCEPTIONS |
1869 # ifdef HAVE_LD_STATIC_DYNAMIC | 1381 # ifdef HAVE_LD_STATIC_DYNAMIC |
1870 " %{!static:-Bstatic} -lunwind %{!static:-Bdynamic}" | 1382 " %{!static:" LD_STATIC_OPTION "} -lunwind" |
1383 " %{!static:" LD_DYNAMIC_OPTION "}" | |
1871 # else | 1384 # else |
1872 " -lunwind" | 1385 " -lunwind" |
1873 # endif | 1386 # endif |
1874 #endif | 1387 #endif |
1875 ); | 1388 ); |
1978 ? concat (old_spec, spec + 1, NULL) | 1491 ? concat (old_spec, spec + 1, NULL) |
1979 : xstrdup (spec)); | 1492 : xstrdup (spec)); |
1980 | 1493 |
1981 #ifdef DEBUG_SPECS | 1494 #ifdef DEBUG_SPECS |
1982 if (verbose_flag) | 1495 if (verbose_flag) |
1983 notice ("Setting spec %s to '%s'\n\n", name, *(sl->ptr_spec)); | 1496 fnotice (stderr, "Setting spec %s to '%s'\n\n", name, *(sl->ptr_spec)); |
1984 #endif | 1497 #endif |
1985 | 1498 |
1986 /* Free the old spec. */ | 1499 /* Free the old spec. */ |
1987 if (old_spec && sl->alloc_p) | 1500 if (old_spec && sl->alloc_p) |
1988 free (CONST_CAST(char *, old_spec)); | 1501 free (CONST_CAST(char *, old_spec)); |
1990 sl->alloc_p = 1; | 1503 sl->alloc_p = 1; |
1991 } | 1504 } |
1992 | 1505 |
1993 /* Accumulate a command (program name and args), and run it. */ | 1506 /* Accumulate a command (program name and args), and run it. */ |
1994 | 1507 |
1508 typedef const char *const_char_p; /* For DEF_VEC_P. */ | |
1509 DEF_VEC_P(const_char_p); | |
1510 DEF_VEC_ALLOC_P(const_char_p,heap); | |
1511 | |
1995 /* Vector of pointers to arguments in the current line of specifications. */ | 1512 /* Vector of pointers to arguments in the current line of specifications. */ |
1996 | 1513 |
1997 static const char **argbuf; | 1514 static VEC(const_char_p,heap) *argbuf; |
1998 | 1515 |
1999 /* Number of elements allocated in argbuf. */ | 1516 /* Position in the argbuf vector containing the name of the output file |
2000 | |
2001 static int argbuf_length; | |
2002 | |
2003 /* Number of elements in argbuf currently in use (containing args). */ | |
2004 | |
2005 static int argbuf_index; | |
2006 | |
2007 /* Position in the argbuf array containing the name of the output file | |
2008 (the value associated with the "-o" flag). */ | 1517 (the value associated with the "-o" flag). */ |
2009 | 1518 |
2010 static int have_o_argbuf_index = 0; | 1519 static int have_o_argbuf_index = 0; |
2011 | 1520 |
2012 /* Were the options -c, -S or -E passed. */ | 1521 /* Were the options -c, -S or -E passed. */ |
2033 static int execution_count; | 1542 static int execution_count; |
2034 | 1543 |
2035 /* Number of commands that exited with a signal. */ | 1544 /* Number of commands that exited with a signal. */ |
2036 | 1545 |
2037 static int signal_count; | 1546 static int signal_count; |
2038 | |
2039 /* Name with which this program was invoked. */ | |
2040 | |
2041 static const char *programname; | |
2042 | 1547 |
2043 /* Allocate the argument vector. */ | 1548 /* Allocate the argument vector. */ |
2044 | 1549 |
2045 static void | 1550 static void |
2046 alloc_args (void) | 1551 alloc_args (void) |
2047 { | 1552 { |
2048 argbuf_length = 10; | 1553 argbuf = VEC_alloc (const_char_p, heap, 10); |
2049 argbuf = XNEWVEC (const char *, argbuf_length); | |
2050 } | 1554 } |
2051 | 1555 |
2052 /* Clear out the vector of arguments (after a command is executed). */ | 1556 /* Clear out the vector of arguments (after a command is executed). */ |
2053 | 1557 |
2054 static void | 1558 static void |
2055 clear_args (void) | 1559 clear_args (void) |
2056 { | 1560 { |
2057 argbuf_index = 0; | 1561 VEC_truncate (const_char_p, argbuf, 0); |
2058 } | 1562 } |
2059 | 1563 |
2060 /* Add one argument to the vector at the end. | 1564 /* Add one argument to the vector at the end. |
2061 This is done when a space is seen or at the end of the line. | 1565 This is done when a space is seen or at the end of the line. |
2062 If DELETE_ALWAYS is nonzero, the arg is a filename | 1566 If DELETE_ALWAYS is nonzero, the arg is a filename |
2065 and the file should be deleted if this compilation fails. */ | 1569 and the file should be deleted if this compilation fails. */ |
2066 | 1570 |
2067 static void | 1571 static void |
2068 store_arg (const char *arg, int delete_always, int delete_failure) | 1572 store_arg (const char *arg, int delete_always, int delete_failure) |
2069 { | 1573 { |
2070 if (argbuf_index + 1 == argbuf_length) | 1574 VEC_safe_push (const_char_p, heap, argbuf, arg); |
2071 argbuf = XRESIZEVEC (const char *, argbuf, (argbuf_length *= 2)); | |
2072 | |
2073 argbuf[argbuf_index++] = arg; | |
2074 argbuf[argbuf_index] = 0; | |
2075 | 1575 |
2076 if (strcmp (arg, "-o") == 0) | 1576 if (strcmp (arg, "-o") == 0) |
2077 have_o_argbuf_index = argbuf_index; | 1577 have_o_argbuf_index = VEC_length (const_char_p, argbuf); |
2078 if (delete_always || delete_failure) | 1578 if (delete_always || delete_failure) |
2079 record_temp_file (arg, delete_always, delete_failure); | 1579 { |
1580 const char *p; | |
1581 /* If the temporary file we should delete is specified as | |
1582 part of a joined argument extract the filename. */ | |
1583 if (arg[0] == '-' | |
1584 && (p = strrchr (arg, '='))) | |
1585 arg = p + 1; | |
1586 record_temp_file (arg, delete_always, delete_failure); | |
1587 } | |
2080 } | 1588 } |
2081 | 1589 |
2082 /* Load specs from a file name named FILENAME, replacing occurrences of | 1590 /* Load specs from a file name named FILENAME, replacing occurrences of |
2083 various different types of line-endings, \r\n, \n\r and just \r, with | 1591 various different types of line-endings, \r\n, \n\r and just \r, with |
2084 a single \n. */ | 1592 a single \n. */ |
2093 char *buffer_p; | 1601 char *buffer_p; |
2094 char *specs; | 1602 char *specs; |
2095 char *specs_p; | 1603 char *specs_p; |
2096 | 1604 |
2097 if (verbose_flag) | 1605 if (verbose_flag) |
2098 notice ("Reading specs from %s\n", filename); | 1606 fnotice (stderr, "Reading specs from %s\n", filename); |
2099 | 1607 |
2100 /* Open and stat the file. */ | 1608 /* Open and stat the file. */ |
2101 desc = open (filename, O_RDONLY, 0); | 1609 desc = open (filename, O_RDONLY, 0); |
2102 if (desc < 0) | 1610 if (desc < 0) |
2103 pfatal_with_name (filename); | 1611 pfatal_with_name (filename); |
2189 p1 += sizeof ("%include"); | 1697 p1 += sizeof ("%include"); |
2190 while (*p1 == ' ' || *p1 == '\t') | 1698 while (*p1 == ' ' || *p1 == '\t') |
2191 p1++; | 1699 p1++; |
2192 | 1700 |
2193 if (*p1++ != '<' || p[-2] != '>') | 1701 if (*p1++ != '<' || p[-2] != '>') |
2194 fatal ("specs %%include syntax malformed after %ld characters", | 1702 fatal_error ("specs %%include syntax malformed after " |
2195 (long) (p1 - buffer + 1)); | 1703 "%ld characters", |
1704 (long) (p1 - buffer + 1)); | |
2196 | 1705 |
2197 p[-2] = '\0'; | 1706 p[-2] = '\0'; |
2198 new_filename = find_a_file (&startfile_prefixes, p1, R_OK, true); | 1707 new_filename = find_a_file (&startfile_prefixes, p1, R_OK, true); |
2199 read_specs (new_filename ? new_filename : p1, FALSE); | 1708 read_specs (new_filename ? new_filename : p1, FALSE); |
2200 continue; | 1709 continue; |
2208 p1 += sizeof "%include_noerr"; | 1717 p1 += sizeof "%include_noerr"; |
2209 while (*p1 == ' ' || *p1 == '\t') | 1718 while (*p1 == ' ' || *p1 == '\t') |
2210 p1++; | 1719 p1++; |
2211 | 1720 |
2212 if (*p1++ != '<' || p[-2] != '>') | 1721 if (*p1++ != '<' || p[-2] != '>') |
2213 fatal ("specs %%include syntax malformed after %ld characters", | 1722 fatal_error ("specs %%include syntax malformed after " |
2214 (long) (p1 - buffer + 1)); | 1723 "%ld characters", |
1724 (long) (p1 - buffer + 1)); | |
2215 | 1725 |
2216 p[-2] = '\0'; | 1726 p[-2] = '\0'; |
2217 new_filename = find_a_file (&startfile_prefixes, p1, R_OK, true); | 1727 new_filename = find_a_file (&startfile_prefixes, p1, R_OK, true); |
2218 if (new_filename) | 1728 if (new_filename) |
2219 read_specs (new_filename, FALSE); | 1729 read_specs (new_filename, FALSE); |
2220 else if (verbose_flag) | 1730 else if (verbose_flag) |
2221 notice ("could not find specs file %s\n", p1); | 1731 fnotice (stderr, "could not find specs file %s\n", p1); |
2222 continue; | 1732 continue; |
2223 } | 1733 } |
2224 else if (!strncmp (p1, "%rename", sizeof "%rename" - 1) | 1734 else if (!strncmp (p1, "%rename", sizeof "%rename" - 1) |
2225 && (p1[sizeof "%rename" - 1] == ' ' | 1735 && (p1[sizeof "%rename" - 1] == ' ' |
2226 || p1[sizeof "%rename" - 1] == '\t')) | 1736 || p1[sizeof "%rename" - 1] == '\t')) |
2233 p1 += sizeof "%rename"; | 1743 p1 += sizeof "%rename"; |
2234 while (*p1 == ' ' || *p1 == '\t') | 1744 while (*p1 == ' ' || *p1 == '\t') |
2235 p1++; | 1745 p1++; |
2236 | 1746 |
2237 if (! ISALPHA ((unsigned char) *p1)) | 1747 if (! ISALPHA ((unsigned char) *p1)) |
2238 fatal ("specs %%rename syntax malformed after %ld characters", | 1748 fatal_error ("specs %%rename syntax malformed after " |
2239 (long) (p1 - buffer)); | 1749 "%ld characters", |
1750 (long) (p1 - buffer)); | |
2240 | 1751 |
2241 p2 = p1; | 1752 p2 = p1; |
2242 while (*p2 && !ISSPACE ((unsigned char) *p2)) | 1753 while (*p2 && !ISSPACE ((unsigned char) *p2)) |
2243 p2++; | 1754 p2++; |
2244 | 1755 |
2245 if (*p2 != ' ' && *p2 != '\t') | 1756 if (*p2 != ' ' && *p2 != '\t') |
2246 fatal ("specs %%rename syntax malformed after %ld characters", | 1757 fatal_error ("specs %%rename syntax malformed after " |
2247 (long) (p2 - buffer)); | 1758 "%ld characters", |
1759 (long) (p2 - buffer)); | |
2248 | 1760 |
2249 name_len = p2 - p1; | 1761 name_len = p2 - p1; |
2250 *p2++ = '\0'; | 1762 *p2++ = '\0'; |
2251 while (*p2 == ' ' || *p2 == '\t') | 1763 while (*p2 == ' ' || *p2 == '\t') |
2252 p2++; | 1764 p2++; |
2253 | 1765 |
2254 if (! ISALPHA ((unsigned char) *p2)) | 1766 if (! ISALPHA ((unsigned char) *p2)) |
2255 fatal ("specs %%rename syntax malformed after %ld characters", | 1767 fatal_error ("specs %%rename syntax malformed after " |
2256 (long) (p2 - buffer)); | 1768 "%ld characters", |
1769 (long) (p2 - buffer)); | |
2257 | 1770 |
2258 /* Get new spec name. */ | 1771 /* Get new spec name. */ |
2259 p3 = p2; | 1772 p3 = p2; |
2260 while (*p3 && !ISSPACE ((unsigned char) *p3)) | 1773 while (*p3 && !ISSPACE ((unsigned char) *p3)) |
2261 p3++; | 1774 p3++; |
2262 | 1775 |
2263 if (p3 != p - 1) | 1776 if (p3 != p - 1) |
2264 fatal ("specs %%rename syntax malformed after %ld characters", | 1777 fatal_error ("specs %%rename syntax malformed after " |
2265 (long) (p3 - buffer)); | 1778 "%ld characters", |
1779 (long) (p3 - buffer)); | |
2266 *p3 = '\0'; | 1780 *p3 = '\0'; |
2267 | 1781 |
2268 for (sl = specs; sl; sl = sl->next) | 1782 for (sl = specs; sl; sl = sl->next) |
2269 if (name_len == sl->name_len && !strcmp (sl->name, p1)) | 1783 if (name_len == sl->name_len && !strcmp (sl->name, p1)) |
2270 break; | 1784 break; |
2271 | 1785 |
2272 if (!sl) | 1786 if (!sl) |
2273 fatal ("specs %s spec was not found to be renamed", p1); | 1787 fatal_error ("specs %s spec was not found to be renamed", p1); |
2274 | 1788 |
2275 if (strcmp (p1, p2) == 0) | 1789 if (strcmp (p1, p2) == 0) |
2276 continue; | 1790 continue; |
2277 | 1791 |
2278 for (newsl = specs; newsl; newsl = newsl->next) | 1792 for (newsl = specs; newsl; newsl = newsl->next) |
2279 if (strcmp (newsl->name, p2) == 0) | 1793 if (strcmp (newsl->name, p2) == 0) |
2280 fatal ("%s: attempt to rename spec '%s' to already defined spec '%s'", | 1794 fatal_error ("%s: attempt to rename spec %qs to " |
1795 "already defined spec %qs", | |
2281 filename, p1, p2); | 1796 filename, p1, p2); |
2282 | 1797 |
2283 if (verbose_flag) | 1798 if (verbose_flag) |
2284 { | 1799 { |
2285 notice ("rename spec %s to %s\n", p1, p2); | 1800 fnotice (stderr, "rename spec %s to %s\n", p1, p2); |
2286 #ifdef DEBUG_SPECS | 1801 #ifdef DEBUG_SPECS |
2287 notice ("spec is '%s'\n\n", *(sl->ptr_spec)); | 1802 fnotice (stderr, "spec is '%s'\n\n", *(sl->ptr_spec)); |
2288 #endif | 1803 #endif |
2289 } | 1804 } |
2290 | 1805 |
2291 set_spec (p2, *(sl->ptr_spec)); | 1806 set_spec (p2, *(sl->ptr_spec)); |
2292 if (sl->alloc_p) | 1807 if (sl->alloc_p) |
2295 *(sl->ptr_spec) = ""; | 1810 *(sl->ptr_spec) = ""; |
2296 sl->alloc_p = 0; | 1811 sl->alloc_p = 0; |
2297 continue; | 1812 continue; |
2298 } | 1813 } |
2299 else | 1814 else |
2300 fatal ("specs unknown %% command after %ld characters", | 1815 fatal_error ("specs unknown %% command after %ld characters", |
2301 (long) (p1 - buffer)); | 1816 (long) (p1 - buffer)); |
2302 } | 1817 } |
2303 | 1818 |
2304 /* Find the colon that should end the suffix. */ | 1819 /* Find the colon that should end the suffix. */ |
2305 p1 = p; | 1820 p1 = p; |
2306 while (*p1 && *p1 != ':' && *p1 != '\n') | 1821 while (*p1 && *p1 != ':' && *p1 != '\n') |
2307 p1++; | 1822 p1++; |
2308 | 1823 |
2309 /* The colon shouldn't be missing. */ | 1824 /* The colon shouldn't be missing. */ |
2310 if (*p1 != ':') | 1825 if (*p1 != ':') |
2311 fatal ("specs file malformed after %ld characters", | 1826 fatal_error ("specs file malformed after %ld characters", |
2312 (long) (p1 - buffer)); | 1827 (long) (p1 - buffer)); |
2313 | 1828 |
2314 /* Skip back over trailing whitespace. */ | 1829 /* Skip back over trailing whitespace. */ |
2315 p2 = p1; | 1830 p2 = p1; |
2316 while (p2 > buffer && (p2[-1] == ' ' || p2[-1] == '\t')) | 1831 while (p2 > buffer && (p2[-1] == ' ' || p2[-1] == '\t')) |
2317 p2--; | 1832 p2--; |
2319 /* Copy the suffix to a string. */ | 1834 /* Copy the suffix to a string. */ |
2320 suffix = save_string (p, p2 - p); | 1835 suffix = save_string (p, p2 - p); |
2321 /* Find the next line. */ | 1836 /* Find the next line. */ |
2322 p = skip_whitespace (p1 + 1); | 1837 p = skip_whitespace (p1 + 1); |
2323 if (p[1] == 0) | 1838 if (p[1] == 0) |
2324 fatal ("specs file malformed after %ld characters", | 1839 fatal_error ("specs file malformed after %ld characters", |
2325 (long) (p - buffer)); | 1840 (long) (p - buffer)); |
2326 | 1841 |
2327 p1 = p; | 1842 p1 = p; |
2328 /* Find next blank line or end of string. */ | 1843 /* Find next blank line or end of string. */ |
2329 while (*p1 && !(*p1 == '\n' && (p1[1] == '\n' || p1[1] == '\0'))) | 1844 while (*p1 && !(*p1 == '\n' && (p1[1] == '\n' || p1[1] == '\0'))) |
2330 p1++; | 1845 p1++; |
2371 if (*suffix == 0) | 1886 if (*suffix == 0) |
2372 link_command_spec = spec; | 1887 link_command_spec = spec; |
2373 } | 1888 } |
2374 | 1889 |
2375 if (link_command_spec == 0) | 1890 if (link_command_spec == 0) |
2376 fatal ("spec file has no spec for linking"); | 1891 fatal_error ("spec file has no spec for linking"); |
2377 } | 1892 } |
2378 | 1893 |
2379 /* Record the names of temporary files we tell compilers to write, | 1894 /* Record the names of temporary files we tell compilers to write, |
2380 and delete them at the end of the run. */ | 1895 and delete them at the end of the run. */ |
2381 | 1896 |
2699 change to standard error if in verbose mode. */ | 2214 change to standard error if in verbose mode. */ |
2700 static void | 2215 static void |
2701 xputenv (const char *string) | 2216 xputenv (const char *string) |
2702 { | 2217 { |
2703 if (verbose_flag) | 2218 if (verbose_flag) |
2704 notice ("%s\n", string); | 2219 fnotice (stderr, "%s\n", string); |
2705 putenv (CONST_CAST (char *, string)); | 2220 putenv (CONST_CAST (char *, string)); |
2706 } | 2221 } |
2707 | 2222 |
2708 /* Build a list of search directories from PATHS. | 2223 /* Build a list of search directories from PATHS. |
2709 PREFIX is a string to prepend to the list. | 2224 PREFIX is a string to prepend to the list. |
2900 const char *component, | 2415 const char *component, |
2901 /* enum prefix_priority */ int priority, | 2416 /* enum prefix_priority */ int priority, |
2902 int require_machine_suffix, int os_multilib) | 2417 int require_machine_suffix, int os_multilib) |
2903 { | 2418 { |
2904 if (!IS_ABSOLUTE_PATH (prefix)) | 2419 if (!IS_ABSOLUTE_PATH (prefix)) |
2905 fatal ("system path '%s' is not absolute", prefix); | 2420 fatal_error ("system path %qs is not absolute", prefix); |
2906 | 2421 |
2907 if (target_system_root) | 2422 if (target_system_root) |
2908 { | 2423 { |
2909 if (target_sysroot_suffix) | 2424 if (target_sysroot_suffix) |
2910 prefix = concat (target_sysroot_suffix, prefix, NULL); | 2425 prefix = concat (target_sysroot_suffix, prefix, NULL); |
2935 struct command | 2450 struct command |
2936 { | 2451 { |
2937 const char *prog; /* program name. */ | 2452 const char *prog; /* program name. */ |
2938 const char **argv; /* vector of args. */ | 2453 const char **argv; /* vector of args. */ |
2939 }; | 2454 }; |
2455 const char *arg; | |
2940 | 2456 |
2941 struct command *commands; /* each command buffer with above info. */ | 2457 struct command *commands; /* each command buffer with above info. */ |
2942 | 2458 |
2943 gcc_assert (!processing_spec_function); | 2459 gcc_assert (!processing_spec_function); |
2944 | 2460 |
2945 if (wrapper_string) | 2461 if (wrapper_string) |
2946 { | 2462 { |
2947 string = find_a_file (&exec_prefixes, argbuf[0], X_OK, false); | 2463 string = find_a_file (&exec_prefixes, |
2948 argbuf[0] = (string) ? string : argbuf[0]; | 2464 VEC_index (const_char_p, argbuf, 0), X_OK, false); |
2465 if (string) | |
2466 VEC_replace (const_char_p, argbuf, 0, string); | |
2949 insert_wrapper (wrapper_string); | 2467 insert_wrapper (wrapper_string); |
2950 } | 2468 } |
2951 | 2469 |
2952 /* Count # of piped commands. */ | 2470 /* Count # of piped commands. */ |
2953 for (n_commands = 1, i = 0; i < argbuf_index; i++) | 2471 for (n_commands = 1, i = 0; VEC_iterate (const_char_p, argbuf, i, arg); i++) |
2954 if (strcmp (argbuf[i], "|") == 0) | 2472 if (strcmp (arg, "|") == 0) |
2955 n_commands++; | 2473 n_commands++; |
2956 | 2474 |
2957 /* Get storage for each command. */ | 2475 /* Get storage for each command. */ |
2958 commands = (struct command *) alloca (n_commands * sizeof (struct command)); | 2476 commands = (struct command *) alloca (n_commands * sizeof (struct command)); |
2959 | 2477 |
2960 /* Split argbuf into its separate piped processes, | 2478 /* Split argbuf into its separate piped processes, |
2961 and record info about each one. | 2479 and record info about each one. |
2962 Also search for the programs that are to be run. */ | 2480 Also search for the programs that are to be run. */ |
2963 | 2481 |
2964 commands[0].prog = argbuf[0]; /* first command. */ | 2482 VEC_safe_push (const_char_p, heap, argbuf, 0); |
2965 commands[0].argv = &argbuf[0]; | 2483 |
2484 commands[0].prog = VEC_index (const_char_p, argbuf, 0); /* first command. */ | |
2485 commands[0].argv = VEC_address (const_char_p, argbuf); | |
2966 | 2486 |
2967 if (!wrapper_string) | 2487 if (!wrapper_string) |
2968 { | 2488 { |
2969 string = find_a_file (&exec_prefixes, commands[0].prog, X_OK, false); | 2489 string = find_a_file (&exec_prefixes, commands[0].prog, X_OK, false); |
2970 commands[0].argv[0] = (string) ? string : commands[0].argv[0]; | 2490 commands[0].argv[0] = (string) ? string : commands[0].argv[0]; |
2971 } | 2491 } |
2972 | 2492 |
2973 for (n_commands = 1, i = 0; i < argbuf_index; i++) | 2493 for (n_commands = 1, i = 0; VEC_iterate (const_char_p, argbuf, i, arg); i++) |
2974 if (strcmp (argbuf[i], "|") == 0) | 2494 if (arg && strcmp (arg, "|") == 0) |
2975 { /* each command. */ | 2495 { /* each command. */ |
2976 #if defined (__MSDOS__) || defined (OS2) || defined (VMS) | 2496 #if defined (__MSDOS__) || defined (OS2) || defined (VMS) |
2977 fatal ("-pipe not supported"); | 2497 fatal_error ("-pipe not supported"); |
2978 #endif | 2498 #endif |
2979 argbuf[i] = 0; /* termination of command args. */ | 2499 VEC_replace (const_char_p, argbuf, i, 0); /* Termination of |
2980 commands[n_commands].prog = argbuf[i + 1]; | 2500 command args. */ |
2981 commands[n_commands].argv = &argbuf[i + 1]; | 2501 commands[n_commands].prog = VEC_index (const_char_p, argbuf, i + 1); |
2502 commands[n_commands].argv | |
2503 = &(VEC_address (const_char_p, argbuf))[i + 1]; | |
2982 string = find_a_file (&exec_prefixes, commands[n_commands].prog, | 2504 string = find_a_file (&exec_prefixes, commands[n_commands].prog, |
2983 X_OK, false); | 2505 X_OK, false); |
2984 if (string) | 2506 if (string) |
2985 commands[n_commands].argv[0] = string; | 2507 commands[n_commands].argv[0] = string; |
2986 n_commands++; | 2508 n_commands++; |
2987 } | 2509 } |
2988 | 2510 |
2989 argbuf[argbuf_index] = 0; | |
2990 | |
2991 /* If -v, print what we are about to do, and maybe query. */ | 2511 /* If -v, print what we are about to do, and maybe query. */ |
2992 | 2512 |
2993 if (verbose_flag) | 2513 if (verbose_flag) |
2994 { | 2514 { |
2995 /* For help listings, put a blank line between sub-processes. */ | 2515 /* For help listings, put a blank line between sub-processes. */ |
3004 if (verbose_only_flag) | 2524 if (verbose_only_flag) |
3005 { | 2525 { |
3006 for (j = commands[i].argv; *j; j++) | 2526 for (j = commands[i].argv; *j; j++) |
3007 { | 2527 { |
3008 const char *p; | 2528 const char *p; |
3009 fprintf (stderr, " \""); | |
3010 for (p = *j; *p; ++p) | 2529 for (p = *j; *p; ++p) |
2530 if (!ISALNUM ((unsigned char) *p) | |
2531 && *p != '_' && *p != '/' && *p != '-' && *p != '.') | |
2532 break; | |
2533 if (*p || !*j) | |
3011 { | 2534 { |
3012 if (*p == '"' || *p == '\\' || *p == '$') | 2535 fprintf (stderr, " \""); |
3013 fputc ('\\', stderr); | 2536 for (p = *j; *p; ++p) |
3014 fputc (*p, stderr); | 2537 { |
2538 if (*p == '"' || *p == '\\' || *p == '$') | |
2539 fputc ('\\', stderr); | |
2540 fputc (*p, stderr); | |
2541 } | |
2542 fputc ('"', stderr); | |
3015 } | 2543 } |
3016 fputc ('"', stderr); | 2544 /* If it's empty, print "". */ |
2545 else if (!**j) | |
2546 fprintf (stderr, " \"\""); | |
2547 else | |
2548 fprintf (stderr, " %s", *j); | |
3017 } | 2549 } |
3018 } | 2550 } |
3019 else | 2551 else |
3020 for (j = commands[i].argv; *j; j++) | 2552 for (j = commands[i].argv; *j; j++) |
3021 fprintf (stderr, " %s", *j); | 2553 /* If it's empty, print "". */ |
2554 if (!**j) | |
2555 fprintf (stderr, " \"\""); | |
2556 else | |
2557 fprintf (stderr, " %s", *j); | |
3022 | 2558 |
3023 /* Print a pipe symbol after all but the last command. */ | 2559 /* Print a pipe symbol after all but the last command. */ |
3024 if (i + 1 != n_commands) | 2560 if (i + 1 != n_commands) |
3025 fprintf (stderr, " |"); | 2561 fprintf (stderr, " |"); |
3026 fprintf (stderr, "\n"); | 2562 fprintf (stderr, "\n"); |
3034 unused linker input files, etc. */ | 2570 unused linker input files, etc. */ |
3035 execution_count++; | 2571 execution_count++; |
3036 return 0; | 2572 return 0; |
3037 } | 2573 } |
3038 #ifdef DEBUG | 2574 #ifdef DEBUG |
3039 notice ("\nGo ahead? (y or n) "); | 2575 fnotice (stderr, "\nGo ahead? (y or n) "); |
3040 fflush (stderr); | 2576 fflush (stderr); |
3041 i = getchar (); | 2577 i = getchar (); |
3042 if (i != '\n') | 2578 if (i != '\n') |
3043 while (getchar () != '\n') | 2579 while (getchar () != '\n') |
3044 ; | 2580 ; |
3077 | 2613 |
3078 /* Run each piped subprocess. */ | 2614 /* Run each piped subprocess. */ |
3079 | 2615 |
3080 pex = pex_init (PEX_USE_PIPES | ((report_times || report_times_to_file) | 2616 pex = pex_init (PEX_USE_PIPES | ((report_times || report_times_to_file) |
3081 ? PEX_RECORD_TIMES : 0), | 2617 ? PEX_RECORD_TIMES : 0), |
3082 programname, temp_filename); | 2618 progname, temp_filename); |
3083 if (pex == NULL) | 2619 if (pex == NULL) |
3084 pfatal_with_name (_("pex_init failed")); | 2620 fatal_error ("pex_init failed: %m"); |
3085 | 2621 |
3086 for (i = 0; i < n_commands; i++) | 2622 for (i = 0; i < n_commands; i++) |
3087 { | 2623 { |
3088 const char *errmsg; | 2624 const char *errmsg; |
3089 int err; | 2625 int err; |
3095 string, CONST_CAST (char **, commands[i].argv), | 2631 string, CONST_CAST (char **, commands[i].argv), |
3096 NULL, NULL, &err); | 2632 NULL, NULL, &err); |
3097 if (errmsg != NULL) | 2633 if (errmsg != NULL) |
3098 { | 2634 { |
3099 if (err == 0) | 2635 if (err == 0) |
3100 fatal (errmsg); | 2636 fatal_error (errmsg); |
3101 else | 2637 else |
3102 { | 2638 { |
3103 errno = err; | 2639 errno = err; |
3104 pfatal_with_name (errmsg); | 2640 pfatal_with_name (errmsg); |
3105 } | 2641 } |
3118 struct pex_time *times = NULL; | 2654 struct pex_time *times = NULL; |
3119 int ret_code = 0; | 2655 int ret_code = 0; |
3120 | 2656 |
3121 statuses = (int *) alloca (n_commands * sizeof (int)); | 2657 statuses = (int *) alloca (n_commands * sizeof (int)); |
3122 if (!pex_get_status (pex, n_commands, statuses)) | 2658 if (!pex_get_status (pex, n_commands, statuses)) |
3123 pfatal_with_name (_("failed to get exit status")); | 2659 fatal_error ("failed to get exit status: %m"); |
3124 | 2660 |
3125 if (report_times || report_times_to_file) | 2661 if (report_times || report_times_to_file) |
3126 { | 2662 { |
3127 times = (struct pex_time *) alloca (n_commands * sizeof (struct pex_time)); | 2663 times = (struct pex_time *) alloca (n_commands * sizeof (struct pex_time)); |
3128 if (!pex_get_times (pex, n_commands, times)) | 2664 if (!pex_get_times (pex, n_commands, times)) |
3129 pfatal_with_name (_("failed to get process times")); | 2665 fatal_error ("failed to get process times: %m"); |
3130 } | 2666 } |
3131 | 2667 |
3132 pex_free (pex); | 2668 pex_free (pex); |
3133 | 2669 |
3134 for (i = 0; i < n_commands; ++i) | 2670 for (i = 0; i < n_commands; ++i) |
3150 signal_count++; | 2686 signal_count++; |
3151 ret_code = -1; | 2687 ret_code = -1; |
3152 } | 2688 } |
3153 else | 2689 else |
3154 #endif | 2690 #endif |
3155 fatal_ice ("\ | 2691 internal_error ("%s (program %s)", |
3156 Internal error: %s (program %s)\n\ | 2692 strsignal (WTERMSIG (status)), commands[i].prog); |
3157 Please submit a full bug report.\n\ | |
3158 See %s for instructions.", | |
3159 strsignal (WTERMSIG (status)), commands[i].prog, | |
3160 bug_report_url); | |
3161 } | 2693 } |
3162 else if (WIFEXITED (status) | 2694 else if (WIFEXITED (status) |
3163 && WEXITSTATUS (status) >= MIN_FATAL_STATUS) | 2695 && WEXITSTATUS (status) >= MIN_FATAL_STATUS) |
3164 { | 2696 { |
3165 if (WEXITSTATUS (status) > greatest_status) | 2697 if (WEXITSTATUS (status) > greatest_status) |
3178 + (double) pt->system_microseconds / 1.0e6); | 2710 + (double) pt->system_microseconds / 1.0e6); |
3179 | 2711 |
3180 if (ut + st != 0) | 2712 if (ut + st != 0) |
3181 { | 2713 { |
3182 if (report_times) | 2714 if (report_times) |
3183 notice ("# %s %.2f %.2f\n", commands[i].prog, ut, st); | 2715 fnotice (stderr, "# %s %.2f %.2f\n", |
2716 commands[i].prog, ut, st); | |
3184 | 2717 |
3185 if (report_times_to_file) | 2718 if (report_times_to_file) |
3186 { | 2719 { |
3187 int c = 0; | 2720 int c = 0; |
3188 const char *const *j; | 2721 const char *const *j; |
3230 is a null-terminated vector containing the following arguments. | 2763 is a null-terminated vector containing the following arguments. |
3231 Bits in the `live_cond' field are: | 2764 Bits in the `live_cond' field are: |
3232 SWITCH_LIVE to indicate this switch is true in a conditional spec. | 2765 SWITCH_LIVE to indicate this switch is true in a conditional spec. |
3233 SWITCH_FALSE to indicate this switch is overridden by a later switch. | 2766 SWITCH_FALSE to indicate this switch is overridden by a later switch. |
3234 SWITCH_IGNORE to indicate this switch should be ignored (used in %<S). | 2767 SWITCH_IGNORE to indicate this switch should be ignored (used in %<S). |
2768 SWITCH_IGNORE_PERMANENTLY to indicate this switch should be ignored | |
2769 in all do_spec calls afterwards. Used for %<S from self specs. | |
3235 The `validated' field is nonzero if any spec has looked at this switch; | 2770 The `validated' field is nonzero if any spec has looked at this switch; |
3236 if it remains zero at the end of the run, it must be meaningless. */ | 2771 if it remains zero at the end of the run, it must be meaningless. */ |
3237 | 2772 |
3238 #define SWITCH_LIVE 0x1 | 2773 #define SWITCH_LIVE (1 << 0) |
3239 #define SWITCH_FALSE 0x2 | 2774 #define SWITCH_FALSE (1 << 1) |
3240 #define SWITCH_IGNORE 0x4 | 2775 #define SWITCH_IGNORE (1 << 2) |
2776 #define SWITCH_IGNORE_PERMANENTLY (1 << 3) | |
2777 #define SWITCH_KEEP_FOR_GCC (1 << 4) | |
3241 | 2778 |
3242 struct switchstr | 2779 struct switchstr |
3243 { | 2780 { |
3244 const char *part1; | 2781 const char *part1; |
3245 const char **args; | 2782 const char **args; |
3249 }; | 2786 }; |
3250 | 2787 |
3251 static struct switchstr *switches; | 2788 static struct switchstr *switches; |
3252 | 2789 |
3253 static int n_switches; | 2790 static int n_switches; |
2791 | |
2792 static int n_switches_alloc; | |
3254 | 2793 |
3255 /* Set to zero if -fcompare-debug is disabled, positive if it's | 2794 /* Set to zero if -fcompare-debug is disabled, positive if it's |
3256 enabled and we're running the first compilation, negative if it's | 2795 enabled and we're running the first compilation, negative if it's |
3257 enabled and we're running the second compilation. For most of the | 2796 enabled and we're running the second compilation. For most of the |
3258 time, it's in the range -1..1, but it can be temporarily set to 2 | 2797 time, it's in the range -1..1, but it can be temporarily set to 2 |
3271 | 2810 |
3272 static struct switchstr *switches_debug_check[2]; | 2811 static struct switchstr *switches_debug_check[2]; |
3273 | 2812 |
3274 static int n_switches_debug_check[2]; | 2813 static int n_switches_debug_check[2]; |
3275 | 2814 |
2815 static int n_switches_alloc_debug_check[2]; | |
2816 | |
3276 static char *debug_check_temp_file[2]; | 2817 static char *debug_check_temp_file[2]; |
3277 | 2818 |
3278 /* Language is one of three things: | 2819 /* Language is one of three things: |
3279 | 2820 |
3280 1) The name of a real programming language. | 2821 1) The name of a real programming language. |
3295 | 2836 |
3296 static struct infile *infiles; | 2837 static struct infile *infiles; |
3297 | 2838 |
3298 int n_infiles; | 2839 int n_infiles; |
3299 | 2840 |
2841 static int n_infiles_alloc; | |
2842 | |
3300 /* True if multiple input files are being compiled to a single | 2843 /* True if multiple input files are being compiled to a single |
3301 assembly file. */ | 2844 assembly file. */ |
3302 | 2845 |
3303 static bool combine_inputs; | 2846 static bool combine_inputs; |
3304 | 2847 |
3369 | 2912 |
3370 /* Display the command line switches accepted by gcc. */ | 2913 /* Display the command line switches accepted by gcc. */ |
3371 static void | 2914 static void |
3372 display_help (void) | 2915 display_help (void) |
3373 { | 2916 { |
3374 printf (_("Usage: %s [options] file...\n"), programname); | 2917 printf (_("Usage: %s [options] file...\n"), progname); |
3375 fputs (_("Options:\n"), stdout); | 2918 fputs (_("Options:\n"), stdout); |
3376 | 2919 |
3377 fputs (_(" -pass-exit-codes Exit with highest error code from a phase\n"), stdout); | 2920 fputs (_(" -pass-exit-codes Exit with highest error code from a phase\n"), stdout); |
3378 fputs (_(" --help Display this information\n"), stdout); | 2921 fputs (_(" --help Display this information\n"), stdout); |
3379 fputs (_(" --target-help Display target specific command line options\n"), stdout); | 2922 fputs (_(" --target-help Display target specific command line options\n"), stdout); |
3400 fputs (_(" -Wp,<options> Pass comma-separated <options> on to the preprocessor\n"), stdout); | 2943 fputs (_(" -Wp,<options> Pass comma-separated <options> on to the preprocessor\n"), stdout); |
3401 fputs (_(" -Wl,<options> Pass comma-separated <options> on to the linker\n"), stdout); | 2944 fputs (_(" -Wl,<options> Pass comma-separated <options> on to the linker\n"), stdout); |
3402 fputs (_(" -Xassembler <arg> Pass <arg> on to the assembler\n"), stdout); | 2945 fputs (_(" -Xassembler <arg> Pass <arg> on to the assembler\n"), stdout); |
3403 fputs (_(" -Xpreprocessor <arg> Pass <arg> on to the preprocessor\n"), stdout); | 2946 fputs (_(" -Xpreprocessor <arg> Pass <arg> on to the preprocessor\n"), stdout); |
3404 fputs (_(" -Xlinker <arg> Pass <arg> on to the linker\n"), stdout); | 2947 fputs (_(" -Xlinker <arg> Pass <arg> on to the linker\n"), stdout); |
3405 fputs (_(" -combine Pass multiple source files to compiler at once\n"), stdout); | |
3406 fputs (_(" -save-temps Do not delete intermediate files\n"), stdout); | 2948 fputs (_(" -save-temps Do not delete intermediate files\n"), stdout); |
3407 fputs (_(" -save-temps=<arg> Do not delete intermediate files\n"), stdout); | 2949 fputs (_(" -save-temps=<arg> Do not delete intermediate files\n"), stdout); |
3408 fputs (_("\ | 2950 fputs (_("\ |
3409 -no-canonical-prefixes Do not canonicalize paths when building relative\n\ | 2951 -no-canonical-prefixes Do not canonicalize paths when building relative\n\ |
3410 prefixes to other gcc components\n"), stdout); | 2952 prefixes to other gcc components\n"), stdout); |
3414 fputs (_(" -std=<standard> Assume that the input sources are for <standard>\n"), stdout); | 2956 fputs (_(" -std=<standard> Assume that the input sources are for <standard>\n"), stdout); |
3415 fputs (_("\ | 2957 fputs (_("\ |
3416 --sysroot=<directory> Use <directory> as the root directory for headers\n\ | 2958 --sysroot=<directory> Use <directory> as the root directory for headers\n\ |
3417 and libraries\n"), stdout); | 2959 and libraries\n"), stdout); |
3418 fputs (_(" -B <directory> Add <directory> to the compiler's search paths\n"), stdout); | 2960 fputs (_(" -B <directory> Add <directory> to the compiler's search paths\n"), stdout); |
3419 fputs (_(" -b <machine> Run gcc for target <machine>, if installed\n"), stdout); | |
3420 fputs (_(" -V <version> Run gcc version number <version>, if installed\n"), stdout); | |
3421 fputs (_(" -v Display the programs invoked by the compiler\n"), stdout); | 2961 fputs (_(" -v Display the programs invoked by the compiler\n"), stdout); |
3422 fputs (_(" -### Like -v but options quoted and commands not executed\n"), stdout); | 2962 fputs (_(" -### Like -v but options quoted and commands not executed\n"), stdout); |
3423 fputs (_(" -E Preprocess only; do not compile, assemble or link\n"), stdout); | 2963 fputs (_(" -E Preprocess only; do not compile, assemble or link\n"), stdout); |
3424 fputs (_(" -S Compile only; do not assemble or link\n"), stdout); | 2964 fputs (_(" -S Compile only; do not assemble or link\n"), stdout); |
3425 fputs (_(" -c Compile and assemble, but do not link\n"), stdout); | 2965 fputs (_(" -c Compile and assemble, but do not link\n"), stdout); |
3433 | 2973 |
3434 printf (_("\ | 2974 printf (_("\ |
3435 \nOptions starting with -g, -f, -m, -O, -W, or --param are automatically\n\ | 2975 \nOptions starting with -g, -f, -m, -O, -W, or --param are automatically\n\ |
3436 passed on to the various sub-processes invoked by %s. In order to pass\n\ | 2976 passed on to the various sub-processes invoked by %s. In order to pass\n\ |
3437 other options on to these processes the -W<letter> options must be used.\n\ | 2977 other options on to these processes the -W<letter> options must be used.\n\ |
3438 "), programname); | 2978 "), progname); |
3439 | 2979 |
3440 /* The rest of the options are displayed by invocations of the various | 2980 /* The rest of the options are displayed by invocations of the various |
3441 sub-processes. */ | 2981 sub-processes. */ |
3442 } | 2982 } |
3443 | 2983 |
3444 static void | 2984 static void |
3445 add_preprocessor_option (const char *option, int len) | 2985 add_preprocessor_option (const char *option, int len) |
3446 { | 2986 { |
3447 n_preprocessor_options++; | 2987 VEC_safe_push (char_p, heap, preprocessor_options, |
3448 | 2988 save_string (option, len)); |
3449 if (! preprocessor_options) | |
3450 preprocessor_options = XNEWVEC (char *, n_preprocessor_options); | |
3451 else | |
3452 preprocessor_options = XRESIZEVEC (char *, preprocessor_options, | |
3453 n_preprocessor_options); | |
3454 | |
3455 preprocessor_options [n_preprocessor_options - 1] = | |
3456 save_string (option, len); | |
3457 } | 2989 } |
3458 | 2990 |
3459 static void | 2991 static void |
3460 add_assembler_option (const char *option, int len) | 2992 add_assembler_option (const char *option, int len) |
3461 { | 2993 { |
3462 n_assembler_options++; | 2994 VEC_safe_push (char_p, heap, assembler_options, save_string (option, len)); |
3463 | |
3464 if (! assembler_options) | |
3465 assembler_options = XNEWVEC (char *, n_assembler_options); | |
3466 else | |
3467 assembler_options = XRESIZEVEC (char *, assembler_options, | |
3468 n_assembler_options); | |
3469 | |
3470 assembler_options [n_assembler_options - 1] = save_string (option, len); | |
3471 } | 2995 } |
3472 | 2996 |
3473 static void | 2997 static void |
3474 add_linker_option (const char *option, int len) | 2998 add_linker_option (const char *option, int len) |
3475 { | 2999 { |
3476 n_linker_options++; | 3000 VEC_safe_push (char_p, heap, linker_options, save_string (option, len)); |
3477 | 3001 } |
3478 if (! linker_options) | 3002 |
3479 linker_options = XNEWVEC (char *, n_linker_options); | 3003 /* Allocate space for an input file in infiles. */ |
3004 | |
3005 static void | |
3006 alloc_infile (void) | |
3007 { | |
3008 if (n_infiles_alloc == 0) | |
3009 { | |
3010 n_infiles_alloc = 16; | |
3011 infiles = XNEWVEC (struct infile, n_infiles_alloc); | |
3012 } | |
3013 else if (n_infiles_alloc == n_infiles) | |
3014 { | |
3015 n_infiles_alloc *= 2; | |
3016 infiles = XRESIZEVEC (struct infile, infiles, n_infiles_alloc); | |
3017 } | |
3018 } | |
3019 | |
3020 /* Store an input file with the given NAME and LANGUAGE in | |
3021 infiles. */ | |
3022 | |
3023 static void | |
3024 add_infile (const char *name, const char *language) | |
3025 { | |
3026 alloc_infile (); | |
3027 infiles[n_infiles].name = name; | |
3028 infiles[n_infiles++].language = language; | |
3029 } | |
3030 | |
3031 /* Allocate space for a switch in switches. */ | |
3032 | |
3033 static void | |
3034 alloc_switch (void) | |
3035 { | |
3036 if (n_switches_alloc == 0) | |
3037 { | |
3038 n_switches_alloc = 16; | |
3039 switches = XNEWVEC (struct switchstr, n_switches_alloc); | |
3040 } | |
3041 else if (n_switches_alloc == n_switches) | |
3042 { | |
3043 n_switches_alloc *= 2; | |
3044 switches = XRESIZEVEC (struct switchstr, switches, n_switches_alloc); | |
3045 } | |
3046 } | |
3047 | |
3048 /* Save an option OPT with N_ARGS arguments in array ARGS, marking it | |
3049 as validated if VALIDATED. */ | |
3050 | |
3051 static void | |
3052 save_switch (const char *opt, size_t n_args, const char *const *args, | |
3053 bool validated) | |
3054 { | |
3055 alloc_switch (); | |
3056 switches[n_switches].part1 = opt + 1; | |
3057 if (n_args == 0) | |
3058 switches[n_switches].args = 0; | |
3480 else | 3059 else |
3481 linker_options = XRESIZEVEC (char *, linker_options, n_linker_options); | 3060 { |
3482 | 3061 switches[n_switches].args = XNEWVEC (const char *, n_args + 1); |
3483 linker_options [n_linker_options - 1] = save_string (option, len); | 3062 memcpy (switches[n_switches].args, args, n_args * sizeof (const char *)); |
3484 } | 3063 switches[n_switches].args[n_args] = NULL; |
3485 | 3064 } |
3065 | |
3066 switches[n_switches].live_cond = 0; | |
3067 switches[n_switches].validated = validated; | |
3068 switches[n_switches].ordering = 0; | |
3069 n_switches++; | |
3070 } | |
3071 | |
3072 /* Handle an option DECODED that is unknown to the option-processing | |
3073 machinery, but may be known to specs. */ | |
3074 | |
3075 static bool | |
3076 driver_unknown_option_callback (const struct cl_decoded_option *decoded) | |
3077 { | |
3078 save_switch (decoded->canonical_option[0], | |
3079 decoded->canonical_option_num_elements - 1, | |
3080 &decoded->canonical_option[1], false); | |
3081 | |
3082 return false; | |
3083 } | |
3084 | |
3085 /* Handle an option DECODED that is not marked as CL_DRIVER. | |
3086 LANG_MASK will always be CL_DRIVER. */ | |
3087 | |
3088 static void | |
3089 driver_wrong_lang_callback (const struct cl_decoded_option *decoded, | |
3090 unsigned int lang_mask ATTRIBUTE_UNUSED) | |
3091 { | |
3092 /* At this point, non-driver options are accepted (and expected to | |
3093 be passed down by specs) unless marked to be rejected by the | |
3094 driver. Options to be rejected by the driver but accepted by the | |
3095 compilers proper are treated just like completely unknown | |
3096 options. */ | |
3097 const struct cl_option *option = &cl_options[decoded->opt_index]; | |
3098 | |
3099 if (option->flags & CL_REJECT_DRIVER) | |
3100 error ("unrecognized command line option %qs", | |
3101 decoded->orig_option_with_args_text); | |
3102 else | |
3103 driver_unknown_option_callback (decoded); | |
3104 } | |
3105 | |
3106 /* Note that an option (index OPT_INDEX, argument ARG, value VALUE) | |
3107 has been successfully handled with a handler for mask MASK. */ | |
3108 | |
3109 static void | |
3110 driver_post_handling_callback (const struct cl_decoded_option *decoded ATTRIBUTE_UNUSED, | |
3111 unsigned int mask ATTRIBUTE_UNUSED) | |
3112 { | |
3113 /* Nothing to do here. */ | |
3114 } | |
3115 | |
3116 static const char *spec_lang = 0; | |
3117 static int last_language_n_infiles; | |
3118 | |
3119 /* Handle a driver option; arguments and return value as for | |
3120 handle_option. */ | |
3121 | |
3122 static bool | |
3123 driver_handle_option (struct gcc_options *opts, | |
3124 struct gcc_options *opts_set, | |
3125 const struct cl_decoded_option *decoded, | |
3126 unsigned int lang_mask ATTRIBUTE_UNUSED, int kind, | |
3127 location_t loc, | |
3128 const struct cl_option_handlers *handlers ATTRIBUTE_UNUSED, | |
3129 diagnostic_context *dc) | |
3130 { | |
3131 size_t opt_index = decoded->opt_index; | |
3132 const char *arg = decoded->arg; | |
3133 const char *compare_debug_replacement_opt; | |
3134 int value = decoded->value; | |
3135 bool validated = false; | |
3136 bool do_save = true; | |
3137 | |
3138 gcc_assert (opts == &global_options); | |
3139 gcc_assert (opts_set == &global_options_set); | |
3140 gcc_assert (kind == DK_UNSPECIFIED); | |
3141 gcc_assert (loc == UNKNOWN_LOCATION); | |
3142 gcc_assert (dc == global_dc); | |
3143 | |
3144 switch (opt_index) | |
3145 { | |
3146 case OPT_dumpspecs: | |
3147 { | |
3148 struct spec_list *sl; | |
3149 init_spec (); | |
3150 for (sl = specs; sl; sl = sl->next) | |
3151 printf ("*%s:\n%s\n\n", sl->name, *(sl->ptr_spec)); | |
3152 if (link_command_spec) | |
3153 printf ("*link_command:\n%s\n\n", link_command_spec); | |
3154 exit (0); | |
3155 } | |
3156 | |
3157 case OPT_dumpversion: | |
3158 printf ("%s\n", spec_version); | |
3159 exit (0); | |
3160 | |
3161 case OPT_dumpmachine: | |
3162 printf ("%s\n", spec_machine); | |
3163 exit (0); | |
3164 | |
3165 case OPT__version: | |
3166 print_version = 1; | |
3167 | |
3168 /* CPP driver cannot obtain switch from cc1_options. */ | |
3169 if (is_cpp_driver) | |
3170 add_preprocessor_option ("--version", strlen ("--version")); | |
3171 add_assembler_option ("--version", strlen ("--version")); | |
3172 add_linker_option ("--version", strlen ("--version")); | |
3173 break; | |
3174 | |
3175 case OPT__help: | |
3176 print_help_list = 1; | |
3177 | |
3178 /* CPP driver cannot obtain switch from cc1_options. */ | |
3179 if (is_cpp_driver) | |
3180 add_preprocessor_option ("--help", 6); | |
3181 add_assembler_option ("--help", 6); | |
3182 add_linker_option ("--help", 6); | |
3183 break; | |
3184 | |
3185 case OPT__help_: | |
3186 print_subprocess_help = 2; | |
3187 break; | |
3188 | |
3189 case OPT__target_help: | |
3190 print_subprocess_help = 1; | |
3191 | |
3192 /* CPP driver cannot obtain switch from cc1_options. */ | |
3193 if (is_cpp_driver) | |
3194 add_preprocessor_option ("--target-help", 13); | |
3195 add_assembler_option ("--target-help", 13); | |
3196 add_linker_option ("--target-help", 13); | |
3197 break; | |
3198 | |
3199 case OPT_pass_exit_codes: | |
3200 case OPT_print_search_dirs: | |
3201 case OPT_print_file_name_: | |
3202 case OPT_print_prog_name_: | |
3203 case OPT_print_multi_lib: | |
3204 case OPT_print_multi_directory: | |
3205 case OPT_print_sysroot: | |
3206 case OPT_print_multi_os_directory: | |
3207 case OPT_print_sysroot_headers_suffix: | |
3208 case OPT_time: | |
3209 case OPT_wrapper: | |
3210 /* These options set the variables specified in common.opt | |
3211 automatically, and do not need to be saved for spec | |
3212 processing. */ | |
3213 do_save = false; | |
3214 break; | |
3215 | |
3216 case OPT_print_libgcc_file_name: | |
3217 print_file_name = "libgcc.a"; | |
3218 do_save = false; | |
3219 break; | |
3220 | |
3221 case OPT_fcompare_debug_second: | |
3222 compare_debug_second = 1; | |
3223 break; | |
3224 | |
3225 case OPT_fcompare_debug: | |
3226 switch (value) | |
3227 { | |
3228 case 0: | |
3229 compare_debug_replacement_opt = "-fcompare-debug="; | |
3230 arg = ""; | |
3231 goto compare_debug_with_arg; | |
3232 | |
3233 case 1: | |
3234 compare_debug_replacement_opt = "-fcompare-debug=-gtoggle"; | |
3235 arg = "-gtoggle"; | |
3236 goto compare_debug_with_arg; | |
3237 | |
3238 default: | |
3239 gcc_unreachable (); | |
3240 } | |
3241 break; | |
3242 | |
3243 case OPT_fcompare_debug_: | |
3244 compare_debug_replacement_opt = decoded->canonical_option[0]; | |
3245 compare_debug_with_arg: | |
3246 gcc_assert (decoded->canonical_option_num_elements == 1); | |
3247 gcc_assert (arg != NULL); | |
3248 if (arg) | |
3249 compare_debug = 1; | |
3250 else | |
3251 compare_debug = -1; | |
3252 if (compare_debug < 0) | |
3253 compare_debug_opt = NULL; | |
3254 else | |
3255 compare_debug_opt = arg; | |
3256 save_switch (compare_debug_replacement_opt, 0, NULL, validated); | |
3257 return true; | |
3258 | |
3259 case OPT_Wa_: | |
3260 { | |
3261 int prev, j; | |
3262 /* Pass the rest of this option to the assembler. */ | |
3263 | |
3264 /* Split the argument at commas. */ | |
3265 prev = 0; | |
3266 for (j = 0; arg[j]; j++) | |
3267 if (arg[j] == ',') | |
3268 { | |
3269 add_assembler_option (arg + prev, j - prev); | |
3270 prev = j + 1; | |
3271 } | |
3272 | |
3273 /* Record the part after the last comma. */ | |
3274 add_assembler_option (arg + prev, j - prev); | |
3275 } | |
3276 do_save = false; | |
3277 break; | |
3278 | |
3279 case OPT_Wp_: | |
3280 { | |
3281 int prev, j; | |
3282 /* Pass the rest of this option to the preprocessor. */ | |
3283 | |
3284 /* Split the argument at commas. */ | |
3285 prev = 0; | |
3286 for (j = 0; arg[j]; j++) | |
3287 if (arg[j] == ',') | |
3288 { | |
3289 add_preprocessor_option (arg + prev, j - prev); | |
3290 prev = j + 1; | |
3291 } | |
3292 | |
3293 /* Record the part after the last comma. */ | |
3294 add_preprocessor_option (arg + prev, j - prev); | |
3295 } | |
3296 do_save = false; | |
3297 break; | |
3298 | |
3299 case OPT_Wl_: | |
3300 { | |
3301 int prev, j; | |
3302 /* Split the argument at commas. */ | |
3303 prev = 0; | |
3304 for (j = 0; arg[j]; j++) | |
3305 if (arg[j] == ',') | |
3306 { | |
3307 add_infile (save_string (arg + prev, j - prev), "*"); | |
3308 prev = j + 1; | |
3309 } | |
3310 /* Record the part after the last comma. */ | |
3311 add_infile (arg + prev, "*"); | |
3312 } | |
3313 do_save = false; | |
3314 break; | |
3315 | |
3316 case OPT_Xlinker: | |
3317 add_infile (arg, "*"); | |
3318 do_save = false; | |
3319 break; | |
3320 | |
3321 case OPT_Xpreprocessor: | |
3322 add_preprocessor_option (arg, strlen (arg)); | |
3323 do_save = false; | |
3324 break; | |
3325 | |
3326 case OPT_Xassembler: | |
3327 add_assembler_option (arg, strlen (arg)); | |
3328 do_save = false; | |
3329 break; | |
3330 | |
3331 case OPT_l: | |
3332 /* POSIX allows separation of -l and the lib arg; canonicalize | |
3333 by concatenating -l with its arg */ | |
3334 add_infile (concat ("-l", arg, NULL), "*"); | |
3335 do_save = false; | |
3336 break; | |
3337 | |
3338 case OPT_L: | |
3339 /* Similarly, canonicalize -L for linkers that may not accept | |
3340 separate arguments. */ | |
3341 save_switch (concat ("-L", arg, NULL), 0, NULL, validated); | |
3342 return true; | |
3343 | |
3344 case OPT_F: | |
3345 /* Likewise -F. */ | |
3346 save_switch (concat ("-F", arg, NULL), 0, NULL, validated); | |
3347 return true; | |
3348 | |
3349 case OPT_save_temps: | |
3350 save_temps_flag = SAVE_TEMPS_CWD; | |
3351 validated = true; | |
3352 break; | |
3353 | |
3354 case OPT_save_temps_: | |
3355 if (strcmp (arg, "cwd") == 0) | |
3356 save_temps_flag = SAVE_TEMPS_CWD; | |
3357 else if (strcmp (arg, "obj") == 0 | |
3358 || strcmp (arg, "object") == 0) | |
3359 save_temps_flag = SAVE_TEMPS_OBJ; | |
3360 else | |
3361 fatal_error ("%qs is an unknown -save-temps option", | |
3362 decoded->orig_option_with_args_text); | |
3363 break; | |
3364 | |
3365 case OPT_no_canonical_prefixes: | |
3366 /* Already handled as a special case, so ignored here. */ | |
3367 do_save = false; | |
3368 break; | |
3369 | |
3370 case OPT_pipe: | |
3371 validated = true; | |
3372 /* These options set the variables specified in common.opt | |
3373 automatically, but do need to be saved for spec | |
3374 processing. */ | |
3375 break; | |
3376 | |
3377 case OPT_specs_: | |
3378 { | |
3379 struct user_specs *user = XNEW (struct user_specs); | |
3380 | |
3381 user->next = (struct user_specs *) 0; | |
3382 user->filename = arg; | |
3383 if (user_specs_tail) | |
3384 user_specs_tail->next = user; | |
3385 else | |
3386 user_specs_head = user; | |
3387 user_specs_tail = user; | |
3388 } | |
3389 do_save = false; | |
3390 break; | |
3391 | |
3392 case OPT__sysroot_: | |
3393 target_system_root = arg; | |
3394 target_system_root_changed = 1; | |
3395 do_save = false; | |
3396 break; | |
3397 | |
3398 case OPT_time_: | |
3399 if (report_times_to_file) | |
3400 fclose (report_times_to_file); | |
3401 report_times_to_file = fopen (arg, "a"); | |
3402 do_save = false; | |
3403 break; | |
3404 | |
3405 case OPT____: | |
3406 /* "-###" | |
3407 This is similar to -v except that there is no execution | |
3408 of the commands and the echoed arguments are quoted. It | |
3409 is intended for use in shell scripts to capture the | |
3410 driver-generated command line. */ | |
3411 verbose_only_flag++; | |
3412 verbose_flag = 1; | |
3413 do_save = false; | |
3414 break; | |
3415 | |
3416 case OPT_B: | |
3417 { | |
3418 size_t len = strlen (arg); | |
3419 | |
3420 /* Catch the case where the user has forgotten to append a | |
3421 directory separator to the path. Note, they may be using | |
3422 -B to add an executable name prefix, eg "i386-elf-", in | |
3423 order to distinguish between multiple installations of | |
3424 GCC in the same directory. Hence we must check to see | |
3425 if appending a directory separator actually makes a | |
3426 valid directory name. */ | |
3427 if (!IS_DIR_SEPARATOR (arg[len - 1]) | |
3428 && is_directory (arg, false)) | |
3429 { | |
3430 char *tmp = XNEWVEC (char, len + 2); | |
3431 strcpy (tmp, arg); | |
3432 tmp[len] = DIR_SEPARATOR; | |
3433 tmp[++len] = 0; | |
3434 arg = tmp; | |
3435 } | |
3436 | |
3437 add_prefix (&exec_prefixes, arg, NULL, | |
3438 PREFIX_PRIORITY_B_OPT, 0, 0); | |
3439 add_prefix (&startfile_prefixes, arg, NULL, | |
3440 PREFIX_PRIORITY_B_OPT, 0, 0); | |
3441 add_prefix (&include_prefixes, arg, NULL, | |
3442 PREFIX_PRIORITY_B_OPT, 0, 0); | |
3443 } | |
3444 validated = true; | |
3445 break; | |
3446 | |
3447 case OPT_x: | |
3448 spec_lang = arg; | |
3449 if (!strcmp (spec_lang, "none")) | |
3450 /* Suppress the warning if -xnone comes after the last input | |
3451 file, because alternate command interfaces like g++ might | |
3452 find it useful to place -xnone after each input file. */ | |
3453 spec_lang = 0; | |
3454 else | |
3455 last_language_n_infiles = n_infiles; | |
3456 do_save = false; | |
3457 break; | |
3458 | |
3459 case OPT_o: | |
3460 have_o = 1; | |
3461 #if defined(HAVE_TARGET_EXECUTABLE_SUFFIX) || defined(HAVE_TARGET_OBJECT_SUFFIX) | |
3462 arg = convert_filename (arg, ! have_c, 0); | |
3463 #endif | |
3464 /* Save the output name in case -save-temps=obj was used. */ | |
3465 save_temps_prefix = xstrdup (arg); | |
3466 /* On some systems, ld cannot handle "-o" without a space. So | |
3467 split the option from its argument. */ | |
3468 save_switch ("-o", 1, &arg, validated); | |
3469 return true; | |
3470 | |
3471 case OPT_static_libgcc: | |
3472 case OPT_shared_libgcc: | |
3473 case OPT_static_libgfortran: | |
3474 case OPT_static_libstdc__: | |
3475 /* These are always valid, since gcc.c itself understands the | |
3476 first two, gfortranspec.c understands -static-libgfortran and | |
3477 g++spec.c understands -static-libstdc++ */ | |
3478 validated = true; | |
3479 break; | |
3480 | |
3481 default: | |
3482 /* Various driver options need no special processing at this | |
3483 point, having been handled in a prescan above or being | |
3484 handled by specs. */ | |
3485 break; | |
3486 } | |
3487 | |
3488 if (do_save) | |
3489 save_switch (decoded->canonical_option[0], | |
3490 decoded->canonical_option_num_elements - 1, | |
3491 &decoded->canonical_option[1], validated); | |
3492 return true; | |
3493 } | |
3494 | |
3495 /* Put the driver's standard set of option handlers in *HANDLERS. */ | |
3496 | |
3497 static void | |
3498 set_option_handlers (struct cl_option_handlers *handlers) | |
3499 { | |
3500 handlers->unknown_option_callback = driver_unknown_option_callback; | |
3501 handlers->wrong_lang_callback = driver_wrong_lang_callback; | |
3502 handlers->post_handling_callback = driver_post_handling_callback; | |
3503 handlers->num_handlers = 1; | |
3504 handlers->handlers[0].handler = driver_handle_option; | |
3505 handlers->handlers[0].mask = CL_DRIVER; | |
3506 } | |
3507 | |
3486 /* Create the vector `switches' and its contents. | 3508 /* Create the vector `switches' and its contents. |
3487 Store its length in `n_switches'. */ | 3509 Store its length in `n_switches'. */ |
3488 | 3510 |
3489 static void | 3511 static void |
3490 process_command (int argc, const char **argv) | 3512 process_command (unsigned int decoded_options_count, |
3491 { | 3513 struct cl_decoded_option *decoded_options) |
3492 int i; | 3514 { |
3493 const char *temp; | 3515 const char *temp; |
3494 char *temp1; | 3516 char *temp1; |
3495 const char *spec_lang = 0; | |
3496 int last_language_n_infiles; | |
3497 int lang_n_infiles = 0; | |
3498 #ifdef MODIFY_TARGET_NAME | |
3499 int is_modify_target_name; | |
3500 unsigned int j; | |
3501 #endif | |
3502 const char *tooldir_prefix; | 3517 const char *tooldir_prefix; |
3503 char *(*get_relative_prefix) (const char *, const char *, | 3518 char *(*get_relative_prefix) (const char *, const char *, |
3504 const char *) = NULL; | 3519 const char *) = NULL; |
3505 | 3520 struct cl_option_handlers handlers; |
3506 GET_ENVIRONMENT (gcc_exec_prefix, "GCC_EXEC_PREFIX"); | 3521 unsigned int j; |
3522 | |
3523 gcc_exec_prefix = getenv ("GCC_EXEC_PREFIX"); | |
3507 | 3524 |
3508 n_switches = 0; | 3525 n_switches = 0; |
3509 n_infiles = 0; | 3526 n_infiles = 0; |
3510 added_libraries = 0; | 3527 added_libraries = 0; |
3511 | 3528 |
3520 *temp1 = '\0'; | 3537 *temp1 = '\0'; |
3521 break; | 3538 break; |
3522 } | 3539 } |
3523 } | 3540 } |
3524 | 3541 |
3525 /* If there is a -V or -b option (or both), process it now, before | |
3526 trying to interpret the rest of the command line. | |
3527 Use heuristic that all configuration names must have at least | |
3528 one dash '-'. This allows us to pass options starting with -b. */ | |
3529 if (argc > 1 && argv[1][0] == '-' | |
3530 && (argv[1][1] == 'V' | |
3531 || (argv[1][1] == 'b' | |
3532 && (argv[1][2] == '\0' | |
3533 || NULL != strchr (argv[1] + 2, '-'))))) | |
3534 { | |
3535 const char *new_version = DEFAULT_TARGET_VERSION; | |
3536 const char *new_machine = DEFAULT_TARGET_MACHINE; | |
3537 const char *progname = argv[0]; | |
3538 char **new_argv; | |
3539 char *new_argv0; | |
3540 int baselen; | |
3541 int status = 0; | |
3542 int err = 0; | |
3543 const char *errmsg; | |
3544 | |
3545 while (argc > 1 && argv[1][0] == '-' | |
3546 && (argv[1][1] == 'V' | |
3547 || (argv[1][1] == 'b' | |
3548 && (argv[1][2] == '\0' | |
3549 || NULL != strchr (argv[1] + 2, '-'))))) | |
3550 { | |
3551 char opt = argv[1][1]; | |
3552 const char *arg; | |
3553 if (argv[1][2] != '\0') | |
3554 { | |
3555 arg = argv[1] + 2; | |
3556 argc -= 1; | |
3557 argv += 1; | |
3558 } | |
3559 else if (argc > 2) | |
3560 { | |
3561 arg = argv[2]; | |
3562 argc -= 2; | |
3563 argv += 2; | |
3564 } | |
3565 else | |
3566 fatal ("'-%c' option must have argument", opt); | |
3567 if (opt == 'V') | |
3568 new_version = arg; | |
3569 else | |
3570 new_machine = arg; | |
3571 } | |
3572 | |
3573 for (baselen = strlen (progname); baselen > 0; baselen--) | |
3574 if (IS_DIR_SEPARATOR (progname[baselen-1])) | |
3575 break; | |
3576 new_argv0 = XDUPVAR (char, progname, baselen, | |
3577 baselen + concat_length (new_version, new_machine, | |
3578 "-gcc-", NULL) + 1); | |
3579 strcpy (new_argv0 + baselen, new_machine); | |
3580 strcat (new_argv0, "-gcc-"); | |
3581 strcat (new_argv0, new_version); | |
3582 | |
3583 new_argv = XDUPVEC (char *, argv, argc + 1); | |
3584 new_argv[0] = new_argv0; | |
3585 | |
3586 errmsg = pex_one (PEX_SEARCH, new_argv0, new_argv, progname, NULL, | |
3587 NULL, &status, &err); | |
3588 | |
3589 if (errmsg) | |
3590 { | |
3591 if (err == 0) | |
3592 fatal ("couldn't run '%s': %s", new_argv0, errmsg); | |
3593 else | |
3594 fatal ("couldn't run '%s': %s: %s", new_argv0, errmsg, | |
3595 xstrerror (err)); | |
3596 } | |
3597 exit (status); | |
3598 } | |
3599 | |
3600 /* Convert new-style -- options to old-style. */ | |
3601 translate_options (&argc, | |
3602 CONST_CAST2 (const char *const **, const char ***, | |
3603 &argv)); | |
3604 | |
3605 /* Do language-specific adjustment/addition of flags. */ | |
3606 lang_specific_driver (&argc, | |
3607 CONST_CAST2 (const char *const **, const char ***, | |
3608 &argv), | |
3609 &added_libraries); | |
3610 | |
3611 /* Handle any -no-canonical-prefixes flag early, to assign the function | 3542 /* Handle any -no-canonical-prefixes flag early, to assign the function |
3612 that builds relative prefixes. This function creates default search | 3543 that builds relative prefixes. This function creates default search |
3613 paths that are needed later in normal option handling. */ | 3544 paths that are needed later in normal option handling. */ |
3614 | 3545 |
3615 for (i = 1; i < argc; i++) | 3546 for (j = 1; j < decoded_options_count; j++) |
3616 { | 3547 { |
3617 if (! strcmp (argv[i], "-no-canonical-prefixes")) | 3548 if (decoded_options[j].opt_index == OPT_no_canonical_prefixes) |
3618 { | 3549 { |
3619 get_relative_prefix = make_relative_prefix_ignore_links; | 3550 get_relative_prefix = make_relative_prefix_ignore_links; |
3620 break; | 3551 break; |
3621 } | 3552 } |
3622 } | 3553 } |
3623 if (! get_relative_prefix) | 3554 if (! get_relative_prefix) |
3624 get_relative_prefix = make_relative_prefix; | 3555 get_relative_prefix = make_relative_prefix; |
3625 | 3556 |
3626 /* Set up the default search paths. If there is no GCC_EXEC_PREFIX, | 3557 /* Set up the default search paths. If there is no GCC_EXEC_PREFIX, |
3627 see if we can create it from the pathname specified in argv[0]. */ | 3558 see if we can create it from the pathname specified in |
3559 decoded_options[0].arg. */ | |
3628 | 3560 |
3629 gcc_libexec_prefix = standard_libexec_prefix; | 3561 gcc_libexec_prefix = standard_libexec_prefix; |
3630 #ifndef VMS | 3562 #ifndef VMS |
3631 /* FIXME: make_relative_prefix doesn't yet work for VMS. */ | 3563 /* FIXME: make_relative_prefix doesn't yet work for VMS. */ |
3632 if (!gcc_exec_prefix) | 3564 if (!gcc_exec_prefix) |
3633 { | 3565 { |
3634 gcc_exec_prefix = get_relative_prefix (argv[0], | 3566 gcc_exec_prefix = get_relative_prefix (decoded_options[0].arg, |
3635 standard_bindir_prefix, | 3567 standard_bindir_prefix, |
3636 standard_exec_prefix); | 3568 standard_exec_prefix); |
3637 gcc_libexec_prefix = get_relative_prefix (argv[0], | 3569 gcc_libexec_prefix = get_relative_prefix (decoded_options[0].arg, |
3638 standard_bindir_prefix, | 3570 standard_bindir_prefix, |
3639 standard_libexec_prefix); | 3571 standard_libexec_prefix); |
3640 if (gcc_exec_prefix) | 3572 if (gcc_exec_prefix) |
3641 xputenv (concat ("GCC_EXEC_PREFIX=", gcc_exec_prefix, NULL)); | 3573 xputenv (concat ("GCC_EXEC_PREFIX=", gcc_exec_prefix, NULL)); |
3642 } | 3574 } |
3659 } | 3591 } |
3660 #else | 3592 #else |
3661 #endif | 3593 #endif |
3662 /* From this point onward, gcc_exec_prefix is non-null if the toolchain | 3594 /* From this point onward, gcc_exec_prefix is non-null if the toolchain |
3663 is relocated. The toolchain was either relocated using GCC_EXEC_PREFIX | 3595 is relocated. The toolchain was either relocated using GCC_EXEC_PREFIX |
3664 or an automatically created GCC_EXEC_PREFIX from argv[0]. */ | 3596 or an automatically created GCC_EXEC_PREFIX from |
3597 decoded_options[0].arg. */ | |
3598 | |
3599 /* Do language-specific adjustment/addition of flags. */ | |
3600 lang_specific_driver (&decoded_options, &decoded_options_count, | |
3601 &added_libraries); | |
3665 | 3602 |
3666 if (gcc_exec_prefix) | 3603 if (gcc_exec_prefix) |
3667 { | 3604 { |
3668 int len = strlen (gcc_exec_prefix); | 3605 int len = strlen (gcc_exec_prefix); |
3669 | 3606 |
3686 } | 3623 } |
3687 | 3624 |
3688 /* COMPILER_PATH and LIBRARY_PATH have values | 3625 /* COMPILER_PATH and LIBRARY_PATH have values |
3689 that are lists of directory names with colons. */ | 3626 that are lists of directory names with colons. */ |
3690 | 3627 |
3691 GET_ENVIRONMENT (temp, "COMPILER_PATH"); | 3628 temp = getenv ("COMPILER_PATH"); |
3692 if (temp) | 3629 if (temp) |
3693 { | 3630 { |
3694 const char *startp, *endp; | 3631 const char *startp, *endp; |
3695 char *nstore = (char *) alloca (strlen (temp) + 3); | 3632 char *nstore = (char *) alloca (strlen (temp) + 3); |
3696 | 3633 |
3720 else | 3657 else |
3721 endp++; | 3658 endp++; |
3722 } | 3659 } |
3723 } | 3660 } |
3724 | 3661 |
3725 GET_ENVIRONMENT (temp, LIBRARY_PATH_ENV); | 3662 temp = getenv (LIBRARY_PATH_ENV); |
3726 if (temp && *cross_compile == '0') | 3663 if (temp && *cross_compile == '0') |
3727 { | 3664 { |
3728 const char *startp, *endp; | 3665 const char *startp, *endp; |
3729 char *nstore = (char *) alloca (strlen (temp) + 3); | 3666 char *nstore = (char *) alloca (strlen (temp) + 3); |
3730 | 3667 |
3753 endp++; | 3690 endp++; |
3754 } | 3691 } |
3755 } | 3692 } |
3756 | 3693 |
3757 /* Use LPATH like LIBRARY_PATH (for the CMU build program). */ | 3694 /* Use LPATH like LIBRARY_PATH (for the CMU build program). */ |
3758 GET_ENVIRONMENT (temp, "LPATH"); | 3695 temp = getenv ("LPATH"); |
3759 if (temp && *cross_compile == '0') | 3696 if (temp && *cross_compile == '0') |
3760 { | 3697 { |
3761 const char *startp, *endp; | 3698 const char *startp, *endp; |
3762 char *nstore = (char *) alloca (strlen (temp) + 3); | 3699 char *nstore = (char *) alloca (strlen (temp) + 3); |
3763 | 3700 |
3785 else | 3722 else |
3786 endp++; | 3723 endp++; |
3787 } | 3724 } |
3788 } | 3725 } |
3789 | 3726 |
3790 /* Scan argv twice. Here, the first time, just count how many switches | 3727 /* Process the options and store input files and switches in their |
3791 there will be in their vector, and how many input files in theirs. | 3728 vectors. */ |
3792 Here we also parse the switches that cc itself uses (e.g. -v). */ | 3729 |
3793 | 3730 last_language_n_infiles = -1; |
3794 for (i = 1; i < argc; i++) | 3731 |
3795 { | 3732 set_option_handlers (&handlers); |
3796 if (! strcmp (argv[i], "-dumpspecs")) | 3733 |
3734 for (j = 1; j < decoded_options_count; j++) | |
3735 { | |
3736 switch (decoded_options[j].opt_index) | |
3797 { | 3737 { |
3798 struct spec_list *sl; | 3738 case OPT_S: |
3799 init_spec (); | 3739 case OPT_c: |
3800 for (sl = specs; sl; sl = sl->next) | 3740 case OPT_E: |
3801 printf ("*%s:\n%s\n\n", sl->name, *(sl->ptr_spec)); | 3741 have_c = 1; |
3802 if (link_command_spec) | 3742 break; |
3803 printf ("*link_command:\n%s\n\n", link_command_spec); | |
3804 exit (0); | |
3805 } | 3743 } |
3806 else if (! strcmp (argv[i], "-dumpversion")) | 3744 if (have_c) |
3745 break; | |
3746 } | |
3747 | |
3748 for (j = 1; j < decoded_options_count; j++) | |
3749 { | |
3750 if (decoded_options[j].opt_index == OPT_SPECIAL_input_file) | |
3807 { | 3751 { |
3808 printf ("%s\n", spec_version); | 3752 const char *arg = decoded_options[j].arg; |
3809 exit (0); | 3753 const char *p = strrchr (arg, '@'); |
3754 char *fname; | |
3755 long offset; | |
3756 int consumed; | |
3757 #ifdef HAVE_TARGET_OBJECT_SUFFIX | |
3758 arg = convert_filename (arg, 0, access (arg, F_OK)); | |
3759 #endif | |
3760 /* For LTO static archive support we handle input file | |
3761 specifications that are composed of a filename and | |
3762 an offset like FNAME@OFFSET. */ | |
3763 if (p | |
3764 && p != arg | |
3765 && sscanf (p, "@%li%n", &offset, &consumed) >= 1 | |
3766 && strlen (p) == (unsigned int)consumed) | |
3767 { | |
3768 fname = (char *)xmalloc (p - arg + 1); | |
3769 memcpy (fname, arg, p - arg); | |
3770 fname[p - arg] = '\0'; | |
3771 /* Only accept non-stdin and existing FNAME parts, otherwise | |
3772 try with the full name. */ | |
3773 if (strcmp (fname, "-") == 0 || access (fname, F_OK) < 0) | |
3774 { | |
3775 free (fname); | |
3776 fname = xstrdup (arg); | |
3777 } | |
3778 } | |
3779 else | |
3780 fname = xstrdup (arg); | |
3781 | |
3782 if (strcmp (fname, "-") != 0 && access (fname, F_OK) < 0) | |
3783 perror_with_name (fname); | |
3784 else | |
3785 add_infile (arg, spec_lang); | |
3786 | |
3787 free (fname); | |
3788 continue; | |
3810 } | 3789 } |
3811 else if (! strcmp (argv[i], "-dumpmachine")) | 3790 |
3812 { | 3791 read_cmdline_option (&global_options, &global_options_set, |
3813 printf ("%s\n", spec_machine); | 3792 decoded_options + j, UNKNOWN_LOCATION, |
3814 exit (0); | 3793 CL_DRIVER, &handlers, global_dc); |
3815 } | |
3816 else if (strcmp (argv[i], "-fversion") == 0) | |
3817 { | |
3818 /* translate_options () has turned --version into -fversion. */ | |
3819 print_version = 1; | |
3820 | |
3821 /* We will be passing a dummy file on to the sub-processes. */ | |
3822 n_infiles++; | |
3823 n_switches++; | |
3824 | |
3825 /* CPP driver cannot obtain switch from cc1_options. */ | |
3826 if (is_cpp_driver) | |
3827 add_preprocessor_option ("--version", strlen ("--version")); | |
3828 add_assembler_option ("--version", strlen ("--version")); | |
3829 add_linker_option ("--version", strlen ("--version")); | |
3830 } | |
3831 else if (strcmp (argv[i], "-fhelp") == 0) | |
3832 { | |
3833 /* translate_options () has turned --help into -fhelp. */ | |
3834 print_help_list = 1; | |
3835 | |
3836 /* We will be passing a dummy file on to the sub-processes. */ | |
3837 n_infiles++; | |
3838 n_switches++; | |
3839 | |
3840 /* CPP driver cannot obtain switch from cc1_options. */ | |
3841 if (is_cpp_driver) | |
3842 add_preprocessor_option ("--help", 6); | |
3843 add_assembler_option ("--help", 6); | |
3844 add_linker_option ("--help", 6); | |
3845 } | |
3846 else if (strncmp (argv[i], "-fhelp=", 7) == 0) | |
3847 { | |
3848 /* translate_options () has turned --help into -fhelp. */ | |
3849 print_subprocess_help = 2; | |
3850 | |
3851 /* We will be passing a dummy file on to the sub-processes. */ | |
3852 n_infiles++; | |
3853 n_switches++; | |
3854 } | |
3855 else if (strcmp (argv[i], "-ftarget-help") == 0) | |
3856 { | |
3857 /* translate_options() has turned --target-help into -ftarget-help. */ | |
3858 print_subprocess_help = 1; | |
3859 | |
3860 /* We will be passing a dummy file on to the sub-processes. */ | |
3861 n_infiles++; | |
3862 n_switches++; | |
3863 | |
3864 /* CPP driver cannot obtain switch from cc1_options. */ | |
3865 if (is_cpp_driver) | |
3866 add_preprocessor_option ("--target-help", 13); | |
3867 add_assembler_option ("--target-help", 13); | |
3868 add_linker_option ("--target-help", 13); | |
3869 } | |
3870 else if (! strcmp (argv[i], "-pass-exit-codes")) | |
3871 { | |
3872 pass_exit_codes = 1; | |
3873 n_switches++; | |
3874 } | |
3875 else if (! strcmp (argv[i], "-print-search-dirs")) | |
3876 print_search_dirs = 1; | |
3877 else if (! strcmp (argv[i], "-print-libgcc-file-name")) | |
3878 print_file_name = "libgcc.a"; | |
3879 else if (! strncmp (argv[i], "-print-file-name=", 17)) | |
3880 print_file_name = argv[i] + 17; | |
3881 else if (! strncmp (argv[i], "-print-prog-name=", 17)) | |
3882 print_prog_name = argv[i] + 17; | |
3883 else if (! strcmp (argv[i], "-print-multi-lib")) | |
3884 print_multi_lib = 1; | |
3885 else if (! strcmp (argv[i], "-print-multi-directory")) | |
3886 print_multi_directory = 1; | |
3887 else if (! strcmp (argv[i], "-print-sysroot")) | |
3888 print_sysroot = 1; | |
3889 else if (! strcmp (argv[i], "-print-multi-os-directory")) | |
3890 print_multi_os_directory = 1; | |
3891 else if (! strcmp (argv[i], "-print-sysroot-headers-suffix")) | |
3892 print_sysroot_headers_suffix = 1; | |
3893 else if (! strcmp (argv[i], "-fcompare-debug-second")) | |
3894 { | |
3895 compare_debug_second = 1; | |
3896 n_switches++; | |
3897 } | |
3898 else if (! strcmp (argv[i], "-fno-compare-debug")) | |
3899 { | |
3900 argv[i] = "-fcompare-debug="; | |
3901 goto compare_debug_with_arg; | |
3902 } | |
3903 else if (! strcmp (argv[i], "-fcompare-debug")) | |
3904 { | |
3905 argv[i] = "-fcompare-debug=-gtoggle"; | |
3906 goto compare_debug_with_arg; | |
3907 } | |
3908 #define OPT "-fcompare-debug=" | |
3909 else if (! strncmp (argv[i], OPT, sizeof (OPT) - 1)) | |
3910 { | |
3911 const char *opt; | |
3912 compare_debug_with_arg: | |
3913 opt = argv[i] + sizeof (OPT) - 1; | |
3914 #undef OPT | |
3915 if (*opt) | |
3916 compare_debug = 1; | |
3917 else | |
3918 compare_debug = -1; | |
3919 if (compare_debug < 0) | |
3920 compare_debug_opt = NULL; | |
3921 else | |
3922 compare_debug_opt = opt; | |
3923 n_switches++; | |
3924 } | |
3925 else if (! strncmp (argv[i], "-Wa,", 4)) | |
3926 { | |
3927 int prev, j; | |
3928 /* Pass the rest of this option to the assembler. */ | |
3929 | |
3930 /* Split the argument at commas. */ | |
3931 prev = 4; | |
3932 for (j = 4; argv[i][j]; j++) | |
3933 if (argv[i][j] == ',') | |
3934 { | |
3935 add_assembler_option (argv[i] + prev, j - prev); | |
3936 prev = j + 1; | |
3937 } | |
3938 | |
3939 /* Record the part after the last comma. */ | |
3940 add_assembler_option (argv[i] + prev, j - prev); | |
3941 } | |
3942 else if (! strncmp (argv[i], "-Wp,", 4)) | |
3943 { | |
3944 int prev, j; | |
3945 /* Pass the rest of this option to the preprocessor. */ | |
3946 | |
3947 /* Split the argument at commas. */ | |
3948 prev = 4; | |
3949 for (j = 4; argv[i][j]; j++) | |
3950 if (argv[i][j] == ',') | |
3951 { | |
3952 add_preprocessor_option (argv[i] + prev, j - prev); | |
3953 prev = j + 1; | |
3954 } | |
3955 | |
3956 /* Record the part after the last comma. */ | |
3957 add_preprocessor_option (argv[i] + prev, j - prev); | |
3958 } | |
3959 else if (argv[i][0] == '+' && argv[i][1] == 'e') | |
3960 /* The +e options to the C++ front-end. */ | |
3961 n_switches++; | |
3962 else if (strncmp (argv[i], "-Wl,", 4) == 0) | |
3963 { | |
3964 int j; | |
3965 /* Split the argument at commas. */ | |
3966 for (j = 3; argv[i][j]; j++) | |
3967 n_infiles += (argv[i][j] == ','); | |
3968 } | |
3969 else if (strcmp (argv[i], "-Xlinker") == 0) | |
3970 { | |
3971 if (i + 1 == argc) | |
3972 fatal ("argument to '-Xlinker' is missing"); | |
3973 | |
3974 n_infiles++; | |
3975 i++; | |
3976 } | |
3977 else if (strcmp (argv[i], "-Xpreprocessor") == 0) | |
3978 { | |
3979 if (i + 1 == argc) | |
3980 fatal ("argument to '-Xpreprocessor' is missing"); | |
3981 | |
3982 add_preprocessor_option (argv[i+1], strlen (argv[i+1])); | |
3983 } | |
3984 else if (strcmp (argv[i], "-Xassembler") == 0) | |
3985 { | |
3986 if (i + 1 == argc) | |
3987 fatal ("argument to '-Xassembler' is missing"); | |
3988 | |
3989 add_assembler_option (argv[i+1], strlen (argv[i+1])); | |
3990 } | |
3991 else if (strcmp (argv[i], "-l") == 0) | |
3992 { | |
3993 if (i + 1 == argc) | |
3994 fatal ("argument to '-l' is missing"); | |
3995 | |
3996 n_infiles++; | |
3997 i++; | |
3998 } | |
3999 else if (strncmp (argv[i], "-l", 2) == 0) | |
4000 n_infiles++; | |
4001 else if (strcmp (argv[i], "-save-temps") == 0) | |
4002 { | |
4003 save_temps_flag = SAVE_TEMPS_CWD; | |
4004 n_switches++; | |
4005 } | |
4006 else if (strncmp (argv[i], "-save-temps=", 12) == 0) | |
4007 { | |
4008 n_switches++; | |
4009 if (strcmp (argv[i]+12, "cwd") == 0) | |
4010 save_temps_flag = SAVE_TEMPS_CWD; | |
4011 else if (strcmp (argv[i]+12, "obj") == 0 | |
4012 || strcmp (argv[i]+12, "object") == 0) | |
4013 save_temps_flag = SAVE_TEMPS_OBJ; | |
4014 else | |
4015 fatal ("'%s' is an unknown -save-temps option", argv[i]); | |
4016 } | |
4017 else if (strcmp (argv[i], "-no-canonical-prefixes") == 0) | |
4018 /* Already handled as a special case, so ignored here. */ | |
4019 ; | |
4020 else if (strcmp (argv[i], "-combine") == 0) | |
4021 { | |
4022 combine_flag = 1; | |
4023 n_switches++; | |
4024 } | |
4025 else if (strcmp (argv[i], "-specs") == 0) | |
4026 { | |
4027 struct user_specs *user = XNEW (struct user_specs); | |
4028 if (++i >= argc) | |
4029 fatal ("argument to '-specs' is missing"); | |
4030 | |
4031 user->next = (struct user_specs *) 0; | |
4032 user->filename = argv[i]; | |
4033 if (user_specs_tail) | |
4034 user_specs_tail->next = user; | |
4035 else | |
4036 user_specs_head = user; | |
4037 user_specs_tail = user; | |
4038 } | |
4039 else if (strncmp (argv[i], "-specs=", 7) == 0) | |
4040 { | |
4041 struct user_specs *user = XNEW (struct user_specs); | |
4042 if (strlen (argv[i]) == 7) | |
4043 fatal ("argument to '-specs=' is missing"); | |
4044 | |
4045 user->next = (struct user_specs *) 0; | |
4046 user->filename = argv[i] + 7; | |
4047 if (user_specs_tail) | |
4048 user_specs_tail->next = user; | |
4049 else | |
4050 user_specs_head = user; | |
4051 user_specs_tail = user; | |
4052 } | |
4053 else if (strcmp (argv[i], "-time") == 0) | |
4054 report_times = 1; | |
4055 else if (strncmp (argv[i], "-time=", sizeof ("-time=") - 1) == 0) | |
4056 { | |
4057 if (report_times_to_file) | |
4058 fclose (report_times_to_file); | |
4059 report_times_to_file = fopen (argv[i] + sizeof ("-time=") - 1, "a"); | |
4060 } | |
4061 else if (strcmp (argv[i], "-pipe") == 0) | |
4062 { | |
4063 /* -pipe has to go into the switches array as well as | |
4064 setting a flag. */ | |
4065 use_pipes = 1; | |
4066 n_switches++; | |
4067 } | |
4068 else if (strcmp (argv[i], "-wrapper") == 0) | |
4069 { | |
4070 if (++i >= argc) | |
4071 fatal ("argument to '-wrapper' is missing"); | |
4072 | |
4073 wrapper_string = argv[i]; | |
4074 n_switches++; | |
4075 n_switches++; | |
4076 } | |
4077 else if (strcmp (argv[i], "-###") == 0) | |
4078 { | |
4079 /* This is similar to -v except that there is no execution | |
4080 of the commands and the echoed arguments are quoted. It | |
4081 is intended for use in shell scripts to capture the | |
4082 driver-generated command line. */ | |
4083 verbose_only_flag++; | |
4084 verbose_flag++; | |
4085 } | |
4086 else if (argv[i][0] == '-' && argv[i][1] != 0) | |
4087 { | |
4088 const char *p = &argv[i][1]; | |
4089 int c = *p; | |
4090 | |
4091 switch (c) | |
4092 { | |
4093 case 'b': | |
4094 if (p[1] && NULL == strchr (argv[i] + 2, '-')) | |
4095 goto normal_switch; | |
4096 | |
4097 /* Fall through. */ | |
4098 case 'V': | |
4099 fatal ("'-%c' must come at the start of the command line", c); | |
4100 break; | |
4101 | |
4102 case 'B': | |
4103 { | |
4104 const char *value; | |
4105 int len; | |
4106 | |
4107 if (p[1] == 0 && i + 1 == argc) | |
4108 fatal ("argument to '-B' is missing"); | |
4109 if (p[1] == 0) | |
4110 value = argv[++i]; | |
4111 else | |
4112 value = p + 1; | |
4113 | |
4114 len = strlen (value); | |
4115 | |
4116 /* Catch the case where the user has forgotten to append a | |
4117 directory separator to the path. Note, they may be using | |
4118 -B to add an executable name prefix, eg "i386-elf-", in | |
4119 order to distinguish between multiple installations of | |
4120 GCC in the same directory. Hence we must check to see | |
4121 if appending a directory separator actually makes a | |
4122 valid directory name. */ | |
4123 if (! IS_DIR_SEPARATOR (value [len - 1]) | |
4124 && is_directory (value, false)) | |
4125 { | |
4126 char *tmp = XNEWVEC (char, len + 2); | |
4127 strcpy (tmp, value); | |
4128 tmp[len] = DIR_SEPARATOR; | |
4129 tmp[++ len] = 0; | |
4130 value = tmp; | |
4131 } | |
4132 | |
4133 add_prefix (&exec_prefixes, value, NULL, | |
4134 PREFIX_PRIORITY_B_OPT, 0, 0); | |
4135 add_prefix (&startfile_prefixes, value, NULL, | |
4136 PREFIX_PRIORITY_B_OPT, 0, 0); | |
4137 add_prefix (&include_prefixes, value, NULL, | |
4138 PREFIX_PRIORITY_B_OPT, 0, 0); | |
4139 n_switches++; | |
4140 } | |
4141 break; | |
4142 | |
4143 case 'v': /* Print our subcommands and print versions. */ | |
4144 n_switches++; | |
4145 /* If they do anything other than exactly `-v', don't set | |
4146 verbose_flag; rather, continue on to give the error. */ | |
4147 if (p[1] != 0) | |
4148 break; | |
4149 verbose_flag++; | |
4150 break; | |
4151 | |
4152 case 'S': | |
4153 case 'c': | |
4154 case 'E': | |
4155 if (p[1] == 0) | |
4156 { | |
4157 have_c = 1; | |
4158 n_switches++; | |
4159 break; | |
4160 } | |
4161 goto normal_switch; | |
4162 | |
4163 case 'o': | |
4164 have_o = 1; | |
4165 #if defined(HAVE_TARGET_EXECUTABLE_SUFFIX) | |
4166 if (! have_c) | |
4167 { | |
4168 int skip; | |
4169 | |
4170 /* Forward scan, just in case -S, -E or -c is specified | |
4171 after -o. */ | |
4172 int j = i + 1; | |
4173 if (p[1] == 0) | |
4174 ++j; | |
4175 while (j < argc) | |
4176 { | |
4177 if (argv[j][0] == '-') | |
4178 { | |
4179 if (SWITCH_CURTAILS_COMPILATION (argv[j][1]) | |
4180 && argv[j][2] == 0) | |
4181 { | |
4182 have_c = 1; | |
4183 break; | |
4184 } | |
4185 else if ((skip = SWITCH_TAKES_ARG (argv[j][1]))) | |
4186 j += skip - (argv[j][2] != 0); | |
4187 else if ((skip = WORD_SWITCH_TAKES_ARG (argv[j] + 1))) | |
4188 j += skip; | |
4189 } | |
4190 j++; | |
4191 } | |
4192 } | |
4193 #endif | |
4194 #if defined(HAVE_TARGET_EXECUTABLE_SUFFIX) || defined(HAVE_TARGET_OBJECT_SUFFIX) | |
4195 if (p[1] == 0) | |
4196 argv[i + 1] = convert_filename (argv[i + 1], ! have_c, 0); | |
4197 else | |
4198 argv[i] = convert_filename (argv[i], ! have_c, 0); | |
4199 #endif | |
4200 /* Save the output name in case -save-temps=obj was used. */ | |
4201 if ((p[1] == 0) && argv[i + 1]) | |
4202 save_temps_prefix = xstrdup(argv[i + 1]); | |
4203 else | |
4204 save_temps_prefix = xstrdup(argv[i] + 1); | |
4205 goto normal_switch; | |
4206 | |
4207 default: | |
4208 normal_switch: | |
4209 | |
4210 #ifdef MODIFY_TARGET_NAME | |
4211 is_modify_target_name = 0; | |
4212 | |
4213 for (j = 0; j < ARRAY_SIZE (modify_target); j++) | |
4214 if (! strcmp (argv[i], modify_target[j].sw)) | |
4215 { | |
4216 char *new_name = XNEWVEC (char, strlen (modify_target[j].str) | |
4217 + strlen (spec_machine)); | |
4218 const char *p, *r; | |
4219 char *q; | |
4220 int made_addition = 0; | |
4221 | |
4222 is_modify_target_name = 1; | |
4223 for (p = spec_machine, q = new_name; *p != 0; ) | |
4224 { | |
4225 if (modify_target[j].add_del == DELETE | |
4226 && (! strncmp (q, modify_target[j].str, | |
4227 strlen (modify_target[j].str)))) | |
4228 p += strlen (modify_target[j].str); | |
4229 else if (modify_target[j].add_del == ADD | |
4230 && ! made_addition && *p == '-') | |
4231 { | |
4232 for (r = modify_target[j].str; *r != 0; ) | |
4233 *q++ = *r++; | |
4234 made_addition = 1; | |
4235 } | |
4236 | |
4237 *q++ = *p++; | |
4238 } | |
4239 | |
4240 spec_machine = new_name; | |
4241 } | |
4242 | |
4243 if (is_modify_target_name) | |
4244 break; | |
4245 #endif | |
4246 | |
4247 n_switches++; | |
4248 | |
4249 if (SWITCH_TAKES_ARG (c) > (p[1] != 0)) | |
4250 i += SWITCH_TAKES_ARG (c) - (p[1] != 0); | |
4251 else if (WORD_SWITCH_TAKES_ARG (p)) | |
4252 i += WORD_SWITCH_TAKES_ARG (p); | |
4253 } | |
4254 } | |
4255 else | |
4256 { | |
4257 n_infiles++; | |
4258 lang_n_infiles++; | |
4259 } | |
4260 } | 3794 } |
4261 | 3795 |
4262 /* If -save-temps=obj and -o name, create the prefix to use for %b. | 3796 /* If -save-temps=obj and -o name, create the prefix to use for %b. |
4263 Otherwise just make -save-temps=obj the same as -save-temps=cwd. */ | 3797 Otherwise just make -save-temps=obj the same as -save-temps=cwd. */ |
4264 if (save_temps_flag == SAVE_TEMPS_OBJ && save_temps_prefix != NULL) | 3798 if (save_temps_flag == SAVE_TEMPS_OBJ && save_temps_prefix != NULL) |
4280 | 3814 |
4281 if (save_temps_flag && use_pipes) | 3815 if (save_temps_flag && use_pipes) |
4282 { | 3816 { |
4283 /* -save-temps overrides -pipe, so that temp files are produced */ | 3817 /* -save-temps overrides -pipe, so that temp files are produced */ |
4284 if (save_temps_flag) | 3818 if (save_temps_flag) |
4285 error ("warning: -pipe ignored because -save-temps specified"); | 3819 warning (0, "-pipe ignored because -save-temps specified"); |
4286 use_pipes = 0; | 3820 use_pipes = 0; |
4287 } | 3821 } |
4288 | 3822 |
4289 if (!compare_debug) | 3823 if (!compare_debug) |
4290 { | 3824 { |
4292 | 3826 |
4293 if (gcd && gcd[0] == '-') | 3827 if (gcd && gcd[0] == '-') |
4294 { | 3828 { |
4295 compare_debug = 2; | 3829 compare_debug = 2; |
4296 compare_debug_opt = gcd; | 3830 compare_debug_opt = gcd; |
4297 n_switches++; | |
4298 } | 3831 } |
4299 else if (gcd && *gcd && strcmp (gcd, "0")) | 3832 else if (gcd && *gcd && strcmp (gcd, "0")) |
4300 { | 3833 { |
4301 compare_debug = 3; | 3834 compare_debug = 3; |
4302 compare_debug_opt = "-gtoggle"; | 3835 compare_debug_opt = "-gtoggle"; |
4303 n_switches++; | |
4304 } | 3836 } |
4305 } | 3837 } |
4306 else if (compare_debug < 0) | 3838 else if (compare_debug < 0) |
4307 { | 3839 { |
4308 compare_debug = 0; | 3840 compare_debug = 0; |
4351 #if defined(TARGET_SYSTEM_ROOT_RELOCATABLE) && !defined(VMS) | 3883 #if defined(TARGET_SYSTEM_ROOT_RELOCATABLE) && !defined(VMS) |
4352 /* If the normal TARGET_SYSTEM_ROOT is inside of $exec_prefix, | 3884 /* If the normal TARGET_SYSTEM_ROOT is inside of $exec_prefix, |
4353 then consider it to relocate with the rest of the GCC installation | 3885 then consider it to relocate with the rest of the GCC installation |
4354 if GCC_EXEC_PREFIX is set. | 3886 if GCC_EXEC_PREFIX is set. |
4355 ``make_relative_prefix'' is not compiled for VMS, so don't call it. */ | 3887 ``make_relative_prefix'' is not compiled for VMS, so don't call it. */ |
4356 if (target_system_root && gcc_exec_prefix) | 3888 if (target_system_root && !target_system_root_changed && gcc_exec_prefix) |
4357 { | 3889 { |
4358 char *tmp_prefix = get_relative_prefix (argv[0], | 3890 char *tmp_prefix = get_relative_prefix (decoded_options[0].arg, |
4359 standard_bindir_prefix, | 3891 standard_bindir_prefix, |
4360 target_system_root); | 3892 target_system_root); |
4361 if (tmp_prefix && access_check (tmp_prefix, F_OK) == 0) | 3893 if (tmp_prefix && access_check (tmp_prefix, F_OK) == 0) |
4362 { | 3894 { |
4363 target_system_root = tmp_prefix; | 3895 target_system_root = tmp_prefix; |
4367 #endif | 3899 #endif |
4368 | 3900 |
4369 /* More prefixes are enabled in main, after we read the specs file | 3901 /* More prefixes are enabled in main, after we read the specs file |
4370 and determine whether this is cross-compilation or not. */ | 3902 and determine whether this is cross-compilation or not. */ |
4371 | 3903 |
4372 /* Then create the space for the vectors and scan again. */ | |
4373 | |
4374 switches = XNEWVEC (struct switchstr, n_switches + 1); | |
4375 infiles = XNEWVEC (struct infile, n_infiles + 1); | |
4376 n_switches = 0; | |
4377 n_infiles = 0; | |
4378 last_language_n_infiles = -1; | |
4379 | |
4380 /* This, time, copy the text of each switch and store a pointer | |
4381 to the copy in the vector of switches. | |
4382 Store all the infiles in their vector. */ | |
4383 | |
4384 for (i = 1; i < argc; i++) | |
4385 { | |
4386 /* Just skip the switches that were handled by the preceding loop. */ | |
4387 #ifdef MODIFY_TARGET_NAME | |
4388 is_modify_target_name = 0; | |
4389 | |
4390 for (j = 0; j < ARRAY_SIZE (modify_target); j++) | |
4391 if (! strcmp (argv[i], modify_target[j].sw)) | |
4392 is_modify_target_name = 1; | |
4393 | |
4394 if (is_modify_target_name) | |
4395 ; | |
4396 else | |
4397 #endif | |
4398 if (! strncmp (argv[i], "-Wa,", 4)) | |
4399 ; | |
4400 else if (! strncmp (argv[i], "-Wp,", 4)) | |
4401 ; | |
4402 else if (! strcmp (argv[i], "-no-canonical-prefixes")) | |
4403 ; | |
4404 else if (! strcmp (argv[i], "-pass-exit-codes")) | |
4405 ; | |
4406 else if (! strcmp (argv[i], "-print-search-dirs")) | |
4407 ; | |
4408 else if (! strcmp (argv[i], "-print-libgcc-file-name")) | |
4409 ; | |
4410 else if (! strncmp (argv[i], "-print-file-name=", 17)) | |
4411 ; | |
4412 else if (! strncmp (argv[i], "-print-prog-name=", 17)) | |
4413 ; | |
4414 else if (! strcmp (argv[i], "-print-multi-lib")) | |
4415 ; | |
4416 else if (! strcmp (argv[i], "-print-multi-directory")) | |
4417 ; | |
4418 else if (! strcmp (argv[i], "-print-sysroot")) | |
4419 ; | |
4420 else if (! strcmp (argv[i], "-print-multi-os-directory")) | |
4421 ; | |
4422 else if (! strcmp (argv[i], "-print-sysroot-headers-suffix")) | |
4423 ; | |
4424 else if (! strncmp (argv[i], "--sysroot=", strlen ("--sysroot="))) | |
4425 { | |
4426 target_system_root = argv[i] + strlen ("--sysroot="); | |
4427 target_system_root_changed = 1; | |
4428 } | |
4429 else if (argv[i][0] == '+' && argv[i][1] == 'e') | |
4430 { | |
4431 /* Compensate for the +e options to the C++ front-end; | |
4432 they're there simply for cfront call-compatibility. We do | |
4433 some magic in default_compilers to pass them down properly. | |
4434 Note we deliberately start at the `+' here, to avoid passing | |
4435 -e0 or -e1 down into the linker. */ | |
4436 switches[n_switches].part1 = &argv[i][0]; | |
4437 switches[n_switches].args = 0; | |
4438 switches[n_switches].live_cond = 0; | |
4439 switches[n_switches].validated = 0; | |
4440 n_switches++; | |
4441 } | |
4442 else if (strncmp (argv[i], "-Wl,", 4) == 0) | |
4443 { | |
4444 int prev, j; | |
4445 /* Split the argument at commas. */ | |
4446 prev = 4; | |
4447 for (j = 4; argv[i][j]; j++) | |
4448 if (argv[i][j] == ',') | |
4449 { | |
4450 infiles[n_infiles].language = "*"; | |
4451 infiles[n_infiles++].name | |
4452 = save_string (argv[i] + prev, j - prev); | |
4453 prev = j + 1; | |
4454 } | |
4455 /* Record the part after the last comma. */ | |
4456 infiles[n_infiles].language = "*"; | |
4457 infiles[n_infiles++].name = argv[i] + prev; | |
4458 } | |
4459 else if (strcmp (argv[i], "-Xlinker") == 0) | |
4460 { | |
4461 infiles[n_infiles].language = "*"; | |
4462 infiles[n_infiles++].name = argv[++i]; | |
4463 } | |
4464 /* Xassembler and Xpreprocessor were already handled in the first argv | |
4465 scan, so all we need to do here is ignore them and their argument. */ | |
4466 else if (strcmp (argv[i], "-Xassembler") == 0) | |
4467 i++; | |
4468 else if (strcmp (argv[i], "-Xpreprocessor") == 0) | |
4469 i++; | |
4470 else if (strcmp (argv[i], "-l") == 0) | |
4471 { /* POSIX allows separation of -l and the lib arg; | |
4472 canonicalize by concatenating -l with its arg */ | |
4473 infiles[n_infiles].language = "*"; | |
4474 infiles[n_infiles++].name = concat ("-l", argv[++i], NULL); | |
4475 } | |
4476 else if (strncmp (argv[i], "-l", 2) == 0) | |
4477 { | |
4478 infiles[n_infiles].language = "*"; | |
4479 infiles[n_infiles++].name = argv[i]; | |
4480 } | |
4481 else if (strcmp (argv[i], "-wrapper") == 0) | |
4482 i++; | |
4483 else if (strcmp (argv[i], "-specs") == 0) | |
4484 i++; | |
4485 else if (strncmp (argv[i], "-specs=", 7) == 0) | |
4486 ; | |
4487 else if (strcmp (argv[i], "-time") == 0) | |
4488 ; | |
4489 else if (strncmp (argv[i], "-time=", sizeof ("-time=") - 1) == 0) | |
4490 ; | |
4491 else if (strcmp (argv[i], "-###") == 0) | |
4492 ; | |
4493 else if (argv[i][0] == '-' && argv[i][1] != 0) | |
4494 { | |
4495 const char *p = &argv[i][1]; | |
4496 int c = *p; | |
4497 | |
4498 if (c == 'x') | |
4499 { | |
4500 if (p[1] == 0 && i + 1 == argc) | |
4501 fatal ("argument to '-x' is missing"); | |
4502 if (p[1] == 0) | |
4503 spec_lang = argv[++i]; | |
4504 else | |
4505 spec_lang = p + 1; | |
4506 if (! strcmp (spec_lang, "none")) | |
4507 /* Suppress the warning if -xnone comes after the last input | |
4508 file, because alternate command interfaces like g++ might | |
4509 find it useful to place -xnone after each input file. */ | |
4510 spec_lang = 0; | |
4511 else | |
4512 last_language_n_infiles = n_infiles; | |
4513 continue; | |
4514 } | |
4515 switches[n_switches].part1 = p; | |
4516 /* Deal with option arguments in separate argv elements. */ | |
4517 if ((SWITCH_TAKES_ARG (c) > (p[1] != 0)) | |
4518 || WORD_SWITCH_TAKES_ARG (p)) | |
4519 { | |
4520 int j = 0; | |
4521 int n_args = WORD_SWITCH_TAKES_ARG (p); | |
4522 | |
4523 if (n_args == 0) | |
4524 { | |
4525 /* Count only the option arguments in separate argv elements. */ | |
4526 n_args = SWITCH_TAKES_ARG (c) - (p[1] != 0); | |
4527 } | |
4528 if (i + n_args >= argc) | |
4529 fatal ("argument to '-%s' is missing", p); | |
4530 switches[n_switches].args | |
4531 = XNEWVEC (const char *, n_args + 1); | |
4532 while (j < n_args) | |
4533 switches[n_switches].args[j++] = argv[++i]; | |
4534 /* Null-terminate the vector. */ | |
4535 switches[n_switches].args[j] = 0; | |
4536 } | |
4537 else if (strchr (switches_need_spaces, c)) | |
4538 { | |
4539 /* On some systems, ld cannot handle some options without | |
4540 a space. So split the option from its argument. */ | |
4541 char *part1 = XNEWVEC (char, 2); | |
4542 part1[0] = c; | |
4543 part1[1] = '\0'; | |
4544 | |
4545 switches[n_switches].part1 = part1; | |
4546 switches[n_switches].args = XNEWVEC (const char *, 2); | |
4547 switches[n_switches].args[0] = xstrdup (p+1); | |
4548 switches[n_switches].args[1] = 0; | |
4549 } | |
4550 else | |
4551 switches[n_switches].args = 0; | |
4552 | |
4553 switches[n_switches].live_cond = 0; | |
4554 switches[n_switches].validated = 0; | |
4555 switches[n_switches].ordering = 0; | |
4556 /* These are always valid, since gcc.c itself understands the | |
4557 first four and gfortranspec.c understands -static-libgfortran. */ | |
4558 if (!strcmp (p, "save-temps") | |
4559 || !strcmp (p, "static-libgcc") | |
4560 || !strcmp (p, "shared-libgcc") | |
4561 || !strcmp (p, "pipe") | |
4562 || !strcmp (p, "static-libgfortran")) | |
4563 switches[n_switches].validated = 1; | |
4564 else | |
4565 { | |
4566 char ch = switches[n_switches].part1[0]; | |
4567 if (ch == 'B') | |
4568 switches[n_switches].validated = 1; | |
4569 } | |
4570 n_switches++; | |
4571 } | |
4572 else | |
4573 { | |
4574 const char *p = strchr (argv[i], '@'); | |
4575 char *fname; | |
4576 #ifdef HAVE_TARGET_OBJECT_SUFFIX | |
4577 argv[i] = convert_filename (argv[i], 0, access (argv[i], F_OK)); | |
4578 #endif | |
4579 if (!p) | |
4580 fname = xstrdup (argv[i]); | |
4581 else | |
4582 { | |
4583 fname = (char *)xmalloc (p - argv[i] + 1); | |
4584 memcpy (fname, argv[i], p - argv[i]); | |
4585 fname[p - argv[i]] = '\0'; | |
4586 } | |
4587 | |
4588 if (strcmp (fname, "-") != 0 && access (fname, F_OK) < 0) | |
4589 { | |
4590 perror_with_name (fname); | |
4591 error_count++; | |
4592 } | |
4593 else | |
4594 { | |
4595 infiles[n_infiles].language = spec_lang; | |
4596 infiles[n_infiles++].name = argv[i]; | |
4597 } | |
4598 | |
4599 free (fname); | |
4600 } | |
4601 } | |
4602 | |
4603 if (n_infiles == last_language_n_infiles && spec_lang != 0) | 3904 if (n_infiles == last_language_n_infiles && spec_lang != 0) |
4604 error ("warning: '-x %s' after last input file has no effect", spec_lang); | 3905 warning (0, "%<-x %s%> after last input file has no effect", spec_lang); |
4605 | 3906 |
4606 if (compare_debug == 2 || compare_debug == 3) | 3907 if (compare_debug == 2 || compare_debug == 3) |
4607 { | 3908 { |
3909 alloc_switch (); | |
4608 switches[n_switches].part1 = concat ("fcompare-debug=", | 3910 switches[n_switches].part1 = concat ("fcompare-debug=", |
4609 compare_debug_opt, | 3911 compare_debug_opt, |
4610 NULL); | 3912 NULL); |
4611 switches[n_switches].args = 0; | 3913 switches[n_switches].args = 0; |
4612 switches[n_switches].live_cond = 0; | 3914 switches[n_switches].live_cond = 0; |
4617 } | 3919 } |
4618 | 3920 |
4619 /* Ensure we only invoke each subprocess once. */ | 3921 /* Ensure we only invoke each subprocess once. */ |
4620 if (print_subprocess_help || print_help_list || print_version) | 3922 if (print_subprocess_help || print_help_list || print_version) |
4621 { | 3923 { |
4622 n_infiles = 1; | 3924 n_infiles = 0; |
4623 | 3925 |
4624 /* Create a dummy input file, so that we can pass | 3926 /* Create a dummy input file, so that we can pass |
4625 the help option on to the various sub-processes. */ | 3927 the help option on to the various sub-processes. */ |
4626 infiles[0].language = "c"; | 3928 add_infile ("help-dummy", "c"); |
4627 infiles[0].name = "help-dummy"; | 3929 } |
4628 } | 3930 |
4629 | 3931 alloc_switch (); |
4630 switches[n_switches].part1 = 0; | 3932 switches[n_switches].part1 = 0; |
3933 alloc_infile (); | |
4631 infiles[n_infiles].name = 0; | 3934 infiles[n_infiles].name = 0; |
4632 } | 3935 } |
4633 | 3936 |
4634 /* Store switches not filtered out by %<S in spec in COLLECT_GCC_OPTIONS | 3937 /* Store switches not filtered out by %<S in spec in COLLECT_GCC_OPTIONS |
4635 and place that in the environment. */ | 3938 and place that in the environment. */ |
4654 obstack_grow (&collect_obstack, " ", 1); | 3957 obstack_grow (&collect_obstack, " ", 1); |
4655 | 3958 |
4656 first_time = FALSE; | 3959 first_time = FALSE; |
4657 | 3960 |
4658 /* Ignore elided switches. */ | 3961 /* Ignore elided switches. */ |
4659 if ((switches[i].live_cond & SWITCH_IGNORE) != 0) | 3962 if ((switches[i].live_cond |
3963 & (SWITCH_IGNORE | SWITCH_KEEP_FOR_GCC)) | |
3964 == SWITCH_IGNORE) | |
4660 continue; | 3965 continue; |
4661 | 3966 |
4662 obstack_grow (&collect_obstack, "'-", 2); | 3967 obstack_grow (&collect_obstack, "'-", 2); |
4663 q = switches[i].part1; | 3968 q = switches[i].part1; |
4664 while ((p = strchr (q, '\''))) | 3969 while ((p = strchr (q, '\''))) |
4695 so that the output file name can be stored for later use by %o. | 4000 so that the output file name can be stored for later use by %o. |
4696 input_basename is the start of the part of the input file | 4001 input_basename is the start of the part of the input file |
4697 sans all directory names, and basename_length is the number | 4002 sans all directory names, and basename_length is the number |
4698 of characters starting there excluding the suffix .c or whatever. */ | 4003 of characters starting there excluding the suffix .c or whatever. */ |
4699 | 4004 |
4700 static const char *input_filename; | 4005 static const char *gcc_input_filename; |
4701 static int input_file_number; | 4006 static int input_file_number; |
4702 size_t input_filename_length; | 4007 size_t input_filename_length; |
4703 static int basename_length; | 4008 static int basename_length; |
4704 static int suffixed_basename_length; | 4009 static int suffixed_basename_length; |
4705 static const char *input_basename; | 4010 static const char *input_basename; |
4762 { | 4067 { |
4763 char * full_script_path = find_a_file (&startfile_prefixes, string, R_OK, true); | 4068 char * full_script_path = find_a_file (&startfile_prefixes, string, R_OK, true); |
4764 | 4069 |
4765 if (full_script_path == NULL) | 4070 if (full_script_path == NULL) |
4766 { | 4071 { |
4767 error (_("unable to locate default linker script '%s' in the library search paths"), string); | 4072 error ("unable to locate default linker script %qs in the library search paths", string); |
4768 /* Script was not found on search path. */ | 4073 /* Script was not found on search path. */ |
4769 return; | 4074 return; |
4770 } | 4075 } |
4771 store_arg ("--script", false, false); | 4076 store_arg ("--script", false, false); |
4772 string = full_script_path; | 4077 string = full_script_path; |
4787 { | 4092 { |
4788 int n = 0; | 4093 int n = 0; |
4789 int i; | 4094 int i; |
4790 char *buf = xstrdup (wrapper); | 4095 char *buf = xstrdup (wrapper); |
4791 char *p = buf; | 4096 char *p = buf; |
4097 unsigned int old_length = VEC_length (const_char_p, argbuf); | |
4792 | 4098 |
4793 do | 4099 do |
4794 { | 4100 { |
4795 n++; | 4101 n++; |
4796 while (*p == ',') | 4102 while (*p == ',') |
4797 p++; | 4103 p++; |
4798 } | 4104 } |
4799 while ((p = strchr (p, ',')) != NULL); | 4105 while ((p = strchr (p, ',')) != NULL); |
4800 | 4106 |
4801 if (argbuf_index + n >= argbuf_length) | 4107 VEC_safe_grow (const_char_p, heap, argbuf, old_length + n); |
4802 { | 4108 memmove (VEC_address (const_char_p, argbuf) + n, |
4803 argbuf_length = argbuf_length * 2; | 4109 VEC_address (const_char_p, argbuf), |
4804 while (argbuf_length < argbuf_index + n) | 4110 old_length * sizeof (const_char_p)); |
4805 argbuf_length *= 2; | |
4806 argbuf = XRESIZEVEC (const char *, argbuf, argbuf_length); | |
4807 } | |
4808 for (i = argbuf_index - 1; i >= 0; i--) | |
4809 argbuf[i + n] = argbuf[i]; | |
4810 | 4111 |
4811 i = 0; | 4112 i = 0; |
4812 p = buf; | 4113 p = buf; |
4813 do | 4114 do |
4814 { | 4115 { |
4815 while (*p == ',') | 4116 while (*p == ',') |
4816 { | 4117 { |
4817 *p = 0; | 4118 *p = 0; |
4818 p++; | 4119 p++; |
4819 } | 4120 } |
4820 argbuf[i++] = p; | 4121 VEC_replace (const_char_p, argbuf, i, p); |
4122 i++; | |
4821 } | 4123 } |
4822 while ((p = strchr (p, ',')) != NULL); | 4124 while ((p = strchr (p, ',')) != NULL); |
4823 gcc_assert (i == n); | 4125 gcc_assert (i == n); |
4824 argbuf_index += n; | |
4825 } | 4126 } |
4826 | 4127 |
4827 /* Process the spec SPEC and run the commands specified therein. | 4128 /* Process the spec SPEC and run the commands specified therein. |
4828 Returns 0 if the spec is successfully processed; -1 if failed. */ | 4129 Returns 0 if the spec is successfully processed; -1 if failed. */ |
4829 | 4130 |
4836 | 4137 |
4837 /* Force out any unfinished command. | 4138 /* Force out any unfinished command. |
4838 If -pipe, this forces out the last command if it ended in `|'. */ | 4139 If -pipe, this forces out the last command if it ended in `|'. */ |
4839 if (value == 0) | 4140 if (value == 0) |
4840 { | 4141 { |
4841 if (argbuf_index > 0 && !strcmp (argbuf[argbuf_index - 1], "|")) | 4142 if (VEC_length (const_char_p, argbuf) > 0 |
4842 argbuf_index--; | 4143 && !strcmp (VEC_last (const_char_p, argbuf), "|")) |
4144 VEC_pop (const_char_p, argbuf); | |
4843 | 4145 |
4844 set_collect_gcc_options (); | 4146 set_collect_gcc_options (); |
4845 | 4147 |
4846 if (argbuf_index > 0) | 4148 if (VEC_length (const_char_p, argbuf) > 0) |
4847 value = execute (); | 4149 value = execute (); |
4848 } | 4150 } |
4849 | 4151 |
4850 return value; | 4152 return value; |
4851 } | 4153 } |
4925 of the switches/n_switches array. */ | 4227 of the switches/n_switches array. */ |
4926 | 4228 |
4927 static void | 4229 static void |
4928 do_self_spec (const char *spec) | 4230 do_self_spec (const char *spec) |
4929 { | 4231 { |
4232 int i; | |
4233 | |
4930 do_spec_2 (spec); | 4234 do_spec_2 (spec); |
4931 do_spec_1 (" ", 0, NULL); | 4235 do_spec_1 (" ", 0, NULL); |
4932 | 4236 |
4933 if (argbuf_index > 0) | 4237 /* Mark %<S switches processed by do_self_spec to be ignored permanently. |
4934 { | 4238 do_self_specs adds the replacements to switches array, so it shouldn't |
4935 int i; | 4239 be processed afterwards. */ |
4936 | 4240 for (i = 0; i < n_switches; i++) |
4937 switches = XRESIZEVEC (struct switchstr, switches, | 4241 if ((switches[i].live_cond & SWITCH_IGNORE)) |
4938 n_switches + argbuf_index + 1); | 4242 switches[i].live_cond |= SWITCH_IGNORE_PERMANENTLY; |
4939 | 4243 |
4940 for (i = 0; i < argbuf_index; i++) | 4244 if (VEC_length (const_char_p, argbuf) > 0) |
4245 { | |
4246 const char **argbuf_copy; | |
4247 struct cl_decoded_option *decoded_options; | |
4248 struct cl_option_handlers handlers; | |
4249 unsigned int decoded_options_count; | |
4250 unsigned int j; | |
4251 | |
4252 /* Create a copy of argbuf with a dummy argv[0] entry for | |
4253 decode_cmdline_options_to_array. */ | |
4254 argbuf_copy = XNEWVEC (const char *, | |
4255 VEC_length (const_char_p, argbuf) + 1); | |
4256 argbuf_copy[0] = ""; | |
4257 memcpy (argbuf_copy + 1, VEC_address (const_char_p, argbuf), | |
4258 VEC_length (const_char_p, argbuf) * sizeof (const char *)); | |
4259 | |
4260 decode_cmdline_options_to_array (VEC_length (const_char_p, argbuf) + 1, | |
4261 argbuf_copy, | |
4262 CL_DRIVER, &decoded_options, | |
4263 &decoded_options_count); | |
4264 | |
4265 set_option_handlers (&handlers); | |
4266 | |
4267 for (j = 1; j < decoded_options_count; j++) | |
4941 { | 4268 { |
4942 struct switchstr *sw; | 4269 switch (decoded_options[j].opt_index) |
4943 const char *p = argbuf[i]; | |
4944 int c = *p; | |
4945 | |
4946 /* Each switch should start with '-'. */ | |
4947 if (c != '-') | |
4948 fatal ("switch '%s' does not start with '-'", argbuf[i]); | |
4949 | |
4950 p++; | |
4951 c = *p; | |
4952 | |
4953 sw = &switches[n_switches++]; | |
4954 sw->part1 = p; | |
4955 sw->live_cond = 0; | |
4956 sw->validated = 0; | |
4957 sw->ordering = 0; | |
4958 | |
4959 /* Deal with option arguments in separate argv elements. */ | |
4960 if ((SWITCH_TAKES_ARG (c) > (p[1] != 0)) | |
4961 || WORD_SWITCH_TAKES_ARG (p)) | |
4962 { | 4270 { |
4963 int j = 0; | 4271 case OPT_SPECIAL_input_file: |
4964 int n_args = WORD_SWITCH_TAKES_ARG (p); | 4272 /* Specs should only generate options, not input |
4965 | 4273 files. */ |
4966 if (n_args == 0) | 4274 if (strcmp (decoded_options[j].arg, "-") != 0) |
4967 { | 4275 fatal_error ("switch %qs does not start with %<-%>", |
4968 /* Count only the option arguments in separate argv elements. */ | 4276 decoded_options[j].arg); |
4969 n_args = SWITCH_TAKES_ARG (c) - (p[1] != 0); | 4277 else |
4970 } | 4278 fatal_error ("spec-generated switch is just %<-%>"); |
4971 if (i + n_args >= argbuf_index) | 4279 break; |
4972 fatal ("argument to '-%s' is missing", p); | 4280 |
4973 sw->args | 4281 case OPT_fcompare_debug_second: |
4974 = XNEWVEC (const char *, n_args + 1); | 4282 case OPT_fcompare_debug: |
4975 while (j < n_args) | 4283 case OPT_fcompare_debug_: |
4976 sw->args[j++] = argbuf[++i]; | 4284 case OPT_o: |
4977 /* Null-terminate the vector. */ | 4285 /* Avoid duplicate processing of some options from |
4978 sw->args[j] = 0; | 4286 compare-debug specs; just save them here. */ |
4287 save_switch (decoded_options[j].canonical_option[0], | |
4288 (decoded_options[j].canonical_option_num_elements | |
4289 - 1), | |
4290 &decoded_options[j].canonical_option[1], false); | |
4291 break; | |
4292 | |
4293 default: | |
4294 read_cmdline_option (&global_options, &global_options_set, | |
4295 decoded_options + j, UNKNOWN_LOCATION, | |
4296 CL_DRIVER, &handlers, global_dc); | |
4297 break; | |
4979 } | 4298 } |
4980 else if (strchr (switches_need_spaces, c)) | |
4981 { | |
4982 /* On some systems, ld cannot handle some options without | |
4983 a space. So split the option from its argument. */ | |
4984 char *part1 = XNEWVEC (char, 2); | |
4985 part1[0] = c; | |
4986 part1[1] = '\0'; | |
4987 | |
4988 sw->part1 = part1; | |
4989 sw->args = XNEWVEC (const char *, 2); | |
4990 sw->args[0] = xstrdup (p+1); | |
4991 sw->args[1] = 0; | |
4992 } | |
4993 else | |
4994 sw->args = 0; | |
4995 } | 4299 } |
4996 | 4300 |
4301 alloc_switch (); | |
4997 switches[n_switches].part1 = 0; | 4302 switches[n_switches].part1 = 0; |
4998 } | 4303 } |
4999 } | 4304 } |
5000 | 4305 |
5001 /* Callback for processing %D and %I specs. */ | 4306 /* Callback for processing %D and %I specs. */ |
5059 char *at_argument = concat ("@", temp_file, NULL); | 4364 char *at_argument = concat ("@", temp_file, NULL); |
5060 FILE *f = fopen (temp_file, "w"); | 4365 FILE *f = fopen (temp_file, "w"); |
5061 int status; | 4366 int status; |
5062 | 4367 |
5063 if (f == NULL) | 4368 if (f == NULL) |
5064 fatal ("could not open temporary response file %s", | 4369 fatal_error ("could not open temporary response file %s", |
5065 temp_file); | 4370 temp_file); |
5066 | 4371 |
5067 status = writeargv (argv, f); | 4372 status = writeargv (argv, f); |
5068 | 4373 |
5069 if (status) | 4374 if (status) |
5070 fatal ("could not write to temporary response file %s", | 4375 fatal_error ("could not write to temporary response file %s", |
5071 temp_file); | 4376 temp_file); |
5072 | 4377 |
5073 status = fclose (f); | 4378 status = fclose (f); |
5074 | 4379 |
5075 if (EOF == status) | 4380 if (EOF == status) |
5076 fatal ("could not close temporary response file %s", | 4381 fatal_error ("could not close temporary response file %s", |
5077 temp_file); | 4382 temp_file); |
5078 | 4383 |
5079 store_arg (at_argument, 0, 0); | 4384 store_arg (at_argument, 0, 0); |
5080 | 4385 |
5081 record_temp_file (temp_file, !save_temps_flag, !save_temps_flag); | 4386 record_temp_file (temp_file, !save_temps_flag, !save_temps_flag); |
5082 } | 4387 } |
5088 { | 4393 { |
5089 if ((!infile->language) || (infile->language[0] != '*')) | 4394 if ((!infile->language) || (infile->language[0] != '*')) |
5090 if (infile->incompiler == input_file_compiler) | 4395 if (infile->incompiler == input_file_compiler) |
5091 return true; | 4396 return true; |
5092 return false; | 4397 return false; |
4398 } | |
4399 | |
4400 /* Process each member of VEC as a spec. */ | |
4401 | |
4402 static void | |
4403 do_specs_vec (VEC(char_p,heap) *vec) | |
4404 { | |
4405 unsigned ix; | |
4406 char *opt; | |
4407 | |
4408 FOR_EACH_VEC_ELT (char_p, vec, ix, opt) | |
4409 { | |
4410 do_spec_1 (opt, 1, NULL); | |
4411 /* Make each accumulated option a separate argument. */ | |
4412 do_spec_1 (" ", 0, NULL); | |
4413 } | |
5093 } | 4414 } |
5094 | 4415 |
5095 /* Process the sub-spec SPEC as a portion of a larger spec. | 4416 /* Process the sub-spec SPEC as a portion of a larger spec. |
5096 This is like processing a whole spec except that we do | 4417 This is like processing a whole spec except that we do |
5097 not initialize at the beginning and we do not supply a | 4418 not initialize at the beginning and we do not supply a |
5110 const char *p = spec; | 4431 const char *p = spec; |
5111 int c; | 4432 int c; |
5112 int i; | 4433 int i; |
5113 int value; | 4434 int value; |
5114 | 4435 |
4436 /* If it's an empty string argument to a switch, keep it as is. */ | |
4437 if (inswitch && !*p) | |
4438 arg_going = 1; | |
4439 | |
5115 while ((c = *p++)) | 4440 while ((c = *p++)) |
5116 /* If substituting a switch, treat all chars like letters. | 4441 /* If substituting a switch, treat all chars like letters. |
5117 Otherwise, NL, SPC, TAB and % are special. */ | 4442 Otherwise, NL, SPC, TAB and % are special. */ |
5118 switch (inswitch ? 'a' : c) | 4443 switch (inswitch ? 'a' : c) |
5119 { | 4444 { |
5120 case '\n': | 4445 case '\n': |
5121 end_going_arg (); | 4446 end_going_arg (); |
5122 | 4447 |
5123 if (argbuf_index > 0 && !strcmp (argbuf[argbuf_index - 1], "|")) | 4448 if (VEC_length (const_char_p, argbuf) > 0 |
4449 && !strcmp (VEC_last (const_char_p, argbuf), "|")) | |
5124 { | 4450 { |
5125 /* A `|' before the newline means use a pipe here, | 4451 /* A `|' before the newline means use a pipe here, |
5126 but only if -pipe was specified. | 4452 but only if -pipe was specified. |
5127 Otherwise, execute now and don't pass the `|' as an arg. */ | 4453 Otherwise, execute now and don't pass the `|' as an arg. */ |
5128 if (use_pipes) | 4454 if (use_pipes) |
5129 { | 4455 { |
5130 input_from_pipe = 1; | 4456 input_from_pipe = 1; |
5131 break; | 4457 break; |
5132 } | 4458 } |
5133 else | 4459 else |
5134 argbuf_index--; | 4460 VEC_pop (const_char_p, argbuf); |
5135 } | 4461 } |
5136 | 4462 |
5137 set_collect_gcc_options (); | 4463 set_collect_gcc_options (); |
5138 | 4464 |
5139 if (argbuf_index > 0) | 4465 if (VEC_length (const_char_p, argbuf) > 0) |
5140 { | 4466 { |
5141 value = execute (); | 4467 value = execute (); |
5142 if (value) | 4468 if (value) |
5143 return value; | 4469 return value; |
5144 } | 4470 } |
5173 | 4499 |
5174 case '%': | 4500 case '%': |
5175 switch (c = *p++) | 4501 switch (c = *p++) |
5176 { | 4502 { |
5177 case 0: | 4503 case 0: |
5178 fatal ("spec '%s' invalid", spec); | 4504 fatal_error ("spec %qs invalid", spec); |
5179 | 4505 |
5180 case 'b': | 4506 case 'b': |
5181 if (save_temps_length) | 4507 if (save_temps_length) |
5182 obstack_grow (&obstack, save_temps_prefix, save_temps_length); | 4508 obstack_grow (&obstack, save_temps_prefix, save_temps_length); |
5183 else | 4509 else |
5235 while (*p != 0 && *p != '\n') | 4561 while (*p != 0 && *p != '\n') |
5236 p++; | 4562 p++; |
5237 buf = (char *) alloca (p - q + 1); | 4563 buf = (char *) alloca (p - q + 1); |
5238 strncpy (buf, q, p - q); | 4564 strncpy (buf, q, p - q); |
5239 buf[p - q] = 0; | 4565 buf[p - q] = 0; |
5240 error ("%s", buf); | 4566 error ("%s", _(buf)); |
5241 return -1; | 4567 return -1; |
5242 } | 4568 } |
5243 break; | 4569 break; |
5244 case 'n': | 4570 case 'n': |
5245 /* %nfoo means report a notice with `foo' on stderr. */ | 4571 /* %nfoo means report a notice with `foo' on stderr. */ |
5249 while (*p != 0 && *p != '\n') | 4575 while (*p != 0 && *p != '\n') |
5250 p++; | 4576 p++; |
5251 buf = (char *) alloca (p - q + 1); | 4577 buf = (char *) alloca (p - q + 1); |
5252 strncpy (buf, q, p - q); | 4578 strncpy (buf, q, p - q); |
5253 buf[p - q] = 0; | 4579 buf[p - q] = 0; |
5254 notice ("%s\n", buf); | 4580 inform (0, "%s", _(buf)); |
5255 if (*p) | 4581 if (*p) |
5256 p++; | 4582 p++; |
5257 } | 4583 } |
5258 break; | 4584 break; |
5259 | 4585 |
5322 if (p[0] == '%' && p[1] == 'O') | 4648 if (p[0] == '%' && p[1] == 'O') |
5323 { | 4649 { |
5324 p += 2; | 4650 p += 2; |
5325 /* We don't support extra suffix characters after %O. */ | 4651 /* We don't support extra suffix characters after %O. */ |
5326 if (*p == '.' || ISALNUM ((unsigned char) *p)) | 4652 if (*p == '.' || ISALNUM ((unsigned char) *p)) |
5327 fatal ("spec '%s' has invalid '%%0%c'", spec, *p); | 4653 fatal_error ("spec %qs has invalid %<%%0%c%>", spec, *p); |
5328 if (suffix_length == 0) | 4654 if (suffix_length == 0) |
5329 suffix = TARGET_OBJECT_SUFFIX; | 4655 suffix = TARGET_OBJECT_SUFFIX; |
5330 else | 4656 else |
5331 { | 4657 { |
5332 saved_suffix | 4658 saved_suffix |
5363 arg_going = 1; | 4689 arg_going = 1; |
5364 delete_this_arg = 0; | 4690 delete_this_arg = 0; |
5365 break; | 4691 break; |
5366 } | 4692 } |
5367 | 4693 |
5368 /* If the input_filename has the same suffix specified | 4694 /* If the gcc_input_filename has the same suffix specified |
5369 for the %g, %u, or %U, and -save-temps is specified, | 4695 for the %g, %u, or %U, and -save-temps is specified, |
5370 we could end up using that file as an intermediate | 4696 we could end up using that file as an intermediate |
5371 thus clobbering the user's source file (.e.g., | 4697 thus clobbering the user's source file (.e.g., |
5372 gcc -save-temps foo.s would clobber foo.s with the | 4698 gcc -save-temps foo.s would clobber foo.s with the |
5373 output of cpp0). So check for this condition and | 4699 output of cpp0). So check for this condition and |
5381 memcpy (tmp, input_basename, basename_length); | 4707 memcpy (tmp, input_basename, basename_length); |
5382 memcpy (tmp + basename_length, suffix, suffix_length); | 4708 memcpy (tmp + basename_length, suffix, suffix_length); |
5383 tmp[basename_length + suffix_length] = '\0'; | 4709 tmp[basename_length + suffix_length] = '\0'; |
5384 temp_filename = tmp; | 4710 temp_filename = tmp; |
5385 | 4711 |
5386 if (strcmp (temp_filename, input_filename) != 0) | 4712 if (strcmp (temp_filename, gcc_input_filename) != 0) |
5387 { | 4713 { |
5388 #ifndef HOST_LACKS_INODE_NUMBERS | 4714 #ifndef HOST_LACKS_INODE_NUMBERS |
5389 struct stat st_temp; | 4715 struct stat st_temp; |
5390 | 4716 |
5391 /* Note, set_input() resets input_stat_set to 0. */ | 4717 /* Note, set_input() resets input_stat_set to 0. */ |
5392 if (input_stat_set == 0) | 4718 if (input_stat_set == 0) |
5393 { | 4719 { |
5394 input_stat_set = stat (input_filename, &input_stat); | 4720 input_stat_set = stat (gcc_input_filename, |
4721 &input_stat); | |
5395 if (input_stat_set >= 0) | 4722 if (input_stat_set >= 0) |
5396 input_stat_set = 1; | 4723 input_stat_set = 1; |
5397 } | 4724 } |
5398 | 4725 |
5399 /* If we have the stat for the input_filename | 4726 /* If we have the stat for the gcc_input_filename |
5400 and we can do the stat for the temp_filename | 4727 and we can do the stat for the temp_filename |
5401 then the they could still refer to the same | 4728 then the they could still refer to the same |
5402 file if st_dev/st_ino's are the same. */ | 4729 file if st_dev/st_ino's are the same. */ |
5403 if (input_stat_set != 1 | 4730 if (input_stat_set != 1 |
5404 || stat (temp_filename, &st_temp) < 0 | 4731 || stat (temp_filename, &st_temp) < 0 |
5405 || input_stat.st_dev != st_temp.st_dev | 4732 || input_stat.st_dev != st_temp.st_dev |
5406 || input_stat.st_ino != st_temp.st_ino) | 4733 || input_stat.st_ino != st_temp.st_ino) |
5407 #else | 4734 #else |
5408 /* Just compare canonical pathnames. */ | 4735 /* Just compare canonical pathnames. */ |
5409 char* input_realname = lrealpath (input_filename); | 4736 char* input_realname = lrealpath (gcc_input_filename); |
5410 char* temp_realname = lrealpath (temp_filename); | 4737 char* temp_realname = lrealpath (temp_filename); |
5411 bool files_differ = strcmp (input_realname, temp_realname); | 4738 bool files_differ = strcmp (input_realname, temp_realname); |
5412 free (input_realname); | 4739 free (input_realname); |
5413 free (temp_realname); | 4740 free (temp_realname); |
5414 if (files_differ) | 4741 if (files_differ) |
5506 infiles[i].compiled = true; | 4833 infiles[i].compiled = true; |
5507 } | 4834 } |
5508 } | 4835 } |
5509 else | 4836 else |
5510 { | 4837 { |
5511 obstack_grow (&obstack, input_filename, input_filename_length); | 4838 obstack_grow (&obstack, gcc_input_filename, |
4839 input_filename_length); | |
5512 arg_going = 1; | 4840 arg_going = 1; |
5513 } | 4841 } |
5514 break; | 4842 break; |
5515 | 4843 |
5516 case 'I': | 4844 case 'I': |
5628 this_is_output_file = 1; | 4956 this_is_output_file = 1; |
5629 break; | 4957 break; |
5630 | 4958 |
5631 case 'W': | 4959 case 'W': |
5632 { | 4960 { |
5633 int cur_index = argbuf_index; | 4961 unsigned int cur_index = VEC_length (const_char_p, argbuf); |
5634 /* Handle the {...} following the %W. */ | 4962 /* Handle the {...} following the %W. */ |
5635 if (*p != '{') | 4963 if (*p != '{') |
5636 fatal ("spec '%s' has invalid '%%W%c", spec, *p); | 4964 fatal_error ("spec %qs has invalid %<%%W%c%>", spec, *p); |
5637 p = handle_braces (p + 1); | 4965 p = handle_braces (p + 1); |
5638 if (p == 0) | 4966 if (p == 0) |
5639 return -1; | 4967 return -1; |
5640 end_going_arg (); | 4968 end_going_arg (); |
5641 /* If any args were output, mark the last one for deletion | 4969 /* If any args were output, mark the last one for deletion |
5642 on failure. */ | 4970 on failure. */ |
5643 if (argbuf_index != cur_index) | 4971 if (VEC_length (const_char_p, argbuf) != cur_index) |
5644 record_temp_file (argbuf[argbuf_index - 1], 0, 1); | 4972 record_temp_file (VEC_last (const_char_p, argbuf), 0, 1); |
5645 break; | 4973 break; |
5646 } | 4974 } |
5647 | 4975 |
5648 /* %x{OPTION} records OPTION for %X to output. */ | 4976 /* %x{OPTION} records OPTION for %X to output. */ |
5649 case 'x': | 4977 case 'x': |
5650 { | 4978 { |
5651 const char *p1 = p; | 4979 const char *p1 = p; |
5652 char *string; | 4980 char *string; |
4981 char *opt; | |
4982 unsigned ix; | |
5653 | 4983 |
5654 /* Skip past the option value and make a copy. */ | 4984 /* Skip past the option value and make a copy. */ |
5655 if (*p != '{') | 4985 if (*p != '{') |
5656 fatal ("spec '%s' has invalid '%%x%c'", spec, *p); | 4986 fatal_error ("spec %qs has invalid %<%%x%c%>", spec, *p); |
5657 while (*p++ != '}') | 4987 while (*p++ != '}') |
5658 ; | 4988 ; |
5659 string = save_string (p1 + 1, p - p1 - 2); | 4989 string = save_string (p1 + 1, p - p1 - 2); |
5660 | 4990 |
5661 /* See if we already recorded this option. */ | 4991 /* See if we already recorded this option. */ |
5662 for (i = 0; i < n_linker_options; i++) | 4992 FOR_EACH_VEC_ELT (char_p, linker_options, ix, opt) |
5663 if (! strcmp (string, linker_options[i])) | 4993 if (! strcmp (string, opt)) |
5664 { | 4994 { |
5665 free (string); | 4995 free (string); |
5666 return 0; | 4996 return 0; |
5667 } | 4997 } |
5668 | 4998 |
5671 } | 5001 } |
5672 break; | 5002 break; |
5673 | 5003 |
5674 /* Dump out the options accumulated previously using %x. */ | 5004 /* Dump out the options accumulated previously using %x. */ |
5675 case 'X': | 5005 case 'X': |
5676 for (i = 0; i < n_linker_options; i++) | 5006 do_specs_vec (linker_options); |
5677 { | |
5678 do_spec_1 (linker_options[i], 1, NULL); | |
5679 /* Make each accumulated option a separate argument. */ | |
5680 do_spec_1 (" ", 0, NULL); | |
5681 } | |
5682 break; | 5007 break; |
5683 | 5008 |
5684 /* Dump out the options accumulated previously using -Wa,. */ | 5009 /* Dump out the options accumulated previously using -Wa,. */ |
5685 case 'Y': | 5010 case 'Y': |
5686 for (i = 0; i < n_assembler_options; i++) | 5011 do_specs_vec (assembler_options); |
5687 { | |
5688 do_spec_1 (assembler_options[i], 1, NULL); | |
5689 /* Make each accumulated option a separate argument. */ | |
5690 do_spec_1 (" ", 0, NULL); | |
5691 } | |
5692 break; | 5012 break; |
5693 | 5013 |
5694 /* Dump out the options accumulated previously using -Wp,. */ | 5014 /* Dump out the options accumulated previously using -Wp,. */ |
5695 case 'Z': | 5015 case 'Z': |
5696 for (i = 0; i < n_preprocessor_options; i++) | 5016 do_specs_vec (preprocessor_options); |
5697 { | |
5698 do_spec_1 (preprocessor_options[i], 1, NULL); | |
5699 /* Make each accumulated option a separate argument. */ | |
5700 do_spec_1 (" ", 0, NULL); | |
5701 } | |
5702 break; | 5017 break; |
5703 | 5018 |
5704 /* Here are digits and numbers that just process | 5019 /* Here are digits and numbers that just process |
5705 a certain constant string as a spec. */ | 5020 a certain constant string as a spec. */ |
5706 | 5021 |
5813 break; | 5128 break; |
5814 | 5129 |
5815 /* Henceforth ignore the option(s) matching the pattern | 5130 /* Henceforth ignore the option(s) matching the pattern |
5816 after the %<. */ | 5131 after the %<. */ |
5817 case '<': | 5132 case '<': |
5133 case '>': | |
5818 { | 5134 { |
5819 unsigned len = 0; | 5135 unsigned len = 0; |
5820 int have_wildcard = 0; | 5136 int have_wildcard = 0; |
5821 int i; | 5137 int i; |
5138 int switch_option; | |
5139 | |
5140 if (c == '>') | |
5141 switch_option = SWITCH_IGNORE | SWITCH_KEEP_FOR_GCC; | |
5142 else | |
5143 switch_option = SWITCH_IGNORE; | |
5822 | 5144 |
5823 while (p[len] && p[len] != ' ' && p[len] != '\t') | 5145 while (p[len] && p[len] != ' ' && p[len] != '\t') |
5824 len++; | 5146 len++; |
5825 | 5147 |
5826 if (p[len-1] == '*') | 5148 if (p[len-1] == '*') |
5828 | 5150 |
5829 for (i = 0; i < n_switches; i++) | 5151 for (i = 0; i < n_switches; i++) |
5830 if (!strncmp (switches[i].part1, p, len - have_wildcard) | 5152 if (!strncmp (switches[i].part1, p, len - have_wildcard) |
5831 && (have_wildcard || switches[i].part1[len] == '\0')) | 5153 && (have_wildcard || switches[i].part1[len] == '\0')) |
5832 { | 5154 { |
5833 switches[i].live_cond |= SWITCH_IGNORE; | 5155 switches[i].live_cond |= switch_option; |
5834 switches[i].validated = 1; | 5156 switches[i].validated = 1; |
5835 } | 5157 } |
5836 | 5158 |
5837 p += len; | 5159 p += len; |
5838 } | 5160 } |
5839 break; | 5161 break; |
5840 | 5162 |
5841 case '*': | 5163 case '*': |
5842 if (soft_matched_part) | 5164 if (soft_matched_part) |
5843 { | 5165 { |
5844 do_spec_1 (soft_matched_part, 1, NULL); | 5166 if (soft_matched_part[0]) |
5167 do_spec_1 (soft_matched_part, 1, NULL); | |
5845 do_spec_1 (" ", 0, NULL); | 5168 do_spec_1 (" ", 0, NULL); |
5846 } | 5169 } |
5847 else | 5170 else |
5848 /* Catch the case where a spec string contains something like | 5171 /* Catch the case where a spec string contains something like |
5849 '%{foo:%*}'. i.e. there is no * in the pattern on the left | 5172 '%{foo:%*}'. i.e. there is no * in the pattern on the left |
5850 hand side of the :. */ | 5173 hand side of the :. */ |
5851 error ("spec failure: '%%*' has not been initialized by pattern match"); | 5174 error ("spec failure: %<%%*%> has not been initialized by pattern match"); |
5852 break; | 5175 break; |
5853 | 5176 |
5854 /* Process a string found as the value of a spec given by name. | 5177 /* Process a string found as the value of a spec given by name. |
5855 This feature allows individual machine descriptions | 5178 This feature allows individual machine descriptions |
5856 to add and use their own specs. | 5179 to add and use their own specs. |
5857 %[...] modifies -D options the way %P does; | 5180 %[...] modifies -D options the way %P does; |
5858 %(...) uses the spec unmodified. */ | 5181 %(...) uses the spec unmodified. */ |
5859 case '[': | 5182 case '[': |
5860 error ("warning: use of obsolete %%[ operator in specs"); | 5183 warning (0, "use of obsolete %%[ operator in specs"); |
5861 case '(': | 5184 case '(': |
5862 { | 5185 { |
5863 const char *name = p; | 5186 const char *name = p; |
5864 struct spec_list *sl; | 5187 struct spec_list *sl; |
5865 int len; | 5188 int len; |
5873 for (len = p - name, sl = specs; sl; sl = sl->next) | 5196 for (len = p - name, sl = specs; sl; sl = sl->next) |
5874 if (sl->name_len == len && !strncmp (sl->name, name, len)) | 5197 if (sl->name_len == len && !strncmp (sl->name, name, len)) |
5875 { | 5198 { |
5876 name = *(sl->ptr_spec); | 5199 name = *(sl->ptr_spec); |
5877 #ifdef DEBUG_SPECS | 5200 #ifdef DEBUG_SPECS |
5878 notice ("Processing spec %c%s%c, which is '%s'\n", | 5201 fnotice (stderr, "Processing spec %c%s%c, which is '%s'\n", |
5879 c, sl->name, (c == '(') ? ')' : ']', name); | 5202 c, sl->name, (c == '(') ? ')' : ']', name); |
5880 #endif | 5203 #endif |
5881 break; | 5204 break; |
5882 } | 5205 } |
5883 | 5206 |
5936 p++; | 5259 p++; |
5937 } | 5260 } |
5938 break; | 5261 break; |
5939 | 5262 |
5940 default: | 5263 default: |
5941 error ("spec failure: unrecognized spec option '%c'", c); | 5264 error ("spec failure: unrecognized spec option %qc", c); |
5942 break; | 5265 break; |
5943 } | 5266 } |
5944 break; | 5267 break; |
5945 | 5268 |
5946 case '\\': | 5269 case '\\': |
5983 { | 5306 { |
5984 const struct spec_function *sf; | 5307 const struct spec_function *sf; |
5985 const char *funcval; | 5308 const char *funcval; |
5986 | 5309 |
5987 /* Saved spec processing context. */ | 5310 /* Saved spec processing context. */ |
5988 int save_argbuf_index; | 5311 VEC(const_char_p,heap) *save_argbuf; |
5989 int save_argbuf_length; | |
5990 const char **save_argbuf; | |
5991 | 5312 |
5992 int save_arg_going; | 5313 int save_arg_going; |
5993 int save_delete_this_arg; | 5314 int save_delete_this_arg; |
5994 int save_this_is_output_file; | 5315 int save_this_is_output_file; |
5995 int save_this_is_library_file; | 5316 int save_this_is_library_file; |
5998 const char *save_suffix_subst; | 5319 const char *save_suffix_subst; |
5999 | 5320 |
6000 | 5321 |
6001 sf = lookup_spec_function (func); | 5322 sf = lookup_spec_function (func); |
6002 if (sf == NULL) | 5323 if (sf == NULL) |
6003 fatal ("unknown spec function '%s'", func); | 5324 fatal_error ("unknown spec function %qs", func); |
6004 | 5325 |
6005 /* Push the spec processing context. */ | 5326 /* Push the spec processing context. */ |
6006 save_argbuf_index = argbuf_index; | |
6007 save_argbuf_length = argbuf_length; | |
6008 save_argbuf = argbuf; | 5327 save_argbuf = argbuf; |
6009 | 5328 |
6010 save_arg_going = arg_going; | 5329 save_arg_going = arg_going; |
6011 save_delete_this_arg = delete_this_arg; | 5330 save_delete_this_arg = delete_this_arg; |
6012 save_this_is_output_file = this_is_output_file; | 5331 save_this_is_output_file = this_is_output_file; |
6018 /* Create a new spec processing context, and build the function | 5337 /* Create a new spec processing context, and build the function |
6019 arguments. */ | 5338 arguments. */ |
6020 | 5339 |
6021 alloc_args (); | 5340 alloc_args (); |
6022 if (do_spec_2 (args) < 0) | 5341 if (do_spec_2 (args) < 0) |
6023 fatal ("error in args to spec function '%s'", func); | 5342 fatal_error ("error in args to spec function %qs", func); |
6024 | 5343 |
6025 /* argbuf_index is an index for the next argument to be inserted, and | 5344 /* argbuf_index is an index for the next argument to be inserted, and |
6026 so contains the count of the args already inserted. */ | 5345 so contains the count of the args already inserted. */ |
6027 | 5346 |
6028 funcval = (*sf->func) (argbuf_index, argbuf); | 5347 funcval = (*sf->func) (VEC_length (const_char_p, argbuf), |
5348 VEC_address (const_char_p, argbuf)); | |
6029 | 5349 |
6030 /* Pop the spec processing context. */ | 5350 /* Pop the spec processing context. */ |
6031 argbuf_index = save_argbuf_index; | 5351 VEC_free (const_char_p, heap, argbuf); |
6032 argbuf_length = save_argbuf_length; | |
6033 free (argbuf); | |
6034 argbuf = save_argbuf; | 5352 argbuf = save_argbuf; |
6035 | 5353 |
6036 arg_going = save_arg_going; | 5354 arg_going = save_arg_going; |
6037 delete_this_arg = save_delete_this_arg; | 5355 delete_this_arg = save_delete_this_arg; |
6038 this_is_output_file = save_this_is_output_file; | 5356 this_is_output_file = save_this_is_output_file; |
6067 { | 5385 { |
6068 if (*endp == '(') /* ) */ | 5386 if (*endp == '(') /* ) */ |
6069 break; | 5387 break; |
6070 /* Only allow [A-Za-z0-9], -, and _ in function names. */ | 5388 /* Only allow [A-Za-z0-9], -, and _ in function names. */ |
6071 if (!ISALNUM (*endp) && !(*endp == '-' || *endp == '_')) | 5389 if (!ISALNUM (*endp) && !(*endp == '-' || *endp == '_')) |
6072 fatal ("malformed spec function name"); | 5390 fatal_error ("malformed spec function name"); |
6073 } | 5391 } |
6074 if (*endp != '(') /* ) */ | 5392 if (*endp != '(') /* ) */ |
6075 fatal ("no arguments for spec function"); | 5393 fatal_error ("no arguments for spec function"); |
6076 func = save_string (p, endp - p); | 5394 func = save_string (p, endp - p); |
6077 p = ++endp; | 5395 p = ++endp; |
6078 | 5396 |
6079 /* Get the arguments. */ | 5397 /* Get the arguments. */ |
6080 for (count = 0; *endp != '\0'; endp++) | 5398 for (count = 0; *endp != '\0'; endp++) |
6089 else if (*endp == '(') /* ) */ | 5407 else if (*endp == '(') /* ) */ |
6090 count++; | 5408 count++; |
6091 } | 5409 } |
6092 /* ( */ | 5410 /* ( */ |
6093 if (*endp != ')') | 5411 if (*endp != ')') |
6094 fatal ("malformed spec function arguments"); | 5412 fatal_error ("malformed spec function arguments"); |
6095 args = save_string (p, endp - p); | 5413 args = save_string (p, endp - p); |
6096 p = ++endp; | 5414 p = ++endp; |
6097 | 5415 |
6098 /* p now points to just past the end of the spec function expression. */ | 5416 /* p now points to just past the end of the spec function expression. */ |
6099 | 5417 |
6335 while (*p++ != '}'); | 5653 while (*p++ != '}'); |
6336 | 5654 |
6337 return p; | 5655 return p; |
6338 | 5656 |
6339 invalid: | 5657 invalid: |
6340 fatal ("braced spec '%s' is invalid at '%c'", orig, *p); | 5658 fatal_error ("braced spec %qs is invalid at %qc", orig, *p); |
6341 | 5659 |
6342 #undef SKIP_WHITE | 5660 #undef SKIP_WHITE |
6343 } | 5661 } |
6344 | 5662 |
6345 /* Subroutine of handle_braces. Scan and process a brace substitution body | 5663 /* Subroutine of handle_braces. Scan and process a brace substitution body |
6423 } | 5741 } |
6424 | 5742 |
6425 return p; | 5743 return p; |
6426 | 5744 |
6427 invalid: | 5745 invalid: |
6428 fatal ("braced spec body '%s' is invalid", body); | 5746 fatal_error ("braced spec body %qs is invalid", body); |
6429 } | 5747 } |
6430 | 5748 |
6431 /* Return 0 iff switch number SWITCHNUM is obsoleted by a later switch | 5749 /* Return 0 iff switch number SWITCHNUM is obsoleted by a later switch |
6432 on the command line. PREFIX_LENGTH is the length of XXX in an {XXX*} | 5750 on the command line. PREFIX_LENGTH is the length of XXX in an {XXX*} |
6433 spec, or -1 if either exact match or %* is used. | 5751 spec, or -1 if either exact match or %* is used. |
6445 /* If we already processed this switch and determined if it was | 5763 /* If we already processed this switch and determined if it was |
6446 live or not, return our past determination. */ | 5764 live or not, return our past determination. */ |
6447 if (switches[switchnum].live_cond != 0) | 5765 if (switches[switchnum].live_cond != 0) |
6448 return ((switches[switchnum].live_cond & SWITCH_LIVE) != 0 | 5766 return ((switches[switchnum].live_cond & SWITCH_LIVE) != 0 |
6449 && (switches[switchnum].live_cond & SWITCH_FALSE) == 0 | 5767 && (switches[switchnum].live_cond & SWITCH_FALSE) == 0 |
6450 && (switches[switchnum].live_cond & SWITCH_IGNORE) == 0); | 5768 && (switches[switchnum].live_cond & SWITCH_IGNORE_PERMANENTLY) |
5769 == 0); | |
6451 | 5770 |
6452 /* In the common case of {<at-most-one-letter>*}, a negating | 5771 /* In the common case of {<at-most-one-letter>*}, a negating |
6453 switch would always match, so ignore that case. We will just | 5772 switch would always match, so ignore that case. We will just |
6454 send the conflicting switches to the compiler phase. */ | 5773 send the conflicting switches to the compiler phase. */ |
6455 if (prefix_length >= 0 && prefix_length <= 1) | 5774 if (prefix_length >= 0 && prefix_length <= 1) |
6611 void | 5930 void |
6612 set_input (const char *filename) | 5931 set_input (const char *filename) |
6613 { | 5932 { |
6614 const char *p; | 5933 const char *p; |
6615 | 5934 |
6616 input_filename = filename; | 5935 gcc_input_filename = filename; |
6617 input_filename_length = strlen (input_filename); | 5936 input_filename_length = strlen (gcc_input_filename); |
6618 input_basename = lbasename (input_filename); | 5937 input_basename = lbasename (gcc_input_filename); |
6619 | 5938 |
6620 /* Find a suffix starting with the last period, | 5939 /* Find a suffix starting with the last period, |
6621 and set basename_length to exclude that suffix. */ | 5940 and set basename_length to exclude that suffix. */ |
6622 basename_length = strlen (input_basename); | 5941 basename_length = strlen (input_basename); |
6623 suffixed_basename_length = basename_length; | 5942 suffixed_basename_length = basename_length; |
6631 } | 5950 } |
6632 else | 5951 else |
6633 input_suffix = ""; | 5952 input_suffix = ""; |
6634 | 5953 |
6635 /* If a spec for 'g', 'u', or 'U' is seen with -save-temps then | 5954 /* If a spec for 'g', 'u', or 'U' is seen with -save-temps then |
6636 we will need to do a stat on the input_filename. The | 5955 we will need to do a stat on the gcc_input_filename. The |
6637 INPUT_STAT_SET signals that the stat is needed. */ | 5956 INPUT_STAT_SET signals that the stat is needed. */ |
6638 input_stat_set = 0; | 5957 input_stat_set = 0; |
6639 } | 5958 } |
6640 | 5959 |
6641 /* On fatal signals, delete all the temporary files. */ | 5960 /* On fatal signals, delete all the temporary files. */ |
6642 | 5961 |
6643 static void | 5962 static void |
6644 fatal_error (int signum) | 5963 fatal_signal (int signum) |
6645 { | 5964 { |
6646 signal (signum, SIG_DFL); | 5965 signal (signum, SIG_DFL); |
6647 delete_failure_queue (); | 5966 delete_failure_queue (); |
6648 delete_temp_files (); | 5967 delete_temp_files (); |
6649 /* Get the same signal again, this time not handled, | 5968 /* Get the same signal again, this time not handled, |
6672 struct stat st; | 5991 struct stat st; |
6673 | 5992 |
6674 if (stat (cmpfile[i], &st) < 0 || !S_ISREG (st.st_mode)) | 5993 if (stat (cmpfile[i], &st) < 0 || !S_ISREG (st.st_mode)) |
6675 { | 5994 { |
6676 error ("%s: could not determine length of compare-debug file %s", | 5995 error ("%s: could not determine length of compare-debug file %s", |
6677 input_filename, cmpfile[i]); | 5996 gcc_input_filename, cmpfile[i]); |
6678 ret = 1; | 5997 ret = 1; |
6679 break; | 5998 break; |
6680 } | 5999 } |
6681 | 6000 |
6682 length[i] = st.st_size; | 6001 length[i] = st.st_size; |
6683 } | 6002 } |
6684 | 6003 |
6685 if (!ret && length[0] != length[1]) | 6004 if (!ret && length[0] != length[1]) |
6686 { | 6005 { |
6687 error ("%s: -fcompare-debug failure (length)", input_filename); | 6006 error ("%s: -fcompare-debug failure (length)", gcc_input_filename); |
6688 ret = 1; | 6007 ret = 1; |
6689 } | 6008 } |
6690 | 6009 |
6691 if (!ret) | 6010 if (!ret) |
6692 for (i = 0; i < 2; i++) | 6011 for (i = 0; i < 2; i++) |
6693 { | 6012 { |
6694 int fd = open (cmpfile[i], O_RDONLY); | 6013 int fd = open (cmpfile[i], O_RDONLY); |
6695 if (fd < 0) | 6014 if (fd < 0) |
6696 { | 6015 { |
6697 error ("%s: could not open compare-debug file %s", | 6016 error ("%s: could not open compare-debug file %s", |
6698 input_filename, cmpfile[i]); | 6017 gcc_input_filename, cmpfile[i]); |
6699 ret = 1; | 6018 ret = 1; |
6700 break; | 6019 break; |
6701 } | 6020 } |
6702 | 6021 |
6703 map[i] = mmap (NULL, length[i], PROT_READ, MAP_PRIVATE, fd, 0); | 6022 map[i] = mmap (NULL, length[i], PROT_READ, MAP_PRIVATE, fd, 0); |
6712 | 6031 |
6713 if (!ret) | 6032 if (!ret) |
6714 { | 6033 { |
6715 if (memcmp (map[0], map[1], length[0]) != 0) | 6034 if (memcmp (map[0], map[1], length[0]) != 0) |
6716 { | 6035 { |
6717 error ("%s: -fcompare-debug failure", input_filename); | 6036 error ("%s: -fcompare-debug failure", gcc_input_filename); |
6718 ret = 1; | 6037 ret = 1; |
6719 } | 6038 } |
6720 } | 6039 } |
6721 | 6040 |
6722 for (i = 0; i < 2; i++) | 6041 for (i = 0; i < 2; i++) |
6734 { | 6053 { |
6735 temp[i] = fopen (cmpfile[i], "r"); | 6054 temp[i] = fopen (cmpfile[i], "r"); |
6736 if (!temp[i]) | 6055 if (!temp[i]) |
6737 { | 6056 { |
6738 error ("%s: could not open compare-debug file %s", | 6057 error ("%s: could not open compare-debug file %s", |
6739 input_filename, cmpfile[i]); | 6058 gcc_input_filename, cmpfile[i]); |
6740 ret = 1; | 6059 ret = 1; |
6741 break; | 6060 break; |
6742 } | 6061 } |
6743 } | 6062 } |
6744 | 6063 |
6750 c1 = fgetc (temp[1]); | 6069 c1 = fgetc (temp[1]); |
6751 | 6070 |
6752 if (c0 != c1) | 6071 if (c0 != c1) |
6753 { | 6072 { |
6754 error ("%s: -fcompare-debug failure", | 6073 error ("%s: -fcompare-debug failure", |
6755 input_filename); | 6074 gcc_input_filename); |
6756 ret = 1; | 6075 ret = 1; |
6757 break; | 6076 break; |
6758 } | 6077 } |
6759 | 6078 |
6760 if (c0 == EOF) | 6079 if (c0 == EOF) |
6780 int linker_was_run = 0; | 6099 int linker_was_run = 0; |
6781 int lang_n_infiles = 0; | 6100 int lang_n_infiles = 0; |
6782 int num_linker_inputs = 0; | 6101 int num_linker_inputs = 0; |
6783 char *explicit_link_files; | 6102 char *explicit_link_files; |
6784 char *specs_file; | 6103 char *specs_file; |
6104 char *lto_wrapper_file; | |
6785 const char *p; | 6105 const char *p; |
6786 struct user_specs *uptr; | 6106 struct user_specs *uptr; |
6787 char **old_argv = argv; | 6107 char **old_argv = argv; |
6108 struct cl_decoded_option *decoded_options; | |
6109 unsigned int decoded_options_count; | |
6788 | 6110 |
6789 /* Initialize here, not in definition. The IRIX 6 O32 cc sometimes chokes | 6111 /* Initialize here, not in definition. The IRIX 6 O32 cc sometimes chokes |
6790 on ?: in file-scope variable initializations. */ | 6112 on ?: in file-scope variable initializations. */ |
6791 asm_debug = ASM_DEBUG_SPEC; | 6113 asm_debug = ASM_DEBUG_SPEC; |
6792 | 6114 |
6793 p = argv[0] + strlen (argv[0]); | 6115 p = argv[0] + strlen (argv[0]); |
6794 while (p != argv[0] && !IS_DIR_SEPARATOR (p[-1])) | 6116 while (p != argv[0] && !IS_DIR_SEPARATOR (p[-1])) |
6795 --p; | 6117 --p; |
6796 programname = p; | 6118 progname = p; |
6797 | 6119 |
6798 xmalloc_set_program_name (programname); | 6120 xmalloc_set_program_name (progname); |
6799 | 6121 |
6800 expandargv (&argc, &argv); | 6122 expandargv (&argc, &argv); |
6801 | 6123 |
6802 /* Determine if any expansions were made. */ | 6124 /* Determine if any expansions were made. */ |
6803 if (argv != old_argv) | 6125 if (argv != old_argv) |
6804 at_file_supplied = true; | 6126 at_file_supplied = true; |
6805 | 6127 |
6806 prune_options (&argc, &argv); | 6128 global_options = global_options_init; |
6129 | |
6130 decode_cmdline_options_to_array (argc, CONST_CAST2 (const char **, char **, | |
6131 argv), | |
6132 CL_DRIVER, | |
6133 &decoded_options, &decoded_options_count); | |
6807 | 6134 |
6808 #ifdef GCC_DRIVER_HOST_INITIALIZATION | 6135 #ifdef GCC_DRIVER_HOST_INITIALIZATION |
6809 /* Perform host dependent initialization when needed. */ | 6136 /* Perform host dependent initialization when needed. */ |
6810 GCC_DRIVER_HOST_INITIALIZATION; | 6137 GCC_DRIVER_HOST_INITIALIZATION; |
6811 #endif | 6138 #endif |
6813 /* Unlock the stdio streams. */ | 6140 /* Unlock the stdio streams. */ |
6814 unlock_std_streams (); | 6141 unlock_std_streams (); |
6815 | 6142 |
6816 gcc_init_libintl (); | 6143 gcc_init_libintl (); |
6817 | 6144 |
6145 diagnostic_initialize (global_dc, 0); | |
6146 if (atexit (delete_temp_files) != 0) | |
6147 fatal_error ("atexit failed"); | |
6148 | |
6818 if (signal (SIGINT, SIG_IGN) != SIG_IGN) | 6149 if (signal (SIGINT, SIG_IGN) != SIG_IGN) |
6819 signal (SIGINT, fatal_error); | 6150 signal (SIGINT, fatal_signal); |
6820 #ifdef SIGHUP | 6151 #ifdef SIGHUP |
6821 if (signal (SIGHUP, SIG_IGN) != SIG_IGN) | 6152 if (signal (SIGHUP, SIG_IGN) != SIG_IGN) |
6822 signal (SIGHUP, fatal_error); | 6153 signal (SIGHUP, fatal_signal); |
6823 #endif | 6154 #endif |
6824 if (signal (SIGTERM, SIG_IGN) != SIG_IGN) | 6155 if (signal (SIGTERM, SIG_IGN) != SIG_IGN) |
6825 signal (SIGTERM, fatal_error); | 6156 signal (SIGTERM, fatal_signal); |
6826 #ifdef SIGPIPE | 6157 #ifdef SIGPIPE |
6827 if (signal (SIGPIPE, SIG_IGN) != SIG_IGN) | 6158 if (signal (SIGPIPE, SIG_IGN) != SIG_IGN) |
6828 signal (SIGPIPE, fatal_error); | 6159 signal (SIGPIPE, fatal_signal); |
6829 #endif | 6160 #endif |
6830 #ifdef SIGCHLD | 6161 #ifdef SIGCHLD |
6831 /* We *MUST* set SIGCHLD to SIG_DFL so that the wait4() call will | 6162 /* We *MUST* set SIGCHLD to SIG_DFL so that the wait4() call will |
6832 receive the signal. A different setting is inheritable */ | 6163 receive the signal. A different setting is inheritable */ |
6833 signal (SIGCHLD, SIG_DFL); | 6164 signal (SIGCHLD, SIG_DFL); |
6887 | 6218 |
6888 /* Make a table of what switches there are (switches, n_switches). | 6219 /* Make a table of what switches there are (switches, n_switches). |
6889 Make a table of specified input files (infiles, n_infiles). | 6220 Make a table of specified input files (infiles, n_infiles). |
6890 Decode switches that are handled locally. */ | 6221 Decode switches that are handled locally. */ |
6891 | 6222 |
6892 process_command (argc, CONST_CAST2 (const char **, char **, argv)); | 6223 process_command (decoded_options_count, decoded_options); |
6893 | 6224 |
6894 /* Initialize the vector of specs to just the default. | 6225 /* Initialize the vector of specs to just the default. |
6895 This means one element containing 0s, as a terminator. */ | 6226 This means one element containing 0s, as a terminator. */ |
6896 | 6227 |
6897 compilers = XNEWVAR (struct compiler, sizeof default_compilers); | 6228 compilers = XNEWVAR (struct compiler, sizeof default_compilers); |
6939 enum save_temps save; | 6270 enum save_temps save; |
6940 | 6271 |
6941 if (!compare_debug_second) | 6272 if (!compare_debug_second) |
6942 { | 6273 { |
6943 n_switches_debug_check[1] = n_switches; | 6274 n_switches_debug_check[1] = n_switches; |
6275 n_switches_alloc_debug_check[1] = n_switches_alloc; | |
6944 switches_debug_check[1] = XDUPVEC (struct switchstr, switches, | 6276 switches_debug_check[1] = XDUPVEC (struct switchstr, switches, |
6945 n_switches + 1); | 6277 n_switches_alloc); |
6946 | 6278 |
6947 do_self_spec ("%:compare-debug-self-opt()"); | 6279 do_self_spec ("%:compare-debug-self-opt()"); |
6948 n_switches_debug_check[0] = n_switches; | 6280 n_switches_debug_check[0] = n_switches; |
6281 n_switches_alloc_debug_check[0] = n_switches_alloc; | |
6949 switches_debug_check[0] = switches; | 6282 switches_debug_check[0] = switches; |
6950 | 6283 |
6951 n_switches = n_switches_debug_check[1]; | 6284 n_switches = n_switches_debug_check[1]; |
6285 n_switches_alloc = n_switches_alloc_debug_check[1]; | |
6952 switches = switches_debug_check[1]; | 6286 switches = switches_debug_check[1]; |
6953 } | 6287 } |
6954 | 6288 |
6955 /* Avoid crash when computing %j in this early. */ | 6289 /* Avoid crash when computing %j in this early. */ |
6956 save = save_temps_flag; | 6290 save = save_temps_flag; |
6962 save_temps_flag = save; | 6296 save_temps_flag = save; |
6963 | 6297 |
6964 if (!compare_debug_second) | 6298 if (!compare_debug_second) |
6965 { | 6299 { |
6966 n_switches_debug_check[1] = n_switches; | 6300 n_switches_debug_check[1] = n_switches; |
6301 n_switches_alloc_debug_check[1] = n_switches_alloc; | |
6967 switches_debug_check[1] = switches; | 6302 switches_debug_check[1] = switches; |
6968 compare_debug = -compare_debug; | 6303 compare_debug = -compare_debug; |
6969 n_switches = n_switches_debug_check[0]; | 6304 n_switches = n_switches_debug_check[0]; |
6305 n_switches_alloc = n_switches_debug_check[0]; | |
6970 switches = switches_debug_check[0]; | 6306 switches = switches_debug_check[0]; |
6971 } | 6307 } |
6972 } | 6308 } |
6973 | 6309 |
6974 /* If not cross-compiling, look for executables in the standard | 6310 /* If not cross-compiling, look for executables in the standard |
6984 | 6320 |
6985 /* Process sysroot_suffix_spec. */ | 6321 /* Process sysroot_suffix_spec. */ |
6986 if (*sysroot_suffix_spec != 0 | 6322 if (*sysroot_suffix_spec != 0 |
6987 && do_spec_2 (sysroot_suffix_spec) == 0) | 6323 && do_spec_2 (sysroot_suffix_spec) == 0) |
6988 { | 6324 { |
6989 if (argbuf_index > 1) | 6325 if (VEC_length (const_char_p, argbuf) > 1) |
6990 error ("spec failure: more than one arg to SYSROOT_SUFFIX_SPEC"); | 6326 error ("spec failure: more than one arg to SYSROOT_SUFFIX_SPEC"); |
6991 else if (argbuf_index == 1) | 6327 else if (VEC_length (const_char_p, argbuf) == 1) |
6992 target_sysroot_suffix = xstrdup (argbuf[argbuf_index -1]); | 6328 target_sysroot_suffix = xstrdup (VEC_last (const_char_p, argbuf)); |
6993 } | 6329 } |
6994 | 6330 |
6995 #ifdef HAVE_LD_SYSROOT | 6331 #ifdef HAVE_LD_SYSROOT |
6996 /* Pass the --sysroot option to the linker, if it supports that. If | 6332 /* Pass the --sysroot option to the linker, if it supports that. If |
6997 there is a sysroot_suffix_spec, it has already been processed by | 6333 there is a sysroot_suffix_spec, it has already been processed by |
7007 | 6343 |
7008 /* Process sysroot_hdrs_suffix_spec. */ | 6344 /* Process sysroot_hdrs_suffix_spec. */ |
7009 if (*sysroot_hdrs_suffix_spec != 0 | 6345 if (*sysroot_hdrs_suffix_spec != 0 |
7010 && do_spec_2 (sysroot_hdrs_suffix_spec) == 0) | 6346 && do_spec_2 (sysroot_hdrs_suffix_spec) == 0) |
7011 { | 6347 { |
7012 if (argbuf_index > 1) | 6348 if (VEC_length (const_char_p, argbuf) > 1) |
7013 error ("spec failure: more than one arg to SYSROOT_HEADERS_SUFFIX_SPEC"); | 6349 error ("spec failure: more than one arg to SYSROOT_HEADERS_SUFFIX_SPEC"); |
7014 else if (argbuf_index == 1) | 6350 else if (VEC_length (const_char_p, argbuf) == 1) |
7015 target_sysroot_hdrs_suffix = xstrdup (argbuf[argbuf_index -1]); | 6351 target_sysroot_hdrs_suffix = xstrdup (VEC_last (const_char_p, argbuf)); |
7016 } | 6352 } |
7017 | 6353 |
7018 /* Look for startfiles in the standard places. */ | 6354 /* Look for startfiles in the standard places. */ |
7019 if (*startfile_prefix_spec != 0 | 6355 if (*startfile_prefix_spec != 0 |
7020 && do_spec_2 (startfile_prefix_spec) == 0 | 6356 && do_spec_2 (startfile_prefix_spec) == 0 |
7021 && do_spec_1 (" ", 0, NULL) == 0) | 6357 && do_spec_1 (" ", 0, NULL) == 0) |
7022 { | 6358 { |
6359 const char *arg; | |
7023 int ndx; | 6360 int ndx; |
7024 for (ndx = 0; ndx < argbuf_index; ndx++) | 6361 FOR_EACH_VEC_ELT (const_char_p, argbuf, ndx, arg) |
7025 add_sysrooted_prefix (&startfile_prefixes, argbuf[ndx], "BINUTILS", | 6362 add_sysrooted_prefix (&startfile_prefixes, arg, "BINUTILS", |
7026 PREFIX_PRIORITY_LAST, 0, 1); | 6363 PREFIX_PRIORITY_LAST, 0, 1); |
7027 } | 6364 } |
7028 /* We should eventually get rid of all these and stick to | 6365 /* We should eventually get rid of all these and stick to |
7029 startfile_prefix_spec exclusively. */ | 6366 startfile_prefix_spec exclusively. */ |
7030 else if (*cross_compile == '0' || target_system_root) | 6367 else if (*cross_compile == '0' || target_system_root) |
7092 /* Now that we have the switches and the specs, set | 6429 /* Now that we have the switches and the specs, set |
7093 the subdirectory based on the options. */ | 6430 the subdirectory based on the options. */ |
7094 set_multilib_dir (); | 6431 set_multilib_dir (); |
7095 | 6432 |
7096 /* Set up to remember the pathname of gcc and any options | 6433 /* Set up to remember the pathname of gcc and any options |
7097 needed for collect. We use argv[0] instead of programname because | 6434 needed for collect. We use argv[0] instead of progname because |
7098 we need the complete pathname. */ | 6435 we need the complete pathname. */ |
7099 obstack_init (&collect_obstack); | 6436 obstack_init (&collect_obstack); |
7100 obstack_grow (&collect_obstack, "COLLECT_GCC=", sizeof ("COLLECT_GCC=") - 1); | 6437 obstack_grow (&collect_obstack, "COLLECT_GCC=", sizeof ("COLLECT_GCC=") - 1); |
7101 obstack_grow (&collect_obstack, argv[0], strlen (argv[0]) + 1); | 6438 obstack_grow (&collect_obstack, argv[0], strlen (argv[0]) + 1); |
7102 xputenv (XOBFINISH (&collect_obstack, char *)); | 6439 xputenv (XOBFINISH (&collect_obstack, char *)); |
7103 | 6440 |
7104 /* Set up to remember the pathname of the lto wrapper. */ | 6441 /* Set up to remember the pathname of the lto wrapper. */ |
7105 | 6442 |
7106 lto_wrapper_spec = find_a_file (&exec_prefixes, "lto-wrapper", X_OK, false); | 6443 lto_wrapper_file = find_a_file (&exec_prefixes, "lto-wrapper", X_OK, false); |
7107 if (lto_wrapper_spec) | 6444 if (lto_wrapper_file) |
7108 { | 6445 { |
6446 lto_wrapper_spec = lto_wrapper_file; | |
7109 obstack_init (&collect_obstack); | 6447 obstack_init (&collect_obstack); |
7110 obstack_grow (&collect_obstack, "COLLECT_LTO_WRAPPER=", | 6448 obstack_grow (&collect_obstack, "COLLECT_LTO_WRAPPER=", |
7111 sizeof ("COLLECT_LTO_WRAPPER=") - 1); | 6449 sizeof ("COLLECT_LTO_WRAPPER=") - 1); |
7112 obstack_grow (&collect_obstack, lto_wrapper_spec, | 6450 obstack_grow (&collect_obstack, lto_wrapper_spec, |
7113 strlen (lto_wrapper_spec) + 1); | 6451 strlen (lto_wrapper_spec) + 1); |
7116 | 6454 |
7117 /* Warn about any switches that no pass was interested in. */ | 6455 /* Warn about any switches that no pass was interested in. */ |
7118 | 6456 |
7119 for (i = 0; (int) i < n_switches; i++) | 6457 for (i = 0; (int) i < n_switches; i++) |
7120 if (! switches[i].validated) | 6458 if (! switches[i].validated) |
7121 error ("unrecognized option '-%s'", switches[i].part1); | 6459 error ("unrecognized option %<-%s%>", switches[i].part1); |
7122 | 6460 |
7123 /* Obey some of the options. */ | 6461 /* Obey some of the options. */ |
7124 | 6462 |
7125 if (print_search_dirs) | 6463 if (print_search_dirs) |
7126 { | 6464 { |
7193 return (0); | 6531 return (0); |
7194 } | 6532 } |
7195 else | 6533 else |
7196 /* The error status indicates that only one set of fixed | 6534 /* The error status indicates that only one set of fixed |
7197 headers should be built. */ | 6535 headers should be built. */ |
7198 fatal ("not configured with sysroot headers suffix"); | 6536 fatal_error ("not configured with sysroot headers suffix"); |
7199 } | 6537 } |
7200 | 6538 |
7201 if (print_help_list) | 6539 if (print_help_list) |
7202 { | 6540 { |
7203 display_help (); | 6541 display_help (); |
7218 fflush (stdout); | 6556 fflush (stdout); |
7219 } | 6557 } |
7220 | 6558 |
7221 if (print_version) | 6559 if (print_version) |
7222 { | 6560 { |
7223 printf (_("%s %s%s\n"), programname, pkgversion_string, | 6561 printf (_("%s %s%s\n"), progname, pkgversion_string, |
7224 version_string); | 6562 version_string); |
7225 printf ("Copyright %s 2009 Free Software Foundation, Inc.\n", | 6563 printf ("Copyright %s 2011 Free Software Foundation, Inc.\n", |
7226 _("(C)")); | 6564 _("(C)")); |
7227 fputs (_("This is free software; see the source for copying conditions. There is NO\n\ | 6565 fputs (_("This is free software; see the source for copying conditions. There is NO\n\ |
7228 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\n"), | 6566 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\n"), |
7229 stdout); | 6567 stdout); |
7230 if (! verbose_flag) | 6568 if (! verbose_flag) |
7239 if (verbose_flag) | 6577 if (verbose_flag) |
7240 { | 6578 { |
7241 int n; | 6579 int n; |
7242 const char *thrmod; | 6580 const char *thrmod; |
7243 | 6581 |
7244 notice ("Target: %s\n", spec_machine); | 6582 fnotice (stderr, "Target: %s\n", spec_machine); |
7245 notice ("Configured with: %s\n", configuration_arguments); | 6583 fnotice (stderr, "Configured with: %s\n", configuration_arguments); |
7246 | 6584 |
7247 #ifdef THREAD_MODEL_SPEC | 6585 #ifdef THREAD_MODEL_SPEC |
7248 /* We could have defined THREAD_MODEL_SPEC to "%*" by default, | 6586 /* We could have defined THREAD_MODEL_SPEC to "%*" by default, |
7249 but there's no point in doing all this processing just to get | 6587 but there's no point in doing all this processing just to get |
7250 thread_model back. */ | 6588 thread_model back. */ |
7254 thrmod = XOBFINISH (&obstack, const char *); | 6592 thrmod = XOBFINISH (&obstack, const char *); |
7255 #else | 6593 #else |
7256 thrmod = thread_model; | 6594 thrmod = thread_model; |
7257 #endif | 6595 #endif |
7258 | 6596 |
7259 notice ("Thread model: %s\n", thrmod); | 6597 fnotice (stderr, "Thread model: %s\n", thrmod); |
7260 | 6598 |
7261 /* compiler_version is truncated at the first space when initialized | 6599 /* compiler_version is truncated at the first space when initialized |
7262 from version string, so truncate version_string at the first space | 6600 from version string, so truncate version_string at the first space |
7263 before comparing. */ | 6601 before comparing. */ |
7264 for (n = 0; version_string[n]; n++) | 6602 for (n = 0; version_string[n]; n++) |
7265 if (version_string[n] == ' ') | 6603 if (version_string[n] == ' ') |
7266 break; | 6604 break; |
7267 | 6605 |
7268 if (! strncmp (version_string, compiler_version, n) | 6606 if (! strncmp (version_string, compiler_version, n) |
7269 && compiler_version[n] == 0) | 6607 && compiler_version[n] == 0) |
7270 notice ("gcc version %s %s\n", version_string, pkgversion_string); | 6608 fnotice (stderr, "gcc version %s %s\n", version_string, |
6609 pkgversion_string); | |
7271 else | 6610 else |
7272 notice ("gcc driver version %s %sexecuting gcc version %s\n", | 6611 fnotice (stderr, "gcc driver version %s %sexecuting gcc version %s\n", |
7273 version_string, pkgversion_string, compiler_version); | 6612 version_string, pkgversion_string, compiler_version); |
7274 | 6613 |
7275 if (n_infiles == 0) | 6614 if (n_infiles == 0) |
7276 return (0); | 6615 return (0); |
7277 } | 6616 } |
7278 | 6617 |
7279 if (n_infiles == added_libraries) | 6618 if (n_infiles == added_libraries) |
7280 fatal ("no input files"); | 6619 fatal_error ("no input files"); |
6620 | |
6621 if (seen_error ()) | |
6622 goto out; | |
7281 | 6623 |
7282 /* Make a place to record the compiler output file names | 6624 /* Make a place to record the compiler output file names |
7283 that correspond to the input files. */ | 6625 that correspond to the input files. */ |
7284 | 6626 |
7285 i = n_infiles; | 6627 i = n_infiles; |
7288 | 6630 |
7289 /* Record which files were specified explicitly as link input. */ | 6631 /* Record which files were specified explicitly as link input. */ |
7290 | 6632 |
7291 explicit_link_files = XCNEWVEC (char, n_infiles); | 6633 explicit_link_files = XCNEWVEC (char, n_infiles); |
7292 | 6634 |
7293 if (combine_flag) | 6635 combine_inputs = have_o || flag_wpa; |
7294 combine_inputs = true; | |
7295 else | |
7296 combine_inputs = false; | |
7297 | 6636 |
7298 for (i = 0; (int) i < n_infiles; i++) | 6637 for (i = 0; (int) i < n_infiles; i++) |
7299 { | 6638 { |
7300 const char *name = infiles[i].name; | 6639 const char *name = infiles[i].name; |
7301 struct compiler *compiler = lookup_compiler (name, | 6640 struct compiler *compiler = lookup_compiler (name, |
7324 infiles[i].compiled = false; | 6663 infiles[i].compiled = false; |
7325 infiles[i].preprocessed = false; | 6664 infiles[i].preprocessed = false; |
7326 } | 6665 } |
7327 | 6666 |
7328 if (!combine_inputs && have_c && have_o && lang_n_infiles > 1) | 6667 if (!combine_inputs && have_c && have_o && lang_n_infiles > 1) |
7329 fatal ("cannot specify -o with -c, -S or -E with multiple files"); | 6668 fatal_error ("cannot specify -o with -c, -S or -E with multiple files"); |
7330 | |
7331 if (combine_flag && save_temps_flag) | |
7332 { | |
7333 bool save_combine_inputs = combine_inputs; | |
7334 /* Must do a separate pre-processing pass for C & Objective-C files, to | |
7335 obtain individual .i files. */ | |
7336 | |
7337 combine_inputs = false; | |
7338 for (i = 0; (int) i < n_infiles; i++) | |
7339 { | |
7340 int this_file_error = 0; | |
7341 | |
7342 input_file_number = i; | |
7343 set_input (infiles[i].name); | |
7344 if (infiles[i].incompiler | |
7345 && (infiles[i].incompiler)->needs_preprocessing) | |
7346 input_file_compiler = infiles[i].incompiler; | |
7347 else | |
7348 continue; | |
7349 | |
7350 if (input_file_compiler) | |
7351 { | |
7352 if (input_file_compiler->spec[0] == '#') | |
7353 { | |
7354 error ("%s: %s compiler not installed on this system", | |
7355 input_filename, &input_file_compiler->spec[1]); | |
7356 this_file_error = 1; | |
7357 } | |
7358 else | |
7359 { | |
7360 value = do_spec (input_file_compiler->spec); | |
7361 infiles[i].preprocessed = true; | |
7362 if (!have_o_argbuf_index) | |
7363 fatal ("spec '%s' is invalid", input_file_compiler->spec); | |
7364 infiles[i].name = argbuf[have_o_argbuf_index]; | |
7365 infiles[i].incompiler | |
7366 = lookup_compiler (infiles[i].name, | |
7367 strlen (infiles[i].name), | |
7368 infiles[i].language); | |
7369 | |
7370 if (value < 0) | |
7371 this_file_error = 1; | |
7372 } | |
7373 } | |
7374 | |
7375 if (this_file_error) | |
7376 { | |
7377 delete_failure_queue (); | |
7378 error_count++; | |
7379 break; | |
7380 } | |
7381 clear_failure_queue (); | |
7382 } | |
7383 combine_inputs = save_combine_inputs; | |
7384 } | |
7385 | 6669 |
7386 for (i = 0; (int) i < n_infiles; i++) | 6670 for (i = 0; (int) i < n_infiles; i++) |
7387 { | 6671 { |
7388 int this_file_error = 0; | 6672 int this_file_error = 0; |
7389 | 6673 |
7395 if (infiles[i].compiled) | 6679 if (infiles[i].compiled) |
7396 continue; | 6680 continue; |
7397 | 6681 |
7398 /* Use the same thing in %o, unless cp->spec says otherwise. */ | 6682 /* Use the same thing in %o, unless cp->spec says otherwise. */ |
7399 | 6683 |
7400 outfiles[i] = input_filename; | 6684 outfiles[i] = gcc_input_filename; |
7401 | 6685 |
7402 /* Figure out which compiler from the file's suffix. */ | 6686 /* Figure out which compiler from the file's suffix. */ |
7403 | 6687 |
7404 if (! combine_inputs) | 6688 input_file_compiler |
7405 input_file_compiler | 6689 = lookup_compiler (infiles[i].name, input_filename_length, |
7406 = lookup_compiler (infiles[i].name, input_filename_length, | 6690 infiles[i].language); |
7407 infiles[i].language); | |
7408 else | |
7409 input_file_compiler = infiles[i].incompiler; | |
7410 | 6691 |
7411 if (input_file_compiler) | 6692 if (input_file_compiler) |
7412 { | 6693 { |
7413 /* Ok, we found an applicable compiler. Run its spec. */ | 6694 /* Ok, we found an applicable compiler. Run its spec. */ |
7414 | 6695 |
7415 if (input_file_compiler->spec[0] == '#') | 6696 if (input_file_compiler->spec[0] == '#') |
7416 { | 6697 { |
7417 error ("%s: %s compiler not installed on this system", | 6698 error ("%s: %s compiler not installed on this system", |
7418 input_filename, &input_file_compiler->spec[1]); | 6699 gcc_input_filename, &input_file_compiler->spec[1]); |
7419 this_file_error = 1; | 6700 this_file_error = 1; |
7420 } | 6701 } |
7421 else | 6702 else |
7422 { | 6703 { |
7423 if (compare_debug) | 6704 if (compare_debug) |
7436 if (value < 0) | 6717 if (value < 0) |
7437 this_file_error = 1; | 6718 this_file_error = 1; |
7438 else if (compare_debug && debug_check_temp_file[0]) | 6719 else if (compare_debug && debug_check_temp_file[0]) |
7439 { | 6720 { |
7440 if (verbose_flag) | 6721 if (verbose_flag) |
7441 error ("Recompiling with -fcompare-debug"); | 6722 inform (0, "recompiling with -fcompare-debug"); |
7442 | 6723 |
7443 compare_debug = -compare_debug; | 6724 compare_debug = -compare_debug; |
7444 n_switches = n_switches_debug_check[1]; | 6725 n_switches = n_switches_debug_check[1]; |
6726 n_switches_alloc = n_switches_alloc_debug_check[1]; | |
7445 switches = switches_debug_check[1]; | 6727 switches = switches_debug_check[1]; |
7446 | 6728 |
7447 value = do_spec (input_file_compiler->spec); | 6729 value = do_spec (input_file_compiler->spec); |
7448 | 6730 |
7449 compare_debug = -compare_debug; | 6731 compare_debug = -compare_debug; |
7450 n_switches = n_switches_debug_check[0]; | 6732 n_switches = n_switches_debug_check[0]; |
6733 n_switches_alloc = n_switches_alloc_debug_check[0]; | |
7451 switches = switches_debug_check[0]; | 6734 switches = switches_debug_check[0]; |
7452 | 6735 |
7453 if (value < 0) | 6736 if (value < 0) |
7454 { | 6737 { |
7455 error ("during -fcompare-debug recompilation"); | 6738 error ("during -fcompare-debug recompilation"); |
7459 gcc_assert (debug_check_temp_file[1] | 6742 gcc_assert (debug_check_temp_file[1] |
7460 && strcmp (debug_check_temp_file[0], | 6743 && strcmp (debug_check_temp_file[0], |
7461 debug_check_temp_file[1])); | 6744 debug_check_temp_file[1])); |
7462 | 6745 |
7463 if (verbose_flag) | 6746 if (verbose_flag) |
7464 error ("Comparing final insns dumps"); | 6747 inform (0, "comparing final insns dumps"); |
7465 | 6748 |
7466 if (compare_files (debug_check_temp_file)) | 6749 if (compare_files (debug_check_temp_file)) |
7467 this_file_error = 1; | 6750 this_file_error = 1; |
7468 } | 6751 } |
7469 | 6752 |
7490 if this compilation failed. */ | 6773 if this compilation failed. */ |
7491 | 6774 |
7492 if (this_file_error) | 6775 if (this_file_error) |
7493 { | 6776 { |
7494 delete_failure_queue (); | 6777 delete_failure_queue (); |
7495 error_count++; | 6778 errorcount++; |
7496 } | 6779 } |
7497 /* If this compilation succeeded, don't delete those files later. */ | 6780 /* If this compilation succeeded, don't delete those files later. */ |
7498 clear_failure_queue (); | 6781 clear_failure_queue (); |
7499 } | 6782 } |
7500 | 6783 |
7505 if (n_infiles > 0) | 6788 if (n_infiles > 0) |
7506 { | 6789 { |
7507 int i; | 6790 int i; |
7508 | 6791 |
7509 for (i = 0; i < n_infiles ; i++) | 6792 for (i = 0; i < n_infiles ; i++) |
7510 if (infiles[i].language && infiles[i].language[0] != '*') | 6793 if (infiles[i].incompiler |
6794 || (infiles[i].language && infiles[i].language[0] != '*')) | |
7511 { | 6795 { |
7512 set_input (infiles[i].name); | 6796 set_input (infiles[i].name); |
7513 break; | 6797 break; |
7514 } | 6798 } |
7515 } | 6799 } |
7516 | 6800 |
7517 if (error_count == 0) | 6801 if (!seen_error ()) |
7518 { | 6802 { |
7519 /* Make sure INPUT_FILE_NUMBER points to first available open | 6803 /* Make sure INPUT_FILE_NUMBER points to first available open |
7520 slot. */ | 6804 slot. */ |
7521 input_file_number = n_infiles; | 6805 input_file_number = n_infiles; |
7522 if (lang_specific_pre_link ()) | 6806 if (lang_specific_pre_link ()) |
7523 error_count++; | 6807 errorcount++; |
7524 } | 6808 } |
7525 | 6809 |
7526 /* Determine if there are any linker input files. */ | 6810 /* Determine if there are any linker input files. */ |
7527 num_linker_inputs = 0; | 6811 num_linker_inputs = 0; |
7528 for (i = 0; (int) i < n_infiles; i++) | 6812 for (i = 0; (int) i < n_infiles; i++) |
7529 if (explicit_link_files[i] || outfiles[i] != NULL) | 6813 if (explicit_link_files[i] || outfiles[i] != NULL) |
7530 num_linker_inputs++; | 6814 num_linker_inputs++; |
7531 | 6815 |
7532 /* Run ld to link all the compiler output files. */ | 6816 /* Run ld to link all the compiler output files. */ |
7533 | 6817 |
7534 if (num_linker_inputs > 0 && error_count == 0 && print_subprocess_help < 2) | 6818 if (num_linker_inputs > 0 && !seen_error () && print_subprocess_help < 2) |
7535 { | 6819 { |
7536 int tmp = execution_count; | 6820 int tmp = execution_count; |
6821 #ifdef HAVE_LTO_PLUGIN | |
6822 const char *fno_use_linker_plugin = "fno-use-linker-plugin"; | |
6823 #else | |
7537 const char *fuse_linker_plugin = "fuse-linker-plugin"; | 6824 const char *fuse_linker_plugin = "fuse-linker-plugin"; |
6825 #endif | |
7538 | 6826 |
7539 /* We'll use ld if we can't find collect2. */ | 6827 /* We'll use ld if we can't find collect2. */ |
7540 if (! strcmp (linker_name_spec, "collect2")) | 6828 if (! strcmp (linker_name_spec, "collect2")) |
7541 { | 6829 { |
7542 char *s = find_a_file (&exec_prefixes, "collect2", X_OK, false); | 6830 char *s = find_a_file (&exec_prefixes, "collect2", X_OK, false); |
7543 if (s == NULL) | 6831 if (s == NULL) |
7544 linker_name_spec = "ld"; | 6832 linker_name_spec = "ld"; |
7545 } | 6833 } |
7546 | 6834 |
6835 #ifdef HAVE_LTO_PLUGIN | |
6836 if (!switch_matches (fno_use_linker_plugin, | |
6837 fno_use_linker_plugin + strlen (fno_use_linker_plugin), 0)) | |
6838 #else | |
7547 if (switch_matches (fuse_linker_plugin, | 6839 if (switch_matches (fuse_linker_plugin, |
7548 fuse_linker_plugin + strlen (fuse_linker_plugin), 0)) | 6840 fuse_linker_plugin + strlen (fuse_linker_plugin), 0)) |
6841 #endif | |
7549 { | 6842 { |
7550 linker_plugin_file_spec = find_a_file (&exec_prefixes, | 6843 linker_plugin_file_spec = find_a_file (&exec_prefixes, |
7551 "liblto_plugin.so", X_OK, | 6844 LTOPLUGINSONAME, R_OK, |
7552 false); | 6845 false); |
7553 if (!linker_plugin_file_spec) | 6846 if (!linker_plugin_file_spec) |
7554 fatal ("-fuse-linker-plugin, but liblto_plugin.so not found"); | 6847 fatal_error ("-fuse-linker-plugin, but " LTOPLUGINSONAME " not found"); |
7555 | |
7556 lto_libgcc_spec = find_a_file (&startfile_prefixes, "libgcc.a", | |
7557 R_OK, true); | |
7558 if (!lto_libgcc_spec) | |
7559 fatal ("could not find libgcc.a"); | |
7560 } | 6848 } |
7561 lto_gcc_spec = argv[0]; | 6849 lto_gcc_spec = argv[0]; |
7562 | 6850 |
7563 /* Rebuild the COMPILER_PATH and LIBRARY_PATH environment variables | 6851 /* Rebuild the COMPILER_PATH and LIBRARY_PATH environment variables |
7564 for collect. */ | 6852 for collect. */ |
7572 " to the linker.\n\n")); | 6860 " to the linker.\n\n")); |
7573 fflush (stdout); | 6861 fflush (stdout); |
7574 } | 6862 } |
7575 value = do_spec (link_command_spec); | 6863 value = do_spec (link_command_spec); |
7576 if (value < 0) | 6864 if (value < 0) |
7577 error_count = 1; | 6865 errorcount = 1; |
7578 linker_was_run = (tmp != execution_count); | 6866 linker_was_run = (tmp != execution_count); |
7579 } | 6867 } |
7580 | 6868 |
7581 /* If options said don't run linker, | 6869 /* If options said don't run linker, |
7582 complain about input files to be given to the linker. */ | 6870 complain about input files to be given to the linker. */ |
7583 | 6871 |
7584 if (! linker_was_run && error_count == 0) | 6872 if (! linker_was_run && !seen_error ()) |
7585 for (i = 0; (int) i < n_infiles; i++) | 6873 for (i = 0; (int) i < n_infiles; i++) |
7586 if (explicit_link_files[i] | 6874 if (explicit_link_files[i] |
7587 && !(infiles[i].language && infiles[i].language[0] == '*')) | 6875 && !(infiles[i].language && infiles[i].language[0] == '*')) |
7588 error ("%s: linker input file unused because linking not done", | 6876 warning (0, "%s: linker input file unused because linking not done", |
7589 outfiles[i]); | 6877 outfiles[i]); |
7590 | 6878 |
7591 /* Delete some or all of the temporary files we made. */ | 6879 /* Delete some or all of the temporary files we made. */ |
7592 | 6880 |
7593 if (error_count) | 6881 if (seen_error ()) |
7594 delete_failure_queue (); | 6882 delete_failure_queue (); |
7595 delete_temp_files (); | 6883 delete_temp_files (); |
7596 | 6884 |
7597 if (print_help_list) | 6885 if (print_help_list) |
7598 { | 6886 { |
7599 printf (("\nFor bug reporting instructions, please see:\n")); | 6887 printf (("\nFor bug reporting instructions, please see:\n")); |
7600 printf ("%s\n", bug_report_url); | 6888 printf ("%s\n", bug_report_url); |
7601 } | 6889 } |
7602 | 6890 |
6891 out: | |
7603 return (signal_count != 0 ? 2 | 6892 return (signal_count != 0 ? 2 |
7604 : error_count > 0 ? (pass_exit_codes ? greatest_status : 1) | 6893 : seen_error () ? (pass_exit_codes ? greatest_status : 1) |
7605 : 0); | 6894 : 0); |
7606 } | 6895 } |
7607 | 6896 |
7608 /* Find the proper compilation spec for the file name NAME, | 6897 /* Find the proper compilation spec for the file name NAME, |
7609 whose length is LENGTH. LANGUAGE is the specified language, | 6898 whose length is LENGTH. LANGUAGE is the specified language, |
7694 } | 6983 } |
7695 | 6984 |
7696 static void | 6985 static void |
7697 perror_with_name (const char *name) | 6986 perror_with_name (const char *name) |
7698 { | 6987 { |
7699 error ("%s: %s", name, xstrerror (errno)); | 6988 error ("%s: %m", name); |
7700 } | |
7701 | |
7702 /* Output an error message and exit. */ | |
7703 | |
7704 void | |
7705 fancy_abort (const char *file, int line, const char *func) | |
7706 { | |
7707 fatal_ice ("internal gcc abort in %s, at %s:%d", func, file, line); | |
7708 } | |
7709 | |
7710 /* Output an error message and exit. */ | |
7711 | |
7712 void | |
7713 fatal_ice (const char *cmsgid, ...) | |
7714 { | |
7715 va_list ap; | |
7716 | |
7717 va_start (ap, cmsgid); | |
7718 | |
7719 fprintf (stderr, "%s: ", programname); | |
7720 vfprintf (stderr, _(cmsgid), ap); | |
7721 va_end (ap); | |
7722 fprintf (stderr, "\n"); | |
7723 delete_temp_files (); | |
7724 exit (pass_exit_codes ? ICE_EXIT_CODE : 1); | |
7725 } | |
7726 | |
7727 void | |
7728 fatal (const char *cmsgid, ...) | |
7729 { | |
7730 va_list ap; | |
7731 | |
7732 va_start (ap, cmsgid); | |
7733 | |
7734 fprintf (stderr, "%s: ", programname); | |
7735 vfprintf (stderr, _(cmsgid), ap); | |
7736 va_end (ap); | |
7737 fprintf (stderr, "\n"); | |
7738 delete_temp_files (); | |
7739 exit (1); | |
7740 } | |
7741 | |
7742 /* The argument is actually c-format, not gcc-internal-format, | |
7743 but because functions with identical names are used through | |
7744 the rest of the compiler with gcc-internal-format, we just | |
7745 need to hope all users of these functions use the common | |
7746 subset between c-format and gcc-internal-format. */ | |
7747 | |
7748 void | |
7749 error (const char *gmsgid, ...) | |
7750 { | |
7751 va_list ap; | |
7752 | |
7753 va_start (ap, gmsgid); | |
7754 fprintf (stderr, "%s: ", programname); | |
7755 vfprintf (stderr, _(gmsgid), ap); | |
7756 va_end (ap); | |
7757 | |
7758 fprintf (stderr, "\n"); | |
7759 } | |
7760 | |
7761 static void | |
7762 notice (const char *cmsgid, ...) | |
7763 { | |
7764 va_list ap; | |
7765 | |
7766 va_start (ap, cmsgid); | |
7767 vfprintf (stderr, _(cmsgid), ap); | |
7768 va_end (ap); | |
7769 } | 6989 } |
7770 | 6990 |
7771 static inline void | 6991 static inline void |
7772 validate_switches_from_spec (const char *spec) | 6992 validate_switches_from_spec (const char *spec) |
7773 { | 6993 { |
7918 while (*q != ' ') | 7138 while (*q != ' ') |
7919 { | 7139 { |
7920 if (*q == '\0') | 7140 if (*q == '\0') |
7921 { | 7141 { |
7922 invalid_matches: | 7142 invalid_matches: |
7923 fatal ("multilib spec '%s' is invalid", multilib_matches); | 7143 fatal_error ("multilib spec %qs is invalid", |
7144 multilib_matches); | |
7924 } | 7145 } |
7925 q++; | 7146 q++; |
7926 } | 7147 } |
7927 matches[i].len = q - matches[i].str; | 7148 matches[i].len = q - matches[i].str; |
7928 | 7149 |
8109 while (*p != ';') | 7330 while (*p != ';') |
8110 { | 7331 { |
8111 if (*p == '\0') | 7332 if (*p == '\0') |
8112 { | 7333 { |
8113 invalid_exclusions: | 7334 invalid_exclusions: |
8114 fatal ("multilib exclusions '%s' is invalid", | 7335 fatal_error ("multilib exclusions %qs is invalid", |
8115 multilib_exclusions); | 7336 multilib_exclusions); |
8116 } | 7337 } |
8117 | 7338 |
8118 if (! ok) | 7339 if (! ok) |
8119 { | 7340 { |
8120 ++p; | 7341 ++p; |
8167 while (*p != ' ') | 7388 while (*p != ' ') |
8168 { | 7389 { |
8169 if (*p == '\0') | 7390 if (*p == '\0') |
8170 { | 7391 { |
8171 invalid_select: | 7392 invalid_select: |
8172 fatal ("multilib select '%s' is invalid", | 7393 fatal_error ("multilib select %qs is invalid", |
8173 multilib_select); | 7394 multilib_select); |
8174 } | 7395 } |
8175 ++p; | 7396 ++p; |
8176 } | 7397 } |
8177 this_path_len = p - this_path; | 7398 this_path_len = p - this_path; |
8178 | 7399 |
8308 while (*p != ' ') | 7529 while (*p != ' ') |
8309 { | 7530 { |
8310 if (*p == '\0') | 7531 if (*p == '\0') |
8311 { | 7532 { |
8312 invalid_select: | 7533 invalid_select: |
8313 fatal ("multilib select '%s' is invalid", multilib_select); | 7534 fatal_error ("multilib select %qs is invalid", multilib_select); |
8314 } | 7535 } |
8315 | 7536 |
8316 ++p; | 7537 ++p; |
8317 } | 7538 } |
8318 | 7539 |
8346 int mp = 0; | 7567 int mp = 0; |
8347 | 7568 |
8348 if (*e == '\0') | 7569 if (*e == '\0') |
8349 { | 7570 { |
8350 invalid_exclusion: | 7571 invalid_exclusion: |
8351 fatal ("multilib exclusion '%s' is invalid", | 7572 fatal_error ("multilib exclusion %qs is invalid", |
8352 multilib_exclusions); | 7573 multilib_exclusions); |
8353 } | 7574 } |
8354 | 7575 |
8355 if (! m) | 7576 if (! m) |
8356 { | 7577 { |
8357 ++e; | 7578 ++e; |
8552 if (argc != 2) | 7773 if (argc != 2) |
8553 return NULL; | 7774 return NULL; |
8554 | 7775 |
8555 value = getenv (argv[0]); | 7776 value = getenv (argv[0]); |
8556 if (!value) | 7777 if (!value) |
8557 fatal ("environment variable \"%s\" not defined", argv[0]); | 7778 fatal_error ("environment variable %qs not defined", argv[0]); |
8558 | 7779 |
8559 /* We have to escape every character of the environment variable so | 7780 /* We have to escape every character of the environment variable so |
8560 they are not interpreted as active spec characters. A | 7781 they are not interpreted as active spec characters. A |
8561 particularly painful case is when we are reading a variable | 7782 particularly painful case is when we are reading a variable |
8562 holding a windows path complete with \ separators. */ | 7783 holding a windows path complete with \ separators. */ |
8628 outfiles[i] = xstrdup (argv[1]); | 7849 outfiles[i] = xstrdup (argv[1]); |
8629 } | 7850 } |
8630 return NULL; | 7851 return NULL; |
8631 } | 7852 } |
8632 | 7853 |
7854 /* remove-outfile built-in spec function. | |
7855 * | |
7856 * This looks for the first argument in the outfiles array's name and | |
7857 * removes it. */ | |
7858 | |
7859 static const char * | |
7860 remove_outfile_spec_function (int argc, const char **argv) | |
7861 { | |
7862 int i; | |
7863 /* Must have exactly one argument. */ | |
7864 if (argc != 1) | |
7865 abort (); | |
7866 | |
7867 for (i = 0; i < n_infiles; i++) | |
7868 { | |
7869 if (outfiles[i] && !strcmp (outfiles[i], argv[0])) | |
7870 outfiles[i] = NULL; | |
7871 } | |
7872 return NULL; | |
7873 } | |
7874 | |
8633 /* Given two version numbers, compares the two numbers. | 7875 /* Given two version numbers, compares the two numbers. |
8634 A version number must match the regular expression | 7876 A version number must match the regular expression |
8635 ([1-9][0-9]*|0)(\.([1-9][0-9]*|0))* | 7877 ([1-9][0-9]*|0)(\.([1-9][0-9]*|0))* |
8636 */ | 7878 */ |
8637 static int | 7879 static int |
8643 if (regcomp (&r, "^([1-9][0-9]*|0)(\\.([1-9][0-9]*|0))*$", | 7885 if (regcomp (&r, "^([1-9][0-9]*|0)(\\.([1-9][0-9]*|0))*$", |
8644 REG_EXTENDED | REG_NOSUB) != 0) | 7886 REG_EXTENDED | REG_NOSUB) != 0) |
8645 abort (); | 7887 abort (); |
8646 rresult = regexec (&r, v1, 0, NULL, 0); | 7888 rresult = regexec (&r, v1, 0, NULL, 0); |
8647 if (rresult == REG_NOMATCH) | 7889 if (rresult == REG_NOMATCH) |
8648 fatal ("invalid version number `%s'", v1); | 7890 fatal_error ("invalid version number %qs", v1); |
8649 else if (rresult != 0) | 7891 else if (rresult != 0) |
8650 abort (); | 7892 abort (); |
8651 rresult = regexec (&r, v2, 0, NULL, 0); | 7893 rresult = regexec (&r, v2, 0, NULL, 0); |
8652 if (rresult == REG_NOMATCH) | 7894 if (rresult == REG_NOMATCH) |
8653 fatal ("invalid version number `%s'", v2); | 7895 fatal_error ("invalid version number %qs", v2); |
8654 else if (rresult != 0) | 7896 else if (rresult != 0) |
8655 abort (); | 7897 abort (); |
8656 | 7898 |
8657 return strverscmp (v1, v2); | 7899 return strverscmp (v1, v2); |
8658 } | 7900 } |
8691 const char *switch_value = NULL; | 7933 const char *switch_value = NULL; |
8692 int nargs = 1, i; | 7934 int nargs = 1, i; |
8693 bool result; | 7935 bool result; |
8694 | 7936 |
8695 if (argc < 3) | 7937 if (argc < 3) |
8696 fatal ("too few arguments to %%:version-compare"); | 7938 fatal_error ("too few arguments to %%:version-compare"); |
8697 if (argv[0][0] == '\0') | 7939 if (argv[0][0] == '\0') |
8698 abort (); | 7940 abort (); |
8699 if ((argv[0][1] == '<' || argv[0][1] == '>') && argv[0][0] != '!') | 7941 if ((argv[0][1] == '<' || argv[0][1] == '>') && argv[0][0] != '!') |
8700 nargs = 2; | 7942 nargs = 2; |
8701 if (argc != nargs + 3) | 7943 if (argc != nargs + 3) |
8702 fatal ("too many arguments to %%:version-compare"); | 7944 fatal_error ("too many arguments to %%:version-compare"); |
8703 | 7945 |
8704 switch_len = strlen (argv[nargs + 1]); | 7946 switch_len = strlen (argv[nargs + 1]); |
8705 for (i = 0; i < n_switches; i++) | 7947 for (i = 0; i < n_switches; i++) |
8706 if (!strncmp (switches[i].part1, argv[nargs + 1], switch_len) | 7948 if (!strncmp (switches[i].part1, argv[nargs + 1], switch_len) |
8707 && check_live_switch (i, switch_len)) | 7949 && check_live_switch (i, switch_len)) |
8738 case '<' << 8 | '>': | 7980 case '<' << 8 | '>': |
8739 result = comp1 < 0 || comp2 >= 0; | 7981 result = comp1 < 0 || comp2 >= 0; |
8740 break; | 7982 break; |
8741 | 7983 |
8742 default: | 7984 default: |
8743 fatal ("unknown operator '%s' in %%:version-compare", argv[0]); | 7985 fatal_error ("unknown operator %qs in %%:version-compare", argv[0]); |
8744 } | 7986 } |
8745 if (! result) | 7987 if (! result) |
8746 return NULL; | 7988 return NULL; |
8747 | 7989 |
8748 return argv[nargs + 2]; | 7990 return argv[nargs + 2]; |
8764 file = find_a_file (&startfile_prefixes, argv[0], R_OK, true); | 8006 file = find_a_file (&startfile_prefixes, argv[0], R_OK, true); |
8765 read_specs (file ? file : argv[0], FALSE); | 8007 read_specs (file ? file : argv[0], FALSE); |
8766 | 8008 |
8767 return NULL; | 8009 return NULL; |
8768 } | 8010 } |
8011 | |
8012 /* %:find-file spec function. This function replaces its argument by | |
8013 the file found thru find_file, that is the -print-file-name gcc | |
8014 program option. */ | |
8015 static const char * | |
8016 find_file_spec_function (int argc, const char **argv) | |
8017 { | |
8018 const char *file; | |
8019 | |
8020 if (argc != 1) | |
8021 abort (); | |
8022 | |
8023 file = find_file (argv[0]); | |
8024 return file; | |
8025 } | |
8026 | |
8027 | |
8028 /* %:find-plugindir spec function. This function replaces its argument | |
8029 by the -iplugindir=<dir> option. `dir' is found thru find_file, that | |
8030 is the -print-file-name gcc program option. */ | |
8031 static const char * | |
8032 find_plugindir_spec_function (int argc, const char **argv ATTRIBUTE_UNUSED) | |
8033 { | |
8034 const char *option; | |
8035 | |
8036 if (argc != 0) | |
8037 abort (); | |
8038 | |
8039 option = concat ("-iplugindir=", find_file ("plugin"), NULL); | |
8040 return option; | |
8041 } | |
8042 | |
8769 | 8043 |
8770 /* %:print-asm-header spec function. Print a banner to say that the | 8044 /* %:print-asm-header spec function. Print a banner to say that the |
8771 following output is from the assembler. */ | 8045 following output is from the assembler. */ |
8772 | 8046 |
8773 static const char * | 8047 static const char * |
8819 char *name; | 8093 char *name; |
8820 int which; | 8094 int which; |
8821 static char random_seed[HOST_BITS_PER_WIDE_INT / 4 + 3]; | 8095 static char random_seed[HOST_BITS_PER_WIDE_INT / 4 + 3]; |
8822 | 8096 |
8823 if (arg != 0) | 8097 if (arg != 0) |
8824 fatal ("too many arguments to %%:compare-debug-dump-opt"); | 8098 fatal_error ("too many arguments to %%:compare-debug-dump-opt"); |
8825 | 8099 |
8826 do_spec_2 ("%{fdump-final-insns=*:%*}"); | 8100 do_spec_2 ("%{fdump-final-insns=*:%*}"); |
8827 do_spec_1 (" ", 0, NULL); | 8101 do_spec_1 (" ", 0, NULL); |
8828 | 8102 |
8829 if (argbuf_index > 0 && strcmp (argv[argbuf_index - 1], ".")) | 8103 if (VEC_length (const_char_p, argbuf) > 0 |
8104 && strcmp (argv[VEC_length (const_char_p, argbuf) - 1], ".")) | |
8830 { | 8105 { |
8831 if (!compare_debug) | 8106 if (!compare_debug) |
8832 return NULL; | 8107 return NULL; |
8833 | 8108 |
8834 name = xstrdup (argv[argbuf_index - 1]); | 8109 name = xstrdup (argv[VEC_length (const_char_p, argbuf) - 1]); |
8835 ret = NULL; | 8110 ret = NULL; |
8836 } | 8111 } |
8837 else | 8112 else |
8838 { | 8113 { |
8839 const char *ext = NULL; | 8114 const char *ext = NULL; |
8840 | 8115 |
8841 if (argbuf_index > 0) | 8116 if (VEC_length (const_char_p, argbuf) > 0) |
8842 { | 8117 { |
8843 do_spec_2 ("%{o*:%*}%{!o:%{!S:%b%O}%{S:%b.s}}"); | 8118 do_spec_2 ("%{o*:%*}%{!o:%{!S:%b%O}%{S:%b.s}}"); |
8844 ext = ".gkd"; | 8119 ext = ".gkd"; |
8845 } | 8120 } |
8846 else if (!compare_debug) | 8121 else if (!compare_debug) |
8848 else | 8123 else |
8849 do_spec_2 ("%g.gkd"); | 8124 do_spec_2 ("%g.gkd"); |
8850 | 8125 |
8851 do_spec_1 (" ", 0, NULL); | 8126 do_spec_1 (" ", 0, NULL); |
8852 | 8127 |
8853 gcc_assert (argbuf_index > 0); | 8128 gcc_assert (VEC_length (const_char_p, argbuf) > 0); |
8854 | 8129 |
8855 name = concat (argbuf[argbuf_index - 1], ext, NULL); | 8130 name = concat (VEC_last (const_char_p, argbuf), ext, NULL); |
8856 | 8131 |
8857 ret = concat ("-fdump-final-insns=", name, NULL); | 8132 ret = concat ("-fdump-final-insns=", name, NULL); |
8858 } | 8133 } |
8859 | 8134 |
8860 which = compare_debug < 0; | 8135 which = compare_debug < 0; |
8886 static const char * | 8161 static const char * |
8887 compare_debug_self_opt_spec_function (int arg, | 8162 compare_debug_self_opt_spec_function (int arg, |
8888 const char **argv ATTRIBUTE_UNUSED) | 8163 const char **argv ATTRIBUTE_UNUSED) |
8889 { | 8164 { |
8890 if (arg != 0) | 8165 if (arg != 0) |
8891 fatal ("too many arguments to %%:compare-debug-self-opt"); | 8166 fatal_error ("too many arguments to %%:compare-debug-self-opt"); |
8892 | 8167 |
8893 if (compare_debug >= 0) | 8168 if (compare_debug >= 0) |
8894 return NULL; | 8169 return NULL; |
8895 | 8170 |
8896 do_spec_2 ("%{c|S:%{o*:%*}}"); | 8171 do_spec_2 ("%{c|S:%{o*:%*}}"); |
8897 do_spec_1 (" ", 0, NULL); | 8172 do_spec_1 (" ", 0, NULL); |
8898 | 8173 |
8899 if (argbuf_index > 0) | 8174 if (VEC_length (const_char_p, argbuf) > 0) |
8900 debug_auxbase_opt = concat ("-auxbase-strip ", | 8175 debug_auxbase_opt = concat ("-auxbase-strip ", |
8901 argbuf[argbuf_index - 1], | 8176 VEC_last (const_char_p, argbuf), |
8902 NULL); | 8177 NULL); |
8903 else | 8178 else |
8904 debug_auxbase_opt = NULL; | 8179 debug_auxbase_opt = NULL; |
8905 | 8180 |
8906 return concat ("\ | 8181 return concat ("\ |
8921 { | 8196 { |
8922 char *name; | 8197 char *name; |
8923 int len; | 8198 int len; |
8924 | 8199 |
8925 if (arg == 0) | 8200 if (arg == 0) |
8926 fatal ("too few arguments to %%:compare-debug-auxbase-opt"); | 8201 fatal_error ("too few arguments to %%:compare-debug-auxbase-opt"); |
8927 | 8202 |
8928 if (arg != 1) | 8203 if (arg != 1) |
8929 fatal ("too many arguments to %%:compare-debug-auxbase-opt"); | 8204 fatal_error ("too many arguments to %%:compare-debug-auxbase-opt"); |
8930 | 8205 |
8931 if (compare_debug >= 0) | 8206 if (compare_debug >= 0) |
8932 return NULL; | 8207 return NULL; |
8933 | 8208 |
8934 len = strlen (argv[0]); | 8209 len = strlen (argv[0]); |
8935 if (len < 3 || strcmp (argv[0] + len - 3, ".gk") != 0) | 8210 if (len < 3 || strcmp (argv[0] + len - 3, ".gk") != 0) |
8936 fatal ("argument to %%:compare-debug-auxbase-opt does not end in .gk"); | 8211 fatal_error ("argument to %%:compare-debug-auxbase-opt " |
8212 "does not end in .gk"); | |
8937 | 8213 |
8938 if (debug_auxbase_opt) | 8214 if (debug_auxbase_opt) |
8939 return debug_auxbase_opt; | 8215 return debug_auxbase_opt; |
8940 | 8216 |
8941 #define OPT "-auxbase " | 8217 #define OPT "-auxbase " |
8948 | 8224 |
8949 #undef OPT | 8225 #undef OPT |
8950 | 8226 |
8951 return name; | 8227 return name; |
8952 } | 8228 } |
8229 | |
8230 /* %:pass-through-libs spec function. Finds all -l options and input | |
8231 file names in the lib spec passed to it, and makes a list of them | |
8232 prepended with the plugin option to cause them to be passed through | |
8233 to the final link after all the new object files have been added. */ | |
8234 | |
8235 const char * | |
8236 pass_through_libs_spec_func (int argc, const char **argv) | |
8237 { | |
8238 char *prepended = xstrdup (" "); | |
8239 int n; | |
8240 /* Shlemiel the painter's algorithm. Innately horrible, but at least | |
8241 we know that there will never be more than a handful of strings to | |
8242 concat, and it's only once per run, so it's not worth optimising. */ | |
8243 for (n = 0; n < argc; n++) | |
8244 { | |
8245 char *old = prepended; | |
8246 /* Anything that isn't an option is a full path to an output | |
8247 file; pass it through if it ends in '.a'. Among options, | |
8248 pass only -l. */ | |
8249 if (argv[n][0] == '-' && argv[n][1] == 'l') | |
8250 { | |
8251 const char *lopt = argv[n] + 2; | |
8252 /* Handle both joined and non-joined -l options. If for any | |
8253 reason there's a trailing -l with no joined or following | |
8254 arg just discard it. */ | |
8255 if (!*lopt && ++n >= argc) | |
8256 break; | |
8257 else if (!*lopt) | |
8258 lopt = argv[n]; | |
8259 prepended = concat (prepended, "-plugin-opt=-pass-through=-l", | |
8260 lopt, " ", NULL); | |
8261 } | |
8262 else if (!strcmp (".a", argv[n] + strlen (argv[n]) - 2)) | |
8263 { | |
8264 prepended = concat (prepended, "-plugin-opt=-pass-through=", | |
8265 argv[n], " ", NULL); | |
8266 } | |
8267 if (prepended != old) | |
8268 free (old); | |
8269 } | |
8270 return prepended; | |
8271 } |