1 /* Compiler driver program that can handle many languages.
2 Copyright (C) 1987, 89, 92-97, 1998 Free Software Foundation, Inc.
4 This file is part of GNU CC.
6 GNU CC is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
11 GNU CC is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU CC; see the file COPYING. If not, write to
18 the Free Software Foundation, 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA.
21 This paragraph is here to try to keep Sun CC from dying.
22 The number of chars here seems crucial!!!! */
24 /* This program is the user interface to the C compiler and possibly to
25 other compilers. It is used because compilation is a complicated procedure
26 which involves running several programs and passing temporary files between
27 them, forwarding the users switches to those programs selectively,
28 and deleting the temporary files at the end.
30 CC recognizes how to compile each input file by suffixes in the file names.
31 Once it knows which kind of compilation to perform, the procedure for
32 compilation is specified by a string called a "spec". */
45 #include "gansidecl.h"
49 /* ??? Need to find a GCC header to put these in. */
50 extern int pexecute PROTO ((const char *, char * const *, const char *,
51 const char *, char **, char **, int));
52 extern int pwait PROTO ((int, int *, int));
53 extern char *update_path PROTO((char *, char *));
54 extern void set_std_prefix PROTO((char *, int));
55 /* Flag arguments to pexecute. */
56 #define PEXECUTE_FIRST 1
57 #define PEXECUTE_LAST 2
58 #define PEXECUTE_SEARCH 4
59 #define PEXECUTE_VERBOSE 8
62 #define WIFSIGNALED(S) (((S) & 0xff) != 0 && ((S) & 0xff) != 0x7f)
65 #define WTERMSIG(S) ((S) & 0x7f)
68 #define WIFEXITED(S) (((S) & 0xff) == 0)
71 #define WEXITSTATUS(S) (((S) & 0xff00) >> 8)
75 #define exit __posix_exit
78 /* Define O_RDONLY if the system hasn't defined it for us. */
87 /* Test if something is a normal file. */
89 #define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
92 /* Test if something is a directory. */
94 #define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
97 /* By default there is no special suffix for executables. */
98 #ifdef EXECUTABLE_SUFFIX
99 #define HAVE_EXECUTABLE_SUFFIX
101 #define EXECUTABLE_SUFFIX ""
104 /* By default, the suffix for object files is ".o". */
106 #define HAVE_OBJECT_SUFFIX
108 #define OBJECT_SUFFIX ".o"
111 /* By default, colon separates directories in a path. */
112 #ifndef PATH_SEPARATOR
113 #define PATH_SEPARATOR ':'
116 #ifndef DIR_SEPARATOR
117 #define DIR_SEPARATOR '/'
120 static char dir_separator_str[] = {DIR_SEPARATOR, 0};
122 #define obstack_chunk_alloc xmalloc
123 #define obstack_chunk_free free
125 #ifndef GET_ENVIRONMENT
126 #define GET_ENVIRONMENT(ENV_VALUE,ENV_NAME) ENV_VALUE = getenv (ENV_NAME)
129 extern char *choose_temp_base PROTO((void));
131 #ifndef HAVE_STRERROR
133 extern char *sys_errlist[];
135 extern char *strerror();
139 #define kill(p,s) raise(s)
142 /* If a stage of compilation returns an exit status >= 1,
143 compilation of that file ceases. */
145 #define MIN_FATAL_STATUS 1
147 /* Flag saying to print the directories gcc will search through looking for
148 programs, libraries, etc. */
150 static int print_search_dirs;
152 /* Flag saying to print the full filename of this file
153 as found through our usual search mechanism. */
155 static char *print_file_name = NULL;
157 /* As print_file_name, but search for executable file. */
159 static char *print_prog_name = NULL;
161 /* Flag saying to print the relative path we'd use to
162 find libgcc.a given the current compiler flags. */
164 static int print_multi_directory;
166 /* Flag saying to print the list of subdirectories and
167 compiler flags used to select them in a standard form. */
169 static int print_multi_lib;
171 /* Flag indicating whether we should print the command and arguments */
173 static int verbose_flag;
175 /* Nonzero means write "temp" files in source directory
176 and use the source file's name in them, and don't delete them. */
178 static int save_temps_flag;
180 /* The compiler version. */
182 static char *compiler_version;
184 /* The target version specified with -V */
186 static char *spec_version = DEFAULT_TARGET_VERSION;
188 /* The target machine specified with -b. */
190 static char *spec_machine = DEFAULT_TARGET_MACHINE;
192 /* Nonzero if cross-compiling.
193 When -b is used, the value comes from the `specs' file. */
196 static char *cross_compile = "1";
198 static char *cross_compile = "0";
201 /* The number of errors that have occurred; the link phase will not be
202 run if this is non-zero. */
203 static int error_count = 0;
205 /* This is the obstack which we use to allocate many strings. */
207 static struct obstack obstack;
209 /* This is the obstack to build an environment variable to pass to
210 collect2 that describes all of the relevant switches of what to
211 pass the compiler in building the list of pointers to constructors
214 static struct obstack collect_obstack;
216 extern char *version_string;
218 /* Forward declaration for prototypes. */
221 static void init_spec PROTO((void));
222 static void read_specs PROTO((char *, int));
223 static void set_spec PROTO((char *, char *));
224 static struct compiler *lookup_compiler PROTO((char *, size_t, char *));
225 static char *build_search_list PROTO((struct path_prefix *, char *, int));
226 static void putenv_from_prefixes PROTO((struct path_prefix *, char *));
227 static char *find_a_file PROTO((struct path_prefix *, char *, int));
228 static void add_prefix PROTO((struct path_prefix *, char *, char *,
230 static char *skip_whitespace PROTO((char *));
231 static void record_temp_file PROTO((char *, int, int));
232 static void delete_if_ordinary PROTO((char *));
233 static void delete_temp_files PROTO((void));
234 static void delete_failure_queue PROTO((void));
235 static void clear_failure_queue PROTO((void));
236 static int check_live_switch PROTO((int, int));
237 static char *handle_braces PROTO((char *));
238 static char *save_string PROTO((char *, int));
239 static char *concat PVPROTO((char *, ...));
240 static int do_spec PROTO((char *));
241 static int do_spec_1 PROTO((char *, int, char *));
242 static char *find_file PROTO((char *));
243 static int is_directory PROTO((char *, char *, int));
244 static void validate_switches PROTO((char *));
245 static void validate_all_switches PROTO((void));
246 static void give_switch PROTO((int, int, int));
247 static int used_arg PROTO((char *, int));
248 static int default_arg PROTO((char *, int));
249 static void set_multilib_dir PROTO((void));
250 static void print_multilib_info PROTO((void));
251 static void pfatal_with_name PROTO((char *));
252 static void perror_with_name PROTO((char *));
253 static void pfatal_pexecute PROTO((char *, char *));
255 static void fatal PVPROTO((char *, ...));
256 static void error PVPROTO((char *, ...));
258 /* We must not provide any prototype here, even if ANSI C. */
259 static void fatal PROTO(());
260 static void error PROTO(());
267 #ifdef LANG_SPECIFIC_DRIVER
268 extern void lang_specific_driver PROTO ((void (*) (), int *, char ***));
271 /* Specs are strings containing lines, each of which (if not blank)
272 is made up of a program name, and arguments separated by spaces.
273 The program name must be exact and start from root, since no path
274 is searched and it is unreliable to depend on the current working directory.
275 Redirection of input or output is not supported; the subprograms must
276 accept filenames saying what files to read and write.
278 In addition, the specs can contain %-sequences to substitute variable text
279 or for conditional text. Here is a table of all defined %-sequences.
280 Note that spaces are not generated automatically around the results of
281 expanding these sequences; therefore, you can concatenate them together
282 or with constant text in a single argument.
284 %% substitute one % into the program name or argument.
285 %i substitute the name of the input file being processed.
286 %b substitute the basename of the input file being processed.
287 This is the substring up to (and not including) the last period
288 and not including the directory.
289 %g substitute the temporary-file-name-base. This is a string chosen
290 once per compilation. Different temporary file names are made by
291 concatenation of constant strings on the end, as in `%g.s'.
292 %g also has the same effect of %d.
293 %u like %g, but make the temporary file name unique.
294 %U returns the last file name generated with %u.
295 %d marks the argument containing or following the %d as a
296 temporary file name, so that that file will be deleted if CC exits
297 successfully. Unlike %g, this contributes no text to the argument.
298 %w marks the argument containing or following the %w as the
299 "output file" of this compilation. This puts the argument
300 into the sequence of arguments that %o will substitute later.
302 like %{...} but mark last argument supplied within
303 as a file to be deleted on failure.
304 %o substitutes the names of all the output files, with spaces
305 automatically placed around them. You should write spaces
306 around the %o as well or the results are undefined.
307 %o is for use in the specs for running the linker.
308 Input files whose names have no recognized suffix are not compiled
309 at all, but they are included among the output files, so they will
311 %O substitutes the suffix for object files.
312 %p substitutes the standard macro predefinitions for the
313 current target machine. Use this when running cpp.
314 %P like %p, but puts `__' before and after the name of each macro.
315 (Except macros that already have __.)
317 %I Substitute a -iprefix option made from GCC_EXEC_PREFIX.
318 %s current argument is the name of a library or startup file of some sort.
319 Search for that file in a standard list of directories
320 and substitute the full name found.
321 %eSTR Print STR as an error message. STR is terminated by a newline.
322 Use this when inconsistent options are detected.
323 %x{OPTION} Accumulate an option for %X.
324 %X Output the accumulated linker options specified by compilations.
325 %Y Output the accumulated assembler options specified by compilations.
326 %Z Output the accumulated preprocessor options specified by compilations.
327 %v1 Substitute the major version number of GCC.
328 (For version 2.5.n, this is 2.)
329 %v2 Substitute the minor version number of GCC.
330 (For version 2.5.n, this is 5.)
331 %a process ASM_SPEC as a spec.
332 This allows config.h to specify part of the spec for running as.
333 %A process ASM_FINAL_SPEC as a spec. A capital A is actually
334 used here. This can be used to run a post-processor after the
335 assembler has done it's job.
336 %D Dump out a -L option for each directory in startfile_prefixes.
337 If multilib_dir is set, extra entries are generated with it affixed.
338 %l process LINK_SPEC as a spec.
339 %L process LIB_SPEC as a spec.
340 %G process LIBGCC_SPEC as a spec.
341 %S process STARTFILE_SPEC as a spec. A capital S is actually used here.
342 %E process ENDFILE_SPEC as a spec. A capital E is actually used here.
343 %c process SIGNED_CHAR_SPEC as a spec.
344 %C process CPP_SPEC as a spec. A capital C is actually used here.
345 %1 process CC1_SPEC as a spec.
346 %2 process CC1PLUS_SPEC as a spec.
347 %| output "-" if the input for the current command is coming from a pipe.
348 %* substitute the variable part of a matched option. (See below.)
349 Note that each comma in the substituted string is replaced by
351 %{S} substitutes the -S switch, if that switch was given to CC.
352 If that switch was not specified, this substitutes nothing.
353 Here S is a metasyntactic variable.
354 %{S*} substitutes all the switches specified to CC whose names start
355 with -S. This is used for -o, -D, -I, etc; switches that take
356 arguments. CC considers `-o foo' as being one switch whose
357 name starts with `o'. %{o*} would substitute this text,
358 including the space; thus, two arguments would be generated.
359 %{^S*} likewise, but don't put a blank between a switch and any args.
360 %{S*:X} substitutes X if one or more switches whose names start with -S are
361 specified to CC. Note that the tail part of the -S option
362 (i.e. the part matched by the `*') will be substituted for each
363 occurrence of %* within X.
364 %{S:X} substitutes X, but only if the -S switch was given to CC.
365 %{!S:X} substitutes X, but only if the -S switch was NOT given to CC.
366 %{|S:X} like %{S:X}, but if no S switch, substitute `-'.
367 %{|!S:X} like %{!S:X}, but if there is an S switch, substitute `-'.
368 %{.S:X} substitutes X, but only if processing a file with suffix S.
369 %{!.S:X} substitutes X, but only if NOT processing a file with suffix S.
370 %(Spec) processes a specification defined in a specs file as *Spec:
371 %[Spec] as above, but put __ around -D arguments
373 The conditional text X in a %{S:X} or %{!S:X} construct may contain
374 other nested % constructs or spaces, or even newlines. They are
375 processed as usual, as described above.
377 The -O, -f, -m, and -W switches are handled specifically in these
378 constructs. If another value of -O or the negated form of a -f, -m, or
379 -W switch is found later in the command line, the earlier switch
380 value is ignored, except with {S*} where S is just one letter; this
381 passes all matching options.
383 The character | is used to indicate that a command should be piped to
384 the following command, but only if -pipe is specified.
386 Note that it is built into CC which switches take arguments and which
387 do not. You might think it would be useful to generalize this to
388 allow each compiler's spec to say which switches take arguments. But
389 this cannot be done in a consistent fashion. CC cannot even decide
390 which input files have been specified without knowing which switches
391 take arguments, and it must know which input files to compile in order
392 to tell which compilers to run.
394 CC also knows implicitly that arguments starting in `-l' are to be
395 treated as compiler output files, and passed to the linker in their
396 proper position among the other output files. */
398 /* Define the macros used for specs %a, %l, %L, %S, %c, %C, %1. */
400 /* config.h can define ASM_SPEC to provide extra args to the assembler
401 or extra switch-translations. */
406 /* config.h can define ASM_FINAL_SPEC to run a post processor after
407 the assembler has run. */
408 #ifndef ASM_FINAL_SPEC
409 #define ASM_FINAL_SPEC ""
412 /* config.h can define CPP_SPEC to provide extra args to the C preprocessor
413 or extra switch-translations. */
418 /* config.h can define CC1_SPEC to provide extra args to cc1 and cc1plus
419 or extra switch-translations. */
424 /* config.h can define CC1PLUS_SPEC to provide extra args to cc1plus
425 or extra switch-translations. */
427 #define CC1PLUS_SPEC ""
430 /* config.h can define LINK_SPEC to provide extra args to the linker
431 or extra switch-translations. */
436 /* config.h can define LIB_SPEC to override the default libraries. */
438 #define LIB_SPEC "%{!shared:%{g*:-lg} %{!p:%{!pg:-lc}}%{p:-lc_p}%{pg:-lc_p}}"
441 /* config.h can define LIBGCC_SPEC to override how and when libgcc.a is
444 #if defined(LINK_LIBGCC_SPECIAL) || defined(LINK_LIBGCC_SPECIAL_1)
445 /* Have gcc do the search for libgcc.a. */
446 #define LIBGCC_SPEC "libgcc.a%s"
448 #define LIBGCC_SPEC "-lgcc"
452 /* config.h can define STARTFILE_SPEC to override the default crt0 files. */
453 #ifndef STARTFILE_SPEC
454 #define STARTFILE_SPEC \
455 "%{!shared:%{pg:gcrt0%O%s}%{!pg:%{p:mcrt0%O%s}%{!p:crt0%O%s}}}"
458 /* config.h can define SWITCHES_NEED_SPACES to control which options
459 require spaces between the option and the argument. */
460 #ifndef SWITCHES_NEED_SPACES
461 #define SWITCHES_NEED_SPACES ""
464 /* config.h can define ENDFILE_SPEC to override the default crtn files. */
466 #define ENDFILE_SPEC ""
469 /* This spec is used for telling cpp whether char is signed or not. */
470 #ifndef SIGNED_CHAR_SPEC
471 /* Use #if rather than ?:
472 because MIPS C compiler rejects like ?: in initializers. */
473 #if DEFAULT_SIGNED_CHAR
474 #define SIGNED_CHAR_SPEC "%{funsigned-char:-D__CHAR_UNSIGNED__}"
476 #define SIGNED_CHAR_SPEC "%{!fsigned-char:-D__CHAR_UNSIGNED__}"
481 #define LINKER_NAME "collect2"
484 static char *cpp_spec = CPP_SPEC;
485 static char *cpp_predefines = CPP_PREDEFINES;
486 static char *cc1_spec = CC1_SPEC;
487 static char *cc1plus_spec = CC1PLUS_SPEC;
488 static char *signed_char_spec = SIGNED_CHAR_SPEC;
489 static char *asm_spec = ASM_SPEC;
490 static char *asm_final_spec = ASM_FINAL_SPEC;
491 static char *link_spec = LINK_SPEC;
492 static char *lib_spec = LIB_SPEC;
493 static char *libgcc_spec = LIBGCC_SPEC;
494 static char *endfile_spec = ENDFILE_SPEC;
495 static char *startfile_spec = STARTFILE_SPEC;
496 static char *switches_need_spaces = SWITCHES_NEED_SPACES;
497 static char *linker_name_spec = LINKER_NAME;
499 /* Some compilers have limits on line lengths, and the multilib_select
500 and/or multilib_matches strings can be very long, so we build them at
502 static struct obstack multilib_obstack;
503 static char *multilib_select;
504 static char *multilib_matches;
505 static char *multilib_defaults;
506 #include "multilib.h"
508 /* Check whether a particular argument is a default argument. */
510 #ifndef MULTILIB_DEFAULTS
511 #define MULTILIB_DEFAULTS { "" }
514 static char *multilib_defaults_raw[] = MULTILIB_DEFAULTS;
517 struct user_specs *next;
521 static struct user_specs *user_specs_head, *user_specs_tail;
523 /* This defines which switch letters take arguments. */
525 #define DEFAULT_SWITCH_TAKES_ARG(CHAR) \
526 ((CHAR) == 'D' || (CHAR) == 'U' || (CHAR) == 'o' \
527 || (CHAR) == 'e' || (CHAR) == 'T' || (CHAR) == 'u' \
528 || (CHAR) == 'I' || (CHAR) == 'm' || (CHAR) == 'x' \
529 || (CHAR) == 'L' || (CHAR) == 'A' || (CHAR) == 'V' \
530 || (CHAR) == 'B' || (CHAR) == 'b')
532 #ifndef SWITCH_TAKES_ARG
533 #define SWITCH_TAKES_ARG(CHAR) DEFAULT_SWITCH_TAKES_ARG(CHAR)
536 /* This defines which multi-letter switches take arguments. */
538 #define DEFAULT_WORD_SWITCH_TAKES_ARG(STR) \
539 (!strcmp (STR, "Tdata") || !strcmp (STR, "Ttext") \
540 || !strcmp (STR, "Tbss") || !strcmp (STR, "include") \
541 || !strcmp (STR, "imacros") || !strcmp (STR, "aux-info") \
542 || !strcmp (STR, "idirafter") || !strcmp (STR, "iprefix") \
543 || !strcmp (STR, "iwithprefix") || !strcmp (STR, "iwithprefixbefore") \
544 || !strcmp (STR, "isystem") || !strcmp (STR, "specs"))
546 #ifndef WORD_SWITCH_TAKES_ARG
547 #define WORD_SWITCH_TAKES_ARG(STR) DEFAULT_WORD_SWITCH_TAKES_ARG (STR)
550 /* Record the mapping from file suffixes for compilation specs. */
554 char *suffix; /* Use this compiler for input files
555 whose names end in this suffix. */
557 char *spec[4]; /* To use this compiler, concatenate these
558 specs and pass to do_spec. */
561 /* Pointer to a vector of `struct compiler' that gives the spec for
562 compiling a file, based on its suffix.
563 A file that does not end in any of these suffixes will be passed
564 unchanged to the loader and nothing else will be done to it.
566 An entry containing two 0s is used to terminate the vector.
568 If multiple entries match a file, the last matching one is used. */
570 static struct compiler *compilers;
572 /* Number of entries in `compilers', not counting the null terminator. */
574 static int n_compilers;
576 /* The default list of file name suffixes and their compilation specs. */
578 static struct compiler default_compilers[] =
580 /* Add lists of suffixes of known languages here. If those languages
581 were not present when we built the driver, we will hit these copies
582 and be given a more meaningful error than "file not used since
583 linking is not done". */
584 {".cc", {"#C++"}}, {".cxx", {"#C++"}}, {".cpp", {"#C++"}}, {".c++", {"#C++"}},
585 {".C", {"#C++"}}, {".ads", {"#Ada"}}, {".adb", {"#Ada"}}, {".ada", {"#Ada"}},
586 {".f", {"#Fortran"}}, {".for", {"#Fortran"}}, {".F", {"#Fortran"}},
587 {".fpp", {"#Fortran"}},
588 {".p", {"#Pascal"}}, {".pas", {"#Pascal"}},
589 /* Next come the entries for C. */
592 {"cpp -lang-c%{ansi:89} %{nostdinc*} %{C} %{v} %{A*} %{I*} %{P} %I\
593 %{C:%{!E:%eGNU C does not support -C without using -E}}\
594 %{M} %{MM} %{MD:-MD %b.d} %{MMD:-MMD %b.d} %{MG}\
595 -undef -D__GNUC__=%v1 -D__GNUC_MINOR__=%v2\
596 %{ansi:-trigraphs -D__STRICT_ANSI__}\
597 %{!undef:%{!ansi:%p} %P} %{trigraphs} \
598 %c %{Os:-D__OPTIMIZE_SIZE__} %{O*:%{!O0:-D__OPTIMIZE__}}\
599 %{traditional} %{ftraditional:-traditional}\
600 %{traditional-cpp:-traditional}\
601 %{g*} %{W*} %{w} %{pedantic*} %{H} %{d*} %C %{D*} %{U*} %{i*} %Z\
602 %i %{!M:%{!MM:%{!E:%{!pipe:%g.i}}}}%{E:%W{o*}}%{M:%W{o*}}%{MM:%W{o*}} |\n",
603 "%{!M:%{!MM:%{!E:cc1 %{!pipe:%g.i} %1 \
604 %{!Q:-quiet} -dumpbase %b.c %{d*} %{m*} %{a*}\
605 %{g*} %{O*} %{W*} %{w} %{pedantic*} %{ansi} \
606 %{traditional} %{v:-version} %{pg:-p} %{p} %{f*}\
608 %{pg:%{fomit-frame-pointer:%e-pg and -fomit-frame-pointer are incompatible}}\
609 %{S:%W{o*}%{!o*:-o %b.s}}%{!S:-o %{|!pipe:%g.s}} |\n\
611 %{c:%W{o*}%{!o*:-o %w%b%O}}%{!c:-o %d%w%u%O}\
612 %{!pipe:%g.s} %A\n }}}}"}},
614 {"%{E:cpp -lang-c%{ansi:89} %{nostdinc*} %{C} %{v} %{A*} %{I*} %{P} %I\
615 %{C:%{!E:%eGNU C does not support -C without using -E}}\
616 %{M} %{MM} %{MD:-MD %b.d} %{MMD:-MMD %b.d} %{MG}\
617 -undef -D__GNUC__=%v1 -D__GNUC_MINOR__=%v2\
618 %{ansi:-trigraphs -D__STRICT_ANSI__}\
619 %{!undef:%{!ansi:%p} %P} %{trigraphs}\
620 %c %{Os:-D__OPTIMIZE_SIZE__} %{O*:%{!O0:-D__OPTIMIZE__}}\
621 %{traditional} %{ftraditional:-traditional}\
622 %{traditional-cpp:-traditional}\
623 %{g*} %{W*} %{w} %{pedantic*} %{H} %{d*} %C %{D*} %{U*} %{i*} %Z\
625 %{!E:%e-E required when input is from standard input}"}},
626 {".m", {"@objective-c"}},
628 {"cpp -lang-objc %{nostdinc*} %{C} %{v} %{A*} %{I*} %{P} %I\
629 %{C:%{!E:%eGNU C does not support -C without using -E}}\
630 %{M} %{MM} %{MD:-MD %b.d} %{MMD:-MMD %b.d} %{MG}\
631 -undef -D__OBJC__ -D__GNUC__=%v1 -D__GNUC_MINOR__=%v2\
632 %{ansi:-trigraphs -D__STRICT_ANSI__}\
633 %{!undef:%{!ansi:%p} %P} %{trigraphs}\
634 %c %{Os:-D__OPTIMIZE_SIZE__} %{O*:%{!O0:-D__OPTIMIZE__}}\
635 %{traditional} %{ftraditional:-traditional}\
636 %{traditional-cpp:-traditional}\
637 %{g*} %{W*} %{w} %{pedantic*} %{H} %{d*} %C %{D*} %{U*} %{i*} %Z\
638 %i %{!M:%{!MM:%{!E:%{!pipe:%g.i}}}}%{E:%W{o*}}%{M:%W{o*}}%{MM:%W{o*}} |\n",
639 "%{!M:%{!MM:%{!E:cc1obj %{!pipe:%g.i} %1 \
640 %{!Q:-quiet} -dumpbase %b.m %{d*} %{m*} %{a*}\
641 %{g*} %{O*} %{W*} %{w} %{pedantic*} %{ansi} \
642 %{traditional} %{v:-version} %{pg:-p} %{p} %{f*} \
643 -lang-objc %{gen-decls} \
645 %{pg:%{fomit-frame-pointer:%e-pg and -fomit-frame-pointer are incompatible}}\
646 %{S:%W{o*}%{!o*:-o %b.s}}%{!S:-o %{|!pipe:%g.s}} |\n\
648 %{c:%W{o*}%{!o*:-o %w%b%O}}%{!c:-o %d%w%u%O}\
649 %{!pipe:%g.s} %A\n }}}}"}},
650 {".h", {"@c-header"}},
652 {"%{!E:%eCompilation of header file requested} \
653 cpp %{nostdinc*} %{C} %{v} %{A*} %{I*} %{P} %I\
654 %{C:%{!E:%eGNU C does not support -C without using -E}}\
655 %{M} %{MM} %{MD:-MD %b.d} %{MMD:-MMD %b.d} %{MG}\
656 -undef -D__GNUC__=%v1 -D__GNUC_MINOR__=%v2\
657 %{ansi:-trigraphs -D__STRICT_ANSI__}\
658 %{!undef:%{!ansi:%p} %P} %{trigraphs}\
659 %c %{Os:-D__OPTIMIZE_SIZE__} %{O*:%{!O0:-D__OPTIMIZE__}}\
660 %{traditional} %{ftraditional:-traditional}\
661 %{traditional-cpp:-traditional}\
662 %{g*} %{W*} %{w} %{pedantic*} %{H} %{d*} %C %{D*} %{U*} %{i*} %Z\
664 {".i", {"@cpp-output"}},
666 {"%{!M:%{!MM:%{!E:cc1 %i %1 %{!Q:-quiet} %{d*} %{m*} %{a*}\
667 %{g*} %{O*} %{W*} %{w} %{pedantic*} %{ansi}\
668 %{traditional} %{v:-version} %{pg:-p} %{p} %{f*}\
670 %{pg:%{fomit-frame-pointer:%e-pg and -fomit-frame-pointer are incompatible}}\
671 %{S:%W{o*}%{!o*:-o %b.s}}%{!S:-o %{|!pipe:%g.s}} |\n\
673 %{c:%W{o*}%{!o*:-o %w%b%O}}%{!c:-o %d%w%u%O}\
674 %{!pipe:%g.s} %A\n }}}}"}},
675 {".s", {"@assembler"}},
677 {"%{!M:%{!MM:%{!E:%{!S:as %a %Y\
678 %{c:%W{o*}%{!o*:-o %w%b%O}}%{!c:-o %d%w%u%O}\
680 {".S", {"@assembler-with-cpp"}},
681 {"@assembler-with-cpp",
682 {"cpp -lang-asm %{nostdinc*} %{C} %{v} %{A*} %{I*} %{P} %I\
683 %{C:%{!E:%eGNU C does not support -C without using -E}}\
684 %{M} %{MM} %{MD:-MD %b.d} %{MMD:-MMD %b.d} %{MG} %{trigraphs}\
685 -undef -$ %{!undef:%p %P} -D__ASSEMBLER__ \
686 %c %{Os:-D__OPTIMIZE_SIZE__} %{O*:%{!O0:-D__OPTIMIZE__}}\
687 %{traditional} %{ftraditional:-traditional}\
688 %{traditional-cpp:-traditional}\
689 %{g*} %{W*} %{w} %{pedantic*} %{H} %{d*} %C %{D*} %{U*} %{i*} %Z\
690 %i %{!M:%{!MM:%{!E:%{!pipe:%g.s}}}}%{E:%W{o*}}%{M:%W{o*}}%{MM:%W{o*}} |\n",
691 "%{!M:%{!MM:%{!E:%{!S:as %a %Y\
692 %{c:%W{o*}%{!o*:-o %w%b%O}}%{!c:-o %d%w%u%O}\
693 %{!pipe:%g.s} %A\n }}}}"}},
695 /* Mark end of table */
699 /* Number of elements in default_compilers, not counting the terminator. */
701 static int n_default_compilers
702 = (sizeof default_compilers / sizeof (struct compiler)) - 1;
704 /* Here is the spec for running the linker, after compiling all files. */
706 /* -u* was put back because both BSD and SysV seem to support it. */
707 /* %{static:} simply prevents an error message if the target machine
708 doesn't handle -static. */
709 /* We want %{T*} after %{L*} and %D so that it can be used to specify linker
710 scripts which exist in user specified directories, or in standard
712 #ifdef LINK_LIBGCC_SPECIAL
713 /* Don't generate -L options. */
714 static char *link_command_spec = "\
716 %{!c:%{!M:%{!MM:%{!E:%{!S:%(linker) %l %X %{o*} %{A} %{d} %{e*} %{m} %{N} %{n} \
717 %{r} %{s} %{t} %{u*} %{x} %{z} %{Z}\
718 %{!A:%{!nostdlib:%{!nostartfiles:%S}}}\
720 %{!nostdlib:%{!nodefaultlibs:%G %L %G}}\
721 %{!A:%{!nostdlib:%{!nostartfiles:%E}}}\
726 static char *link_command_spec = "\
728 %{!c:%{!M:%{!MM:%{!E:%{!S:%(linker) %l %X %{o*} %{A} %{d} %{e*} %{m} %{N} %{n} \
729 %{r} %{s} %{t} %{u*} %{x} %{z} %{Z}\
730 %{!A:%{!nostdlib:%{!nostartfiles:%S}}}\
731 %{static:} %{L*} %D %o\
732 %{!nostdlib:%{!nodefaultlibs:%G %L %G}}\
733 %{!A:%{!nostdlib:%{!nostartfiles:%E}}}\
738 /* A vector of options to give to the linker.
739 These options are accumulated by %x,
740 and substituted into the linker command with %X. */
741 static int n_linker_options;
742 static char **linker_options;
744 /* A vector of options to give to the assembler.
745 These options are accumulated by -Wa,
746 and substituted into the assembler command with %Y. */
747 static int n_assembler_options;
748 static char **assembler_options;
750 /* A vector of options to give to the preprocessor.
751 These options are accumulated by -Wp,
752 and substituted into the preprocessor command with %Z. */
753 static int n_preprocessor_options;
754 static char **preprocessor_options;
756 /* Define how to map long options into short ones. */
758 /* This structure describes one mapping. */
761 /* The long option's name. */
763 /* The equivalent short option. */
765 /* Argument info. A string of flag chars; NULL equals no options.
766 a => argument required.
767 o => argument optional.
768 j => join argument to equivalent, making one word.
769 * => require other text after NAME as an argument. */
773 /* This is the table of mappings. Mappings are tried sequentially
774 for each option encountered; the first one that matches, wins. */
776 struct option_map option_map[] =
778 {"--all-warnings", "-Wall", 0},
779 {"--ansi", "-ansi", 0},
780 {"--assemble", "-S", 0},
781 {"--assert", "-A", "a"},
782 {"--comments", "-C", 0},
783 {"--compile", "-c", 0},
784 {"--debug", "-g", "oj"},
785 {"--define-macro", "-D", "aj"},
786 {"--dependencies", "-M", 0},
787 {"--dump", "-d", "a"},
788 {"--dumpbase", "-dumpbase", "a"},
789 {"--entry", "-e", 0},
790 {"--extra-warnings", "-W", 0},
791 {"--for-assembler", "-Wa", "a"},
792 {"--for-linker", "-Xlinker", "a"},
793 {"--force-link", "-u", "a"},
794 {"--imacros", "-imacros", "a"},
795 {"--include", "-include", "a"},
796 {"--include-barrier", "-I-", 0},
797 {"--include-directory", "-I", "aj"},
798 {"--include-directory-after", "-idirafter", "a"},
799 {"--include-prefix", "-iprefix", "a"},
800 {"--include-with-prefix", "-iwithprefix", "a"},
801 {"--include-with-prefix-before", "-iwithprefixbefore", "a"},
802 {"--include-with-prefix-after", "-iwithprefix", "a"},
803 {"--language", "-x", "a"},
804 {"--library-directory", "-L", "a"},
805 {"--machine", "-m", "aj"},
806 {"--machine-", "-m", "*j"},
807 {"--no-line-commands", "-P", 0},
808 {"--no-precompiled-includes", "-noprecomp", 0},
809 {"--no-standard-includes", "-nostdinc", 0},
810 {"--no-standard-libraries", "-nostdlib", 0},
811 {"--no-warnings", "-w", 0},
812 {"--optimize", "-O", "oj"},
813 {"--output", "-o", "a"},
814 {"--pedantic", "-pedantic", 0},
815 {"--pedantic-errors", "-pedantic-errors", 0},
816 {"--pipe", "-pipe", 0},
817 {"--prefix", "-B", "a"},
818 {"--preprocess", "-E", 0},
819 {"--print-search-dirs", "-print-search-dirs", 0},
820 {"--print-file-name", "-print-file-name=", "aj"},
821 {"--print-libgcc-file-name", "-print-libgcc-file-name", 0},
822 {"--print-missing-file-dependencies", "-MG", 0},
823 {"--print-multi-lib", "-print-multi-lib", 0},
824 {"--print-multi-directory", "-print-multi-directory", 0},
825 {"--print-prog-name", "-print-prog-name=", "aj"},
826 {"--profile", "-p", 0},
827 {"--profile-blocks", "-a", 0},
828 {"--quiet", "-q", 0},
829 {"--save-temps", "-save-temps", 0},
830 {"--shared", "-shared", 0},
831 {"--silent", "-q", 0},
832 {"--specs", "-specs=", "aj"},
833 {"--static", "-static", 0},
834 {"--symbolic", "-symbolic", 0},
835 {"--target", "-b", "a"},
836 {"--trace-includes", "-H", 0},
837 {"--traditional", "-traditional", 0},
838 {"--traditional-cpp", "-traditional-cpp", 0},
839 {"--trigraphs", "-trigraphs", 0},
840 {"--undefine-macro", "-U", "aj"},
841 {"--use-version", "-V", "a"},
842 {"--user-dependencies", "-MM", 0},
843 {"--verbose", "-v", 0},
844 {"--version", "-dumpversion", 0},
845 {"--warn-", "-W", "*j"},
846 {"--write-dependencies", "-MD", 0},
847 {"--write-user-dependencies", "-MMD", 0},
851 /* Translate the options described by *ARGCP and *ARGVP.
852 Make a new vector and store it back in *ARGVP,
853 and store its length in *ARGVC. */
856 translate_options (argcp, argvp)
862 char **argv = *argvp;
863 char **newv = (char **) xmalloc ((argc + 2) * 2 * sizeof (char *));
867 newv[newindex++] = argv[i++];
871 /* Translate -- options. */
872 if (argv[i][0] == '-' && argv[i][1] == '-')
874 /* Find a mapping that applies to this option. */
875 for (j = 0; j < sizeof (option_map) / sizeof (option_map[0]); j++)
877 size_t optlen = strlen (option_map[j].name);
878 size_t arglen = strlen (argv[i]);
879 size_t complen = arglen > optlen ? optlen : arglen;
880 char *arginfo = option_map[j].arg_info;
885 if (!strncmp (argv[i], option_map[j].name, complen))
892 k < sizeof (option_map) / sizeof (option_map[0]);
894 if (strlen (option_map[k].name) >= arglen
895 && !strncmp (argv[i], option_map[k].name, arglen))
897 error ("Ambiguous abbreviation %s", argv[i]);
901 if (k != sizeof (option_map) / sizeof (option_map[0]))
907 /* If the option has an argument, accept that. */
908 if (argv[i][optlen] == '=')
909 arg = argv[i] + optlen + 1;
911 /* If this mapping requires extra text at end of name,
912 accept that as "argument". */
913 else if (index (arginfo, '*') != 0)
914 arg = argv[i] + optlen;
916 /* Otherwise, extra text at end means mismatch.
917 Try other mappings. */
922 else if (index (arginfo, '*') != 0)
924 error ("Incomplete `%s' option", option_map[j].name);
928 /* Handle arguments. */
929 if (index (arginfo, 'a') != 0)
935 error ("Missing argument to `%s' option",
943 else if (index (arginfo, '*') != 0)
945 else if (index (arginfo, 'o') == 0)
948 error ("Extraneous argument to `%s' option",
953 /* Store the translation as one argv elt or as two. */
954 if (arg != 0 && index (arginfo, 'j') != 0)
955 newv[newindex++] = concat (option_map[j].equivalent, arg,
959 newv[newindex++] = option_map[j].equivalent;
960 newv[newindex++] = arg;
963 newv[newindex++] = option_map[j].equivalent;
971 /* Handle old-fashioned options--just copy them through,
972 with their arguments. */
973 else if (argv[i][0] == '-')
975 char *p = argv[i] + 1;
979 if (SWITCH_TAKES_ARG (c) > (p[1] != 0))
980 nskip += SWITCH_TAKES_ARG (c) - (p[1] != 0);
981 else if (WORD_SWITCH_TAKES_ARG (p))
982 nskip += WORD_SWITCH_TAKES_ARG (p);
983 else if ((c == 'B' || c == 'b' || c == 'V' || c == 'x')
986 else if (! strcmp (p, "Xlinker"))
989 /* Watch out for an option at the end of the command line that
990 is missing arguments, and avoid skipping past the end of the
992 if (nskip + i > argc)
997 newv[newindex++] = argv[i++];
1002 /* Ordinary operands, or +e options. */
1003 newv[newindex++] = argv[i++];
1016 #ifdef HAVE_STRERROR
1022 static char buffer[30];
1024 return "cannot access";
1026 if (e > 0 && e < sys_nerr)
1027 return sys_errlist[e];
1029 sprintf (buffer, "Unknown error %d", e);
1040 /* A fully-blank line is a delimiter in the SPEC file and shouldn't
1041 be considered whitespace. */
1042 if (p[0] == '\n' && p[1] == '\n' && p[2] == '\n')
1044 else if (*p == '\n' || *p == ' ' || *p == '\t')
1048 while (*p != '\n') p++;
1058 /* Structure to keep track of the specs that have been defined so far.
1059 These are accessed using %(specname) or %[specname] in a compiler
1064 /* The following 2 fields must be first */
1065 /* to allow EXTRA_SPECS to be initialized */
1066 char *name; /* name of the spec. */
1067 char *ptr; /* available ptr if no static pointer */
1069 /* The following fields are not initialized */
1070 /* by EXTRA_SPECS */
1071 char **ptr_spec; /* pointer to the spec itself. */
1072 struct spec_list *next; /* Next spec in linked list. */
1073 int name_len; /* length of the name */
1074 int alloc_p; /* whether string was allocated */
1077 #define INIT_STATIC_SPEC(NAME,PTR) \
1078 { NAME, NULL_PTR, PTR, (struct spec_list *)0, sizeof (NAME)-1, 0 }
1080 /* List of statically defined specs */
1081 static struct spec_list static_specs[] = {
1082 INIT_STATIC_SPEC ("asm", &asm_spec),
1083 INIT_STATIC_SPEC ("asm_final", &asm_final_spec),
1084 INIT_STATIC_SPEC ("cpp", &cpp_spec),
1085 INIT_STATIC_SPEC ("cc1", &cc1_spec),
1086 INIT_STATIC_SPEC ("cc1plus", &cc1plus_spec),
1087 INIT_STATIC_SPEC ("endfile", &endfile_spec),
1088 INIT_STATIC_SPEC ("link", &link_spec),
1089 INIT_STATIC_SPEC ("lib", &lib_spec),
1090 INIT_STATIC_SPEC ("libgcc", &libgcc_spec),
1091 INIT_STATIC_SPEC ("startfile", &startfile_spec),
1092 INIT_STATIC_SPEC ("switches_need_spaces", &switches_need_spaces),
1093 INIT_STATIC_SPEC ("signed_char", &signed_char_spec),
1094 INIT_STATIC_SPEC ("predefines", &cpp_predefines),
1095 INIT_STATIC_SPEC ("cross_compile", &cross_compile),
1096 INIT_STATIC_SPEC ("version", &compiler_version),
1097 INIT_STATIC_SPEC ("multilib", &multilib_select),
1098 INIT_STATIC_SPEC ("multilib_defaults", &multilib_defaults),
1099 INIT_STATIC_SPEC ("multilib_extra", &multilib_extra),
1100 INIT_STATIC_SPEC ("multilib_matches", &multilib_matches),
1101 INIT_STATIC_SPEC ("linker", &linker_name_spec),
1104 #ifdef EXTRA_SPECS /* additional specs needed */
1105 static struct spec_list extra_specs[] = { EXTRA_SPECS };
1108 /* List of dynamically allocates specs that have been defined so far. */
1110 static struct spec_list *specs = (struct spec_list *)0;
1113 /* Initialize the specs lookup routines. */
1118 struct spec_list *next = (struct spec_list *)0;
1119 struct spec_list *sl = (struct spec_list *)0;
1123 return; /* already initialized */
1126 fprintf (stderr, "Using builtin specs.\n");
1129 for (i = (sizeof (extra_specs) / sizeof (extra_specs[0])) - 1; i >= 0; i--)
1131 sl = &extra_specs[i];
1133 sl->name_len = strlen (sl->name);
1134 sl->ptr_spec = &sl->ptr;
1139 for (i = (sizeof (static_specs) / sizeof (static_specs[0])) - 1; i >= 0; i--)
1141 sl = &static_specs[i];
1150 /* Change the value of spec NAME to SPEC. If SPEC is empty, then the spec is
1151 removed; If the spec starts with a + then SPEC is added to the end of the
1155 set_spec (name, spec)
1159 struct spec_list *sl;
1161 int name_len = strlen (name);
1164 /* If this is the first call, initialize the statically allocated specs */
1167 struct spec_list *next = (struct spec_list *)0;
1168 for (i = (sizeof (static_specs) / sizeof (static_specs[0])) - 1;
1171 sl = &static_specs[i];
1178 /* See if the spec already exists */
1179 for (sl = specs; sl; sl = sl->next)
1180 if (name_len == sl->name_len && !strcmp (sl->name, name))
1185 /* Not found - make it */
1186 sl = (struct spec_list *) xmalloc (sizeof (struct spec_list));
1187 sl->name = save_string (name, strlen (name));
1188 sl->name_len = name_len;
1189 sl->ptr_spec = &sl->ptr;
1191 *(sl->ptr_spec) = "";
1196 old_spec = *(sl->ptr_spec);
1197 *(sl->ptr_spec) = ((spec[0] == '+' && ISSPACE (spec[1]))
1198 ? concat (old_spec, spec + 1, NULL_PTR)
1199 : save_string (spec, strlen (spec)));
1203 fprintf (stderr, "Setting spec %s to '%s'\n\n", name, *(sl->ptr_spec));
1206 /* Free the old spec */
1207 if (old_spec && sl->alloc_p)
1213 /* Accumulate a command (program name and args), and run it. */
1215 /* Vector of pointers to arguments in the current line of specifications. */
1217 static char **argbuf;
1219 /* Number of elements allocated in argbuf. */
1221 static int argbuf_length;
1223 /* Number of elements in argbuf currently in use (containing args). */
1225 static int argbuf_index;
1227 #ifdef MKTEMP_EACH_FILE
1228 /* This is the list of suffixes and codes (%g/%u/%U) and the associated
1231 static struct temp_name {
1232 char *suffix; /* suffix associated with the code. */
1233 int length; /* strlen (suffix). */
1234 int unique; /* Indicates whether %g or %u/%U was used. */
1235 char *filename; /* associated filename. */
1236 int filename_length; /* strlen (filename). */
1237 struct temp_name *next;
1241 /* Number of commands executed so far. */
1243 static int execution_count;
1245 /* Number of commands that exited with a signal. */
1247 static int signal_count;
1249 /* Name with which this program was invoked. */
1251 static char *programname;
1253 /* Structures to keep track of prefixes to try when looking for files. */
1257 char *prefix; /* String to prepend to the path. */
1258 struct prefix_list *next; /* Next in linked list. */
1259 int require_machine_suffix; /* Don't use without machine_suffix. */
1260 /* 2 means try both machine_suffix and just_machine_suffix. */
1261 int *used_flag_ptr; /* 1 if a file was found with this prefix. */
1266 struct prefix_list *plist; /* List of prefixes to try */
1267 int max_len; /* Max length of a prefix in PLIST */
1268 char *name; /* Name of this list (used in config stuff) */
1271 /* List of prefixes to try when looking for executables. */
1273 static struct path_prefix exec_prefixes = { 0, 0, "exec" };
1275 /* List of prefixes to try when looking for startup (crt0) files. */
1277 static struct path_prefix startfile_prefixes = { 0, 0, "startfile" };
1279 /* List of prefixes to try when looking for include files. */
1281 static struct path_prefix include_prefixes = { 0, 0, "include" };
1283 /* Suffix to attach to directories searched for commands.
1284 This looks like `MACHINE/VERSION/'. */
1286 static char *machine_suffix = 0;
1288 /* Suffix to attach to directories searched for commands.
1289 This is just `MACHINE/'. */
1291 static char *just_machine_suffix = 0;
1293 /* Adjusted value of GCC_EXEC_PREFIX envvar. */
1295 static char *gcc_exec_prefix;
1297 /* Default prefixes to attach to command names. */
1299 #ifdef CROSS_COMPILE /* Don't use these prefixes for a cross compiler. */
1300 #undef MD_EXEC_PREFIX
1301 #undef MD_STARTFILE_PREFIX
1302 #undef MD_STARTFILE_PREFIX_1
1305 #ifndef STANDARD_EXEC_PREFIX
1306 #define STANDARD_EXEC_PREFIX "/usr/local/lib/gcc-lib/"
1307 #endif /* !defined STANDARD_EXEC_PREFIX */
1309 static char *standard_exec_prefix = STANDARD_EXEC_PREFIX;
1310 static char *standard_exec_prefix_1 = "/usr/lib/gcc/";
1311 #ifdef MD_EXEC_PREFIX
1312 static char *md_exec_prefix = MD_EXEC_PREFIX;
1315 #ifndef STANDARD_STARTFILE_PREFIX
1316 #define STANDARD_STARTFILE_PREFIX "/usr/local/lib/"
1317 #endif /* !defined STANDARD_STARTFILE_PREFIX */
1319 #ifdef MD_STARTFILE_PREFIX
1320 static char *md_startfile_prefix = MD_STARTFILE_PREFIX;
1322 #ifdef MD_STARTFILE_PREFIX_1
1323 static char *md_startfile_prefix_1 = MD_STARTFILE_PREFIX_1;
1325 static char *standard_startfile_prefix = STANDARD_STARTFILE_PREFIX;
1326 static char *standard_startfile_prefix_1 = "/lib/";
1327 static char *standard_startfile_prefix_2 = "/usr/lib/";
1329 #ifndef TOOLDIR_BASE_PREFIX
1330 #define TOOLDIR_BASE_PREFIX "/usr/local/"
1332 static char *tooldir_base_prefix = TOOLDIR_BASE_PREFIX;
1333 static char *tooldir_prefix;
1335 /* Subdirectory to use for locating libraries. Set by
1336 set_multilib_dir based on the compilation options. */
1338 static char *multilib_dir;
1340 /* Clear out the vector of arguments (after a command is executed). */
1348 /* Add one argument to the vector at the end.
1349 This is done when a space is seen or at the end of the line.
1350 If DELETE_ALWAYS is nonzero, the arg is a filename
1351 and the file should be deleted eventually.
1352 If DELETE_FAILURE is nonzero, the arg is a filename
1353 and the file should be deleted if this compilation fails. */
1356 store_arg (arg, delete_always, delete_failure)
1358 int delete_always, delete_failure;
1360 if (argbuf_index + 1 == argbuf_length)
1362 = (char **) xrealloc (argbuf, (argbuf_length *= 2) * sizeof (char *));
1364 argbuf[argbuf_index++] = arg;
1365 argbuf[argbuf_index] = 0;
1367 if (delete_always || delete_failure)
1368 record_temp_file (arg, delete_always, delete_failure);
1371 /* Read compilation specs from a file named FILENAME,
1372 replacing the default ones.
1374 A suffix which starts with `*' is a definition for
1375 one of the machine-specific sub-specs. The "suffix" should be
1376 *asm, *cc1, *cpp, *link, *startfile, *signed_char, etc.
1377 The corresponding spec is stored in asm_spec, etc.,
1378 rather than in the `compilers' vector.
1380 Anything invalid in the file is a fatal error. */
1383 read_specs (filename, main_p)
1389 struct stat statbuf;
1394 fprintf (stderr, "Reading specs from %s\n", filename);
1396 /* Open and stat the file. */
1397 desc = open (filename, O_RDONLY, 0);
1399 pfatal_with_name (filename);
1400 if (stat (filename, &statbuf) < 0)
1401 pfatal_with_name (filename);
1403 /* Read contents of file into BUFFER. */
1404 buffer = xmalloc ((unsigned) statbuf.st_size + 1);
1405 readlen = read (desc, buffer, (unsigned) statbuf.st_size);
1407 pfatal_with_name (filename);
1408 buffer[readlen] = 0;
1411 /* Scan BUFFER for specs, putting them in the vector. */
1417 char *in, *out, *p1, *p2, *p3;
1419 /* Advance P in BUFFER to the next nonblank nocomment line. */
1420 p = skip_whitespace (p);
1424 /* Is this a special command that starts with '%'? */
1425 /* Don't allow this for the main specs file, since it would
1426 encourage people to overwrite it. */
1427 if (*p == '%' && !main_p)
1430 while (*p && *p != '\n')
1433 p++; /* Skip '\n' */
1435 if (!strncmp (p1, "%include", sizeof ("%include")-1)
1436 && (p1[sizeof "%include" - 1] == ' '
1437 || p1[sizeof "%include" - 1] == '\t'))
1441 p1 += sizeof ("%include");
1442 while (*p1 == ' ' || *p1 == '\t')
1445 if (*p1++ != '<' || p[-2] != '>')
1446 fatal ("specs %%include syntax malformed after %d characters",
1450 new_filename = find_a_file (&startfile_prefixes, p1, R_OK);
1451 read_specs (new_filename ? new_filename : p1, FALSE);
1454 else if (!strncmp (p1, "%include_noerr", sizeof "%include_noerr" - 1)
1455 && (p1[sizeof "%include_noerr" - 1] == ' '
1456 || p1[sizeof "%include_noerr" - 1] == '\t'))
1460 p1 += sizeof "%include_noerr";
1461 while (*p1 == ' ' || *p1 == '\t') p1++;
1463 if (*p1++ != '<' || p[-2] != '>')
1464 fatal ("specs %%include syntax malformed after %d characters",
1468 new_filename = find_a_file (&startfile_prefixes, p1, R_OK);
1470 read_specs (new_filename, FALSE);
1471 else if (verbose_flag)
1472 fprintf (stderr, "Could not find specs file %s\n", p1);
1475 else if (!strncmp (p1, "%rename", sizeof "%rename" - 1)
1476 && (p1[sizeof "%rename" - 1] == ' '
1477 || p1[sizeof "%rename" - 1] == '\t'))
1480 struct spec_list *sl;
1482 /* Get original name */
1483 p1 += sizeof "%rename";
1484 while (*p1 == ' ' || *p1 == '\t')
1487 if (! ISALPHA (*p1))
1488 fatal ("specs %%rename syntax malformed after %d characters",
1492 while (*p2 && !ISSPACE (*p2))
1495 if (*p2 != ' ' && *p2 != '\t')
1496 fatal ("specs %%rename syntax malformed after %d characters",
1501 while (*p2 == ' ' || *p2 == '\t')
1504 if (! ISALPHA (*p2))
1505 fatal ("specs %%rename syntax malformed after %d characters",
1508 /* Get new spec name */
1510 while (*p3 && !ISSPACE (*p3))
1514 fatal ("specs %%rename syntax malformed after %d characters",
1518 for (sl = specs; sl; sl = sl->next)
1519 if (name_len == sl->name_len && !strcmp (sl->name, p1))
1523 fatal ("specs %s spec was not found to be renamed", p1);
1525 if (strcmp (p1, p2) == 0)
1530 fprintf (stderr, "rename spec %s to %s\n", p1, p2);
1532 fprintf (stderr, "spec is '%s'\n\n", *(sl->ptr_spec));
1536 set_spec (p2, *(sl->ptr_spec));
1538 free (*(sl->ptr_spec));
1540 *(sl->ptr_spec) = "";
1545 fatal ("specs unknown %% command after %d characters",
1549 /* Find the colon that should end the suffix. */
1551 while (*p1 && *p1 != ':' && *p1 != '\n')
1554 /* The colon shouldn't be missing. */
1556 fatal ("specs file malformed after %d characters", p1 - buffer);
1558 /* Skip back over trailing whitespace. */
1560 while (p2 > buffer && (p2[-1] == ' ' || p2[-1] == '\t'))
1563 /* Copy the suffix to a string. */
1564 suffix = save_string (p, p2 - p);
1565 /* Find the next line. */
1566 p = skip_whitespace (p1 + 1);
1568 fatal ("specs file malformed after %d characters", p - buffer);
1571 /* Find next blank line. */
1572 while (*p1 && !(*p1 == '\n' && p1[1] == '\n'))
1575 /* Specs end at the blank line and do not include the newline. */
1576 spec = save_string (p, p1 - p);
1579 /* Delete backslash-newline sequences from the spec. */
1584 if (in[0] == '\\' && in[1] == '\n')
1586 else if (in[0] == '#')
1587 while (*in && *in != '\n')
1595 if (suffix[0] == '*')
1597 if (! strcmp (suffix, "*link_command"))
1598 link_command_spec = spec;
1600 set_spec (suffix + 1, spec);
1604 /* Add this pair to the vector. */
1606 = ((struct compiler *)
1607 xrealloc (compilers,
1608 (n_compilers + 2) * sizeof (struct compiler)));
1610 compilers[n_compilers].suffix = suffix;
1611 bzero ((char *) compilers[n_compilers].spec,
1612 sizeof compilers[n_compilers].spec);
1613 compilers[n_compilers].spec[0] = spec;
1615 bzero ((char *) &compilers[n_compilers],
1616 sizeof compilers[n_compilers]);
1620 link_command_spec = spec;
1623 if (link_command_spec == 0)
1624 fatal ("spec file has no spec for linking");
1627 /* Record the names of temporary files we tell compilers to write,
1628 and delete them at the end of the run. */
1630 /* This is the common prefix we use to make temp file names.
1631 It is chosen once for each run of this program.
1632 It is substituted into a spec by %g.
1633 Thus, all temp file names contain this prefix.
1634 In practice, all temp file names start with this prefix.
1636 This prefix comes from the envvar TMPDIR if it is defined;
1637 otherwise, from the P_tmpdir macro if that is defined;
1638 otherwise, in /usr/tmp or /tmp;
1639 or finally the current directory if all else fails. */
1641 static char *temp_filename;
1643 /* Length of the prefix. */
1645 static int temp_filename_length;
1647 /* Define the list of temporary files to delete. */
1652 struct temp_file *next;
1655 /* Queue of files to delete on success or failure of compilation. */
1656 static struct temp_file *always_delete_queue;
1657 /* Queue of files to delete on failure of compilation. */
1658 static struct temp_file *failure_delete_queue;
1660 /* Record FILENAME as a file to be deleted automatically.
1661 ALWAYS_DELETE nonzero means delete it if all compilation succeeds;
1662 otherwise delete it in any case.
1663 FAIL_DELETE nonzero means delete it if a compilation step fails;
1664 otherwise delete it in any case. */
1667 record_temp_file (filename, always_delete, fail_delete)
1672 register char *name;
1673 name = xmalloc (strlen (filename) + 1);
1674 strcpy (name, filename);
1678 register struct temp_file *temp;
1679 for (temp = always_delete_queue; temp; temp = temp->next)
1680 if (! strcmp (name, temp->name))
1683 temp = (struct temp_file *) xmalloc (sizeof (struct temp_file));
1684 temp->next = always_delete_queue;
1686 always_delete_queue = temp;
1693 register struct temp_file *temp;
1694 for (temp = failure_delete_queue; temp; temp = temp->next)
1695 if (! strcmp (name, temp->name))
1698 temp = (struct temp_file *) xmalloc (sizeof (struct temp_file));
1699 temp->next = failure_delete_queue;
1701 failure_delete_queue = temp;
1707 /* Delete all the temporary files whose names we previously recorded. */
1710 delete_if_ordinary (name)
1717 printf ("Delete %s? (y or n) ", name);
1721 while ((c = getchar ()) != '\n' && c != EOF)
1724 if (i == 'y' || i == 'Y')
1726 if (stat (name, &st) >= 0 && S_ISREG (st.st_mode))
1727 if (unlink (name) < 0)
1729 perror_with_name (name);
1733 delete_temp_files ()
1735 register struct temp_file *temp;
1737 for (temp = always_delete_queue; temp; temp = temp->next)
1738 delete_if_ordinary (temp->name);
1739 always_delete_queue = 0;
1742 /* Delete all the files to be deleted on error. */
1745 delete_failure_queue ()
1747 register struct temp_file *temp;
1749 for (temp = failure_delete_queue; temp; temp = temp->next)
1750 delete_if_ordinary (temp->name);
1754 clear_failure_queue ()
1756 failure_delete_queue = 0;
1759 /* Routine to add variables to the environment. We do this to pass
1760 the pathname of the gcc driver, and the directories search to the
1761 collect2 program, which is being run as ld. This way, we can be
1762 sure of executing the right compiler when collect2 wants to build
1763 constructors and destructors. Since the environment variables we
1764 use come from an obstack, we don't have to worry about allocating
1773 #ifndef VMS /* nor about VMS */
1775 extern char **environ;
1776 char **old_environ = environ;
1780 int str_len = strlen (str);
1784 while ((ch = *p++) != '\0' && ch != '=')
1790 /* Search for replacing an existing environment variable, and
1791 count the number of total environment variables. */
1792 for (envp = old_environ; *envp; envp++)
1795 if (!strncmp (str, *envp, name_len))
1802 /* Add a new environment variable */
1803 environ = (char **) xmalloc (sizeof (char *) * (num_envs+2));
1805 bcopy ((char *) old_environ, (char *) (environ + 1),
1806 sizeof (char *) * (num_envs+1));
1811 #endif /* HAVE_PUTENV */
1814 /* Build a list of search directories from PATHS.
1815 PREFIX is a string to prepend to the list.
1816 If CHECK_DIR_P is non-zero we ensure the directory exists.
1817 This is used mostly by putenv_from_prefixes so we use `collect_obstack'.
1818 It is also used by the --print-search-dirs flag. */
1821 build_search_list (paths, prefix, check_dir_p)
1822 struct path_prefix *paths;
1826 int suffix_len = (machine_suffix) ? strlen (machine_suffix) : 0;
1828 = (just_machine_suffix) ? strlen (just_machine_suffix) : 0;
1829 int first_time = TRUE;
1830 struct prefix_list *pprefix;
1832 obstack_grow (&collect_obstack, prefix, strlen (prefix));
1834 for (pprefix = paths->plist; pprefix != 0; pprefix = pprefix->next)
1836 int len = strlen (pprefix->prefix);
1840 || is_directory (pprefix->prefix, machine_suffix, 0)))
1843 obstack_1grow (&collect_obstack, PATH_SEPARATOR);
1846 obstack_grow (&collect_obstack, pprefix->prefix, len);
1847 obstack_grow (&collect_obstack, machine_suffix, suffix_len);
1850 if (just_machine_suffix
1851 && pprefix->require_machine_suffix == 2
1853 || is_directory (pprefix->prefix, just_machine_suffix, 0)))
1856 obstack_1grow (&collect_obstack, PATH_SEPARATOR);
1859 obstack_grow (&collect_obstack, pprefix->prefix, len);
1860 obstack_grow (&collect_obstack, just_machine_suffix,
1864 if (! pprefix->require_machine_suffix)
1867 obstack_1grow (&collect_obstack, PATH_SEPARATOR);
1870 obstack_grow (&collect_obstack, pprefix->prefix, len);
1874 obstack_1grow (&collect_obstack, '\0');
1875 return obstack_finish (&collect_obstack);
1878 /* Rebuild the COMPILER_PATH and LIBRARY_PATH environment variables
1882 putenv_from_prefixes (paths, env_var)
1883 struct path_prefix *paths;
1886 putenv (build_search_list (paths, env_var, 1));
1889 /* Search for NAME using the prefix list PREFIXES. MODE is passed to
1890 access to check permissions.
1891 Return 0 if not found, otherwise return its name, allocated with malloc. */
1894 find_a_file (pprefix, name, mode)
1895 struct path_prefix *pprefix;
1900 char *file_suffix = ((mode & X_OK) != 0 ? EXECUTABLE_SUFFIX : "");
1901 struct prefix_list *pl;
1902 int len = pprefix->max_len + strlen (name) + strlen (file_suffix) + 1;
1905 len += strlen (machine_suffix);
1907 temp = xmalloc (len);
1909 /* Determine the filename to execute (special case for absolute paths). */
1911 if (*name == '/' || *name == DIR_SEPARATOR
1912 /* Check for disk name on MS-DOS-based systems. */
1913 || (DIR_SEPARATOR == '\\' && name[1] == ':'
1914 && (name[2] == DIR_SEPARATOR || name[2] == '/')))
1916 if (access (name, mode))
1918 strcpy (temp, name);
1923 for (pl = pprefix->plist; pl; pl = pl->next)
1927 /* Some systems have a suffix for executable files.
1928 So try appending that first. */
1929 if (file_suffix[0] != 0)
1931 strcpy (temp, pl->prefix);
1932 strcat (temp, machine_suffix);
1933 strcat (temp, name);
1934 strcat (temp, file_suffix);
1935 if (access (temp, mode) == 0)
1937 if (pl->used_flag_ptr != 0)
1938 *pl->used_flag_ptr = 1;
1943 /* Now try just the name. */
1944 strcpy (temp, pl->prefix);
1945 strcat (temp, machine_suffix);
1946 strcat (temp, name);
1947 if (access (temp, mode) == 0)
1949 if (pl->used_flag_ptr != 0)
1950 *pl->used_flag_ptr = 1;
1955 /* Certain prefixes are tried with just the machine type,
1956 not the version. This is used for finding as, ld, etc. */
1957 if (just_machine_suffix && pl->require_machine_suffix == 2)
1959 /* Some systems have a suffix for executable files.
1960 So try appending that first. */
1961 if (file_suffix[0] != 0)
1963 strcpy (temp, pl->prefix);
1964 strcat (temp, just_machine_suffix);
1965 strcat (temp, name);
1966 strcat (temp, file_suffix);
1967 if (access (temp, mode) == 0)
1969 if (pl->used_flag_ptr != 0)
1970 *pl->used_flag_ptr = 1;
1975 strcpy (temp, pl->prefix);
1976 strcat (temp, just_machine_suffix);
1977 strcat (temp, name);
1978 if (access (temp, mode) == 0)
1980 if (pl->used_flag_ptr != 0)
1981 *pl->used_flag_ptr = 1;
1986 /* Certain prefixes can't be used without the machine suffix
1987 when the machine or version is explicitly specified. */
1988 if (! pl->require_machine_suffix)
1990 /* Some systems have a suffix for executable files.
1991 So try appending that first. */
1992 if (file_suffix[0] != 0)
1994 strcpy (temp, pl->prefix);
1995 strcat (temp, name);
1996 strcat (temp, file_suffix);
1997 if (access (temp, mode) == 0)
1999 if (pl->used_flag_ptr != 0)
2000 *pl->used_flag_ptr = 1;
2005 strcpy (temp, pl->prefix);
2006 strcat (temp, name);
2007 if (access (temp, mode) == 0)
2009 if (pl->used_flag_ptr != 0)
2010 *pl->used_flag_ptr = 1;
2020 /* Add an entry for PREFIX in PLIST. If FIRST is set, it goes
2021 at the start of the list, otherwise it goes at the end.
2023 If WARN is nonzero, we will warn if no file is found
2024 through this prefix. WARN should point to an int
2025 which will be set to 1 if this entry is used.
2027 COMPONENT is the value to be passed to update_path.
2029 REQUIRE_MACHINE_SUFFIX is 1 if this prefix can't be used without
2030 the complete value of machine_suffix.
2031 2 means try both machine_suffix and just_machine_suffix. */
2034 add_prefix (pprefix, prefix, component, first, require_machine_suffix, warn)
2035 struct path_prefix *pprefix;
2039 int require_machine_suffix;
2042 struct prefix_list *pl, **prev;
2045 if (! first && pprefix->plist)
2047 for (pl = pprefix->plist; pl->next; pl = pl->next)
2052 prev = &pprefix->plist;
2054 /* Keep track of the longest prefix */
2056 prefix = update_path (prefix, component);
2057 len = strlen (prefix);
2058 if (len > pprefix->max_len)
2059 pprefix->max_len = len;
2061 pl = (struct prefix_list *) xmalloc (sizeof (struct prefix_list));
2062 pl->prefix = save_string (prefix, len);
2063 pl->require_machine_suffix = require_machine_suffix;
2064 pl->used_flag_ptr = warn;
2071 pl->next = (struct prefix_list *) 0;
2075 /* Print warnings for any prefixes in the list PPREFIX that were not used. */
2078 unused_prefix_warnings (pprefix)
2079 struct path_prefix *pprefix;
2081 struct prefix_list *pl = pprefix->plist;
2085 if (pl->used_flag_ptr != 0 && !*pl->used_flag_ptr)
2087 if (pl->require_machine_suffix && machine_suffix)
2088 error ("file path prefix `%s%s' never used", pl->prefix,
2091 error ("file path prefix `%s' never used", pl->prefix);
2093 /* Prevent duplicate warnings. */
2094 *pl->used_flag_ptr = 1;
2102 /* Execute the command specified by the arguments on the current line of spec.
2103 When using pipes, this includes several piped-together commands
2104 with `|' between them.
2106 Return 0 if successful, -1 if failed. */
2112 int n_commands; /* # of command. */
2116 char *prog; /* program name. */
2117 char **argv; /* vector of args. */
2118 int pid; /* pid of process for this command. */
2121 struct command *commands; /* each command buffer with above info. */
2123 /* Count # of piped commands. */
2124 for (n_commands = 1, i = 0; i < argbuf_index; i++)
2125 if (strcmp (argbuf[i], "|") == 0)
2128 /* Get storage for each command. */
2130 = (struct command *) alloca (n_commands * sizeof (struct command));
2132 /* Split argbuf into its separate piped processes,
2133 and record info about each one.
2134 Also search for the programs that are to be run. */
2136 commands[0].prog = argbuf[0]; /* first command. */
2137 commands[0].argv = &argbuf[0];
2138 string = find_a_file (&exec_prefixes, commands[0].prog, X_OK);
2141 commands[0].argv[0] = string;
2143 for (n_commands = 1, i = 0; i < argbuf_index; i++)
2144 if (strcmp (argbuf[i], "|") == 0)
2145 { /* each command. */
2146 #if defined (__MSDOS__) || (defined (_WIN32) && defined (__CYGWIN32_)) || defined (OS2) || defined (VMS)
2147 fatal ("-pipe not supported");
2149 argbuf[i] = 0; /* termination of command args. */
2150 commands[n_commands].prog = argbuf[i + 1];
2151 commands[n_commands].argv = &argbuf[i + 1];
2152 string = find_a_file (&exec_prefixes, commands[n_commands].prog, X_OK);
2154 commands[n_commands].argv[0] = string;
2158 argbuf[argbuf_index] = 0;
2160 /* If -v, print what we are about to do, and maybe query. */
2164 /* Print each piped command as a separate line. */
2165 for (i = 0; i < n_commands ; i++)
2169 for (j = commands[i].argv; *j; j++)
2170 fprintf (stderr, " %s", *j);
2172 /* Print a pipe symbol after all but the last command. */
2173 if (i + 1 != n_commands)
2174 fprintf (stderr, " |");
2175 fprintf (stderr, "\n");
2179 fprintf (stderr, "\nGo ahead? (y or n) ");
2183 while (getchar () != '\n')
2186 if (i != 'y' && i != 'Y')
2191 /* Run each piped subprocess. */
2193 for (i = 0; i < n_commands; i++)
2195 char *errmsg_fmt, *errmsg_arg;
2196 char *string = commands[i].argv[0];
2198 commands[i].pid = pexecute (string, commands[i].argv,
2199 programname, temp_filename,
2200 &errmsg_fmt, &errmsg_arg,
2201 ((i == 0 ? PEXECUTE_FIRST : 0)
2202 | (i + 1 == n_commands ? PEXECUTE_LAST : 0)
2203 | (string == commands[i].prog
2204 ? PEXECUTE_SEARCH : 0)
2205 | (verbose_flag ? PEXECUTE_VERBOSE : 0)));
2207 if (commands[i].pid == -1)
2208 pfatal_pexecute (errmsg_fmt, errmsg_arg);
2210 if (string != commands[i].prog)
2216 /* Wait for all the subprocesses to finish.
2217 We don't care what order they finish in;
2218 we know that N_COMMANDS waits will get them all.
2219 Ignore subprocesses that we don't know about,
2220 since they can be spawned by the process that exec'ed us. */
2225 for (i = 0; i < n_commands; )
2231 pid = pwait (commands[i].pid, &status, 0);
2235 for (j = 0; j < n_commands; j++)
2236 if (commands[j].pid == pid)
2241 if (WIFSIGNALED (status))
2243 fatal ("Internal compiler error: program %s got fatal signal %d",
2244 commands[j].prog, WTERMSIG (status));
2248 else if (WIFEXITED (status)
2249 && WEXITSTATUS (status) >= MIN_FATAL_STATUS)
2259 /* Find all the switches given to us
2260 and make a vector describing them.
2261 The elements of the vector are strings, one per switch given.
2262 If a switch uses following arguments, then the `part1' field
2263 is the switch itself and the `args' field
2264 is a null-terminated vector containing the following arguments.
2265 The `live_cond' field is 1 if the switch is true in a conditional spec,
2266 -1 if false (overridden by a later switch), and is initialized to zero.
2267 The `valid' field is nonzero if any spec has looked at this switch;
2268 if it remains zero at the end of the run, it must be meaningless. */
2278 static struct switchstr *switches;
2280 static int n_switches;
2288 /* Also a vector of input files specified. */
2290 static struct infile *infiles;
2292 static int n_infiles;
2294 /* And a vector of corresponding output files is made up later. */
2296 static char **outfiles;
2298 /* Used to track if none of the -B paths are used. */
2301 /* Used to track if standard path isn't used and -b or -V is specified. */
2302 static int warn_std;
2304 /* Gives value to pass as "warn" to add_prefix for standard prefixes. */
2305 static int *warn_std_ptr = 0;
2308 #if defined(HAVE_OBJECT_SUFFIX) || defined(HAVE_EXECUTABLE_SUFFIX)
2310 /* Convert NAME to a new name if it is the standard suffix. DO_EXE
2311 is true if we should look for an executable suffix as well. */
2314 convert_filename (name, do_exe)
2319 int len = strlen (name);
2321 #ifdef HAVE_OBJECT_SUFFIX
2322 /* Convert x.o to x.obj if OBJECT_SUFFIX is ".obj". */
2324 && name[len - 2] == '.'
2325 && name[len - 1] == 'o')
2327 obstack_grow (&obstack, name, len - 2);
2328 obstack_grow0 (&obstack, OBJECT_SUFFIX, strlen (OBJECT_SUFFIX));
2329 name = obstack_finish (&obstack);
2333 #ifdef HAVE_EXECUTABLE_SUFFIX
2334 /* If there is no filetype, make it the executable suffix (which includes
2335 the "."). But don't get confused if we have just "-o". */
2336 if (! do_exe || EXECUTABLE_SUFFIX[0] == 0 || (len == 2 && name[0] == '-'))
2339 for (i = len - 1; i >= 0; i--)
2340 if (name[i] == '/' || name[i] == DIR_SEPARATOR)
2343 for (i++; i < len; i++)
2347 obstack_grow (&obstack, name, len);
2348 obstack_grow0 (&obstack, EXECUTABLE_SUFFIX, strlen (EXECUTABLE_SUFFIX));
2349 name = obstack_finish (&obstack);
2356 /* Create the vector `switches' and its contents.
2357 Store its length in `n_switches'. */
2360 process_command (argc, argv)
2366 char *spec_lang = 0;
2367 int last_language_n_infiles;
2370 int lang_n_infiles = 0;
2372 GET_ENVIRONMENT (gcc_exec_prefix, "GCC_EXEC_PREFIX");
2377 /* Figure compiler version from version string. */
2379 compiler_version = save_string (version_string, strlen (version_string));
2380 for (temp = compiler_version; *temp; ++temp)
2389 /* Set up the default search paths. */
2391 if (gcc_exec_prefix)
2393 int len = strlen (gcc_exec_prefix);
2394 if (len > sizeof ("/lib/gcc-lib/")-1
2395 && (gcc_exec_prefix[len-1] == '/'
2396 || gcc_exec_prefix[len-1] == DIR_SEPARATOR))
2398 temp = gcc_exec_prefix + len - sizeof ("/lib/gcc-lib/") + 1;
2399 if ((*temp == '/' || *temp == DIR_SEPARATOR)
2400 && strncmp (temp+1, "lib", 3) == 0
2401 && (temp[4] == '/' || temp[4] == DIR_SEPARATOR)
2402 && strncmp (temp+5, "gcc-lib", 7) == 0)
2403 len -= sizeof ("/lib/gcc-lib/") - 1;
2406 set_std_prefix (gcc_exec_prefix, len);
2407 add_prefix (&exec_prefixes, gcc_exec_prefix, "GCC", 0, 0, NULL_PTR);
2408 add_prefix (&startfile_prefixes, gcc_exec_prefix, "GCC", 0, 0, NULL_PTR);
2411 /* COMPILER_PATH and LIBRARY_PATH have values
2412 that are lists of directory names with colons. */
2414 GET_ENVIRONMENT (temp, "COMPILER_PATH");
2417 char *startp, *endp;
2418 char *nstore = (char *) alloca (strlen (temp) + 3);
2420 startp = endp = temp;
2423 if (*endp == PATH_SEPARATOR || *endp == 0)
2425 strncpy (nstore, startp, endp-startp);
2427 strcpy (nstore, concat (".", dir_separator_str, NULL_PTR));
2428 else if (endp[-1] != '/' && endp[-1] != DIR_SEPARATOR)
2430 nstore[endp-startp] = DIR_SEPARATOR;
2431 nstore[endp-startp+1] = 0;
2434 nstore[endp-startp] = 0;
2435 add_prefix (&exec_prefixes, nstore, 0, 0, 0, NULL_PTR);
2436 add_prefix (&include_prefixes,
2437 concat (nstore, "include", NULL_PTR),
2441 endp = startp = endp + 1;
2448 GET_ENVIRONMENT (temp, "LIBRARY_PATH");
2449 if (temp && *cross_compile == '0')
2451 char *startp, *endp;
2452 char *nstore = (char *) alloca (strlen (temp) + 3);
2454 startp = endp = temp;
2457 if (*endp == PATH_SEPARATOR || *endp == 0)
2459 strncpy (nstore, startp, endp-startp);
2461 strcpy (nstore, concat (".", dir_separator_str, NULL_PTR));
2462 else if (endp[-1] != '/' && endp[-1] != DIR_SEPARATOR)
2464 nstore[endp-startp] = DIR_SEPARATOR;
2465 nstore[endp-startp+1] = 0;
2468 nstore[endp-startp] = 0;
2469 add_prefix (&startfile_prefixes, nstore, NULL_PTR,
2473 endp = startp = endp + 1;
2480 /* Use LPATH like LIBRARY_PATH (for the CMU build program). */
2481 GET_ENVIRONMENT (temp, "LPATH");
2482 if (temp && *cross_compile == '0')
2484 char *startp, *endp;
2485 char *nstore = (char *) alloca (strlen (temp) + 3);
2487 startp = endp = temp;
2490 if (*endp == PATH_SEPARATOR || *endp == 0)
2492 strncpy (nstore, startp, endp-startp);
2494 strcpy (nstore, concat (".", dir_separator_str, NULL_PTR));
2495 else if (endp[-1] != '/' && endp[-1] != DIR_SEPARATOR)
2497 nstore[endp-startp] = DIR_SEPARATOR;
2498 nstore[endp-startp+1] = 0;
2501 nstore[endp-startp] = 0;
2502 add_prefix (&startfile_prefixes, nstore, NULL_PTR,
2506 endp = startp = endp + 1;
2513 /* Convert new-style -- options to old-style. */
2514 translate_options (&argc, &argv);
2516 #ifdef LANG_SPECIFIC_DRIVER
2517 /* Do language-specific adjustment/addition of flags. */
2518 lang_specific_driver (fatal, &argc, &argv);
2521 /* Scan argv twice. Here, the first time, just count how many switches
2522 there will be in their vector, and how many input files in theirs.
2523 Here we also parse the switches that cc itself uses (e.g. -v). */
2525 for (i = 1; i < argc; i++)
2527 if (! strcmp (argv[i], "-dumpspecs"))
2529 struct spec_list *sl;
2531 for (sl = specs; sl; sl = sl->next)
2532 printf ("*%s:\n%s\n\n", sl->name, *(sl->ptr_spec));
2535 else if (! strcmp (argv[i], "-dumpversion"))
2537 printf ("%s\n", spec_version);
2540 else if (! strcmp (argv[i], "-dumpmachine"))
2542 printf ("%s\n", spec_machine);
2545 else if (! strcmp (argv[i], "-print-search-dirs"))
2546 print_search_dirs = 1;
2547 else if (! strcmp (argv[i], "-print-libgcc-file-name"))
2548 print_file_name = "libgcc.a";
2549 else if (! strncmp (argv[i], "-print-file-name=", 17))
2550 print_file_name = argv[i] + 17;
2551 else if (! strncmp (argv[i], "-print-prog-name=", 17))
2552 print_prog_name = argv[i] + 17;
2553 else if (! strcmp (argv[i], "-print-multi-lib"))
2554 print_multi_lib = 1;
2555 else if (! strcmp (argv[i], "-print-multi-directory"))
2556 print_multi_directory = 1;
2557 else if (! strncmp (argv[i], "-Wa,", 4))
2560 /* Pass the rest of this option to the assembler. */
2562 n_assembler_options++;
2563 if (!assembler_options)
2565 = (char **) xmalloc (n_assembler_options * sizeof (char **));
2568 = (char **) xrealloc (assembler_options,
2569 n_assembler_options * sizeof (char **));
2571 /* Split the argument at commas. */
2573 for (j = 4; argv[i][j]; j++)
2574 if (argv[i][j] == ',')
2576 assembler_options[n_assembler_options - 1]
2577 = save_string (argv[i] + prev, j - prev);
2578 n_assembler_options++;
2580 = (char **) xrealloc (assembler_options,
2581 n_assembler_options * sizeof (char **));
2584 /* Record the part after the last comma. */
2585 assembler_options[n_assembler_options - 1] = argv[i] + prev;
2587 else if (! strncmp (argv[i], "-Wp,", 4))
2590 /* Pass the rest of this option to the preprocessor. */
2592 n_preprocessor_options++;
2593 if (!preprocessor_options)
2594 preprocessor_options
2595 = (char **) xmalloc (n_preprocessor_options * sizeof (char **));
2597 preprocessor_options
2598 = (char **) xrealloc (preprocessor_options,
2599 n_preprocessor_options * sizeof (char **));
2601 /* Split the argument at commas. */
2603 for (j = 4; argv[i][j]; j++)
2604 if (argv[i][j] == ',')
2606 preprocessor_options[n_preprocessor_options - 1]
2607 = save_string (argv[i] + prev, j - prev);
2608 n_preprocessor_options++;
2609 preprocessor_options
2610 = (char **) xrealloc (preprocessor_options,
2611 n_preprocessor_options * sizeof (char **));
2614 /* Record the part after the last comma. */
2615 preprocessor_options[n_preprocessor_options - 1] = argv[i] + prev;
2617 else if (argv[i][0] == '+' && argv[i][1] == 'e')
2618 /* The +e options to the C++ front-end. */
2620 else if (strncmp (argv[i], "-Wl,", 4) == 0)
2623 /* Split the argument at commas. */
2624 for (j = 3; argv[i][j]; j++)
2625 n_infiles += (argv[i][j] == ',');
2627 else if (strcmp (argv[i], "-Xlinker") == 0)
2630 fatal ("argument to `-Xlinker' is missing");
2635 else if (strncmp (argv[i], "-l", 2) == 0)
2637 else if (strcmp (argv[i], "-save-temps") == 0)
2639 save_temps_flag = 1;
2642 else if (strcmp (argv[i], "-specs") == 0)
2644 struct user_specs *user = (struct user_specs *)
2645 xmalloc (sizeof (struct user_specs));
2647 fatal ("argument to `-specs' is missing");
2649 user->next = (struct user_specs *)0;
2650 user->filename = argv[i];
2651 if (user_specs_tail)
2652 user_specs_tail->next = user;
2654 user_specs_head = user;
2655 user_specs_tail = user;
2657 else if (strncmp (argv[i], "-specs=", 7) == 0)
2659 struct user_specs *user = (struct user_specs *)
2660 xmalloc (sizeof (struct user_specs));
2661 if (strlen (argv[i]) == 7)
2662 fatal ("argument to `-specs=' is missing");
2664 user->next = (struct user_specs *)0;
2665 user->filename = argv[i]+7;
2666 if (user_specs_tail)
2667 user_specs_tail->next = user;
2669 user_specs_head = user;
2670 user_specs_tail = user;
2672 else if (argv[i][0] == '-' && argv[i][1] != 0)
2674 register char *p = &argv[i][1];
2675 register int c = *p;
2681 if (p[1] == 0 && i + 1 == argc)
2682 fatal ("argument to `-b' is missing");
2684 spec_machine = argv[++i];
2686 spec_machine = p + 1;
2688 warn_std_ptr = &warn_std;
2694 if (p[1] == 0 && i + 1 == argc)
2695 fatal ("argument to `-B' is missing");
2700 add_prefix (&exec_prefixes, value, NULL_PTR, 1, 0, &warn_B);
2701 add_prefix (&startfile_prefixes, value, NULL_PTR,
2703 add_prefix (&include_prefixes, concat (value, "include",
2705 NULL_PTR, 1, 0, NULL_PTR);
2707 /* As a kludge, if the arg is "[foo/]stageN/", just add
2708 "[foo/]include" to the include prefix. */
2710 int len = strlen (value);
2713 && (value[len - 8] == '/'
2714 || value[len - 8] == DIR_SEPARATOR)))
2715 && strncmp (value + len - 7, "stage", 5) == 0
2716 && ISDIGIT (value[len - 2])
2717 && (value[len - 1] == '/'
2718 || value[len - 1] == DIR_SEPARATOR))
2721 add_prefix (&include_prefixes, "include", NULL_PTR,
2725 char *string = xmalloc (len + 1);
2726 strncpy (string, value, len-7);
2727 strcpy (string+len-7, "include");
2728 add_prefix (&include_prefixes, string, NULL_PTR,
2737 case 'v': /* Print our subcommands and print versions. */
2739 /* If they do anything other than exactly `-v', don't set
2740 verbose_flag; rather, continue on to give the error. */
2748 if (p[1] == 0 && i + 1 == argc)
2749 fatal ("argument to `-V' is missing");
2751 spec_version = argv[++i];
2753 spec_version = p + 1;
2754 compiler_version = spec_version;
2755 warn_std_ptr = &warn_std;
2757 /* Validate the version number. Use the same checks
2758 done when inserting it into a spec.
2760 The format of the version string is
2761 ([^0-9]*-)?[0-9]+[.][0-9]+([.][0-9]+)?([- ].*)? */
2763 char *v = compiler_version;
2765 /* Ignore leading non-digits. i.e. "foo-" in "foo-2.7.2". */
2766 while (! isdigit (*v))
2769 if (v > compiler_version && v[-1] != '-')
2770 fatal ("invalid version number format");
2772 /* Set V after the first period. */
2773 while (isdigit (*v))
2777 fatal ("invalid version number format");
2780 while (isdigit (*v))
2783 if (*v != 0 && *v != ' ' && *v != '.' && *v != '-')
2784 fatal ("invalid version number format");
2799 #if defined(HAVE_EXECUTABLE_SUFFIX) || defined(HAVE_OBJECT_SUFFIX)
2800 argv[i] = convert_filename (argv[i], 1);
2802 argv[i+1] = convert_filename (argv[i+1], 1);
2810 if (SWITCH_TAKES_ARG (c) > (p[1] != 0))
2811 i += SWITCH_TAKES_ARG (c) - (p[1] != 0);
2812 else if (WORD_SWITCH_TAKES_ARG (p))
2813 i += WORD_SWITCH_TAKES_ARG (p);
2823 if (have_c && have_o && lang_n_infiles > 1)
2824 fatal ("cannot specify -o with -c or -S and multiple compilations");
2826 /* Set up the search paths before we go looking for config files. */
2828 /* These come before the md prefixes so that we will find gcc's subcommands
2829 (such as cpp) rather than those of the host system. */
2830 /* Use 2 as fourth arg meaning try just the machine as a suffix,
2831 as well as trying the machine and the version. */
2833 add_prefix (&exec_prefixes, standard_exec_prefix, "BINUTILS",
2834 0, 2, warn_std_ptr);
2835 add_prefix (&exec_prefixes, standard_exec_prefix_1, "BINUTILS",
2836 0, 2, warn_std_ptr);
2839 add_prefix (&startfile_prefixes, standard_exec_prefix, "BINUTILS",
2840 0, 1, warn_std_ptr);
2841 add_prefix (&startfile_prefixes, standard_exec_prefix_1, "BINUTILS",
2842 0, 1, warn_std_ptr);
2844 tooldir_prefix = concat (tooldir_base_prefix, spec_machine,
2845 dir_separator_str, NULL_PTR);
2847 /* If tooldir is relative, base it on exec_prefixes. A relative
2848 tooldir lets us move the installed tree as a unit.
2850 If GCC_EXEC_PREFIX is defined, then we want to add two relative
2851 directories, so that we can search both the user specified directory
2852 and the standard place. */
2854 if (*tooldir_prefix != '/' && *tooldir_prefix != DIR_SEPARATOR)
2856 if (gcc_exec_prefix)
2858 char *gcc_exec_tooldir_prefix
2859 = concat (gcc_exec_prefix, spec_machine, dir_separator_str,
2860 spec_version, dir_separator_str, tooldir_prefix, NULL_PTR);
2862 add_prefix (&exec_prefixes,
2863 concat (gcc_exec_tooldir_prefix, "bin",
2864 dir_separator_str, NULL_PTR),
2865 NULL_PTR, 0, 0, NULL_PTR);
2866 add_prefix (&startfile_prefixes,
2867 concat (gcc_exec_tooldir_prefix, "lib",
2868 dir_separator_str, NULL_PTR),
2869 NULL_PTR, 0, 0, NULL_PTR);
2872 tooldir_prefix = concat (standard_exec_prefix, spec_machine,
2873 dir_separator_str, spec_version,
2874 dir_separator_str, tooldir_prefix, NULL_PTR);
2877 add_prefix (&exec_prefixes,
2878 concat (tooldir_prefix, "bin", dir_separator_str, NULL_PTR),
2879 "BINUTILS", 0, 0, NULL_PTR);
2880 add_prefix (&startfile_prefixes,
2881 concat (tooldir_prefix, "lib", dir_separator_str, NULL_PTR),
2882 "BINUTILS", 0, 0, NULL_PTR);
2884 /* More prefixes are enabled in main, after we read the specs file
2885 and determine whether this is cross-compilation or not. */
2888 /* Then create the space for the vectors and scan again. */
2890 switches = ((struct switchstr *)
2891 xmalloc ((n_switches + 1) * sizeof (struct switchstr)));
2892 infiles = (struct infile *) xmalloc ((n_infiles + 1) * sizeof (struct infile));
2895 last_language_n_infiles = -1;
2897 /* This, time, copy the text of each switch and store a pointer
2898 to the copy in the vector of switches.
2899 Store all the infiles in their vector. */
2901 for (i = 1; i < argc; i++)
2903 /* Just skip the switches that were handled by the preceding loop. */
2904 if (! strncmp (argv[i], "-Wa,", 4))
2906 else if (! strncmp (argv[i], "-Wp,", 4))
2908 else if (! strcmp (argv[i], "-print-search-dirs"))
2910 else if (! strcmp (argv[i], "-print-libgcc-file-name"))
2912 else if (! strncmp (argv[i], "-print-file-name=", 17))
2914 else if (! strncmp (argv[i], "-print-prog-name=", 17))
2916 else if (! strcmp (argv[i], "-print-multi-lib"))
2918 else if (! strcmp (argv[i], "-print-multi-directory"))
2920 else if (argv[i][0] == '+' && argv[i][1] == 'e')
2922 /* Compensate for the +e options to the C++ front-end;
2923 they're there simply for cfront call-compatibility. We do
2924 some magic in default_compilers to pass them down properly.
2925 Note we deliberately start at the `+' here, to avoid passing
2926 -e0 or -e1 down into the linker. */
2927 switches[n_switches].part1 = &argv[i][0];
2928 switches[n_switches].args = 0;
2929 switches[n_switches].live_cond = 0;
2930 switches[n_switches].valid = 0;
2933 else if (strncmp (argv[i], "-Wl,", 4) == 0)
2936 /* Split the argument at commas. */
2938 for (j = 4; argv[i][j]; j++)
2939 if (argv[i][j] == ',')
2941 infiles[n_infiles].language = "*";
2942 infiles[n_infiles++].name
2943 = save_string (argv[i] + prev, j - prev);
2946 /* Record the part after the last comma. */
2947 infiles[n_infiles].language = "*";
2948 infiles[n_infiles++].name = argv[i] + prev;
2950 else if (strcmp (argv[i], "-Xlinker") == 0)
2952 infiles[n_infiles].language = "*";
2953 infiles[n_infiles++].name = argv[++i];
2955 else if (strncmp (argv[i], "-l", 2) == 0)
2957 infiles[n_infiles].language = "*";
2958 infiles[n_infiles++].name = argv[i];
2960 else if (strcmp (argv[i], "-specs") == 0)
2962 else if (strncmp (argv[i], "-specs=", 7) == 0)
2964 /* -save-temps overrides -pipe, so that temp files are produced */
2965 else if (save_temps_flag && strcmp (argv[i], "-pipe") == 0)
2966 error ("Warning: -pipe ignored since -save-temps specified");
2967 else if (argv[i][0] == '-' && argv[i][1] != 0)
2969 register char *p = &argv[i][1];
2970 register int c = *p;
2974 if (p[1] == 0 && i + 1 == argc)
2975 fatal ("argument to `-x' is missing");
2977 spec_lang = argv[++i];
2980 if (! strcmp (spec_lang, "none"))
2981 /* Suppress the warning if -xnone comes after the last input
2982 file, because alternate command interfaces like g++ might
2983 find it useful to place -xnone after each input file. */
2986 last_language_n_infiles = n_infiles;
2989 switches[n_switches].part1 = p;
2990 /* Deal with option arguments in separate argv elements. */
2991 if ((SWITCH_TAKES_ARG (c) > (p[1] != 0))
2992 || WORD_SWITCH_TAKES_ARG (p))
2995 int n_args = WORD_SWITCH_TAKES_ARG (p);
2999 /* Count only the option arguments in separate argv elements. */
3000 n_args = SWITCH_TAKES_ARG (c) - (p[1] != 0);
3002 if (i + n_args >= argc)
3003 fatal ("argument to `-%s' is missing", p);
3004 switches[n_switches].args
3005 = (char **) xmalloc ((n_args + 1) * sizeof (char *));
3007 switches[n_switches].args[j++] = argv[++i];
3008 /* Null-terminate the vector. */
3009 switches[n_switches].args[j] = 0;
3011 else if (index (switches_need_spaces, c))
3013 /* On some systems, ld cannot handle some options without
3014 a space. So split the option from its argument. */
3015 char *part1 = (char *) xmalloc (2);
3019 switches[n_switches].part1 = part1;
3020 switches[n_switches].args = (char **) xmalloc (2 * sizeof (char *));
3021 switches[n_switches].args[0] = xmalloc (strlen (p));
3022 strcpy (switches[n_switches].args[0], &p[1]);
3023 switches[n_switches].args[1] = 0;
3026 switches[n_switches].args = 0;
3028 switches[n_switches].live_cond = 0;
3029 switches[n_switches].valid = 0;
3030 /* This is always valid, since gcc.c itself understands it. */
3031 if (!strcmp (p, "save-temps"))
3032 switches[n_switches].valid = 1;
3035 char ch = switches[n_switches].part1[0];
3036 if (ch == 'V' || ch == 'b' || ch == 'B')
3037 switches[n_switches].valid = 1;
3043 #ifdef HAVE_OBJECT_SUFFIX
3044 argv[i] = convert_filename (argv[i], 0);
3047 if (strcmp (argv[i], "-") != 0 && access (argv[i], R_OK) < 0)
3049 perror_with_name (argv[i]);
3054 infiles[n_infiles].language = spec_lang;
3055 infiles[n_infiles++].name = argv[i];
3060 if (n_infiles == last_language_n_infiles && spec_lang != 0)
3061 error ("Warning: `-x %s' after last input file has no effect", spec_lang);
3063 switches[n_switches].part1 = 0;
3064 infiles[n_infiles].name = 0;
3067 /* Process a spec string, accumulating and running commands. */
3069 /* These variables describe the input file name.
3070 input_file_number is the index on outfiles of this file,
3071 so that the output file name can be stored for later use by %o.
3072 input_basename is the start of the part of the input file
3073 sans all directory names, and basename_length is the number
3074 of characters starting there excluding the suffix .c or whatever. */
3076 static char *input_filename;
3077 static int input_file_number;
3078 static size_t input_filename_length;
3079 static int basename_length;
3080 static char *input_basename;
3081 static char *input_suffix;
3083 /* These are variables used within do_spec and do_spec_1. */
3085 /* Nonzero if an arg has been started and not yet terminated
3086 (with space, tab or newline). */
3087 static int arg_going;
3089 /* Nonzero means %d or %g has been seen; the next arg to be terminated
3090 is a temporary file name. */
3091 static int delete_this_arg;
3093 /* Nonzero means %w has been seen; the next arg to be terminated
3094 is the output file name of this compilation. */
3095 static int this_is_output_file;
3097 /* Nonzero means %s has been seen; the next arg to be terminated
3098 is the name of a library file and we should try the standard
3099 search dirs for it. */
3100 static int this_is_library_file;
3102 /* Nonzero means that the input of this command is coming from a pipe. */
3103 static int input_from_pipe;
3105 /* Process the spec SPEC and run the commands specified therein.
3106 Returns 0 if the spec is successfully processed; -1 if failed. */
3116 delete_this_arg = 0;
3117 this_is_output_file = 0;
3118 this_is_library_file = 0;
3119 input_from_pipe = 0;
3121 value = do_spec_1 (spec, 0, NULL_PTR);
3123 /* Force out any unfinished command.
3124 If -pipe, this forces out the last command if it ended in `|'. */
3127 if (argbuf_index > 0 && !strcmp (argbuf[argbuf_index - 1], "|"))
3130 if (argbuf_index > 0)
3137 /* Process the sub-spec SPEC as a portion of a larger spec.
3138 This is like processing a whole spec except that we do
3139 not initialize at the beginning and we do not supply a
3140 newline by default at the end.
3141 INSWITCH nonzero means don't process %-sequences in SPEC;
3142 in this case, % is treated as an ordinary character.
3143 This is used while substituting switches.
3144 INSWITCH nonzero also causes SPC not to terminate an argument.
3146 Value is zero unless a line was finished
3147 and the command on that line reported an error. */
3150 do_spec_1 (spec, inswitch, soft_matched_part)
3153 char *soft_matched_part;
3155 register char *p = spec;
3162 /* If substituting a switch, treat all chars like letters.
3163 Otherwise, NL, SPC, TAB and % are special. */
3164 switch (inswitch ? 'a' : c)
3167 /* End of line: finish any pending argument,
3168 then run the pending command if one has been started. */
3171 obstack_1grow (&obstack, 0);
3172 string = obstack_finish (&obstack);
3173 if (this_is_library_file)
3174 string = find_file (string);
3175 store_arg (string, delete_this_arg, this_is_output_file);
3176 if (this_is_output_file)
3177 outfiles[input_file_number] = string;
3181 if (argbuf_index > 0 && !strcmp (argbuf[argbuf_index - 1], "|"))
3183 for (i = 0; i < n_switches; i++)
3184 if (!strcmp (switches[i].part1, "pipe"))
3187 /* A `|' before the newline means use a pipe here,
3188 but only if -pipe was specified.
3189 Otherwise, execute now and don't pass the `|' as an arg. */
3192 input_from_pipe = 1;
3193 switches[i].valid = 1;
3200 if (argbuf_index > 0)
3206 /* Reinitialize for a new command, and for a new argument. */
3209 delete_this_arg = 0;
3210 this_is_output_file = 0;
3211 this_is_library_file = 0;
3212 input_from_pipe = 0;
3216 /* End any pending argument. */
3219 obstack_1grow (&obstack, 0);
3220 string = obstack_finish (&obstack);
3221 if (this_is_library_file)
3222 string = find_file (string);
3223 store_arg (string, delete_this_arg, this_is_output_file);
3224 if (this_is_output_file)
3225 outfiles[input_file_number] = string;
3229 obstack_1grow (&obstack, c);
3235 /* Space or tab ends an argument if one is pending. */
3238 obstack_1grow (&obstack, 0);
3239 string = obstack_finish (&obstack);
3240 if (this_is_library_file)
3241 string = find_file (string);
3242 store_arg (string, delete_this_arg, this_is_output_file);
3243 if (this_is_output_file)
3244 outfiles[input_file_number] = string;
3246 /* Reinitialize for a new argument. */
3248 delete_this_arg = 0;
3249 this_is_output_file = 0;
3250 this_is_library_file = 0;
3257 fatal ("Invalid specification! Bug in cc.");
3260 obstack_grow (&obstack, input_basename, basename_length);
3265 delete_this_arg = 2;
3268 /* Dump out the directories specified with LIBRARY_PATH,
3269 followed by the absolute directories
3270 that we search for startfiles. */
3273 struct prefix_list *pl = startfile_prefixes.plist;
3274 size_t bufsize = 100;
3275 char *buffer = (char *) xmalloc (bufsize);
3278 for (; pl; pl = pl->next)
3280 #ifdef RELATIVE_PREFIX_NOT_LINKDIR
3281 /* Used on systems which record the specified -L dirs
3282 and use them to search for dynamic linking. */
3283 /* Relative directories always come from -B,
3284 and it is better not to use them for searching
3285 at run time. In particular, stage1 loses */
3286 if (pl->prefix[0] != '/' && pl->prefix[0] != DIR_SEPARATOR)
3289 /* Try subdirectory if there is one. */
3290 if (multilib_dir != NULL)
3294 if (strlen (pl->prefix) + strlen (machine_suffix)
3296 bufsize = (strlen (pl->prefix)
3297 + strlen (machine_suffix)) * 2 + 1;
3298 buffer = (char *) xrealloc (buffer, bufsize);
3299 strcpy (buffer, pl->prefix);
3300 strcat (buffer, machine_suffix);
3301 if (is_directory (buffer, multilib_dir, 1))
3303 do_spec_1 ("-L", 0, NULL_PTR);
3304 #ifdef SPACE_AFTER_L_OPTION
3305 do_spec_1 (" ", 0, NULL_PTR);
3307 do_spec_1 (buffer, 1, NULL_PTR);
3308 do_spec_1 (multilib_dir, 1, NULL_PTR);
3309 /* Make this a separate argument. */
3310 do_spec_1 (" ", 0, NULL_PTR);
3313 if (!pl->require_machine_suffix)
3315 if (is_directory (pl->prefix, multilib_dir, 1))
3317 do_spec_1 ("-L", 0, NULL_PTR);
3318 #ifdef SPACE_AFTER_L_OPTION
3319 do_spec_1 (" ", 0, NULL_PTR);
3321 do_spec_1 (pl->prefix, 1, NULL_PTR);
3322 do_spec_1 (multilib_dir, 1, NULL_PTR);
3323 /* Make this a separate argument. */
3324 do_spec_1 (" ", 0, NULL_PTR);
3330 if (is_directory (pl->prefix, machine_suffix, 1))
3332 do_spec_1 ("-L", 0, NULL_PTR);
3333 #ifdef SPACE_AFTER_L_OPTION
3334 do_spec_1 (" ", 0, NULL_PTR);
3336 do_spec_1 (pl->prefix, 1, NULL_PTR);
3337 /* Remove slash from machine_suffix. */
3338 if (strlen (machine_suffix) >= bufsize)
3339 bufsize = strlen (machine_suffix) * 2 + 1;
3340 buffer = (char *) xrealloc (buffer, bufsize);
3341 strcpy (buffer, machine_suffix);
3342 idx = strlen (buffer);
3343 if (buffer[idx - 1] == '/'
3344 || buffer[idx - 1] == DIR_SEPARATOR)
3345 buffer[idx - 1] = 0;
3346 do_spec_1 (buffer, 1, NULL_PTR);
3347 /* Make this a separate argument. */
3348 do_spec_1 (" ", 0, NULL_PTR);
3351 if (!pl->require_machine_suffix)
3353 if (is_directory (pl->prefix, "", 1))
3355 do_spec_1 ("-L", 0, NULL_PTR);
3356 #ifdef SPACE_AFTER_L_OPTION
3357 do_spec_1 (" ", 0, NULL_PTR);
3359 /* Remove slash from pl->prefix. */
3360 if (strlen (pl->prefix) >= bufsize)
3361 bufsize = strlen (pl->prefix) * 2 + 1;
3362 buffer = (char *) xrealloc (buffer, bufsize);
3363 strcpy (buffer, pl->prefix);
3364 idx = strlen (buffer);
3365 if (buffer[idx - 1] == '/'
3366 || buffer[idx - 1] == DIR_SEPARATOR)
3367 buffer[idx - 1] = 0;
3368 do_spec_1 (buffer, 1, NULL_PTR);
3369 /* Make this a separate argument. */
3370 do_spec_1 (" ", 0, NULL_PTR);
3379 /* {...:%efoo} means report an error with `foo' as error message
3380 and don't execute any more commands for this file. */
3384 while (*p != 0 && *p != '\n') p++;
3385 buf = (char *) alloca (p - q + 1);
3386 strncpy (buf, q, p - q);
3396 if (save_temps_flag)
3398 obstack_grow (&obstack, input_basename, basename_length);
3399 delete_this_arg = 0;
3403 #ifdef MKTEMP_EACH_FILE
3404 /* ??? This has a problem: the total number of
3405 values mktemp can return is limited.
3406 That matters for the names of object files.
3407 In 2.4, do something about that. */
3408 struct temp_name *t;
3410 while (*p == '.' || ISALPHA (*p)
3411 || (p[0] == '%' && p[1] == 'O'))
3414 /* See if we already have an association of %g/%u/%U and
3416 for (t = temp_names; t; t = t->next)
3417 if (t->length == p - suffix
3418 && strncmp (t->suffix, suffix, p - suffix) == 0
3419 && t->unique == (c != 'g'))
3422 /* Make a new association if needed. %u requires one. */
3423 if (t == 0 || c == 'u')
3427 t = (struct temp_name *) xmalloc (sizeof (struct temp_name));
3428 t->next = temp_names;
3431 t->length = p - suffix;
3432 t->suffix = save_string (suffix, p - suffix);
3433 t->unique = (c != 'g');
3434 temp_filename = choose_temp_base ();
3435 temp_filename_length = strlen (temp_filename);
3436 t->filename = temp_filename;
3437 t->filename_length = temp_filename_length;
3440 obstack_grow (&obstack, t->filename, t->filename_length);
3441 delete_this_arg = 1;
3443 obstack_grow (&obstack, temp_filename, temp_filename_length);
3444 if (c == 'u' || c == 'U')
3450 sprintf (buff, "%d", unique);
3451 obstack_grow (&obstack, buff, strlen (buff));
3454 delete_this_arg = 1;
3460 obstack_grow (&obstack, input_filename, input_filename_length);
3466 struct prefix_list *pl = include_prefixes.plist;
3468 if (gcc_exec_prefix)
3470 do_spec_1 ("-iprefix", 1, NULL_PTR);
3471 /* Make this a separate argument. */
3472 do_spec_1 (" ", 0, NULL_PTR);
3473 do_spec_1 (gcc_exec_prefix, 1, NULL_PTR);
3474 do_spec_1 (" ", 0, NULL_PTR);
3477 for (; pl; pl = pl->next)
3479 do_spec_1 ("-isystem", 1, NULL_PTR);
3480 /* Make this a separate argument. */
3481 do_spec_1 (" ", 0, NULL_PTR);
3482 do_spec_1 (pl->prefix, 1, NULL_PTR);
3483 do_spec_1 (" ", 0, NULL_PTR);
3489 for (i = 0; i < n_infiles; i++)
3490 store_arg (outfiles[i], 0, 0);
3494 obstack_grow (&obstack, OBJECT_SUFFIX, strlen (OBJECT_SUFFIX));
3499 this_is_library_file = 1;
3503 this_is_output_file = 1;
3508 int cur_index = argbuf_index;
3509 /* Handle the {...} following the %W. */
3512 p = handle_braces (p + 1);
3515 /* If any args were output, mark the last one for deletion
3517 if (argbuf_index != cur_index)
3518 record_temp_file (argbuf[argbuf_index - 1], 0, 1);
3522 /* %x{OPTION} records OPTION for %X to output. */
3528 /* Skip past the option value and make a copy. */
3533 string = save_string (p1 + 1, p - p1 - 2);
3535 /* See if we already recorded this option. */
3536 for (i = 0; i < n_linker_options; i++)
3537 if (! strcmp (string, linker_options[i]))
3543 /* This option is new; add it. */
3545 if (!linker_options)
3547 = (char **) xmalloc (n_linker_options * sizeof (char **));
3550 = (char **) xrealloc (linker_options,
3551 n_linker_options * sizeof (char **));
3553 linker_options[n_linker_options - 1] = string;
3557 /* Dump out the options accumulated previously using %x. */
3559 for (i = 0; i < n_linker_options; i++)
3561 do_spec_1 (linker_options[i], 1, NULL_PTR);
3562 /* Make each accumulated option a separate argument. */
3563 do_spec_1 (" ", 0, NULL_PTR);
3567 /* Dump out the options accumulated previously using -Wa,. */
3569 for (i = 0; i < n_assembler_options; i++)
3571 do_spec_1 (assembler_options[i], 1, NULL_PTR);
3572 /* Make each accumulated option a separate argument. */
3573 do_spec_1 (" ", 0, NULL_PTR);
3577 /* Dump out the options accumulated previously using -Wp,. */
3579 for (i = 0; i < n_preprocessor_options; i++)
3581 do_spec_1 (preprocessor_options[i], 1, NULL_PTR);
3582 /* Make each accumulated option a separate argument. */
3583 do_spec_1 (" ", 0, NULL_PTR);
3587 /* Here are digits and numbers that just process
3588 a certain constant string as a spec. */
3591 value = do_spec_1 (cc1_spec, 0, NULL_PTR);
3597 value = do_spec_1 (cc1plus_spec, 0, NULL_PTR);
3603 value = do_spec_1 (asm_spec, 0, NULL_PTR);
3609 value = do_spec_1 (asm_final_spec, 0, NULL_PTR);
3615 value = do_spec_1 (signed_char_spec, 0, NULL_PTR);
3621 value = do_spec_1 (cpp_spec, 0, NULL_PTR);
3627 value = do_spec_1 (endfile_spec, 0, NULL_PTR);
3633 value = do_spec_1 (link_spec, 0, NULL_PTR);
3639 value = do_spec_1 (lib_spec, 0, NULL_PTR);
3645 value = do_spec_1 (libgcc_spec, 0, NULL_PTR);
3652 char *x = (char *) alloca (strlen (cpp_predefines) + 1);
3656 /* Copy all of the -D options in CPP_PREDEFINES into BUF. */
3660 if (! strncmp (y, "-D", 2))
3661 /* Copy the whole option. */
3662 while (*y && *y != ' ' && *y != '\t')
3664 else if (*y == ' ' || *y == '\t')
3665 /* Copy whitespace to the result. */
3667 /* Don't copy other options. */
3674 value = do_spec_1 (buf, 0, NULL_PTR);
3682 char *x = (char *) alloca (strlen (cpp_predefines) * 4 + 1);
3686 /* Copy all of CPP_PREDEFINES into BUF,
3687 but put __ after every -D and at the end of each arg. */
3691 if (! strncmp (y, "-D", 2))
3699 || (*(y+1) != '_' && ! ISUPPER (*(y+1))))
3701 /* Stick __ at front of macro name. */
3704 /* Arrange to stick __ at the end as well. */
3708 /* Copy the macro name. */
3709 while (*y && *y != '=' && *y != ' ' && *y != '\t')
3718 /* Copy the value given, if any. */
3719 while (*y && *y != ' ' && *y != '\t')
3722 else if (*y == ' ' || *y == '\t')
3723 /* Copy whitespace to the result. */
3725 /* Don't copy -A options */
3731 /* Copy all of CPP_PREDEFINES into BUF,
3732 but put __ after every -D. */
3736 if (! strncmp (y, "-D", 2))
3741 || (*(y+1) != '_' && ! ISUPPER (*(y+1))))
3743 /* Stick -D__ at front of macro name. */
3749 /* Copy the macro name. */
3750 while (*y && *y != '=' && *y != ' ' && *y != '\t')
3753 /* Copy the value given, if any. */
3754 while (*y && *y != ' ' && *y != '\t')
3759 /* Do not copy this macro - we have just done it before */
3760 while (*y && *y != ' ' && *y != '\t')
3764 else if (*y == ' ' || *y == '\t')
3765 /* Copy whitespace to the result. */
3767 /* Don't copy -A options */
3773 /* Copy all of the -A options in CPP_PREDEFINES into BUF. */
3777 if (! strncmp (y, "-A", 2))
3778 /* Copy the whole option. */
3779 while (*y && *y != ' ' && *y != '\t')
3781 else if (*y == ' ' || *y == '\t')
3782 /* Copy whitespace to the result. */
3784 /* Don't copy other options. */
3791 value = do_spec_1 (buf, 0, NULL_PTR);
3798 value = do_spec_1 (startfile_spec, 0, NULL_PTR);
3803 /* Here we define characters other than letters and digits. */
3806 p = handle_braces (p);
3812 obstack_1grow (&obstack, '%');
3816 do_spec_1 (soft_matched_part, 1, NULL_PTR);
3817 do_spec_1 (" ", 0, NULL_PTR);
3820 /* Process a string found as the value of a spec given by name.
3821 This feature allows individual machine descriptions
3822 to add and use their own specs.
3823 %[...] modifies -D options the way %P does;
3824 %(...) uses the spec unmodified. */
3829 struct spec_list *sl;
3832 /* The string after the S/P is the name of a spec that is to be
3834 while (*p && *p != ')' && *p != ']')
3837 /* See if it's in the list */
3838 for (len = p - name, sl = specs; sl; sl = sl->next)
3839 if (sl->name_len == len && !strncmp (sl->name, name, len))
3841 name = *(sl->ptr_spec);
3843 fprintf (stderr, "Processing spec %c%s%c, which is '%s'\n",
3844 c, sl->name, (c == '(') ? ')' : ']', name);
3853 value = do_spec_1 (name, 0, NULL_PTR);
3859 char *x = (char *) alloca (strlen (name) * 2 + 1);
3863 /* Copy all of NAME into BUF, but put __ after
3864 every -D and at the end of each arg, */
3869 if (! strncmp (y, "-D", 2))
3879 else if (flag && (*y == ' ' || *y == '\t' || *y == '='
3880 || *y == '}' || *y == 0))
3893 value = do_spec_1 (buf, 0, NULL_PTR);
3899 /* Discard the closing paren or bracket. */
3907 int c1 = *p++; /* Select first or second version number. */
3908 char *v = compiler_version;
3911 /* The format of the version string is
3912 ([^0-9]*-)?[0-9]+[.][0-9]+([.][0-9]+)?([- ].*)? */
3914 /* Ignore leading non-digits. i.e. "foo-" in "foo-2.7.2". */
3915 while (! ISDIGIT (*v))
3917 if (v > compiler_version && v[-1] != '-')
3920 /* If desired, advance to second version number. */
3923 /* Set V after the first period. */
3924 while (ISDIGIT (*v))
3931 /* Set Q at the next period or at the end. */
3933 while (ISDIGIT (*q))
3935 if (*q != 0 && *q != ' ' && *q != '.' && *q != '-')
3938 /* Put that part into the command. */
3939 obstack_grow (&obstack, v, q - v);
3945 if (input_from_pipe)
3946 do_spec_1 ("-", 0, NULL_PTR);
3955 /* Backslash: treat next character as ordinary. */
3960 /* Ordinary character: put it into the current argument. */
3961 obstack_1grow (&obstack, c);
3965 return 0; /* End of string */
3968 /* Return 0 if we call do_spec_1 and that returns -1. */
3979 int include_blanks = 1;
3982 /* A '^' after the open-brace means to not give blanks before args. */
3983 include_blanks = 0, ++p;
3986 /* A `|' after the open-brace means,
3987 if the test fails, output a single minus sign rather than nothing.
3988 This is used in %{|!pipe:...}. */
3992 /* A `!' after the open-brace negates the condition:
3993 succeed if the specified switch is not present. */
3997 /* A `.' after the open-brace means test against the current suffix. */
4007 while (*p != ':' && *p != '}') p++;
4010 register int count = 1;
4028 int found = (input_suffix != 0
4029 && strlen (input_suffix) == p - filter
4030 && strncmp (input_suffix, filter, p - filter) == 0);
4036 && do_spec_1 (save_string (p + 1, q - p - 2), 0, NULL_PTR) < 0)
4041 else if (p[-1] == '*' && p[0] == '}')
4043 /* Substitute all matching switches as separate args. */
4046 for (i = 0; i < n_switches; i++)
4047 if (!strncmp (switches[i].part1, filter, p - filter)
4048 && check_live_switch (i, p - filter))
4049 give_switch (i, 0, include_blanks);
4053 /* Test for presence of the specified switch. */
4057 /* If name specified ends in *, as in {x*:...},
4058 check for %* and handle that case. */
4059 if (p[-1] == '*' && !negate)
4064 /* First see whether we have %*. */
4068 if (*r == '%' && r[1] == '*')
4072 /* If we do, handle that case. */
4075 /* Substitute all matching switches as separate args.
4076 But do this by substituting for %*
4077 in the text that follows the colon. */
4079 unsigned hard_match_len = p - filter - 1;
4080 char *string = save_string (p + 1, q - p - 2);
4082 for (i = 0; i < n_switches; i++)
4083 if (!strncmp (switches[i].part1, filter, hard_match_len)
4084 && check_live_switch (i, -1))
4086 do_spec_1 (string, 0, &switches[i].part1[hard_match_len]);
4087 /* Pass any arguments this switch has. */
4088 give_switch (i, 1, 1);
4095 /* If name specified ends in *, as in {x*:...},
4096 check for presence of any switch name starting with x. */
4099 for (i = 0; i < n_switches; i++)
4101 unsigned hard_match_len = p - filter - 1;
4103 if (!strncmp (switches[i].part1, filter, hard_match_len)
4104 && check_live_switch (i, hard_match_len))
4110 /* Otherwise, check for presence of exact name specified. */
4113 for (i = 0; i < n_switches; i++)
4115 if (!strncmp (switches[i].part1, filter, p - filter)
4116 && switches[i].part1[p - filter] == 0
4117 && check_live_switch (i, -1))
4125 /* If it is as desired (present for %{s...}, absent for %{-s...})
4126 then substitute either the switch or the specified
4127 conditional text. */
4128 if (present != negate)
4132 give_switch (i, 0, include_blanks);
4136 if (do_spec_1 (save_string (p + 1, q - p - 2), 0, NULL_PTR) < 0)
4142 /* Here if a %{|...} conditional fails: output a minus sign,
4143 which means "standard output" or "standard input". */
4144 do_spec_1 ("-", 0, NULL_PTR);
4151 /* Return 0 iff switch number SWITCHNUM is obsoleted by a later switch
4152 on the command line. PREFIX_LENGTH is the length of XXX in an {XXX*}
4153 spec, or -1 if either exact match or %* is used.
4155 A -O switch is obsoleted by a later -O switch. A -f, -m, or -W switch
4156 whose value does not begin with "no-" is obsoleted by the same value
4157 with the "no-", similarly for a switch with the "no-" prefix. */
4160 check_live_switch (switchnum, prefix_length)
4164 char *name = switches[switchnum].part1;
4167 /* In the common case of {<at-most-one-letter>*}, a negating
4168 switch would always match, so ignore that case. We will just
4169 send the conflicting switches to the compiler phase. */
4170 if (prefix_length >= 0 && prefix_length <= 1)
4173 /* If we already processed this switch and determined if it was
4174 live or not, return our past determination. */
4175 if (switches[switchnum].live_cond != 0)
4176 return switches[switchnum].live_cond > 0;
4178 /* Now search for duplicate in a manner that depends on the name. */
4182 for (i = switchnum + 1; i < n_switches; i++)
4183 if (switches[i].part1[0] == 'O')
4185 switches[switchnum].valid = 1;
4186 switches[switchnum].live_cond = -1;
4191 case 'W': case 'f': case 'm':
4192 if (! strncmp (name + 1, "no-", 3))
4194 /* We have Xno-YYY, search for XYYY. */
4195 for (i = switchnum + 1; i < n_switches; i++)
4196 if (switches[i].part1[0] == name[0]
4197 && ! strcmp (&switches[i].part1[1], &name[4]))
4199 switches[switchnum].valid = 1;
4200 switches[switchnum].live_cond = -1;
4206 /* We have XYYY, search for Xno-YYY. */
4207 for (i = switchnum + 1; i < n_switches; i++)
4208 if (switches[i].part1[0] == name[0]
4209 && switches[i].part1[1] == 'n'
4210 && switches[i].part1[2] == 'o'
4211 && switches[i].part1[3] == '-'
4212 && !strcmp (&switches[i].part1[4], &name[1]))
4214 switches[switchnum].valid = 1;
4215 switches[switchnum].live_cond = -1;
4222 /* Otherwise the switch is live. */
4223 switches[switchnum].live_cond = 1;
4227 /* Pass a switch to the current accumulating command
4228 in the same form that we received it.
4229 SWITCHNUM identifies the switch; it is an index into
4230 the vector of switches gcc received, which is `switches'.
4231 This cannot fail since it never finishes a command line.
4233 If OMIT_FIRST_WORD is nonzero, then we omit .part1 of the argument.
4235 If INCLUDE_BLANKS is nonzero, then we include blanks before each argument
4239 give_switch (switchnum, omit_first_word, include_blanks)
4241 int omit_first_word;
4244 if (!omit_first_word)
4246 do_spec_1 ("-", 0, NULL_PTR);
4247 do_spec_1 (switches[switchnum].part1, 1, NULL_PTR);
4250 if (switches[switchnum].args != 0)
4253 for (p = switches[switchnum].args; *p; p++)
4256 do_spec_1 (" ", 0, NULL_PTR);
4257 do_spec_1 (*p, 1, NULL_PTR);
4261 do_spec_1 (" ", 0, NULL_PTR);
4262 switches[switchnum].valid = 1;
4265 /* Search for a file named NAME trying various prefixes including the
4266 user's -B prefix and some standard ones.
4267 Return the absolute file name found. If nothing is found, return NAME. */
4275 /* Try multilib_dir if it is defined. */
4276 if (multilib_dir != NULL)
4280 try = (char *) alloca (strlen (multilib_dir) + strlen (name) + 2);
4281 strcpy (try, multilib_dir);
4282 strcat (try, dir_separator_str);
4285 newname = find_a_file (&startfile_prefixes, try, R_OK);
4287 /* If we don't find it in the multi library dir, then fall
4288 through and look for it in the normal places. */
4289 if (newname != NULL)
4293 newname = find_a_file (&startfile_prefixes, name, R_OK);
4294 return newname ? newname : name;
4297 /* Determine whether a directory exists. If LINKER, return 0 for
4298 certain fixed names not needed by the linker. If not LINKER, it is
4299 only important to return 0 if the host machine has a small ARG_MAX
4303 is_directory (path1, path2, linker)
4308 int len1 = strlen (path1);
4309 int len2 = strlen (path2);
4310 char *path = (char *) alloca (3 + len1 + len2);
4314 #ifndef SMALL_ARG_MAX
4319 /* Construct the path from the two parts. Ensure the string ends with "/.".
4320 The resulting path will be a directory even if the given path is a
4322 bcopy (path1, path, len1);
4323 bcopy (path2, path + len1, len2);
4324 cp = path + len1 + len2;
4325 if (cp[-1] != '/' && cp[-1] != DIR_SEPARATOR)
4326 *cp++ = DIR_SEPARATOR;
4330 /* Exclude directories that the linker is known to search. */
4333 && strcmp (path, concat (dir_separator_str, "lib",
4334 dir_separator_str, ".", NULL_PTR)) == 0)
4336 && strcmp (path, concat (dir_separator_str, "usr",
4337 dir_separator_str, "lib",
4338 dir_separator_str, ".", NULL_PTR)) == 0)))
4341 return (stat (path, &st) >= 0 && S_ISDIR (st.st_mode));
4344 /* On fatal signals, delete all the temporary files. */
4347 fatal_error (signum)
4350 signal (signum, SIG_DFL);
4351 delete_failure_queue ();
4352 delete_temp_files ();
4353 /* Get the same signal again, this time not handled,
4354 so its normal effect occurs. */
4355 kill (getpid (), signum);
4366 int linker_was_run = 0;
4367 char *explicit_link_files;
4370 struct user_specs *uptr;
4372 p = argv[0] + strlen (argv[0]);
4373 while (p != argv[0] && p[-1] != '/' && p[-1] != DIR_SEPARATOR) --p;
4376 if (signal (SIGINT, SIG_IGN) != SIG_IGN)
4377 signal (SIGINT, fatal_error);
4379 if (signal (SIGHUP, SIG_IGN) != SIG_IGN)
4380 signal (SIGHUP, fatal_error);
4382 if (signal (SIGTERM, SIG_IGN) != SIG_IGN)
4383 signal (SIGTERM, fatal_error);
4385 if (signal (SIGPIPE, SIG_IGN) != SIG_IGN)
4386 signal (SIGPIPE, fatal_error);
4390 argbuf = (char **) xmalloc (argbuf_length * sizeof (char *));
4392 obstack_init (&obstack);
4394 /* Build multilib_select, et. al from the separate lines that make up each
4395 multilib selection. */
4397 char **q = multilib_raw;
4400 obstack_init (&multilib_obstack);
4401 while ((p = *q++) != (char *) 0)
4402 obstack_grow (&multilib_obstack, p, strlen (p));
4404 obstack_1grow (&multilib_obstack, 0);
4405 multilib_select = obstack_finish (&multilib_obstack);
4407 q = multilib_matches_raw;
4408 while ((p = *q++) != (char *) 0)
4409 obstack_grow (&multilib_obstack, p, strlen (p));
4411 obstack_1grow (&multilib_obstack, 0);
4412 multilib_matches = obstack_finish (&multilib_obstack);
4416 i < sizeof (multilib_defaults_raw) / sizeof (multilib_defaults_raw[0]);
4420 obstack_1grow (&multilib_obstack, ' ');
4421 obstack_grow (&multilib_obstack,
4422 multilib_defaults_raw[i],
4423 strlen (multilib_defaults_raw[i]));
4427 obstack_1grow (&multilib_obstack, 0);
4428 multilib_defaults = obstack_finish (&multilib_obstack);
4431 /* Set up to remember the pathname of gcc and any options
4432 needed for collect. We use argv[0] instead of programname because
4433 we need the complete pathname. */
4434 obstack_init (&collect_obstack);
4435 obstack_grow (&collect_obstack, "COLLECT_GCC=", sizeof ("COLLECT_GCC=")-1);
4436 obstack_grow (&collect_obstack, argv[0], strlen (argv[0])+1);
4437 putenv (obstack_finish (&collect_obstack));
4439 #ifdef INIT_ENVIRONMENT
4440 /* Set up any other necessary machine specific environment variables. */
4441 putenv (INIT_ENVIRONMENT);
4444 /* Choose directory for temp files. */
4446 temp_filename = choose_temp_base ();
4447 temp_filename_length = strlen (temp_filename);
4449 /* Make a table of what switches there are (switches, n_switches).
4450 Make a table of specified input files (infiles, n_infiles).
4451 Decode switches that are handled locally. */
4453 process_command (argc, argv);
4458 /* Build COLLECT_GCC_OPTIONS to have all of the options specified to
4460 obstack_grow (&collect_obstack, "COLLECT_GCC_OPTIONS=",
4461 sizeof ("COLLECT_GCC_OPTIONS=")-1);
4464 for (i = 0; i < n_switches; i++)
4469 obstack_grow (&collect_obstack, " ", 1);
4472 obstack_grow (&collect_obstack, "'-", 2);
4473 q = switches[i].part1;
4474 while ((p = index (q,'\'')))
4476 obstack_grow (&collect_obstack, q, p-q);
4477 obstack_grow (&collect_obstack, "'\\''", 4);
4480 obstack_grow (&collect_obstack, q, strlen (q));
4481 obstack_grow (&collect_obstack, "'", 1);
4483 for (args = switches[i].args; args && *args; args++)
4485 obstack_grow (&collect_obstack, " '", 2);
4487 while ((p = index (q,'\'')))
4489 obstack_grow (&collect_obstack, q, p-q);
4490 obstack_grow (&collect_obstack, "'\\''", 4);
4493 obstack_grow (&collect_obstack, q, strlen (q));
4494 obstack_grow (&collect_obstack, "'", 1);
4497 obstack_grow (&collect_obstack, "\0", 1);
4498 putenv (obstack_finish (&collect_obstack));
4501 /* Initialize the vector of specs to just the default.
4502 This means one element containing 0s, as a terminator. */
4504 compilers = (struct compiler *) xmalloc (sizeof default_compilers);
4505 bcopy ((char *) default_compilers, (char *) compilers,
4506 sizeof default_compilers);
4507 n_compilers = n_default_compilers;
4509 /* Read specs from a file if there is one. */
4511 machine_suffix = concat (spec_machine, dir_separator_str,
4512 spec_version, dir_separator_str, NULL_PTR);
4513 just_machine_suffix = concat (spec_machine, dir_separator_str, NULL_PTR);
4515 specs_file = find_a_file (&startfile_prefixes, "specs", R_OK);
4516 /* Read the specs file unless it is a default one. */
4517 if (specs_file != 0 && strcmp (specs_file, "specs"))
4518 read_specs (specs_file, TRUE);
4522 /* We need to check standard_exec_prefix/just_machine_suffix/specs
4523 for any override of as, ld and libraries. */
4524 specs_file = (char *) alloca (strlen (standard_exec_prefix)
4525 + strlen (just_machine_suffix)
4526 + sizeof ("specs"));
4528 strcpy (specs_file, standard_exec_prefix);
4529 strcat (specs_file, just_machine_suffix);
4530 strcat (specs_file, "specs");
4531 if (access (specs_file, R_OK) == 0)
4532 read_specs (specs_file, TRUE);
4534 /* Process any user specified specs in the order given on the command
4536 for (uptr = user_specs_head; uptr; uptr = uptr->next)
4538 char *filename = find_a_file (&startfile_prefixes, uptr->filename, R_OK);
4539 read_specs (filename ? filename : uptr->filename, FALSE);
4542 /* If not cross-compiling, look for startfiles in the standard places. */
4543 /* The fact that these are done here, after reading the specs file,
4544 means that it cannot be found in these directories.
4545 But that's okay. It should never be there anyway. */
4546 if (*cross_compile == '0')
4548 #ifdef MD_EXEC_PREFIX
4549 add_prefix (&exec_prefixes, md_exec_prefix, "GCC", 0, 0, NULL_PTR);
4550 add_prefix (&startfile_prefixes, md_exec_prefix, "GCC", 0, 0, NULL_PTR);
4553 #ifdef MD_STARTFILE_PREFIX
4554 add_prefix (&startfile_prefixes, md_startfile_prefix, "GCC",
4558 #ifdef MD_STARTFILE_PREFIX_1
4559 add_prefix (&startfile_prefixes, md_startfile_prefix_1, "GCC",
4563 /* If standard_startfile_prefix is relative, base it on
4564 standard_exec_prefix. This lets us move the installed tree
4565 as a unit. If GCC_EXEC_PREFIX is defined, base
4566 standard_startfile_prefix on that as well. */
4567 if (*standard_startfile_prefix == '/'
4568 || *standard_startfile_prefix == DIR_SEPARATOR
4569 || *standard_startfile_prefix == '$'
4571 /* Check for disk name on MS-DOS-based systems. */
4572 || (standard_startfile_prefix[1] == ':'
4573 && (standard_startfile_prefix[2] == DIR_SEPARATOR
4574 || standard_startfile_prefix[2] == '/'))
4577 add_prefix (&startfile_prefixes, standard_startfile_prefix, "BINUTILS",
4581 if (gcc_exec_prefix)
4582 add_prefix (&startfile_prefixes,
4583 concat (gcc_exec_prefix, machine_suffix,
4584 standard_startfile_prefix, NULL_PTR),
4585 NULL_PTR, 0, 0, NULL_PTR);
4586 add_prefix (&startfile_prefixes,
4587 concat (standard_exec_prefix,
4589 standard_startfile_prefix, NULL_PTR),
4590 NULL_PTR, 0, 0, NULL_PTR);
4593 add_prefix (&startfile_prefixes, standard_startfile_prefix_1,
4594 "BINUTILS", 0, 0, NULL_PTR);
4595 add_prefix (&startfile_prefixes, standard_startfile_prefix_2,
4596 "BINUTILS", 0, 0, NULL_PTR);
4597 #if 0 /* Can cause surprises, and one can use -B./ instead. */
4598 add_prefix (&startfile_prefixes, "./", NULL_PTR, 0, 1, NULL_PTR);
4603 if (*standard_startfile_prefix != DIR_SEPARATOR && gcc_exec_prefix)
4604 add_prefix (&startfile_prefixes,
4605 concat (gcc_exec_prefix, machine_suffix,
4606 standard_startfile_prefix, NULL_PTR),
4607 "BINUTILS", 0, 0, NULL_PTR);
4610 /* If we have a GCC_EXEC_PREFIX envvar, modify it for cpp's sake. */
4611 if (gcc_exec_prefix)
4613 char * temp = (char *) xmalloc (strlen (gcc_exec_prefix)
4614 + strlen (spec_version)
4615 + strlen (spec_machine) + 3);
4616 strcpy (temp, gcc_exec_prefix);
4617 strcat (temp, spec_machine);
4618 strcat (temp, dir_separator_str);
4619 strcat (temp, spec_version);
4620 strcat (temp, dir_separator_str);
4621 gcc_exec_prefix = temp;
4624 /* Now we have the specs.
4625 Set the `valid' bits for switches that match anything in any spec. */
4627 validate_all_switches ();
4629 /* Now that we have the switches and the specs, set
4630 the subdirectory based on the options. */
4631 set_multilib_dir ();
4633 /* Warn about any switches that no pass was interested in. */
4635 for (i = 0; i < n_switches; i++)
4636 if (! switches[i].valid)
4637 error ("unrecognized option `-%s'", switches[i].part1);
4639 /* Obey some of the options. */
4641 if (print_search_dirs)
4643 printf ("install: %s%s\n", standard_exec_prefix, machine_suffix);
4644 printf ("programs: %s\n", build_search_list (&exec_prefixes, "", 0));
4645 printf ("libraries: %s\n", build_search_list (&startfile_prefixes, "", 0));
4649 if (print_file_name)
4651 printf ("%s\n", find_file (print_file_name));
4655 if (print_prog_name)
4657 char *newname = find_a_file (&exec_prefixes, print_prog_name, X_OK);
4658 printf ("%s\n", (newname ? newname : print_prog_name));
4662 if (print_multi_lib)
4664 print_multilib_info ();
4668 if (print_multi_directory)
4670 if (multilib_dir == NULL)
4673 printf ("%s\n", multilib_dir);
4681 /* compiler_version is truncated at the first space when initialized
4682 from version string, so truncate version_string at the first space
4683 before comparing. */
4684 for (n = 0; version_string[n]; n++)
4685 if (version_string[n] == ' ')
4688 if (! strncmp (version_string, compiler_version, n)
4689 && compiler_version[n] == 0)
4690 fprintf (stderr, "gcc version %s\n", version_string);
4692 fprintf (stderr, "gcc driver version %s executing gcc version %s\n",
4693 version_string, compiler_version);
4700 fatal ("No input files");
4702 /* Make a place to record the compiler output file names
4703 that correspond to the input files. */
4705 outfiles = (char **) xmalloc (n_infiles * sizeof (char *));
4706 bzero ((char *) outfiles, n_infiles * sizeof (char *));
4708 /* Record which files were specified explicitly as link input. */
4710 explicit_link_files = xmalloc (n_infiles);
4711 bzero (explicit_link_files, n_infiles);
4713 for (i = 0; i < n_infiles; i++)
4715 register struct compiler *cp = 0;
4716 int this_file_error = 0;
4718 /* Tell do_spec what to substitute for %i. */
4720 input_filename = infiles[i].name;
4721 input_filename_length = strlen (input_filename);
4722 input_file_number = i;
4724 /* Use the same thing in %o, unless cp->spec says otherwise. */
4726 outfiles[i] = input_filename;
4728 /* Figure out which compiler from the file's suffix. */
4730 cp = lookup_compiler (infiles[i].name, input_filename_length,
4731 infiles[i].language);
4735 /* Ok, we found an applicable compiler. Run its spec. */
4736 /* First say how much of input_filename to substitute for %b */
4740 if (cp->spec[0][0] == '#')
4741 error ("%s: %s compiler not installed on this system",
4742 input_filename, &cp->spec[0][1]);
4744 input_basename = input_filename;
4745 for (p = input_filename; *p; p++)
4746 if (*p == '/' || *p == DIR_SEPARATOR)
4747 input_basename = p + 1;
4749 /* Find a suffix starting with the last period,
4750 and set basename_length to exclude that suffix. */
4751 basename_length = strlen (input_basename);
4752 p = input_basename + basename_length;
4753 while (p != input_basename && *p != '.') --p;
4754 if (*p == '.' && p != input_basename)
4756 basename_length = p - input_basename;
4757 input_suffix = p + 1;
4763 for (j = 0; j < sizeof cp->spec / sizeof cp->spec[0]; j++)
4765 len += strlen (cp->spec[j]);
4767 p = (char *) xmalloc (len + 1);
4770 for (j = 0; j < sizeof cp->spec / sizeof cp->spec[0]; j++)
4773 strcpy (p + len, cp->spec[j]);
4774 len += strlen (cp->spec[j]);
4777 value = do_spec (p);
4780 this_file_error = 1;
4783 /* If this file's name does not contain a recognized suffix,
4784 record it as explicit linker input. */
4787 explicit_link_files[i] = 1;
4789 /* Clear the delete-on-failure queue, deleting the files in it
4790 if this compilation failed. */
4792 if (this_file_error)
4794 delete_failure_queue ();
4797 /* If this compilation succeeded, don't delete those files later. */
4798 clear_failure_queue ();
4801 /* Run ld to link all the compiler output files. */
4803 if (error_count == 0)
4805 int tmp = execution_count;
4807 /* We'll use ld if we can't find collect2. */
4808 if (! strcmp (linker_name_spec, "collect2"))
4810 char *s = find_a_file (&exec_prefixes, "collect2", X_OK);
4812 linker_name_spec = "ld";
4814 /* Rebuild the COMPILER_PATH and LIBRARY_PATH environment variables
4816 putenv_from_prefixes (&exec_prefixes, "COMPILER_PATH=");
4817 putenv_from_prefixes (&startfile_prefixes, "LIBRARY_PATH=");
4819 value = do_spec (link_command_spec);
4822 linker_was_run = (tmp != execution_count);
4825 /* Warn if a -B option was specified but the prefix was never used. */
4826 unused_prefix_warnings (&exec_prefixes);
4827 unused_prefix_warnings (&startfile_prefixes);
4829 /* If options said don't run linker,
4830 complain about input files to be given to the linker. */
4832 if (! linker_was_run && error_count == 0)
4833 for (i = 0; i < n_infiles; i++)
4834 if (explicit_link_files[i])
4835 error ("%s: linker input file unused since linking not done",
4838 /* Delete some or all of the temporary files we made. */
4841 delete_failure_queue ();
4842 delete_temp_files ();
4844 exit (error_count > 0 ? (signal_count ? 2 : 1) : 0);
4849 /* Find the proper compilation spec for the file name NAME,
4850 whose length is LENGTH. LANGUAGE is the specified language,
4851 or 0 if this file is to be passed to the linker. */
4853 static struct compiler *
4854 lookup_compiler (name, length, language)
4859 struct compiler *cp;
4861 /* If this was specified by the user to be a linker input, indicate that. */
4862 if (language != 0 && language[0] == '*')
4865 /* Otherwise, look for the language, if one is spec'd. */
4868 for (cp = compilers + n_compilers - 1; cp >= compilers; cp--)
4869 if (cp->suffix[0] == '@' && !strcmp (cp->suffix + 1, language))
4872 error ("language %s not recognized", language);
4876 /* Look for a suffix. */
4877 for (cp = compilers + n_compilers - 1; cp >= compilers; cp--)
4879 if (/* The suffix `-' matches only the file name `-'. */
4880 (!strcmp (cp->suffix, "-") && !strcmp (name, "-"))
4881 || (strlen (cp->suffix) < length
4882 /* See if the suffix matches the end of NAME. */
4884 && ((!strcmp (cp->suffix,
4885 name + length - strlen (cp->suffix))
4886 || !strpbrk (cp->suffix, "ABCDEFGHIJKLMNOPQRSTUVWXYZ"))
4887 && !strcasecmp (cp->suffix,
4888 name + length - strlen (cp->suffix)))
4890 && !strcmp (cp->suffix,
4891 name + length - strlen (cp->suffix))
4895 if (cp->spec[0][0] == '@')
4897 struct compiler *new;
4899 /* An alias entry maps a suffix to a language.
4900 Search for the language; pass 0 for NAME and LENGTH
4901 to avoid infinite recursion if language not found.
4902 Construct the new compiler spec. */
4903 language = cp->spec[0] + 1;
4904 new = (struct compiler *) xmalloc (sizeof (struct compiler));
4905 new->suffix = cp->suffix;
4906 bcopy ((char *) lookup_compiler (NULL_PTR, 0, language)->spec,
4907 (char *) new->spec, sizeof new->spec);
4911 /* A non-alias entry: return it. */
4923 register char *value = (char *) malloc (size);
4925 fatal ("virtual memory exhausted");
4930 xrealloc (ptr, size)
4934 register char *value = (char *) realloc (ptr, size);
4936 fatal ("virtual memory exhausted");
4940 /* This function is based on the one in libiberty. */
4943 concat VPROTO((char *first, ...))
4945 register int length;
4946 register char *newstr;
4954 /* First compute the size of the result and get sufficient memory. */
4956 VA_START (args, first);
4958 first = va_arg (args, char *);
4966 length += strlen (arg);
4967 arg = va_arg (args, char *);
4970 newstr = (char *) xmalloc (length + 1);
4973 /* Now copy the individual pieces to the result string. */
4975 VA_START (args, first);
4977 first = va_arg (args, char *);
4986 arg = va_arg (args, char *);
4995 save_string (s, len)
4999 register char *result = xmalloc (len + 1);
5001 bcopy (s, result, len);
5007 pfatal_with_name (name)
5010 fatal ("%s: %s", name, my_strerror (errno));
5014 perror_with_name (name)
5017 error ("%s: %s", name, my_strerror (errno));
5021 pfatal_pexecute (errmsg_fmt, errmsg_arg)
5025 int save_errno = errno;
5029 /* Space for trailing '\0' is in %s. */
5030 char *msg = xmalloc (strlen (errmsg_fmt) + strlen (errmsg_arg));
5031 sprintf (msg, errmsg_fmt, errmsg_arg);
5035 fatal ("%s: %s", errmsg_fmt, my_strerror (save_errno));
5038 /* More 'friendly' abort that prints the line and file.
5039 config.h can #define abort fancy_abort if you like that sort of thing. */
5044 fatal ("Internal gcc abort.");
5049 /* Output an error message and exit */
5052 fatal VPROTO((char *format, ...))
5059 VA_START (ap, format);
5062 format = va_arg (ap, char *);
5065 fprintf (stderr, "%s: ", programname);
5066 vfprintf (stderr, format, ap);
5068 fprintf (stderr, "\n");
5069 delete_temp_files ();
5074 error VPROTO((char *format, ...))
5081 VA_START (ap, format);
5084 format = va_arg (ap, char *);
5087 fprintf (stderr, "%s: ", programname);
5088 vfprintf (stderr, format, ap);
5091 fprintf (stderr, "\n");
5094 #else /* not HAVE_VPRINTF */
5097 fatal (msg, arg1, arg2)
5098 char *msg, *arg1, *arg2;
5100 error (msg, arg1, arg2);
5101 delete_temp_files ();
5106 error (msg, arg1, arg2)
5107 char *msg, *arg1, *arg2;
5109 fprintf (stderr, "%s: ", programname);
5110 fprintf (stderr, msg, arg1, arg2);
5111 fprintf (stderr, "\n");
5114 #endif /* not HAVE_VPRINTF */
5118 validate_all_switches ()
5120 struct compiler *comp;
5123 struct spec_list *spec;
5125 for (comp = compilers; comp->spec[0]; comp++)
5128 for (i = 0; i < sizeof comp->spec / sizeof comp->spec[0] && comp->spec[i]; i++)
5132 if (c == '%' && *p == '{')
5133 /* We have a switch spec. */
5134 validate_switches (p + 1);
5138 /* look through the linked list of specs read from the specs file */
5139 for (spec = specs; spec ; spec = spec->next)
5141 p = *(spec->ptr_spec);
5143 if (c == '%' && *p == '{')
5144 /* We have a switch spec. */
5145 validate_switches (p + 1);
5148 p = link_command_spec;
5150 if (c == '%' && *p == '{')
5151 /* We have a switch spec. */
5152 validate_switches (p + 1);
5155 /* Look at the switch-name that comes after START
5156 and mark as valid all supplied switches that match it. */
5159 validate_switches (start)
5162 register char *p = start;
5177 while (*p != ':' && *p != '}') p++;
5181 else if (p[-1] == '*')
5183 /* Mark all matching switches as valid. */
5185 for (i = 0; i < n_switches; i++)
5186 if (!strncmp (switches[i].part1, filter, p - filter))
5187 switches[i].valid = 1;
5191 /* Mark an exact matching switch as valid. */
5192 for (i = 0; i < n_switches; i++)
5194 if (!strncmp (switches[i].part1, filter, p - filter)
5195 && switches[i].part1[p - filter] == 0)
5196 switches[i].valid = 1;
5201 /* Check whether a particular argument was used. The first time we
5202 canonicalize the switches to keep only the ones we care about. */
5216 static struct mswitchstr *mswitches;
5217 static int n_mswitches;
5222 struct mswitchstr *matches;
5226 /* Break multilib_matches into the component strings of string and replacement
5228 for (q = multilib_matches; *q != '\0'; q++)
5232 matches = (struct mswitchstr *) alloca ((sizeof (struct mswitchstr)) * cnt);
5234 q = multilib_matches;
5245 matches[i].len = q - matches[i].str;
5247 matches[i].replace = ++q;
5248 while (*q != ';' && *q != '\0')
5254 matches[i].rep_len = q - matches[i].replace;
5262 /* Now build a list of the replacement string for switches that we care
5263 about. Make sure we allocate at least one entry. This prevents
5264 xmalloc from calling fatal, and prevents us from re-executing this
5267 = (struct mswitchstr *) xmalloc ((sizeof (struct mswitchstr))
5268 * (n_switches ? n_switches : 1));
5269 for (i = 0; i < n_switches; i++)
5271 int xlen = strlen (switches[i].part1);
5272 for (j = 0; j < cnt; j++)
5273 if (xlen == matches[j].len && ! strcmp (switches[i].part1, matches[j].str))
5275 mswitches[n_mswitches].str = matches[j].replace;
5276 mswitches[n_mswitches].len = matches[j].rep_len;
5277 mswitches[n_mswitches].replace = (char *)0;
5278 mswitches[n_mswitches].rep_len = 0;
5285 for (i = 0; i < n_mswitches; i++)
5286 if (len == mswitches[i].len && ! strncmp (p, mswitches[i].str, len))
5293 default_arg (p, len)
5299 for (start = multilib_defaults; *start != '\0'; start = end+1)
5301 while (*start == ' ' || *start == '\t')
5307 for (end = start+1; *end != ' ' && *end != '\t' && *end != '\0'; end++)
5310 if ((end - start) == len && strncmp (p, start, len) == 0)
5320 /* Work out the subdirectory to use based on the
5321 options. The format of multilib_select is a list of elements.
5322 Each element is a subdirectory name followed by a list of options
5323 followed by a semicolon. gcc will consider each line in turn. If
5324 none of the options beginning with an exclamation point are
5325 present, and all of the other options are present, that
5326 subdirectory will be used. */
5331 char *p = multilib_select;
5333 char *this_path, *this_arg;
5339 /* Ignore newlines. */
5346 /* Get the initial path. */
5354 this_path_len = p - this_path;
5356 /* Check the arguments. */
5371 while (*p != ' ' && *p != ';')
5378 if (*this_arg != '!')
5386 /* If this is a default argument, we can just ignore it.
5387 This is true even if this_arg begins with '!'. Beginning
5388 with '!' does not mean that this argument is necessarily
5389 inappropriate for this library: it merely means that
5390 there is a more specific library which uses this
5391 argument. If this argument is a default, we need not
5392 consider that more specific library. */
5393 if (! default_arg (this_arg, p - this_arg))
5395 ok = used_arg (this_arg, p - this_arg);
5406 if (this_path_len != 1
5407 || this_path[0] != '.')
5409 multilib_dir = xmalloc (this_path_len + 1);
5410 strncpy (multilib_dir, this_path, this_path_len);
5411 multilib_dir[this_path_len] = '\0';
5420 /* Print out the multiple library subdirectory selection
5421 information. This prints out a series of lines. Each line looks
5422 like SUBDIRECTORY;@OPTION@OPTION, with as many options as is
5423 required. Only the desired options are printed out, the negative
5424 matches. The options are print without a leading dash. There are
5425 no spaces to make it easy to use the information in the shell.
5426 Each subdirectory is printed only once. This assumes the ordering
5427 generated by the genmultilib script. */
5430 print_multilib_info ()
5432 char *p = multilib_select;
5433 char *last_path = 0, *this_path;
5435 int last_path_len = 0;
5439 /* Ignore newlines. */
5446 /* Get the initial path. */
5455 /* If this is a duplicate, skip it. */
5456 skip = (last_path != 0 && p - this_path == last_path_len
5457 && ! strncmp (last_path, this_path, last_path_len));
5459 last_path = this_path;
5460 last_path_len = p - this_path;
5462 /* If this directory requires any default arguments, we can skip
5463 it. We will already have printed a directory identical to
5464 this one which does not require that default argument. */
5482 while (*q != ' ' && *q != ';')
5490 && default_arg (arg, q - arg))
5505 for (p1 = last_path; p1 < p; p1++)
5524 use_arg = *p != '!';
5529 while (*p != ' ' && *p != ';')
5544 /* If there are extra options, print them now */
5545 if (multilib_extra && *multilib_extra)
5547 int print_at = TRUE;
5550 for (q = multilib_extra; *q != '\0'; q++)