comparison gcc/gcc.c @ 57:326d9e06c2e3

modify c-parser.c
author ryoma <e075725@ie.u-ryukyu.ac.jp>
date Mon, 15 Feb 2010 00:54:17 +0900
parents 9907f3135723 77e2b8dfacca
children 1b10fe6932e1
comparison
equal deleted inserted replaced
54:f62c169bbc24 57:326d9e06c2e3
82 #include "prefix.h" 82 #include "prefix.h"
83 #include "gcc.h" 83 #include "gcc.h"
84 #include "flags.h" 84 #include "flags.h"
85 #include "opts.h" 85 #include "opts.h"
86 86
87 #ifdef HAVE_MMAP_FILE
88 # include <sys/mman.h>
89 # ifdef HAVE_MINCORE
90 /* This is on Solaris. */
91 # include <sys/types.h>
92 # endif
93 #endif
94
95 #ifndef MAP_FAILED
96 # define MAP_FAILED ((void *)-1)
97 #endif
98
87 /* By default there is no special suffix for target executables. */ 99 /* By default there is no special suffix for target executables. */
88 /* FIXME: when autoconf is fixed, remove the host check - dj */ 100 /* FIXME: when autoconf is fixed, remove the host check - dj */
89 #if defined(TARGET_EXECUTABLE_SUFFIX) && defined(HOST_EXECUTABLE_SUFFIX) 101 #if defined(TARGET_EXECUTABLE_SUFFIX) && defined(HOST_EXECUTABLE_SUFFIX)
90 #define HAVE_TARGET_EXECUTABLE_SUFFIX 102 #define HAVE_TARGET_EXECUTABLE_SUFFIX
91 #endif 103 #endif
166 178
167 /* Flag saying to print the command line options understood by gcc and its 179 /* Flag saying to print the command line options understood by gcc and its
168 sub-processes. */ 180 sub-processes. */
169 181
170 static int print_help_list; 182 static int print_help_list;
183
184 /* Flag saying to print the version of gcc and its sub-processes. */
185
186 static int print_version;
171 187
172 /* Flag saying to print the sysroot suffix used for searching for 188 /* Flag saying to print the sysroot suffix used for searching for
173 headers. */ 189 headers. */
174 190
175 static int print_sysroot_headers_suffix; 191 static int print_sysroot_headers_suffix;
192 /* Flag indicating whether we should report subprocess execution times 208 /* Flag indicating whether we should report subprocess execution times
193 (if this is supported by the system - see pexecute.c). */ 209 (if this is supported by the system - see pexecute.c). */
194 210
195 static int report_times; 211 static int report_times;
196 212
213 /* Whether we should report subprocess execution times to a file. */
214
215 FILE *report_times_to_file = NULL;
216
197 /* Nonzero means place this string before uses of /, so that include 217 /* Nonzero means place this string before uses of /, so that include
198 and library files can be found in an alternate location. */ 218 and library files can be found in an alternate location. */
199 219
200 #ifdef TARGET_SYSTEM_ROOT 220 #ifdef TARGET_SYSTEM_ROOT
201 static const char *target_system_root = TARGET_SYSTEM_ROOT; 221 static const char *target_system_root = TARGET_SYSTEM_ROOT;
216 static const char *target_sysroot_hdrs_suffix = 0; 236 static const char *target_sysroot_hdrs_suffix = 0;
217 237
218 /* Nonzero means write "temp" files in source directory 238 /* Nonzero means write "temp" files in source directory
219 and use the source file's name in them, and don't delete them. */ 239 and use the source file's name in them, and don't delete them. */
220 240
221 static int save_temps_flag; 241 static enum save_temps {
242 SAVE_TEMPS_NONE, /* no -save-temps */
243 SAVE_TEMPS_CWD, /* -save-temps in current directory */
244 SAVE_TEMPS_OBJ /* -save-temps in object directory */
245 } save_temps_flag;
246
247 /* Output file to use to get the object directory for -save-temps=obj */
248 static char *save_temps_prefix = 0;
249 static size_t save_temps_length = 0;
222 250
223 /* Nonzero means pass multiple source files to the compiler at one time. */ 251 /* Nonzero means pass multiple source files to the compiler at one time. */
224 252
225 static int combine_flag = 0; 253 static int combine_flag = 0;
226 254
254 282
255 /* Information on how to alter the target name based on a command-line 283 /* Information on how to alter the target name based on a command-line
256 switch. The only case we support now is simply appending or deleting a 284 switch. The only case we support now is simply appending or deleting a
257 string to or from the end of the first part of the configuration name. */ 285 string to or from the end of the first part of the configuration name. */
258 286
287 enum add_del {ADD, DELETE};
288
259 static const struct modify_target 289 static const struct modify_target
260 { 290 {
261 const char *const sw; 291 const char *const sw;
262 const enum add_del {ADD, DELETE} add_del; 292 const enum add_del add_del;
263 const char *const str; 293 const char *const str;
264 } 294 }
265 modify_target[] = MODIFY_TARGET_NAME; 295 modify_target[] = MODIFY_TARGET_NAME;
266 #endif 296 #endif
267 297
371 static const char *if_exists_else_spec_function (int, const char **); 401 static const char *if_exists_else_spec_function (int, const char **);
372 static const char *replace_outfile_spec_function (int, const char **); 402 static const char *replace_outfile_spec_function (int, const char **);
373 static const char *version_compare_spec_function (int, const char **); 403 static const char *version_compare_spec_function (int, const char **);
374 static const char *include_spec_function (int, const char **); 404 static const char *include_spec_function (int, const char **);
375 static const char *print_asm_header_spec_function (int, const char **); 405 static const char *print_asm_header_spec_function (int, const char **);
406 static const char *compare_debug_dump_opt_spec_function (int, const char **);
407 static const char *compare_debug_self_opt_spec_function (int, const char **);
408 static const char *compare_debug_auxbase_opt_spec_function (int, const char **);
376 409
377 /* The Specs Language 410 /* The Specs Language
378 411
379 Specs are strings containing lines, each of which (if not blank) 412 Specs are strings containing lines, each of which (if not blank)
380 is made up of a program name, and arguments separated by spaces. 413 is made up of a program name, and arguments separated by spaces.
391 424
392 %% substitute one % into the program name or argument. 425 %% substitute one % into the program name or argument.
393 %i substitute the name of the input file being processed. 426 %i substitute the name of the input file being processed.
394 %b substitute the basename of the input file being processed. 427 %b substitute the basename of the input file being processed.
395 This is the substring up to (and not including) the last period 428 This is the substring up to (and not including) the last period
396 and not including the directory. 429 and not including the directory unless -save-temps was specified
430 to put temporaries in a different location.
397 %B same as %b, but include the file suffix (text after the last period). 431 %B same as %b, but include the file suffix (text after the last period).
398 %gSUFFIX 432 %gSUFFIX
399 substitute a file name that has suffix SUFFIX and is chosen 433 substitute a file name that has suffix SUFFIX and is chosen
400 once per compilation, and mark the argument a la %d. To reduce 434 once per compilation, and mark the argument a la %d. To reduce
401 exposure to denial-of-service attacks, the file name is now 435 exposure to denial-of-service attacks, the file name is now
434 %.SUFFIX 468 %.SUFFIX
435 substitutes .SUFFIX for the suffixes of a matched switch's args when 469 substitutes .SUFFIX for the suffixes of a matched switch's args when
436 it is subsequently output with %*. SUFFIX is terminated by the next 470 it is subsequently output with %*. SUFFIX is terminated by the next
437 space or %. 471 space or %.
438 %d marks the argument containing or following the %d as a 472 %d marks the argument containing or following the %d as a
439 temporary file name, so that that file will be deleted if CC exits 473 temporary file name, so that that file will be deleted if GCC exits
440 successfully. Unlike %g, this contributes no text to the argument. 474 successfully. Unlike %g, this contributes no text to the argument.
441 %w marks the argument containing or following the %w as the 475 %w marks the argument containing or following the %w as the
442 "output file" of this compilation. This puts the argument 476 "output file" of this compilation. This puts the argument
443 into the sequence of arguments that %o will substitute later. 477 into the sequence of arguments that %o will substitute later.
444 %V indicates that this compilation produces no "output file". 478 %V indicates that this compilation produces no "output file".
503 Call the named function FUNCTION, passing it ARGS. ARGS is 537 Call the named function FUNCTION, passing it ARGS. ARGS is
504 first processed as a nested spec string, then split into an 538 first processed as a nested spec string, then split into an
505 argument vector in the usual fashion. The function returns 539 argument vector in the usual fashion. The function returns
506 a string which is processed as if it had appeared literally 540 a string which is processed as if it had appeared literally
507 as part of the current spec. 541 as part of the current spec.
508 %{S} substitutes the -S switch, if that switch was given to CC. 542 %{S} substitutes the -S switch, if that switch was given to GCC.
509 If that switch was not specified, this substitutes nothing. 543 If that switch was not specified, this substitutes nothing.
510 Here S is a metasyntactic variable. 544 Here S is a metasyntactic variable.
511 %{S*} substitutes all the switches specified to CC whose names start 545 %{S*} substitutes all the switches specified to GCC whose names start
512 with -S. This is used for -o, -I, etc; switches that take 546 with -S. This is used for -o, -I, etc; switches that take
513 arguments. CC considers `-o foo' as being one switch whose 547 arguments. GCC considers `-o foo' as being one switch whose
514 name starts with `o'. %{o*} would substitute this text, 548 name starts with `o'. %{o*} would substitute this text,
515 including the space; thus, two arguments would be generated. 549 including the space; thus, two arguments would be generated.
516 %{S*&T*} likewise, but preserve order of S and T options (the order 550 %{S*&T*} likewise, but preserve order of S and T options (the order
517 of S and T in the spec is not significant). Can be any number 551 of S and T in the spec is not significant). Can be any number
518 of ampersand-separated variables; for each the wild card is 552 of ampersand-separated variables; for each the wild card is
519 optional. Useful for CPP as %{D*&U*&A*}. 553 optional. Useful for CPP as %{D*&U*&A*}.
520 554
521 %{S:X} substitutes X, if the -S switch was given to CC. 555 %{S:X} substitutes X, if the -S switch was given to GCC.
522 %{!S:X} substitutes X, if the -S switch was NOT given to CC. 556 %{!S:X} substitutes X, if the -S switch was NOT given to GCC.
523 %{S*:X} substitutes X if one or more switches whose names start 557 %{S*:X} substitutes X if one or more switches whose names start
524 with -S was given to CC. Normally X is substituted only 558 with -S was given to GCC. Normally X is substituted only
525 once, no matter how many such switches appeared. However, 559 once, no matter how many such switches appeared. However,
526 if %* appears somewhere in X, then X will be substituted 560 if %* appears somewhere in X, then X will be substituted
527 once for each matching switch, with the %* replaced by the 561 once for each matching switch, with the %* replaced by the
528 part of that switch that matched the '*'. 562 part of that switch that matched the '*'.
529 %{.S:X} substitutes X, if processing a file with suffix S. 563 %{.S:X} substitutes X, if processing a file with suffix S.
530 %{!.S:X} substitutes X, if NOT processing a file with suffix S. 564 %{!.S:X} substitutes X, if NOT processing a file with suffix S.
531 %{,S:X} substitutes X, if processing a file which will use spec S. 565 %{,S:X} substitutes X, if processing a file which will use spec S.
532 %{!,S:X} substitutes X, if NOT processing a file which will use spec S. 566 %{!,S:X} substitutes X, if NOT processing a file which will use spec S.
533 567
534 %{S|T:X} substitutes X if either -S or -T was given to CC. This may be 568 %{S|T:X} substitutes X if either -S or -T was given to GCC. This may be
535 combined with '!', '.', ',', and '*' as above binding stronger 569 combined with '!', '.', ',', and '*' as above binding stronger
536 than the OR. 570 than the OR.
537 If %* appears in X, all of the alternatives must be starred, and 571 If %* appears in X, all of the alternatives must be starred, and
538 only the first matching alternative is substituted. 572 only the first matching alternative is substituted.
539 %{S:X; if S was given to CC, substitutes X; 573 %{S:X; if S was given to GCC, substitutes X;
540 T:Y; else if T was given to CC, substitutes Y; 574 T:Y; else if T was given to GCC, substitutes Y;
541 :D} else substitutes D. There can be as many clauses as you need. 575 :D} else substitutes D. There can be as many clauses as you need.
542 This may be combined with '.', '!', ',', '|', and '*' as above. 576 This may be combined with '.', '!', ',', '|', and '*' as above.
543 577
544 %(Spec) processes a specification defined in a specs file as *Spec: 578 %(Spec) processes a specification defined in a specs file as *Spec:
545 %[Spec] as above, but put __ around -D arguments 579 %[Spec] as above, but put __ around -D arguments
559 593
560 The character | at the beginning of the predicate text is used to indicate 594 The character | at the beginning of the predicate text is used to indicate
561 that a command should be piped to the following command, but only if -pipe 595 that a command should be piped to the following command, but only if -pipe
562 is specified. 596 is specified.
563 597
564 Note that it is built into CC which switches take arguments and which 598 Note that it is built into GCC which switches take arguments and which
565 do not. You might think it would be useful to generalize this to 599 do not. You might think it would be useful to generalize this to
566 allow each compiler's spec to say which switches take arguments. But 600 allow each compiler's spec to say which switches take arguments. But
567 this cannot be done in a consistent fashion. CC cannot even decide 601 this cannot be done in a consistent fashion. GCC cannot even decide
568 which input files have been specified without knowing which switches 602 which input files have been specified without knowing which switches
569 take arguments, and it must know which input files to compile in order 603 take arguments, and it must know which input files to compile in order
570 to tell which compilers to run. 604 to tell which compilers to run.
571 605
572 CC also knows implicitly that arguments starting in `-l' are to be 606 GCC also knows implicitly that arguments starting in `-l' are to be
573 treated as compiler output files, and passed to the linker in their 607 treated as compiler output files, and passed to the linker in their
574 proper position among the other output files. */ 608 proper position among the other output files. */
575 609
576 /* Define the macros used for specs %a, %l, %L, %S, %C, %1. */ 610 /* Define the macros used for specs %a, %l, %L, %S, %C, %1. */
577 611
648 #define STARTFILE_SPEC \ 682 #define STARTFILE_SPEC \
649 "%{!shared:%{pg:gcrt0%O%s}%{!pg:%{p:mcrt0%O%s}%{!p:crt0%O%s}}}" 683 "%{!shared:%{pg:gcrt0%O%s}%{!pg:%{p:mcrt0%O%s}%{!p:crt0%O%s}}}"
650 #endif 684 #endif
651 685
652 /* config.h can define SWITCHES_NEED_SPACES to control which options 686 /* config.h can define SWITCHES_NEED_SPACES to control which options
653 require spaces between the option and the argument. */ 687 require spaces between the option and the argument.
688
689 We define SWITCHES_NEED_SPACES to include "o" by default. This
690 causes "-ofoo.o" to be split into "-o foo.o" during the initial
691 processing of the command-line, before being seen by the specs
692 machinery. This makes sure we record "foo.o" as the temporary file
693 to be deleted in the case of error, rather than "-ofoo.o". */
654 #ifndef SWITCHES_NEED_SPACES 694 #ifndef SWITCHES_NEED_SPACES
655 #define SWITCHES_NEED_SPACES "" 695 #define SWITCHES_NEED_SPACES "o"
656 #endif 696 #endif
657 697
658 /* config.h can define ENDFILE_SPEC to override the default crtn files. */ 698 /* config.h can define ENDFILE_SPEC to override the default crtn files. */
659 #ifndef ENDFILE_SPEC 699 #ifndef ENDFILE_SPEC
660 #define ENDFILE_SPEC "" 700 #define ENDFILE_SPEC ""
715 #else 755 #else
716 #define LINK_PIE_SPEC "%{pie:} " 756 #define LINK_PIE_SPEC "%{pie:} "
717 #endif 757 #endif
718 #endif 758 #endif
719 759
760 #ifndef LINK_BUILDID_SPEC
761 # if defined(HAVE_LD_BUILDID) && defined(ENABLE_LD_BUILDID)
762 # define LINK_BUILDID_SPEC "%{!r:--build-id} "
763 # endif
764 #endif
765
766
720 /* -u* was put back because both BSD and SysV seem to support it. */ 767 /* -u* was put back because both BSD and SysV seem to support it. */
721 /* %{static:} simply prevents an error message if the target machine 768 /* %{static:} simply prevents an error message if the target machine
722 doesn't handle -static. */ 769 doesn't handle -static. */
723 /* We want %{T*} after %{L*} and %D so that it can be used to specify linker 770 /* We want %{T*} after %{L*} and %D so that it can be used to specify linker
724 scripts which exist in user specified directories, or in standard 771 scripts which exist in user specified directories, or in standard
725 directories. */ 772 directories. */
773 /* We pass any -flto and -fwhopr flags on to the linker, which is expected
774 to understand them. In practice, this means it had better be collect2. */
726 #ifndef LINK_COMMAND_SPEC 775 #ifndef LINK_COMMAND_SPEC
727 #define LINK_COMMAND_SPEC "\ 776 #define LINK_COMMAND_SPEC "\
728 %{!fsyntax-only:%{!c:%{!M:%{!MM:%{!E:%{!S:\ 777 %{!fsyntax-only:%{!c:%{!M:%{!MM:%{!E:%{!S:\
729 %(linker) %l " LINK_PIE_SPEC "%X %{o*} %{A} %{d} %{e*} %{m} %{N} %{n} %{r}\ 778 %(linker) \
779 %{fuse-linker-plugin: \
780 -plugin %(linker_plugin_file) \
781 -plugin-opt=%(lto_wrapper) \
782 -plugin-opt=%(lto_gcc) \
783 %{static|static-libgcc:-plugin-opt=-pass-through=%(lto_libgcc)} \
784 %{static:-plugin-opt=-pass-through=-lc} \
785 %{O*:-plugin-opt=-O%*} \
786 %{w:-plugin-opt=-w} \
787 %{f*:-plugin-opt=-f%*} \
788 } \
789 %{flto} %{fwhopr} %l " LINK_PIE_SPEC \
790 "%X %{o*} %{A} %{d} %{e*} %{m} %{N} %{n} %{r}\
730 %{s} %{t} %{u*} %{x} %{z} %{Z} %{!A:%{!nostdlib:%{!nostartfiles:%S}}}\ 791 %{s} %{t} %{u*} %{x} %{z} %{Z} %{!A:%{!nostdlib:%{!nostartfiles:%S}}}\
731 %{static:} %{L*} %(mfwrap) %(link_libgcc) %o\ 792 %{static:} %{L*} %(mfwrap) %(link_libgcc) %o\
732 %{fopenmp|ftree-parallelize-loops=*:%:include(libgomp.spec)%(link_gomp)} %(mflib)\ 793 %{fopenmp|ftree-parallelize-loops=*:%:include(libgomp.spec)%(link_gomp)} %(mflib)\
733 %{fprofile-arcs|fprofile-generate|coverage:-lgcov}\ 794 %{fprofile-arcs|fprofile-generate*|coverage:-lgcov}\
734 %{!nostdlib:%{!nodefaultlibs:%(link_ssp) %(link_gcc_c_sequence)}}\ 795 %{!nostdlib:%{!nodefaultlibs:%(link_ssp) %(link_gcc_c_sequence)}}\
735 %{!A:%{!nostdlib:%{!nostartfiles:%E}}} %{T*} }}}}}}" 796 %{!A:%{!nostdlib:%{!nostartfiles:%E}}} %{T*} }}}}}}"
736 #endif 797 #endif
737 798
738 #ifndef LINK_LIBGCC_SPEC 799 #ifndef LINK_LIBGCC_SPEC
772 static const char *libgcc_spec = LIBGCC_SPEC; 833 static const char *libgcc_spec = LIBGCC_SPEC;
773 static const char *endfile_spec = ENDFILE_SPEC; 834 static const char *endfile_spec = ENDFILE_SPEC;
774 static const char *startfile_spec = STARTFILE_SPEC; 835 static const char *startfile_spec = STARTFILE_SPEC;
775 static const char *switches_need_spaces = SWITCHES_NEED_SPACES; 836 static const char *switches_need_spaces = SWITCHES_NEED_SPACES;
776 static const char *linker_name_spec = LINKER_NAME; 837 static const char *linker_name_spec = LINKER_NAME;
838 static const char *linker_plugin_file_spec = "";
839 static const char *lto_wrapper_spec = "";
840 static const char *lto_gcc_spec = "";
841 static const char *lto_libgcc_spec = "";
777 static const char *link_command_spec = LINK_COMMAND_SPEC; 842 static const char *link_command_spec = LINK_COMMAND_SPEC;
778 static const char *link_libgcc_spec = LINK_LIBGCC_SPEC; 843 static const char *link_libgcc_spec = LINK_LIBGCC_SPEC;
779 static const char *startfile_prefix_spec = STARTFILE_PREFIX_SPEC; 844 static const char *startfile_prefix_spec = STARTFILE_PREFIX_SPEC;
780 static const char *sysroot_spec = SYSROOT_SPEC; 845 static const char *sysroot_spec = SYSROOT_SPEC;
781 static const char *sysroot_suffix_spec = SYSROOT_SUFFIX_SPEC; 846 static const char *sysroot_suffix_spec = SYSROOT_SUFFIX_SPEC;
815 options used to set target flags. Those special target flags settings may 880 options used to set target flags. Those special target flags settings may
816 in turn cause preprocessor symbols to be defined specially. */ 881 in turn cause preprocessor symbols to be defined specially. */
817 static const char *cpp_options = 882 static const char *cpp_options =
818 "%(cpp_unique_options) %1 %{m*} %{std*&ansi&trigraphs} %{W*&pedantic*} %{w}\ 883 "%(cpp_unique_options) %1 %{m*} %{std*&ansi&trigraphs} %{W*&pedantic*} %{w}\
819 %{f*} %{g*:%{!g0:%{g*} %{!fno-working-directory:-fworking-directory}}} %{O*}\ 884 %{f*} %{g*:%{!g0:%{g*} %{!fno-working-directory:-fworking-directory}}} %{O*}\
820 %{undef} %{save-temps:-fpch-preprocess}"; 885 %{undef} %{save-temps*:-fpch-preprocess}";
821 886
822 /* This contains cpp options which are not passed when the preprocessor 887 /* This contains cpp options which are not passed when the preprocessor
823 output will be used by another program. */ 888 output will be used by another program. */
824 static const char *cpp_debug_options = "%{d*}"; 889 static const char *cpp_debug_options = "%{d*}";
825 890
826 /* NB: This is shared amongst all front-ends, except for Ada. */ 891 /* NB: This is shared amongst all front-ends, except for Ada. */
827 static const char *cc1_options = 892 static const char *cc1_options =
828 "%{pg:%{fomit-frame-pointer:%e-pg and -fomit-frame-pointer are incompatible}}\ 893 "%{pg:%{fomit-frame-pointer:%e-pg and -fomit-frame-pointer are incompatible}}\
829 %1 %{!Q:-quiet} -dumpbase %B %{d*} %{m*} %{a*}\ 894 %1 %{!Q:-quiet} -dumpbase %B %{d*} %{m*} %{a*}\
830 %{c|S:%{o*:-auxbase-strip %*}%{!o*:-auxbase %b}}%{!c:%{!S:-auxbase %b}}\ 895 %{fcompare-debug-second:%:compare-debug-auxbase-opt(%b)} \
896 %{!fcompare-debug-second:%{c|S:%{o*:-auxbase-strip %*}%{!o*:-auxbase %b}}}%{!c:%{!S:-auxbase %b}} \
831 %{g*} %{O*} %{W*&pedantic*} %{w} %{std*&ansi&trigraphs}\ 897 %{g*} %{O*} %{W*&pedantic*} %{w} %{std*&ansi&trigraphs}\
832 %{v:-version} %{pg:-p} %{p} %{f*} %{undef}\ 898 %{v:-version} %{pg:-p} %{p} %{f*} %{undef}\
833 %{Qn:-fno-ident} %{--help:--help}\ 899 %{Qn:-fno-ident} %{--help:--help}\
834 %{--target-help:--target-help}\ 900 %{--target-help:--target-help}\
835 %{--help=*:--help=%(VALUE)}\ 901 %{--help=*:--help=%(VALUE)}\
847 #endif 913 #endif
848 "%a %Y %{c:%W{o*}%{!o*:-o %w%b%O}}%{!c:-o %d%w%u%O}"; 914 "%a %Y %{c:%W{o*}%{!o*:-o %w%b%O}}%{!c:-o %d%w%u%O}";
849 915
850 static const char *invoke_as = 916 static const char *invoke_as =
851 #ifdef AS_NEEDS_DASH_FOR_PIPED_INPUT 917 #ifdef AS_NEEDS_DASH_FOR_PIPED_INPUT
852 "%{!S:-o %|.s |\n as %(asm_options) %|.s %A }"; 918 "%{!fwpa:\
919 %{fcompare-debug=*|fdump-final-insns=*:%:compare-debug-dump-opt()}\
920 %{!S:-o %|.s |\n as %(asm_options) %|.s %A }\
921 }";
853 #else 922 #else
854 "%{!S:-o %|.s |\n as %(asm_options) %m.s %A }"; 923 "%{!fwpa:\
924 %{fcompare-debug=*|fdump-final-insns=*:%:compare-debug-dump-opt()}\
925 %{!S:-o %|.s |\n as %(asm_options) %m.s %A }\
926 }";
855 #endif 927 #endif
856 928
857 /* Some compilers have limits on line lengths, and the multilib_select 929 /* Some compilers have limits on line lengths, and the multilib_select
858 and/or multilib_matches strings can be very long, so we build them at 930 and/or multilib_matches strings can be very long, so we build them at
859 run time. */ 931 run time. */
880 #ifndef GOMP_SELF_SPECS 952 #ifndef GOMP_SELF_SPECS
881 #define GOMP_SELF_SPECS "%{fopenmp|ftree-parallelize-loops=*: -pthread}" 953 #define GOMP_SELF_SPECS "%{fopenmp|ftree-parallelize-loops=*: -pthread}"
882 #endif 954 #endif
883 955
884 static const char *const driver_self_specs[] = { 956 static const char *const driver_self_specs[] = {
885 DRIVER_SELF_SPECS, GOMP_SELF_SPECS 957 "%{fdump-final-insns:-fdump-final-insns=.} %<fdump-final-insns",
958 DRIVER_SELF_SPECS, CONFIGURE_SPECS, GOMP_SELF_SPECS
886 }; 959 };
887 960
888 #ifndef OPTION_DEFAULT_SPECS 961 #ifndef OPTION_DEFAULT_SPECS
889 #define OPTION_DEFAULT_SPECS { "", "" } 962 #define OPTION_DEFAULT_SPECS { "", "" }
890 #endif 963 #endif
915 #endif 988 #endif
916 989
917 #ifdef HAVE_TARGET_EXECUTABLE_SUFFIX 990 #ifdef HAVE_TARGET_EXECUTABLE_SUFFIX
918 /* This defines which switches stop a full compilation. */ 991 /* This defines which switches stop a full compilation. */
919 #define DEFAULT_SWITCH_CURTAILS_COMPILATION(CHAR) \ 992 #define DEFAULT_SWITCH_CURTAILS_COMPILATION(CHAR) \
920 ((CHAR) == 'c' || (CHAR) == 'S') 993 ((CHAR) == 'c' || (CHAR) == 'S' || (CHAR) == 'E')
921 994
922 #ifndef SWITCH_CURTAILS_COMPILATION 995 #ifndef SWITCH_CURTAILS_COMPILATION
923 #define SWITCH_CURTAILS_COMPILATION(CHAR) \ 996 #define SWITCH_CURTAILS_COMPILATION(CHAR) \
924 DEFAULT_SWITCH_CURTAILS_COMPILATION(CHAR) 997 DEFAULT_SWITCH_CURTAILS_COMPILATION(CHAR)
925 #endif 998 #endif
997 "%{E|M|MM:%(trad_capable_cpp) %(cpp_options) %(cpp_debug_options)}\ 1070 "%{E|M|MM:%(trad_capable_cpp) %(cpp_options) %(cpp_debug_options)}\
998 %{!E:%{!M:%{!MM:\ 1071 %{!E:%{!M:%{!MM:\
999 %{traditional|ftraditional:\ 1072 %{traditional|ftraditional:\
1000 %eGNU C no longer supports -traditional without -E}\ 1073 %eGNU C no longer supports -traditional without -E}\
1001 %{!combine:\ 1074 %{!combine:\
1002 %{save-temps|traditional-cpp|no-integrated-cpp:%(trad_capable_cpp) \ 1075 %{save-temps*|traditional-cpp|no-integrated-cpp:%(trad_capable_cpp) \
1003 %(cpp_options) -o %{save-temps:%b.i} %{!save-temps:%g.i} \n\ 1076 %(cpp_options) -o %{save-temps*:%b.i} %{!save-temps*:%g.i} \n\
1004 cc1 -fpreprocessed %{save-temps:%b.i} %{!save-temps:%g.i} \ 1077 cc1 -fpreprocessed %{save-temps*:%b.i} %{!save-temps*:%g.i} \
1005 %(cc1_options)}\ 1078 %(cc1_options)}\
1006 %{!save-temps:%{!traditional-cpp:%{!no-integrated-cpp:\ 1079 %{!save-temps*:%{!traditional-cpp:%{!no-integrated-cpp:\
1007 cc1 %(cpp_unique_options) %(cc1_options)}}}\ 1080 cc1 %(cpp_unique_options) %(cc1_options)}}}\
1008 %{!fsyntax-only:%(invoke_as)}} \ 1081 %{!fsyntax-only:%(invoke_as)}} \
1009 %{combine:\ 1082 %{combine:\
1010 %{save-temps|traditional-cpp|no-integrated-cpp:%(trad_capable_cpp) \ 1083 %{save-temps*|traditional-cpp|no-integrated-cpp:%(trad_capable_cpp) \
1011 %(cpp_options) -o %{save-temps:%b.i} %{!save-temps:%g.i}}\ 1084 %(cpp_options) -o %{save-temps*:%b.i} %{!save-temps*:%g.i}}\
1012 %{!save-temps:%{!traditional-cpp:%{!no-integrated-cpp:\ 1085 %{!save-temps*:%{!traditional-cpp:%{!no-integrated-cpp:\
1013 cc1 %(cpp_unique_options) %(cc1_options)}}\ 1086 cc1 %(cpp_unique_options) %(cc1_options)}}\
1014 %{!fsyntax-only:%(invoke_as)}}}}}}", 0, 1, 1}, 1087 %{!fsyntax-only:%(invoke_as)}}}}}}", 0, 1, 1},
1015 {"-", 1088 {"-",
1016 "%{!E:%e-E or -x required when input is from standard input}\ 1089 "%{!E:%e-E or -x required when input is from standard input}\
1017 %(trad_capable_cpp) %(cpp_options) %(cpp_debug_options)", 0, 0, 0}, 1090 %(trad_capable_cpp) %(cpp_options) %(cpp_debug_options)", 0, 0, 0},
1019 {"@c-header", 1092 {"@c-header",
1020 /* cc1 has an integrated ISO C preprocessor. We should invoke the 1093 /* cc1 has an integrated ISO C preprocessor. We should invoke the
1021 external preprocessor if -save-temps is given. */ 1094 external preprocessor if -save-temps is given. */
1022 "%{E|M|MM:%(trad_capable_cpp) %(cpp_options) %(cpp_debug_options)}\ 1095 "%{E|M|MM:%(trad_capable_cpp) %(cpp_options) %(cpp_debug_options)}\
1023 %{!E:%{!M:%{!MM:\ 1096 %{!E:%{!M:%{!MM:\
1024 %{save-temps|traditional-cpp|no-integrated-cpp:%(trad_capable_cpp) \ 1097 %{save-temps*|traditional-cpp|no-integrated-cpp:%(trad_capable_cpp) \
1025 %(cpp_options) -o %{save-temps:%b.i} %{!save-temps:%g.i} \n\ 1098 %(cpp_options) -o %{save-temps*:%b.i} %{!save-temps*:%g.i} \n\
1026 cc1 -fpreprocessed %{save-temps:%b.i} %{!save-temps:%g.i} \ 1099 cc1 -fpreprocessed %{save-temps*:%b.i} %{!save-temps*:%g.i} \
1027 %(cc1_options)\ 1100 %(cc1_options)\
1028 -o %g.s %{!o*:--output-pch=%i.gch}\ 1101 -o %g.s %{!o*:--output-pch=%i.gch}\
1029 %W{o*:--output-pch=%*}%V}\ 1102 %W{o*:--output-pch=%*}%V}\
1030 %{!save-temps:%{!traditional-cpp:%{!no-integrated-cpp:\ 1103 %{!save-temps*:%{!traditional-cpp:%{!no-integrated-cpp:\
1031 cc1 %(cpp_unique_options) %(cc1_options)\ 1104 cc1 %(cpp_unique_options) %(cc1_options)\
1032 -o %g.s %{!o*:--output-pch=%i.gch}\ 1105 -o %g.s %{!o*:--output-pch=%i.gch}\
1033 %W{o*:--output-pch=%*}%V}}}}}}", 0, 0, 0}, 1106 %W{o*:--output-pch=%*}%V}}}}}}", 0, 0, 0},
1034 {".i", "@cpp-output", 0, 1, 0}, 1107 {".i", "@cpp-output", 0, 1, 0},
1035 {"@cpp-output", 1108 {"@cpp-output",
1137 {"--include-with-prefix-after", "-iwithprefix", "a"}, 1210 {"--include-with-prefix-after", "-iwithprefix", "a"},
1138 {"--language", "-x", "a"}, 1211 {"--language", "-x", "a"},
1139 {"--library-directory", "-L", "a"}, 1212 {"--library-directory", "-L", "a"},
1140 {"--machine", "-m", "aj"}, 1213 {"--machine", "-m", "aj"},
1141 {"--machine-", "-m", "*j"}, 1214 {"--machine-", "-m", "*j"},
1215 {"--no-canonical-prefixes", "-no-canonical-prefixes", 0},
1142 {"--no-integrated-cpp", "-no-integrated-cpp", 0}, 1216 {"--no-integrated-cpp", "-no-integrated-cpp", 0},
1143 {"--no-line-commands", "-P", 0}, 1217 {"--no-line-commands", "-P", 0},
1144 {"--no-precompiled-includes", "-noprecomp", 0}, 1218 {"--no-precompiled-includes", "-noprecomp", 0},
1145 {"--no-standard-includes", "-nostdinc", 0}, 1219 {"--no-standard-includes", "-nostdinc", 0},
1146 {"--no-standard-libraries", "-nostdlib", 0}, 1220 {"--no-standard-libraries", "-nostdlib", 0},
1528 static const char *const standard_startfile_prefix = STANDARD_STARTFILE_PREFIX; 1602 static const char *const standard_startfile_prefix = STANDARD_STARTFILE_PREFIX;
1529 1603
1530 /* For native compilers, these are well-known paths containing 1604 /* For native compilers, these are well-known paths containing
1531 components that may be provided by the system. For cross 1605 components that may be provided by the system. For cross
1532 compilers, these paths are not used. */ 1606 compilers, these paths are not used. */
1533 static const char *const standard_exec_prefix_1 = "/usr/libexec/gcc/";
1534 static const char *const standard_exec_prefix_2 = "/usr/lib/gcc/";
1535 static const char *md_exec_prefix = MD_EXEC_PREFIX; 1607 static const char *md_exec_prefix = MD_EXEC_PREFIX;
1536 static const char *md_startfile_prefix = MD_STARTFILE_PREFIX; 1608 static const char *md_startfile_prefix = MD_STARTFILE_PREFIX;
1537 static const char *md_startfile_prefix_1 = MD_STARTFILE_PREFIX_1; 1609 static const char *md_startfile_prefix_1 = MD_STARTFILE_PREFIX_1;
1538 static const char *const standard_startfile_prefix_1 1610 static const char *const standard_startfile_prefix_1
1539 = STANDARD_STARTFILE_PREFIX_1; 1611 = STANDARD_STARTFILE_PREFIX_1;
1610 INIT_STATIC_SPEC ("multilib_extra", &multilib_extra), 1682 INIT_STATIC_SPEC ("multilib_extra", &multilib_extra),
1611 INIT_STATIC_SPEC ("multilib_matches", &multilib_matches), 1683 INIT_STATIC_SPEC ("multilib_matches", &multilib_matches),
1612 INIT_STATIC_SPEC ("multilib_exclusions", &multilib_exclusions), 1684 INIT_STATIC_SPEC ("multilib_exclusions", &multilib_exclusions),
1613 INIT_STATIC_SPEC ("multilib_options", &multilib_options), 1685 INIT_STATIC_SPEC ("multilib_options", &multilib_options),
1614 INIT_STATIC_SPEC ("linker", &linker_name_spec), 1686 INIT_STATIC_SPEC ("linker", &linker_name_spec),
1687 INIT_STATIC_SPEC ("linker_plugin_file", &linker_plugin_file_spec),
1688 INIT_STATIC_SPEC ("lto_wrapper", &lto_wrapper_spec),
1689 INIT_STATIC_SPEC ("lto_gcc", &lto_gcc_spec),
1690 INIT_STATIC_SPEC ("lto_libgcc", &lto_libgcc_spec),
1615 INIT_STATIC_SPEC ("link_libgcc", &link_libgcc_spec), 1691 INIT_STATIC_SPEC ("link_libgcc", &link_libgcc_spec),
1616 INIT_STATIC_SPEC ("md_exec_prefix", &md_exec_prefix), 1692 INIT_STATIC_SPEC ("md_exec_prefix", &md_exec_prefix),
1617 INIT_STATIC_SPEC ("md_startfile_prefix", &md_startfile_prefix), 1693 INIT_STATIC_SPEC ("md_startfile_prefix", &md_startfile_prefix),
1618 INIT_STATIC_SPEC ("md_startfile_prefix_1", &md_startfile_prefix_1), 1694 INIT_STATIC_SPEC ("md_startfile_prefix_1", &md_startfile_prefix_1),
1619 INIT_STATIC_SPEC ("startfile_prefix_spec", &startfile_prefix_spec), 1695 INIT_STATIC_SPEC ("startfile_prefix_spec", &startfile_prefix_spec),
1648 { "if-exists-else", if_exists_else_spec_function }, 1724 { "if-exists-else", if_exists_else_spec_function },
1649 { "replace-outfile", replace_outfile_spec_function }, 1725 { "replace-outfile", replace_outfile_spec_function },
1650 { "version-compare", version_compare_spec_function }, 1726 { "version-compare", version_compare_spec_function },
1651 { "include", include_spec_function }, 1727 { "include", include_spec_function },
1652 { "print-asm-header", print_asm_header_spec_function }, 1728 { "print-asm-header", print_asm_header_spec_function },
1729 { "compare-debug-dump-opt", compare_debug_dump_opt_spec_function },
1730 { "compare-debug-self-opt", compare_debug_self_opt_spec_function },
1731 { "compare-debug-auxbase-opt", compare_debug_auxbase_opt_spec_function },
1653 #ifdef EXTRA_SPEC_FUNCTIONS 1732 #ifdef EXTRA_SPEC_FUNCTIONS
1654 EXTRA_SPEC_FUNCTIONS 1733 EXTRA_SPEC_FUNCTIONS
1655 #endif 1734 #endif
1656 { 0, 0 } 1735 { 0, 0 }
1657 }; 1736 };
1832 obstack_grow (&obstack, tf, sizeof(tf) - 1); 1911 obstack_grow (&obstack, tf, sizeof(tf) - 1);
1833 obstack_grow0 (&obstack, asm_spec, strlen (asm_spec)); 1912 obstack_grow0 (&obstack, asm_spec, strlen (asm_spec));
1834 asm_spec = XOBFINISH (&obstack, const char *); 1913 asm_spec = XOBFINISH (&obstack, const char *);
1835 } 1914 }
1836 #endif 1915 #endif
1837 #ifdef LINK_EH_SPEC 1916
1917 #if defined LINK_EH_SPEC || defined LINK_BUILDID_SPEC
1918 # ifdef LINK_BUILDID_SPEC
1919 /* Prepend LINK_BUILDID_SPEC to whatever link_spec we had before. */
1920 obstack_grow (&obstack, LINK_BUILDID_SPEC, sizeof(LINK_BUILDID_SPEC) - 1);
1921 # endif
1922 # ifdef LINK_EH_SPEC
1838 /* Prepend LINK_EH_SPEC to whatever link_spec we had before. */ 1923 /* Prepend LINK_EH_SPEC to whatever link_spec we had before. */
1839 obstack_grow (&obstack, LINK_EH_SPEC, sizeof(LINK_EH_SPEC) - 1); 1924 obstack_grow (&obstack, LINK_EH_SPEC, sizeof(LINK_EH_SPEC) - 1);
1925 # endif
1840 obstack_grow0 (&obstack, link_spec, strlen (link_spec)); 1926 obstack_grow0 (&obstack, link_spec, strlen (link_spec));
1841 link_spec = XOBFINISH (&obstack, const char *); 1927 link_spec = XOBFINISH (&obstack, const char *);
1842 #endif 1928 #endif
1843 1929
1844 specs = sl; 1930 specs = sl;
1921 /* Position in the argbuf array containing the name of the output file 2007 /* Position in the argbuf array containing the name of the output file
1922 (the value associated with the "-o" flag). */ 2008 (the value associated with the "-o" flag). */
1923 2009
1924 static int have_o_argbuf_index = 0; 2010 static int have_o_argbuf_index = 0;
1925 2011
1926 /* Were the options -c or -S passed. */ 2012 /* Were the options -c, -S or -E passed. */
1927 static int have_c = 0; 2013 static int have_c = 0;
1928 2014
1929 /* Was the option -o passed. */ 2015 /* Was the option -o passed. */
1930 static int have_o = 0; 2016 static int have_o = 0;
1931 2017
2875 and record info about each one. 2961 and record info about each one.
2876 Also search for the programs that are to be run. */ 2962 Also search for the programs that are to be run. */
2877 2963
2878 commands[0].prog = argbuf[0]; /* first command. */ 2964 commands[0].prog = argbuf[0]; /* first command. */
2879 commands[0].argv = &argbuf[0]; 2965 commands[0].argv = &argbuf[0];
2880 2966
2881 if (!wrapper_string) 2967 if (!wrapper_string)
2882 { 2968 {
2883 string = find_a_file (&exec_prefixes, commands[0].prog, X_OK, false); 2969 string = find_a_file (&exec_prefixes, commands[0].prog, X_OK, false);
2884 commands[0].argv[0] = (string) ? string : commands[0].argv[0]; 2970 commands[0].argv[0] = (string) ? string : commands[0].argv[0];
2885 } 2971 }
2989 } 3075 }
2990 #endif 3076 #endif
2991 3077
2992 /* Run each piped subprocess. */ 3078 /* Run each piped subprocess. */
2993 3079
2994 pex = pex_init (PEX_USE_PIPES | (report_times ? PEX_RECORD_TIMES : 0), 3080 pex = pex_init (PEX_USE_PIPES | ((report_times || report_times_to_file)
3081 ? PEX_RECORD_TIMES : 0),
2995 programname, temp_filename); 3082 programname, temp_filename);
2996 if (pex == NULL) 3083 if (pex == NULL)
2997 pfatal_with_name (_("pex_init failed")); 3084 pfatal_with_name (_("pex_init failed"));
2998 3085
2999 for (i = 0; i < n_commands; i++) 3086 for (i = 0; i < n_commands; i++)
3033 3120
3034 statuses = (int *) alloca (n_commands * sizeof (int)); 3121 statuses = (int *) alloca (n_commands * sizeof (int));
3035 if (!pex_get_status (pex, n_commands, statuses)) 3122 if (!pex_get_status (pex, n_commands, statuses))
3036 pfatal_with_name (_("failed to get exit status")); 3123 pfatal_with_name (_("failed to get exit status"));
3037 3124
3038 if (report_times) 3125 if (report_times || report_times_to_file)
3039 { 3126 {
3040 times = (struct pex_time *) alloca (n_commands * sizeof (struct pex_time)); 3127 times = (struct pex_time *) alloca (n_commands * sizeof (struct pex_time));
3041 if (!pex_get_times (pex, n_commands, times)) 3128 if (!pex_get_times (pex, n_commands, times))
3042 pfatal_with_name (_("failed to get process times")); 3129 pfatal_with_name (_("failed to get process times"));
3043 } 3130 }
3078 if (WEXITSTATUS (status) > greatest_status) 3165 if (WEXITSTATUS (status) > greatest_status)
3079 greatest_status = WEXITSTATUS (status); 3166 greatest_status = WEXITSTATUS (status);
3080 ret_code = -1; 3167 ret_code = -1;
3081 } 3168 }
3082 3169
3083 if (report_times) 3170 if (report_times || report_times_to_file)
3084 { 3171 {
3085 struct pex_time *pt = &times[i]; 3172 struct pex_time *pt = &times[i];
3086 double ut, st; 3173 double ut, st;
3087 3174
3088 ut = ((double) pt->user_seconds 3175 ut = ((double) pt->user_seconds
3089 + (double) pt->user_microseconds / 1.0e6); 3176 + (double) pt->user_microseconds / 1.0e6);
3090 st = ((double) pt->system_seconds 3177 st = ((double) pt->system_seconds
3091 + (double) pt->system_microseconds / 1.0e6); 3178 + (double) pt->system_microseconds / 1.0e6);
3092 3179
3093 if (ut + st != 0) 3180 if (ut + st != 0)
3094 notice ("# %s %.2f %.2f\n", commands[i].prog, ut, st); 3181 {
3182 if (report_times)
3183 notice ("# %s %.2f %.2f\n", commands[i].prog, ut, st);
3184
3185 if (report_times_to_file)
3186 {
3187 int c = 0;
3188 const char *const *j;
3189
3190 fprintf (report_times_to_file, "%g %g", ut, st);
3191
3192 for (j = &commands[i].prog; *j; j = &commands[i].argv[++c])
3193 {
3194 const char *p;
3195 for (p = *j; *p; ++p)
3196 if (*p == '"' || *p == '\\' || *p == '$'
3197 || ISSPACE (*p))
3198 break;
3199
3200 if (*p)
3201 {
3202 fprintf (report_times_to_file, " \"");
3203 for (p = *j; *p; ++p)
3204 {
3205 if (*p == '"' || *p == '\\' || *p == '$')
3206 fputc ('\\', report_times_to_file);
3207 fputc (*p, report_times_to_file);
3208 }
3209 fputc ('"', report_times_to_file);
3210 }
3211 else
3212 fprintf (report_times_to_file, " %s", *j);
3213 }
3214
3215 fputc ('\n', report_times_to_file);
3216 }
3217 }
3095 } 3218 }
3096 } 3219 }
3097 3220
3098 return ret_code; 3221 return ret_code;
3099 } 3222 }
3126 }; 3249 };
3127 3250
3128 static struct switchstr *switches; 3251 static struct switchstr *switches;
3129 3252
3130 static int n_switches; 3253 static int n_switches;
3254
3255 /* Set to zero if -fcompare-debug is disabled, positive if it's
3256 enabled and we're running the first compilation, negative if it's
3257 enabled and we're running the second compilation. For most of the
3258 time, it's in the range -1..1, but it can be temporarily set to 2
3259 or 3 to indicate that the -fcompare-debug flags didn't come from
3260 the command-line, but rather from the GCC_COMPARE_DEBUG environment
3261 variable, until a synthesized -fcompare-debug flag is added to the
3262 command line. */
3263 int compare_debug;
3264
3265 /* Set to nonzero if we've seen the -fcompare-debug-second flag. */
3266 int compare_debug_second;
3267
3268 /* Set to the flags that should be passed to the second compilation in
3269 a -fcompare-debug compilation. */
3270 const char *compare_debug_opt;
3271
3272 static struct switchstr *switches_debug_check[2];
3273
3274 static int n_switches_debug_check[2];
3275
3276 static char *debug_check_temp_file[2];
3131 3277
3132 /* Language is one of three things: 3278 /* Language is one of three things:
3133 3279
3134 1) The name of a real programming language. 3280 1) The name of a real programming language.
3135 2) NULL, indicating that no one has figured out 3281 2) NULL, indicating that no one has figured out
3256 fputs (_(" -Xassembler <arg> Pass <arg> on to the assembler\n"), stdout); 3402 fputs (_(" -Xassembler <arg> Pass <arg> on to the assembler\n"), stdout);
3257 fputs (_(" -Xpreprocessor <arg> Pass <arg> on to the preprocessor\n"), stdout); 3403 fputs (_(" -Xpreprocessor <arg> Pass <arg> on to the preprocessor\n"), stdout);
3258 fputs (_(" -Xlinker <arg> Pass <arg> on to the linker\n"), stdout); 3404 fputs (_(" -Xlinker <arg> Pass <arg> on to the linker\n"), stdout);
3259 fputs (_(" -combine Pass multiple source files to compiler at once\n"), stdout); 3405 fputs (_(" -combine Pass multiple source files to compiler at once\n"), stdout);
3260 fputs (_(" -save-temps Do not delete intermediate files\n"), stdout); 3406 fputs (_(" -save-temps Do not delete intermediate files\n"), stdout);
3407 fputs (_(" -save-temps=<arg> Do not delete intermediate files\n"), stdout);
3408 fputs (_("\
3409 -no-canonical-prefixes Do not canonicalize paths when building relative\n\
3410 prefixes to other gcc components\n"), stdout);
3261 fputs (_(" -pipe Use pipes rather than intermediate files\n"), stdout); 3411 fputs (_(" -pipe Use pipes rather than intermediate files\n"), stdout);
3262 fputs (_(" -time Time the execution of each subprocess\n"), stdout); 3412 fputs (_(" -time Time the execution of each subprocess\n"), stdout);
3263 fputs (_(" -specs=<file> Override built-in specs with the contents of <file>\n"), stdout); 3413 fputs (_(" -specs=<file> Override built-in specs with the contents of <file>\n"), stdout);
3264 fputs (_(" -std=<standard> Assume that the input sources are for <standard>\n"), stdout); 3414 fputs (_(" -std=<standard> Assume that the input sources are for <standard>\n"), stdout);
3265 fputs (_("\ 3415 fputs (_("\
3326 n_linker_options++; 3476 n_linker_options++;
3327 3477
3328 if (! linker_options) 3478 if (! linker_options)
3329 linker_options = XNEWVEC (char *, n_linker_options); 3479 linker_options = XNEWVEC (char *, n_linker_options);
3330 else 3480 else
3331 linker_options = XRESIZEVEC (char *, linker_options, n_linker_options); 3481 linker_options = XRESIZEVEC (char *, linker_options, n_linker_options);
3332 3482
3333 linker_options [n_linker_options - 1] = save_string (option, len); 3483 linker_options [n_linker_options - 1] = save_string (option, len);
3334 } 3484 }
3335 3485
3336 /* Create the vector `switches' and its contents. 3486 /* Create the vector `switches' and its contents.
3348 #ifdef MODIFY_TARGET_NAME 3498 #ifdef MODIFY_TARGET_NAME
3349 int is_modify_target_name; 3499 int is_modify_target_name;
3350 unsigned int j; 3500 unsigned int j;
3351 #endif 3501 #endif
3352 const char *tooldir_prefix; 3502 const char *tooldir_prefix;
3503 char *(*get_relative_prefix) (const char *, const char *,
3504 const char *) = NULL;
3353 3505
3354 GET_ENVIRONMENT (gcc_exec_prefix, "GCC_EXEC_PREFIX"); 3506 GET_ENVIRONMENT (gcc_exec_prefix, "GCC_EXEC_PREFIX");
3355 3507
3356 n_switches = 0; 3508 n_switches = 0;
3357 n_infiles = 0; 3509 n_infiles = 0;
3443 xstrerror (err)); 3595 xstrerror (err));
3444 } 3596 }
3445 exit (status); 3597 exit (status);
3446 } 3598 }
3447 3599
3600 /* Convert new-style -- options to old-style. */
3601 translate_options (&argc,
3602 CONST_CAST2 (const char *const **, const char ***,
3603 &argv));
3604
3605 /* Do language-specific adjustment/addition of flags. */
3606 lang_specific_driver (&argc,
3607 CONST_CAST2 (const char *const **, const char ***,
3608 &argv),
3609 &added_libraries);
3610
3611 /* Handle any -no-canonical-prefixes flag early, to assign the function
3612 that builds relative prefixes. This function creates default search
3613 paths that are needed later in normal option handling. */
3614
3615 for (i = 1; i < argc; i++)
3616 {
3617 if (! strcmp (argv[i], "-no-canonical-prefixes"))
3618 {
3619 get_relative_prefix = make_relative_prefix_ignore_links;
3620 break;
3621 }
3622 }
3623 if (! get_relative_prefix)
3624 get_relative_prefix = make_relative_prefix;
3625
3448 /* Set up the default search paths. If there is no GCC_EXEC_PREFIX, 3626 /* Set up the default search paths. If there is no GCC_EXEC_PREFIX,
3449 see if we can create it from the pathname specified in argv[0]. */ 3627 see if we can create it from the pathname specified in argv[0]. */
3450 3628
3451 gcc_libexec_prefix = standard_libexec_prefix; 3629 gcc_libexec_prefix = standard_libexec_prefix;
3452 #ifndef VMS 3630 #ifndef VMS
3453 /* FIXME: make_relative_prefix doesn't yet work for VMS. */ 3631 /* FIXME: make_relative_prefix doesn't yet work for VMS. */
3454 if (!gcc_exec_prefix) 3632 if (!gcc_exec_prefix)
3455 { 3633 {
3456 gcc_exec_prefix = make_relative_prefix (argv[0], standard_bindir_prefix, 3634 gcc_exec_prefix = get_relative_prefix (argv[0],
3457 standard_exec_prefix); 3635 standard_bindir_prefix,
3458 gcc_libexec_prefix = make_relative_prefix (argv[0], 3636 standard_exec_prefix);
3459 standard_bindir_prefix, 3637 gcc_libexec_prefix = get_relative_prefix (argv[0],
3460 standard_libexec_prefix); 3638 standard_bindir_prefix,
3639 standard_libexec_prefix);
3461 if (gcc_exec_prefix) 3640 if (gcc_exec_prefix)
3462 xputenv (concat ("GCC_EXEC_PREFIX=", gcc_exec_prefix, NULL)); 3641 xputenv (concat ("GCC_EXEC_PREFIX=", gcc_exec_prefix, NULL));
3463 } 3642 }
3464 else 3643 else
3465 { 3644 {
3466 /* make_relative_prefix requires a program name, but 3645 /* make_relative_prefix requires a program name, but
3467 GCC_EXEC_PREFIX is typically a directory name with a trailing 3646 GCC_EXEC_PREFIX is typically a directory name with a trailing
3468 / (which is ignored by make_relative_prefix), so append a 3647 / (which is ignored by make_relative_prefix), so append a
3469 program name. */ 3648 program name. */
3470 char *tmp_prefix = concat (gcc_exec_prefix, "gcc", NULL); 3649 char *tmp_prefix = concat (gcc_exec_prefix, "gcc", NULL);
3471 gcc_libexec_prefix = make_relative_prefix (tmp_prefix, 3650 gcc_libexec_prefix = get_relative_prefix (tmp_prefix,
3472 standard_exec_prefix, 3651 standard_exec_prefix,
3473 standard_libexec_prefix); 3652 standard_libexec_prefix);
3474 3653
3475 /* The path is unrelocated, so fallback to the original setting. */ 3654 /* The path is unrelocated, so fallback to the original setting. */
3476 if (!gcc_libexec_prefix) 3655 if (!gcc_libexec_prefix)
3477 gcc_libexec_prefix = standard_libexec_prefix; 3656 gcc_libexec_prefix = standard_libexec_prefix;
3478 3657
3606 else 3785 else
3607 endp++; 3786 endp++;
3608 } 3787 }
3609 } 3788 }
3610 3789
3611 /* Convert new-style -- options to old-style. */
3612 translate_options (&argc, (const char *const **) &argv);
3613
3614 /* Do language-specific adjustment/addition of flags. */
3615 lang_specific_driver (&argc, (const char *const **) &argv, &added_libraries);
3616
3617 /* Scan argv twice. Here, the first time, just count how many switches 3790 /* Scan argv twice. Here, the first time, just count how many switches
3618 there will be in their vector, and how many input files in theirs. 3791 there will be in their vector, and how many input files in theirs.
3619 Here we also parse the switches that cc itself uses (e.g. -v). */ 3792 Here we also parse the switches that cc itself uses (e.g. -v). */
3620 3793
3621 for (i = 1; i < argc; i++) 3794 for (i = 1; i < argc; i++)
3641 exit (0); 3814 exit (0);
3642 } 3815 }
3643 else if (strcmp (argv[i], "-fversion") == 0) 3816 else if (strcmp (argv[i], "-fversion") == 0)
3644 { 3817 {
3645 /* translate_options () has turned --version into -fversion. */ 3818 /* translate_options () has turned --version into -fversion. */
3646 printf (_("%s %s%s\n"), programname, pkgversion_string, 3819 print_version = 1;
3647 version_string); 3820
3648 printf ("Copyright %s 2010 Free Software Foundation, Inc.\n", 3821 /* We will be passing a dummy file on to the sub-processes. */
3649 _("(C)")); 3822 n_infiles++;
3650 fputs (_("This is free software; see the source for copying conditions. There is NO\n\ 3823 n_switches++;
3651 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\n"), 3824
3652 stdout); 3825 /* CPP driver cannot obtain switch from cc1_options. */
3653 exit (0); 3826 if (is_cpp_driver)
3827 add_preprocessor_option ("--version", strlen ("--version"));
3828 add_assembler_option ("--version", strlen ("--version"));
3829 add_linker_option ("--version", strlen ("--version"));
3654 } 3830 }
3655 else if (strcmp (argv[i], "-fhelp") == 0) 3831 else if (strcmp (argv[i], "-fhelp") == 0)
3656 { 3832 {
3657 /* translate_options () has turned --help into -fhelp. */ 3833 /* translate_options () has turned --help into -fhelp. */
3658 print_help_list = 1; 3834 print_help_list = 1;
3712 print_sysroot = 1; 3888 print_sysroot = 1;
3713 else if (! strcmp (argv[i], "-print-multi-os-directory")) 3889 else if (! strcmp (argv[i], "-print-multi-os-directory"))
3714 print_multi_os_directory = 1; 3890 print_multi_os_directory = 1;
3715 else if (! strcmp (argv[i], "-print-sysroot-headers-suffix")) 3891 else if (! strcmp (argv[i], "-print-sysroot-headers-suffix"))
3716 print_sysroot_headers_suffix = 1; 3892 print_sysroot_headers_suffix = 1;
3893 else if (! strcmp (argv[i], "-fcompare-debug-second"))
3894 {
3895 compare_debug_second = 1;
3896 n_switches++;
3897 }
3898 else if (! strcmp (argv[i], "-fno-compare-debug"))
3899 {
3900 argv[i] = "-fcompare-debug=";
3901 goto compare_debug_with_arg;
3902 }
3903 else if (! strcmp (argv[i], "-fcompare-debug"))
3904 {
3905 argv[i] = "-fcompare-debug=-gtoggle";
3906 goto compare_debug_with_arg;
3907 }
3908 #define OPT "-fcompare-debug="
3909 else if (! strncmp (argv[i], OPT, sizeof (OPT) - 1))
3910 {
3911 const char *opt;
3912 compare_debug_with_arg:
3913 opt = argv[i] + sizeof (OPT) - 1;
3914 #undef OPT
3915 if (*opt)
3916 compare_debug = 1;
3917 else
3918 compare_debug = -1;
3919 if (compare_debug < 0)
3920 compare_debug_opt = NULL;
3921 else
3922 compare_debug_opt = opt;
3923 n_switches++;
3924 }
3717 else if (! strncmp (argv[i], "-Wa,", 4)) 3925 else if (! strncmp (argv[i], "-Wa,", 4))
3718 { 3926 {
3719 int prev, j; 3927 int prev, j;
3720 /* Pass the rest of this option to the assembler. */ 3928 /* Pass the rest of this option to the assembler. */
3721 3929
3790 } 3998 }
3791 else if (strncmp (argv[i], "-l", 2) == 0) 3999 else if (strncmp (argv[i], "-l", 2) == 0)
3792 n_infiles++; 4000 n_infiles++;
3793 else if (strcmp (argv[i], "-save-temps") == 0) 4001 else if (strcmp (argv[i], "-save-temps") == 0)
3794 { 4002 {
3795 save_temps_flag = 1; 4003 save_temps_flag = SAVE_TEMPS_CWD;
3796 n_switches++; 4004 n_switches++;
3797 } 4005 }
4006 else if (strncmp (argv[i], "-save-temps=", 12) == 0)
4007 {
4008 n_switches++;
4009 if (strcmp (argv[i]+12, "cwd") == 0)
4010 save_temps_flag = SAVE_TEMPS_CWD;
4011 else if (strcmp (argv[i]+12, "obj") == 0
4012 || strcmp (argv[i]+12, "object") == 0)
4013 save_temps_flag = SAVE_TEMPS_OBJ;
4014 else
4015 fatal ("'%s' is an unknown -save-temps option", argv[i]);
4016 }
4017 else if (strcmp (argv[i], "-no-canonical-prefixes") == 0)
4018 /* Already handled as a special case, so ignored here. */
4019 ;
3798 else if (strcmp (argv[i], "-combine") == 0) 4020 else if (strcmp (argv[i], "-combine") == 0)
3799 { 4021 {
3800 combine_flag = 1; 4022 combine_flag = 1;
3801 n_switches++; 4023 n_switches++;
3802 } 4024 }
3828 user_specs_head = user; 4050 user_specs_head = user;
3829 user_specs_tail = user; 4051 user_specs_tail = user;
3830 } 4052 }
3831 else if (strcmp (argv[i], "-time") == 0) 4053 else if (strcmp (argv[i], "-time") == 0)
3832 report_times = 1; 4054 report_times = 1;
4055 else if (strncmp (argv[i], "-time=", sizeof ("-time=") - 1) == 0)
4056 {
4057 if (report_times_to_file)
4058 fclose (report_times_to_file);
4059 report_times_to_file = fopen (argv[i] + sizeof ("-time=") - 1, "a");
4060 }
3833 else if (strcmp (argv[i], "-pipe") == 0) 4061 else if (strcmp (argv[i], "-pipe") == 0)
3834 { 4062 {
3835 /* -pipe has to go into the switches array as well as 4063 /* -pipe has to go into the switches array as well as
3836 setting a flag. */ 4064 setting a flag. */
3837 use_pipes = 1; 4065 use_pipes = 1;
3921 verbose_flag++; 4149 verbose_flag++;
3922 break; 4150 break;
3923 4151
3924 case 'S': 4152 case 'S':
3925 case 'c': 4153 case 'c':
4154 case 'E':
3926 if (p[1] == 0) 4155 if (p[1] == 0)
3927 { 4156 {
3928 have_c = 1; 4157 have_c = 1;
3929 n_switches++; 4158 n_switches++;
3930 break; 4159 break;
3936 #if defined(HAVE_TARGET_EXECUTABLE_SUFFIX) 4165 #if defined(HAVE_TARGET_EXECUTABLE_SUFFIX)
3937 if (! have_c) 4166 if (! have_c)
3938 { 4167 {
3939 int skip; 4168 int skip;
3940 4169
3941 /* Forward scan, just in case -S or -c is specified 4170 /* Forward scan, just in case -S, -E or -c is specified
3942 after -o. */ 4171 after -o. */
3943 int j = i + 1; 4172 int j = i + 1;
3944 if (p[1] == 0) 4173 if (p[1] == 0)
3945 ++j; 4174 ++j;
3946 while (j < argc) 4175 while (j < argc)
3966 if (p[1] == 0) 4195 if (p[1] == 0)
3967 argv[i + 1] = convert_filename (argv[i + 1], ! have_c, 0); 4196 argv[i + 1] = convert_filename (argv[i + 1], ! have_c, 0);
3968 else 4197 else
3969 argv[i] = convert_filename (argv[i], ! have_c, 0); 4198 argv[i] = convert_filename (argv[i], ! have_c, 0);
3970 #endif 4199 #endif
4200 /* Save the output name in case -save-temps=obj was used. */
4201 if ((p[1] == 0) && argv[i + 1])
4202 save_temps_prefix = xstrdup(argv[i + 1]);
4203 else
4204 save_temps_prefix = xstrdup(argv[i] + 1);
3971 goto normal_switch; 4205 goto normal_switch;
3972 4206
3973 default: 4207 default:
3974 normal_switch: 4208 normal_switch:
3975 4209
4023 n_infiles++; 4257 n_infiles++;
4024 lang_n_infiles++; 4258 lang_n_infiles++;
4025 } 4259 }
4026 } 4260 }
4027 4261
4262 /* If -save-temps=obj and -o name, create the prefix to use for %b.
4263 Otherwise just make -save-temps=obj the same as -save-temps=cwd. */
4264 if (save_temps_flag == SAVE_TEMPS_OBJ && save_temps_prefix != NULL)
4265 {
4266 save_temps_length = strlen (save_temps_prefix);
4267 temp = strrchr (lbasename (save_temps_prefix), '.');
4268 if (temp)
4269 {
4270 save_temps_length -= strlen (temp);
4271 save_temps_prefix[save_temps_length] = '\0';
4272 }
4273
4274 }
4275 else if (save_temps_prefix != NULL)
4276 {
4277 free (save_temps_prefix);
4278 save_temps_prefix = NULL;
4279 }
4280
4028 if (save_temps_flag && use_pipes) 4281 if (save_temps_flag && use_pipes)
4029 { 4282 {
4030 /* -save-temps overrides -pipe, so that temp files are produced */ 4283 /* -save-temps overrides -pipe, so that temp files are produced */
4031 if (save_temps_flag) 4284 if (save_temps_flag)
4032 error ("warning: -pipe ignored because -save-temps specified"); 4285 error ("warning: -pipe ignored because -save-temps specified");
4033 use_pipes = 0; 4286 use_pipes = 0;
4034 } 4287 }
4035 4288
4289 if (!compare_debug)
4290 {
4291 const char *gcd = getenv ("GCC_COMPARE_DEBUG");
4292
4293 if (gcd && gcd[0] == '-')
4294 {
4295 compare_debug = 2;
4296 compare_debug_opt = gcd;
4297 n_switches++;
4298 }
4299 else if (gcd && *gcd && strcmp (gcd, "0"))
4300 {
4301 compare_debug = 3;
4302 compare_debug_opt = "-gtoggle";
4303 n_switches++;
4304 }
4305 }
4306 else if (compare_debug < 0)
4307 {
4308 compare_debug = 0;
4309 gcc_assert (!compare_debug_opt);
4310 }
4311
4036 /* Set up the search paths. We add directories that we expect to 4312 /* Set up the search paths. We add directories that we expect to
4037 contain GNU Toolchain components before directories specified by 4313 contain GNU Toolchain components before directories specified by
4038 the machine description so that we will find GNU components (like 4314 the machine description so that we will find GNU components (like
4039 the GNU assembler) before those of the host system. */ 4315 the GNU assembler) before those of the host system. */
4040 4316
4041 /* If we don't know where the toolchain has been installed, use the 4317 /* If we don't know where the toolchain has been installed, use the
4042 configured-in locations. */ 4318 configured-in locations. */
4043 if (!gcc_exec_prefix) 4319 if (!gcc_exec_prefix)
4044 { 4320 {
4052 #endif 4328 #endif
4053 add_prefix (&startfile_prefixes, standard_exec_prefix, "BINUTILS", 4329 add_prefix (&startfile_prefixes, standard_exec_prefix, "BINUTILS",
4054 PREFIX_PRIORITY_LAST, 1, 0); 4330 PREFIX_PRIORITY_LAST, 1, 0);
4055 } 4331 }
4056 4332
4057 /* If not cross-compiling, search well-known system locations. */
4058 if (*cross_compile == '0')
4059 {
4060 #ifndef OS2
4061 add_prefix (&exec_prefixes, standard_exec_prefix_1, "BINUTILS",
4062 PREFIX_PRIORITY_LAST, 2, 0);
4063 add_prefix (&exec_prefixes, standard_exec_prefix_2, "BINUTILS",
4064 PREFIX_PRIORITY_LAST, 2, 0);
4065 #endif
4066 add_prefix (&startfile_prefixes, standard_exec_prefix_2, "BINUTILS",
4067 PREFIX_PRIORITY_LAST, 1, 0);
4068 }
4069
4070 gcc_assert (!IS_ABSOLUTE_PATH (tooldir_base_prefix)); 4333 gcc_assert (!IS_ABSOLUTE_PATH (tooldir_base_prefix));
4071 tooldir_prefix = concat (tooldir_base_prefix, spec_machine, 4334 tooldir_prefix = concat (tooldir_base_prefix, spec_machine,
4072 dir_separator_str, NULL); 4335 dir_separator_str, NULL);
4073 4336
4074 /* Look for tools relative to the location from which the driver is 4337 /* Look for tools relative to the location from which the driver is
4090 then consider it to relocate with the rest of the GCC installation 4353 then consider it to relocate with the rest of the GCC installation
4091 if GCC_EXEC_PREFIX is set. 4354 if GCC_EXEC_PREFIX is set.
4092 ``make_relative_prefix'' is not compiled for VMS, so don't call it. */ 4355 ``make_relative_prefix'' is not compiled for VMS, so don't call it. */
4093 if (target_system_root && gcc_exec_prefix) 4356 if (target_system_root && gcc_exec_prefix)
4094 { 4357 {
4095 char *tmp_prefix = make_relative_prefix (argv[0], 4358 char *tmp_prefix = get_relative_prefix (argv[0],
4096 standard_bindir_prefix, 4359 standard_bindir_prefix,
4097 target_system_root); 4360 target_system_root);
4098 if (tmp_prefix && access_check (tmp_prefix, F_OK) == 0) 4361 if (tmp_prefix && access_check (tmp_prefix, F_OK) == 0)
4099 { 4362 {
4100 target_system_root = tmp_prefix; 4363 target_system_root = tmp_prefix;
4101 target_system_root_changed = 1; 4364 target_system_root_changed = 1;
4102 } 4365 }
4133 else 4396 else
4134 #endif 4397 #endif
4135 if (! strncmp (argv[i], "-Wa,", 4)) 4398 if (! strncmp (argv[i], "-Wa,", 4))
4136 ; 4399 ;
4137 else if (! strncmp (argv[i], "-Wp,", 4)) 4400 else if (! strncmp (argv[i], "-Wp,", 4))
4401 ;
4402 else if (! strcmp (argv[i], "-no-canonical-prefixes"))
4138 ; 4403 ;
4139 else if (! strcmp (argv[i], "-pass-exit-codes")) 4404 else if (! strcmp (argv[i], "-pass-exit-codes"))
4140 ; 4405 ;
4141 else if (! strcmp (argv[i], "-print-search-dirs")) 4406 else if (! strcmp (argv[i], "-print-search-dirs"))
4142 ; 4407 ;
4218 else if (strcmp (argv[i], "-specs") == 0) 4483 else if (strcmp (argv[i], "-specs") == 0)
4219 i++; 4484 i++;
4220 else if (strncmp (argv[i], "-specs=", 7) == 0) 4485 else if (strncmp (argv[i], "-specs=", 7) == 0)
4221 ; 4486 ;
4222 else if (strcmp (argv[i], "-time") == 0) 4487 else if (strcmp (argv[i], "-time") == 0)
4488 ;
4489 else if (strncmp (argv[i], "-time=", sizeof ("-time=") - 1) == 0)
4223 ; 4490 ;
4224 else if (strcmp (argv[i], "-###") == 0) 4491 else if (strcmp (argv[i], "-###") == 0)
4225 ; 4492 ;
4226 else if (argv[i][0] == '-' && argv[i][1] != 0) 4493 else if (argv[i][0] == '-' && argv[i][1] != 0)
4227 { 4494 {
4302 } 4569 }
4303 n_switches++; 4570 n_switches++;
4304 } 4571 }
4305 else 4572 else
4306 { 4573 {
4574 const char *p = strchr (argv[i], '@');
4575 char *fname;
4307 #ifdef HAVE_TARGET_OBJECT_SUFFIX 4576 #ifdef HAVE_TARGET_OBJECT_SUFFIX
4308 argv[i] = convert_filename (argv[i], 0, access (argv[i], F_OK)); 4577 argv[i] = convert_filename (argv[i], 0, access (argv[i], F_OK));
4309 #endif 4578 #endif
4310 4579 if (!p)
4311 if (strcmp (argv[i], "-") != 0 && access (argv[i], F_OK) < 0) 4580 fname = xstrdup (argv[i]);
4312 { 4581 else
4313 perror_with_name (argv[i]); 4582 {
4314 error_count++; 4583 fname = (char *)xmalloc (p - argv[i] + 1);
4315 } 4584 memcpy (fname, argv[i], p - argv[i]);
4316 else 4585 fname[p - argv[i]] = '\0';
4317 { 4586 }
4318 infiles[n_infiles].language = spec_lang; 4587
4319 infiles[n_infiles++].name = argv[i]; 4588 if (strcmp (fname, "-") != 0 && access (fname, F_OK) < 0)
4320 } 4589 {
4590 perror_with_name (fname);
4591 error_count++;
4592 }
4593 else
4594 {
4595 infiles[n_infiles].language = spec_lang;
4596 infiles[n_infiles++].name = argv[i];
4597 }
4598
4599 free (fname);
4321 } 4600 }
4322 } 4601 }
4323 4602
4324 if (n_infiles == last_language_n_infiles && spec_lang != 0) 4603 if (n_infiles == last_language_n_infiles && spec_lang != 0)
4325 error ("warning: '-x %s' after last input file has no effect", spec_lang); 4604 error ("warning: '-x %s' after last input file has no effect", spec_lang);
4326 4605
4606 if (compare_debug == 2 || compare_debug == 3)
4607 {
4608 switches[n_switches].part1 = concat ("fcompare-debug=",
4609 compare_debug_opt,
4610 NULL);
4611 switches[n_switches].args = 0;
4612 switches[n_switches].live_cond = 0;
4613 switches[n_switches].validated = 0;
4614 switches[n_switches].ordering = 0;
4615 n_switches++;
4616 compare_debug = 1;
4617 }
4618
4327 /* Ensure we only invoke each subprocess once. */ 4619 /* Ensure we only invoke each subprocess once. */
4328 if (print_subprocess_help || print_help_list) 4620 if (print_subprocess_help || print_help_list || print_version)
4329 { 4621 {
4330 n_infiles = 1; 4622 n_infiles = 1;
4331 4623
4332 /* Create a dummy input file, so that we can pass 4624 /* Create a dummy input file, so that we can pass
4333 the help option on to the various sub-processes. */ 4625 the help option on to the various sub-processes. */
4437 /* Nonzero means %s has been seen; the next arg to be terminated 4729 /* Nonzero means %s has been seen; the next arg to be terminated
4438 is the name of a library file and we should try the standard 4730 is the name of a library file and we should try the standard
4439 search dirs for it. */ 4731 search dirs for it. */
4440 static int this_is_library_file; 4732 static int this_is_library_file;
4441 4733
4734 /* Nonzero means %T has been seen; the next arg to be terminated
4735 is the name of a linker script and we should try all of the
4736 standard search dirs for it. If it is found insert a --script
4737 command line switch and then substitute the full path in place,
4738 otherwise generate an error message. */
4739 static int this_is_linker_script;
4740
4442 /* Nonzero means that the input of this command is coming from a pipe. */ 4741 /* Nonzero means that the input of this command is coming from a pipe. */
4443 static int input_from_pipe; 4742 static int input_from_pipe;
4444 4743
4445 /* Nonnull means substitute this for any suffix when outputting a switches 4744 /* Nonnull means substitute this for any suffix when outputting a switches
4446 arguments. */ 4745 arguments. */
4457 4756
4458 obstack_1grow (&obstack, 0); 4757 obstack_1grow (&obstack, 0);
4459 string = XOBFINISH (&obstack, const char *); 4758 string = XOBFINISH (&obstack, const char *);
4460 if (this_is_library_file) 4759 if (this_is_library_file)
4461 string = find_file (string); 4760 string = find_file (string);
4761 if (this_is_linker_script)
4762 {
4763 char * full_script_path = find_a_file (&startfile_prefixes, string, R_OK, true);
4764
4765 if (full_script_path == NULL)
4766 {
4767 error (_("unable to locate default linker script '%s' in the library search paths"), string);
4768 /* Script was not found on search path. */
4769 return;
4770 }
4771 store_arg ("--script", false, false);
4772 string = full_script_path;
4773 }
4462 store_arg (string, delete_this_arg, this_is_output_file); 4774 store_arg (string, delete_this_arg, this_is_output_file);
4463 if (this_is_output_file) 4775 if (this_is_output_file)
4464 outfiles[input_file_number] = string; 4776 outfiles[input_file_number] = string;
4465 arg_going = 0; 4777 arg_going = 0;
4466 } 4778 }
4546 clear_args (); 4858 clear_args ();
4547 arg_going = 0; 4859 arg_going = 0;
4548 delete_this_arg = 0; 4860 delete_this_arg = 0;
4549 this_is_output_file = 0; 4861 this_is_output_file = 0;
4550 this_is_library_file = 0; 4862 this_is_library_file = 0;
4863 this_is_linker_script = 0;
4551 input_from_pipe = 0; 4864 input_from_pipe = 0;
4552 suffix_subst = NULL; 4865 suffix_subst = NULL;
4553 4866
4554 result = do_spec_1 (spec, 0, NULL); 4867 result = do_spec_1 (spec, 0, NULL);
4555 4868
4617 do_spec_2 (spec); 4930 do_spec_2 (spec);
4618 do_spec_1 (" ", 0, NULL); 4931 do_spec_1 (" ", 0, NULL);
4619 4932
4620 if (argbuf_index > 0) 4933 if (argbuf_index > 0)
4621 { 4934 {
4622 int i, first; 4935 int i;
4623 4936
4624 first = n_switches; 4937 switches = XRESIZEVEC (struct switchstr, switches,
4625 n_switches += argbuf_index; 4938 n_switches + argbuf_index + 1);
4626 switches = XRESIZEVEC (struct switchstr, switches, n_switches + 1); 4939
4627
4628 switches[n_switches] = switches[first];
4629 for (i = 0; i < argbuf_index; i++) 4940 for (i = 0; i < argbuf_index; i++)
4630 { 4941 {
4631 struct switchstr *sw; 4942 struct switchstr *sw;
4943 const char *p = argbuf[i];
4944 int c = *p;
4632 4945
4633 /* Each switch should start with '-'. */ 4946 /* Each switch should start with '-'. */
4634 if (argbuf[i][0] != '-') 4947 if (c != '-')
4635 fatal ("switch '%s' does not start with '-'", argbuf[i]); 4948 fatal ("switch '%s' does not start with '-'", argbuf[i]);
4636 4949
4637 sw = &switches[i + first]; 4950 p++;
4638 sw->part1 = &argbuf[i][1]; 4951 c = *p;
4639 sw->args = 0; 4952
4953 sw = &switches[n_switches++];
4954 sw->part1 = p;
4640 sw->live_cond = 0; 4955 sw->live_cond = 0;
4641 sw->validated = 0; 4956 sw->validated = 0;
4642 sw->ordering = 0; 4957 sw->ordering = 0;
4643 } 4958
4959 /* Deal with option arguments in separate argv elements. */
4960 if ((SWITCH_TAKES_ARG (c) > (p[1] != 0))
4961 || WORD_SWITCH_TAKES_ARG (p))
4962 {
4963 int j = 0;
4964 int n_args = WORD_SWITCH_TAKES_ARG (p);
4965
4966 if (n_args == 0)
4967 {
4968 /* Count only the option arguments in separate argv elements. */
4969 n_args = SWITCH_TAKES_ARG (c) - (p[1] != 0);
4970 }
4971 if (i + n_args >= argbuf_index)
4972 fatal ("argument to '-%s' is missing", p);
4973 sw->args
4974 = XNEWVEC (const char *, n_args + 1);
4975 while (j < n_args)
4976 sw->args[j++] = argbuf[++i];
4977 /* Null-terminate the vector. */
4978 sw->args[j] = 0;
4979 }
4980 else if (strchr (switches_need_spaces, c))
4981 {
4982 /* On some systems, ld cannot handle some options without
4983 a space. So split the option from its argument. */
4984 char *part1 = XNEWVEC (char, 2);
4985 part1[0] = c;
4986 part1[1] = '\0';
4987
4988 sw->part1 = part1;
4989 sw->args = XNEWVEC (const char *, 2);
4990 sw->args[0] = xstrdup (p+1);
4991 sw->args[1] = 0;
4992 }
4993 else
4994 sw->args = 0;
4995 }
4996
4997 switches[n_switches].part1 = 0;
4644 } 4998 }
4645 } 4999 }
4646 5000
4647 /* Callback for processing %D and %I specs. */ 5001 /* Callback for processing %D and %I specs. */
4648 5002
4691 /* Must not damage the original path. */ 5045 /* Must not damage the original path. */
4692 if (info->append_len == 0) 5046 if (info->append_len == 0)
4693 path[len - 1] = save; 5047 path[len - 1] = save;
4694 5048
4695 return NULL; 5049 return NULL;
5050 }
5051
5052 /* Create a temporary FILE with the contents of ARGV. Add @FILE to the
5053 argument list. */
5054
5055 static void
5056 create_at_file (char **argv)
5057 {
5058 char *temp_file = make_temp_file ("");
5059 char *at_argument = concat ("@", temp_file, NULL);
5060 FILE *f = fopen (temp_file, "w");
5061 int status;
5062
5063 if (f == NULL)
5064 fatal ("could not open temporary response file %s",
5065 temp_file);
5066
5067 status = writeargv (argv, f);
5068
5069 if (status)
5070 fatal ("could not write to temporary response file %s",
5071 temp_file);
5072
5073 status = fclose (f);
5074
5075 if (EOF == status)
5076 fatal ("could not close temporary response file %s",
5077 temp_file);
5078
5079 store_arg (at_argument, 0, 0);
5080
5081 record_temp_file (temp_file, !save_temps_flag, !save_temps_flag);
5082 }
5083
5084 /* True if we should compile INFILE. */
5085
5086 static bool
5087 compile_input_file_p (struct infile *infile)
5088 {
5089 if ((!infile->language) || (infile->language[0] != '*'))
5090 if (infile->incompiler == input_file_compiler)
5091 return true;
5092 return false;
4696 } 5093 }
4697 5094
4698 /* Process the sub-spec SPEC as a portion of a larger spec. 5095 /* Process the sub-spec SPEC as a portion of a larger spec.
4699 This is like processing a whole spec except that we do 5096 This is like processing a whole spec except that we do
4700 not initialize at the beginning and we do not supply a 5097 not initialize at the beginning and we do not supply a
4749 clear_args (); 5146 clear_args ();
4750 arg_going = 0; 5147 arg_going = 0;
4751 delete_this_arg = 0; 5148 delete_this_arg = 0;
4752 this_is_output_file = 0; 5149 this_is_output_file = 0;
4753 this_is_library_file = 0; 5150 this_is_library_file = 0;
5151 this_is_linker_script = 0;
4754 input_from_pipe = 0; 5152 input_from_pipe = 0;
4755 break; 5153 break;
4756 5154
4757 case '|': 5155 case '|':
4758 end_going_arg (); 5156 end_going_arg ();
4768 5166
4769 /* Reinitialize for a new argument. */ 5167 /* Reinitialize for a new argument. */
4770 delete_this_arg = 0; 5168 delete_this_arg = 0;
4771 this_is_output_file = 0; 5169 this_is_output_file = 0;
4772 this_is_library_file = 0; 5170 this_is_library_file = 0;
5171 this_is_linker_script = 0;
4773 break; 5172 break;
4774 5173
4775 case '%': 5174 case '%':
4776 switch (c = *p++) 5175 switch (c = *p++)
4777 { 5176 {
4778 case 0: 5177 case 0:
4779 fatal ("spec '%s' invalid", spec); 5178 fatal ("spec '%s' invalid", spec);
4780 5179
4781 case 'b': 5180 case 'b':
4782 obstack_grow (&obstack, input_basename, basename_length); 5181 if (save_temps_length)
5182 obstack_grow (&obstack, save_temps_prefix, save_temps_length);
5183 else
5184 obstack_grow (&obstack, input_basename, basename_length);
5185 if (compare_debug < 0)
5186 obstack_grow (&obstack, ".gk", 3);
4783 arg_going = 1; 5187 arg_going = 1;
4784 break; 5188 break;
4785 5189
4786 case 'B': 5190 case 'B':
4787 obstack_grow (&obstack, input_basename, suffixed_basename_length); 5191 if (save_temps_length)
5192 obstack_grow (&obstack, save_temps_prefix, save_temps_length);
5193 else
5194 obstack_grow (&obstack, input_basename, suffixed_basename_length);
5195 if (compare_debug < 0)
5196 obstack_grow (&obstack, ".gk", 3);
4788 arg_going = 1; 5197 arg_going = 1;
4789 break; 5198 break;
4790 5199
4791 case 'd': 5200 case 'd':
4792 delete_this_arg = 2; 5201 delete_this_arg = 2;
4928 TARGET_OBJECT_SUFFIX); 5337 TARGET_OBJECT_SUFFIX);
4929 } 5338 }
4930 suffix_length += strlen (TARGET_OBJECT_SUFFIX); 5339 suffix_length += strlen (TARGET_OBJECT_SUFFIX);
4931 } 5340 }
4932 5341
5342 if (compare_debug < 0)
5343 {
5344 suffix = concat (".gk", suffix, NULL);
5345 suffix_length += 3;
5346 }
5347
5348 /* If -save-temps=obj and -o were specified, use that for the
5349 temp file. */
5350 if (save_temps_length)
5351 {
5352 char *tmp;
5353 temp_filename_length
5354 = save_temps_length + suffix_length + 1;
5355 tmp = (char *) alloca (temp_filename_length);
5356 memcpy (tmp, save_temps_prefix, save_temps_length);
5357 memcpy (tmp + save_temps_length, suffix, suffix_length);
5358 tmp[save_temps_length + suffix_length] = '\0';
5359 temp_filename = save_string (tmp,
5360 temp_filename_length + 1);
5361 obstack_grow (&obstack, temp_filename,
5362 temp_filename_length);
5363 arg_going = 1;
5364 delete_this_arg = 0;
5365 break;
5366 }
5367
4933 /* If the input_filename has the same suffix specified 5368 /* If the input_filename has the same suffix specified
4934 for the %g, %u, or %U, and -save-temps is specified, 5369 for the %g, %u, or %U, and -save-temps is specified,
4935 we could end up using that file as an intermediate 5370 we could end up using that file as an intermediate
4936 thus clobbering the user's source file (.e.g., 5371 thus clobbering the user's source file (.e.g.,
4937 gcc -save-temps foo.s would clobber foo.s with the 5372 gcc -save-temps foo.s would clobber foo.s with the
4939 generate a temp file as the intermediate. */ 5374 generate a temp file as the intermediate. */
4940 5375
4941 if (save_temps_flag) 5376 if (save_temps_flag)
4942 { 5377 {
4943 char *tmp; 5378 char *tmp;
4944 5379 temp_filename_length = basename_length + suffix_length + 1;
4945 temp_filename_length = basename_length + suffix_length; 5380 tmp = (char *) alloca (temp_filename_length);
4946 tmp = (char *) alloca (temp_filename_length + 1); 5381 memcpy (tmp, input_basename, basename_length);
4947 strncpy (tmp, input_basename, basename_length); 5382 memcpy (tmp + basename_length, suffix, suffix_length);
4948 strncpy (tmp + basename_length, suffix, suffix_length); 5383 tmp[basename_length + suffix_length] = '\0';
4949 tmp[temp_filename_length] = '\0';
4950 temp_filename = tmp; 5384 temp_filename = tmp;
5385
4951 if (strcmp (temp_filename, input_filename) != 0) 5386 if (strcmp (temp_filename, input_filename) != 0)
4952 { 5387 {
4953 #ifndef HOST_LACKS_INODE_NUMBERS 5388 #ifndef HOST_LACKS_INODE_NUMBERS
4954 struct stat st_temp; 5389 struct stat st_temp;
4955 5390
5033 break; 5468 break;
5034 5469
5035 case 'i': 5470 case 'i':
5036 if (combine_inputs) 5471 if (combine_inputs)
5037 { 5472 {
5038 for (i = 0; (int) i < n_infiles; i++) 5473 if (at_file_supplied)
5039 if ((!infiles[i].language) || (infiles[i].language[0] != '*')) 5474 {
5040 if (infiles[i].incompiler == input_file_compiler) 5475 /* We are going to expand `%i' to `@FILE', where FILE
5476 is a newly-created temporary filename. The filenames
5477 that would usually be expanded in place of %o will be
5478 written to the temporary file. */
5479 char **argv;
5480 int n_files = 0;
5481 int j;
5482
5483 for (i = 0; i < n_infiles; i++)
5484 if (compile_input_file_p (&infiles[i]))
5485 n_files++;
5486
5487 argv = (char **) alloca (sizeof (char *) * (n_files + 1));
5488
5489 /* Copy the strings over. */
5490 for (i = 0, j = 0; i < n_infiles; i++)
5491 if (compile_input_file_p (&infiles[i]))
5492 {
5493 argv[j] = CONST_CAST (char *, infiles[i].name);
5494 infiles[i].compiled = true;
5495 j++;
5496 }
5497 argv[j] = NULL;
5498
5499 create_at_file (argv);
5500 }
5501 else
5502 for (i = 0; (int) i < n_infiles; i++)
5503 if (compile_input_file_p (&infiles[i]))
5041 { 5504 {
5042 store_arg (infiles[i].name, 0, 0); 5505 store_arg (infiles[i].name, 0, 0);
5043 infiles[i].compiled = true; 5506 infiles[i].compiled = true;
5044 } 5507 }
5045 } 5508 }
5113 /* We are going to expand `%o' to `@FILE', where FILE 5576 /* We are going to expand `%o' to `@FILE', where FILE
5114 is a newly-created temporary filename. The filenames 5577 is a newly-created temporary filename. The filenames
5115 that would usually be expanded in place of %o will be 5578 that would usually be expanded in place of %o will be
5116 written to the temporary file. */ 5579 written to the temporary file. */
5117 5580
5118 char *temp_file = make_temp_file ("");
5119 char *at_argument;
5120 char **argv; 5581 char **argv;
5121 int n_files, j, status; 5582 int n_files, j;
5122 FILE *f;
5123
5124 at_argument = concat ("@", temp_file, NULL);
5125 store_arg (at_argument, 0, 0);
5126 5583
5127 /* Convert OUTFILES into a form suitable for writeargv. */ 5584 /* Convert OUTFILES into a form suitable for writeargv. */
5128 5585
5129 /* Determine how many are non-NULL. */ 5586 /* Determine how many are non-NULL. */
5130 for (n_files = 0, i = 0; i < max; i++) 5587 for (n_files = 0, i = 0; i < max; i++)
5139 argv[j] = CONST_CAST (char *, outfiles[i]); 5596 argv[j] = CONST_CAST (char *, outfiles[i]);
5140 j++; 5597 j++;
5141 } 5598 }
5142 argv[j] = NULL; 5599 argv[j] = NULL;
5143 5600
5144 f = fopen (temp_file, "w"); 5601 create_at_file (argv);
5145
5146 if (f == NULL)
5147 fatal ("could not open temporary response file %s",
5148 temp_file);
5149
5150 status = writeargv (argv, f);
5151
5152 if (status)
5153 fatal ("could not write to temporary response file %s",
5154 temp_file);
5155
5156 status = fclose (f);
5157
5158 if (EOF == status)
5159 fatal ("could not close temporary response file %s",
5160 temp_file);
5161
5162 record_temp_file (temp_file, !save_temps_flag, !save_temps_flag);
5163 } 5602 }
5164 else 5603 else
5165 for (i = 0; i < max; i++) 5604 for (i = 0; i < max; i++)
5166 if (outfiles[i]) 5605 if (outfiles[i])
5167 store_arg (outfiles[i], 0, 0); 5606 store_arg (outfiles[i], 0, 0);
5173 arg_going = 1; 5612 arg_going = 1;
5174 break; 5613 break;
5175 5614
5176 case 's': 5615 case 's':
5177 this_is_library_file = 1; 5616 this_is_library_file = 1;
5617 break;
5618
5619 case 'T':
5620 this_is_linker_script = 1;
5178 break; 5621 break;
5179 5622
5180 case 'V': 5623 case 'V':
5181 outfiles[input_file_number] = NULL; 5624 outfiles[input_file_number] = NULL;
5182 break; 5625 break;
5549 int save_arg_going; 5992 int save_arg_going;
5550 int save_delete_this_arg; 5993 int save_delete_this_arg;
5551 int save_this_is_output_file; 5994 int save_this_is_output_file;
5552 int save_this_is_library_file; 5995 int save_this_is_library_file;
5553 int save_input_from_pipe; 5996 int save_input_from_pipe;
5997 int save_this_is_linker_script;
5554 const char *save_suffix_subst; 5998 const char *save_suffix_subst;
5555 5999
5556 6000
5557 sf = lookup_spec_function (func); 6001 sf = lookup_spec_function (func);
5558 if (sf == NULL) 6002 if (sf == NULL)
5565 6009
5566 save_arg_going = arg_going; 6010 save_arg_going = arg_going;
5567 save_delete_this_arg = delete_this_arg; 6011 save_delete_this_arg = delete_this_arg;
5568 save_this_is_output_file = this_is_output_file; 6012 save_this_is_output_file = this_is_output_file;
5569 save_this_is_library_file = this_is_library_file; 6013 save_this_is_library_file = this_is_library_file;
6014 save_this_is_linker_script = this_is_linker_script;
5570 save_input_from_pipe = input_from_pipe; 6015 save_input_from_pipe = input_from_pipe;
5571 save_suffix_subst = suffix_subst; 6016 save_suffix_subst = suffix_subst;
5572 6017
5573 /* Create a new spec processing context, and build the function 6018 /* Create a new spec processing context, and build the function
5574 arguments. */ 6019 arguments. */
5590 6035
5591 arg_going = save_arg_going; 6036 arg_going = save_arg_going;
5592 delete_this_arg = save_delete_this_arg; 6037 delete_this_arg = save_delete_this_arg;
5593 this_is_output_file = save_this_is_output_file; 6038 this_is_output_file = save_this_is_output_file;
5594 this_is_library_file = save_this_is_library_file; 6039 this_is_library_file = save_this_is_library_file;
6040 this_is_linker_script = save_this_is_linker_script;
5595 input_from_pipe = save_input_from_pipe; 6041 input_from_pipe = save_input_from_pipe;
5596 suffix_subst = save_suffix_subst; 6042 suffix_subst = save_suffix_subst;
5597 6043
5598 return funcval; 6044 return funcval;
5599 } 6045 }
5820 goto invalid; 6266 goto invalid;
5821 6267
5822 if (atom == end_atom) 6268 if (atom == end_atom)
5823 { 6269 {
5824 if (!n_way_choice || disj_matched || *p == '|' 6270 if (!n_way_choice || disj_matched || *p == '|'
5825 || a_is_negated || a_is_suffix || a_is_spectype 6271 || a_is_negated || a_is_suffix || a_is_spectype
5826 || a_is_starred) 6272 || a_is_starred)
5827 goto invalid; 6273 goto invalid;
5828 6274
5829 /* An empty term may appear as the last choice of an 6275 /* An empty term may appear as the last choice of an
5830 N-way choice set; it means "otherwise". */ 6276 N-way choice set; it means "otherwise". */
5834 } 6280 }
5835 else 6281 else
5836 { 6282 {
5837 if ((a_is_suffix || a_is_spectype) && a_is_starred) 6283 if ((a_is_suffix || a_is_spectype) && a_is_starred)
5838 goto invalid; 6284 goto invalid;
5839 6285
5840 if (!a_is_starred) 6286 if (!a_is_starred)
5841 disj_starred = false; 6287 disj_starred = false;
5842 6288
5843 /* Don't bother testing this atom if we already have a 6289 /* Don't bother testing this atom if we already have a
5844 match. */ 6290 match. */
5848 a_matched = input_suffix_matches (atom, end_atom); 6294 a_matched = input_suffix_matches (atom, end_atom);
5849 else if (a_is_spectype) 6295 else if (a_is_spectype)
5850 a_matched = input_spec_matches (atom, end_atom); 6296 a_matched = input_spec_matches (atom, end_atom);
5851 else 6297 else
5852 a_matched = switch_matches (atom, end_atom, a_is_starred); 6298 a_matched = switch_matches (atom, end_atom, a_is_starred);
5853 6299
5854 if (a_matched != a_is_negated) 6300 if (a_matched != a_is_negated)
5855 { 6301 {
5856 disj_matched = true; 6302 disj_matched = true;
5857 d_atom = atom; 6303 d_atom = atom;
5858 d_end_atom = end_atom; 6304 d_end_atom = end_atom;
5994 check_live_switch (int switchnum, int prefix_length) 6440 check_live_switch (int switchnum, int prefix_length)
5995 { 6441 {
5996 const char *name = switches[switchnum].part1; 6442 const char *name = switches[switchnum].part1;
5997 int i; 6443 int i;
5998 6444
6445 /* If we already processed this switch and determined if it was
6446 live or not, return our past determination. */
6447 if (switches[switchnum].live_cond != 0)
6448 return ((switches[switchnum].live_cond & SWITCH_LIVE) != 0
6449 && (switches[switchnum].live_cond & SWITCH_FALSE) == 0
6450 && (switches[switchnum].live_cond & SWITCH_IGNORE) == 0);
6451
5999 /* In the common case of {<at-most-one-letter>*}, a negating 6452 /* In the common case of {<at-most-one-letter>*}, a negating
6000 switch would always match, so ignore that case. We will just 6453 switch would always match, so ignore that case. We will just
6001 send the conflicting switches to the compiler phase. */ 6454 send the conflicting switches to the compiler phase. */
6002 if (prefix_length >= 0 && prefix_length <= 1) 6455 if (prefix_length >= 0 && prefix_length <= 1)
6003 return 1; 6456 return 1;
6004
6005 /* If we already processed this switch and determined if it was
6006 live or not, return our past determination. */
6007 if (switches[switchnum].live_cond != 0)
6008 return ((switches[switchnum].live_cond & SWITCH_LIVE) != 0
6009 && (switches[switchnum].live_cond & SWITCH_FALSE) == 0);
6010 6457
6011 /* Now search for duplicate in a manner that depends on the name. */ 6458 /* Now search for duplicate in a manner that depends on the name. */
6012 switch (*name) 6459 switch (*name)
6013 { 6460 {
6014 case 'O': 6461 case 'O':
6166 { 6613 {
6167 const char *p; 6614 const char *p;
6168 6615
6169 input_filename = filename; 6616 input_filename = filename;
6170 input_filename_length = strlen (input_filename); 6617 input_filename_length = strlen (input_filename);
6171 6618 input_basename = lbasename (input_filename);
6172 input_basename = input_filename;
6173 #ifdef HAVE_DOS_BASED_FILE_SYSTEM
6174 /* Skip drive name so 'x:foo' is handled properly. */
6175 if (input_basename[1] == ':')
6176 input_basename += 2;
6177 #endif
6178 for (p = input_basename; *p; p++)
6179 if (IS_DIR_SEPARATOR (*p))
6180 input_basename = p + 1;
6181 6619
6182 /* Find a suffix starting with the last period, 6620 /* Find a suffix starting with the last period,
6183 and set basename_length to exclude that suffix. */ 6621 and set basename_length to exclude that suffix. */
6184 basename_length = strlen (input_basename); 6622 basename_length = strlen (input_basename);
6185 suffixed_basename_length = basename_length; 6623 suffixed_basename_length = basename_length;
6209 delete_failure_queue (); 6647 delete_failure_queue ();
6210 delete_temp_files (); 6648 delete_temp_files ();
6211 /* Get the same signal again, this time not handled, 6649 /* Get the same signal again, this time not handled,
6212 so its normal effect occurs. */ 6650 so its normal effect occurs. */
6213 kill (getpid (), signum); 6651 kill (getpid (), signum);
6652 }
6653
6654 /* Compare the contents of the two files named CMPFILE[0] and
6655 CMPFILE[1]. Return zero if they're identical, nonzero
6656 otherwise. */
6657
6658 static int
6659 compare_files (char *cmpfile[])
6660 {
6661 int ret = 0;
6662 FILE *temp[2] = { NULL, NULL };
6663 int i;
6664
6665 #if HAVE_MMAP_FILE
6666 {
6667 size_t length[2];
6668 void *map[2] = { NULL, NULL };
6669
6670 for (i = 0; i < 2; i++)
6671 {
6672 struct stat st;
6673
6674 if (stat (cmpfile[i], &st) < 0 || !S_ISREG (st.st_mode))
6675 {
6676 error ("%s: could not determine length of compare-debug file %s",
6677 input_filename, cmpfile[i]);
6678 ret = 1;
6679 break;
6680 }
6681
6682 length[i] = st.st_size;
6683 }
6684
6685 if (!ret && length[0] != length[1])
6686 {
6687 error ("%s: -fcompare-debug failure (length)", input_filename);
6688 ret = 1;
6689 }
6690
6691 if (!ret)
6692 for (i = 0; i < 2; i++)
6693 {
6694 int fd = open (cmpfile[i], O_RDONLY);
6695 if (fd < 0)
6696 {
6697 error ("%s: could not open compare-debug file %s",
6698 input_filename, cmpfile[i]);
6699 ret = 1;
6700 break;
6701 }
6702
6703 map[i] = mmap (NULL, length[i], PROT_READ, MAP_PRIVATE, fd, 0);
6704 close (fd);
6705
6706 if (map[i] == (void *) MAP_FAILED)
6707 {
6708 ret = -1;
6709 break;
6710 }
6711 }
6712
6713 if (!ret)
6714 {
6715 if (memcmp (map[0], map[1], length[0]) != 0)
6716 {
6717 error ("%s: -fcompare-debug failure", input_filename);
6718 ret = 1;
6719 }
6720 }
6721
6722 for (i = 0; i < 2; i++)
6723 if (map[i])
6724 munmap ((caddr_t) map[i], length[i]);
6725
6726 if (ret >= 0)
6727 return ret;
6728
6729 ret = 0;
6730 }
6731 #endif
6732
6733 for (i = 0; i < 2; i++)
6734 {
6735 temp[i] = fopen (cmpfile[i], "r");
6736 if (!temp[i])
6737 {
6738 error ("%s: could not open compare-debug file %s",
6739 input_filename, cmpfile[i]);
6740 ret = 1;
6741 break;
6742 }
6743 }
6744
6745 if (!ret && temp[0] && temp[1])
6746 for (;;)
6747 {
6748 int c0, c1;
6749 c0 = fgetc (temp[0]);
6750 c1 = fgetc (temp[1]);
6751
6752 if (c0 != c1)
6753 {
6754 error ("%s: -fcompare-debug failure",
6755 input_filename);
6756 ret = 1;
6757 break;
6758 }
6759
6760 if (c0 == EOF)
6761 break;
6762 }
6763
6764 for (i = 1; i >= 0; i--)
6765 {
6766 if (temp[i])
6767 fclose (temp[i]);
6768 }
6769
6770 return ret;
6214 } 6771 }
6215 6772
6216 extern int main (int, char **); 6773 extern int main (int, char **);
6217 6774
6218 int 6775 int
6321 6878
6322 obstack_1grow (&multilib_obstack, 0); 6879 obstack_1grow (&multilib_obstack, 0);
6323 multilib_defaults = XOBFINISH (&multilib_obstack, const char *); 6880 multilib_defaults = XOBFINISH (&multilib_obstack, const char *);
6324 } 6881 }
6325 6882
6326 /* Set up to remember the pathname of gcc and any options
6327 needed for collect. We use argv[0] instead of programname because
6328 we need the complete pathname. */
6329 obstack_init (&collect_obstack);
6330 obstack_grow (&collect_obstack, "COLLECT_GCC=", sizeof ("COLLECT_GCC=") - 1);
6331 obstack_grow (&collect_obstack, argv[0], strlen (argv[0]) + 1);
6332 xputenv (XOBFINISH (&collect_obstack, char *));
6333
6334 #ifdef INIT_ENVIRONMENT 6883 #ifdef INIT_ENVIRONMENT
6335 /* Set up any other necessary machine specific environment variables. */ 6884 /* Set up any other necessary machine specific environment variables. */
6336 xputenv (INIT_ENVIRONMENT); 6885 xputenv (INIT_ENVIRONMENT);
6337 #endif 6886 #endif
6338 6887
6339 /* Make a table of what switches there are (switches, n_switches). 6888 /* Make a table of what switches there are (switches, n_switches).
6340 Make a table of specified input files (infiles, n_infiles). 6889 Make a table of specified input files (infiles, n_infiles).
6341 Decode switches that are handled locally. */ 6890 Decode switches that are handled locally. */
6342 6891
6343 process_command (argc, (const char **) argv); 6892 process_command (argc, CONST_CAST2 (const char **, char **, argv));
6344 6893
6345 /* Initialize the vector of specs to just the default. 6894 /* Initialize the vector of specs to just the default.
6346 This means one element containing 0s, as a terminator. */ 6895 This means one element containing 0s, as a terminator. */
6347 6896
6348 compilers = XNEWVAR (struct compiler, sizeof default_compilers); 6897 compilers = XNEWVAR (struct compiler, sizeof default_compilers);
6382 /* Process DRIVER_SELF_SPECS, adding any new options to the end 6931 /* Process DRIVER_SELF_SPECS, adding any new options to the end
6383 of the command line. */ 6932 of the command line. */
6384 6933
6385 for (i = 0; i < ARRAY_SIZE (driver_self_specs); i++) 6934 for (i = 0; i < ARRAY_SIZE (driver_self_specs); i++)
6386 do_self_spec (driver_self_specs[i]); 6935 do_self_spec (driver_self_specs[i]);
6936
6937 if (compare_debug)
6938 {
6939 enum save_temps save;
6940
6941 if (!compare_debug_second)
6942 {
6943 n_switches_debug_check[1] = n_switches;
6944 switches_debug_check[1] = XDUPVEC (struct switchstr, switches,
6945 n_switches + 1);
6946
6947 do_self_spec ("%:compare-debug-self-opt()");
6948 n_switches_debug_check[0] = n_switches;
6949 switches_debug_check[0] = switches;
6950
6951 n_switches = n_switches_debug_check[1];
6952 switches = switches_debug_check[1];
6953 }
6954
6955 /* Avoid crash when computing %j in this early. */
6956 save = save_temps_flag;
6957 save_temps_flag = SAVE_TEMPS_NONE;
6958
6959 compare_debug = -compare_debug;
6960 do_self_spec ("%:compare-debug-self-opt()");
6961
6962 save_temps_flag = save;
6963
6964 if (!compare_debug_second)
6965 {
6966 n_switches_debug_check[1] = n_switches;
6967 switches_debug_check[1] = switches;
6968 compare_debug = -compare_debug;
6969 n_switches = n_switches_debug_check[0];
6970 switches = switches_debug_check[0];
6971 }
6972 }
6387 6973
6388 /* If not cross-compiling, look for executables in the standard 6974 /* If not cross-compiling, look for executables in the standard
6389 places. */ 6975 places. */
6390 if (*cross_compile == '0') 6976 if (*cross_compile == '0')
6391 { 6977 {
6463 standard_startfile_prefix, "BINUTILS", 7049 standard_startfile_prefix, "BINUTILS",
6464 PREFIX_PRIORITY_LAST, 0, 1); 7050 PREFIX_PRIORITY_LAST, 0, 1);
6465 else if (*cross_compile == '0') 7051 else if (*cross_compile == '0')
6466 { 7052 {
6467 add_prefix (&startfile_prefixes, 7053 add_prefix (&startfile_prefixes,
6468 concat (gcc_exec_prefix 7054 concat (gcc_exec_prefix
6469 ? gcc_exec_prefix : standard_exec_prefix, 7055 ? gcc_exec_prefix : standard_exec_prefix,
6470 machine_suffix, 7056 machine_suffix,
6471 standard_startfile_prefix, NULL), 7057 standard_startfile_prefix, NULL),
6472 NULL, PREFIX_PRIORITY_LAST, 0, 1); 7058 NULL, PREFIX_PRIORITY_LAST, 0, 1);
6473 } 7059 }
6474 7060
6475 /* Sysrooted prefixes are relocated because target_system_root is 7061 /* Sysrooted prefixes are relocated because target_system_root is
6505 7091
6506 /* Now that we have the switches and the specs, set 7092 /* Now that we have the switches and the specs, set
6507 the subdirectory based on the options. */ 7093 the subdirectory based on the options. */
6508 set_multilib_dir (); 7094 set_multilib_dir ();
6509 7095
7096 /* Set up to remember the pathname of gcc and any options
7097 needed for collect. We use argv[0] instead of programname because
7098 we need the complete pathname. */
7099 obstack_init (&collect_obstack);
7100 obstack_grow (&collect_obstack, "COLLECT_GCC=", sizeof ("COLLECT_GCC=") - 1);
7101 obstack_grow (&collect_obstack, argv[0], strlen (argv[0]) + 1);
7102 xputenv (XOBFINISH (&collect_obstack, char *));
7103
7104 /* Set up to remember the pathname of the lto wrapper. */
7105
7106 lto_wrapper_spec = find_a_file (&exec_prefixes, "lto-wrapper", X_OK, false);
7107 if (lto_wrapper_spec)
7108 {
7109 obstack_init (&collect_obstack);
7110 obstack_grow (&collect_obstack, "COLLECT_LTO_WRAPPER=",
7111 sizeof ("COLLECT_LTO_WRAPPER=") - 1);
7112 obstack_grow (&collect_obstack, lto_wrapper_spec,
7113 strlen (lto_wrapper_spec) + 1);
7114 xputenv (XOBFINISH (&collect_obstack, char *));
7115 }
7116
6510 /* Warn about any switches that no pass was interested in. */ 7117 /* Warn about any switches that no pass was interested in. */
6511 7118
6512 for (i = 0; (int) i < n_switches; i++) 7119 for (i = 0; (int) i < n_switches; i++)
6513 if (! switches[i].validated) 7120 if (! switches[i].validated)
6514 error ("unrecognized option '-%s'", switches[i].part1); 7121 error ("unrecognized option '-%s'", switches[i].part1);
6605 7212
6606 /* We do not exit here. Instead we have created a fake input file 7213 /* We do not exit here. Instead we have created a fake input file
6607 called 'help-dummy' which needs to be compiled, and we pass this 7214 called 'help-dummy' which needs to be compiled, and we pass this
6608 on the various sub-processes, along with the --help switch. 7215 on the various sub-processes, along with the --help switch.
6609 Ensure their output appears after ours. */ 7216 Ensure their output appears after ours. */
7217 fputc ('\n', stdout);
7218 fflush (stdout);
7219 }
7220
7221 if (print_version)
7222 {
7223 printf (_("%s %s%s\n"), programname, pkgversion_string,
7224 version_string);
7225 printf ("Copyright %s 2009 Free Software Foundation, Inc.\n",
7226 _("(C)"));
7227 fputs (_("This is free software; see the source for copying conditions. There is NO\n\
7228 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\n"),
7229 stdout);
7230 if (! verbose_flag)
7231 return 0;
7232
7233 /* We do not exit here. We use the same mechanism of --help to print
7234 the version of the sub-processes. */
6610 fputc ('\n', stdout); 7235 fputc ('\n', stdout);
6611 fflush (stdout); 7236 fflush (stdout);
6612 } 7237 }
6613 7238
6614 if (verbose_flag) 7239 if (verbose_flag)
6699 infiles[i].compiled = false; 7324 infiles[i].compiled = false;
6700 infiles[i].preprocessed = false; 7325 infiles[i].preprocessed = false;
6701 } 7326 }
6702 7327
6703 if (!combine_inputs && have_c && have_o && lang_n_infiles > 1) 7328 if (!combine_inputs && have_c && have_o && lang_n_infiles > 1)
6704 fatal ("cannot specify -o with -c or -S with multiple files"); 7329 fatal ("cannot specify -o with -c, -S or -E with multiple files");
6705 7330
6706 if (combine_flag && save_temps_flag) 7331 if (combine_flag && save_temps_flag)
6707 { 7332 {
6708 bool save_combine_inputs = combine_inputs; 7333 bool save_combine_inputs = combine_inputs;
6709 /* Must do a separate pre-processing pass for C & Objective-C files, to 7334 /* Must do a separate pre-processing pass for C & Objective-C files, to
6793 input_filename, &input_file_compiler->spec[1]); 7418 input_filename, &input_file_compiler->spec[1]);
6794 this_file_error = 1; 7419 this_file_error = 1;
6795 } 7420 }
6796 else 7421 else
6797 { 7422 {
7423 if (compare_debug)
7424 {
7425 if (debug_check_temp_file[0])
7426 free (debug_check_temp_file[0]);
7427 debug_check_temp_file[0] = NULL;
7428
7429 if (debug_check_temp_file[1])
7430 free (debug_check_temp_file[1]);
7431 debug_check_temp_file[1] = NULL;
7432 }
7433
6798 value = do_spec (input_file_compiler->spec); 7434 value = do_spec (input_file_compiler->spec);
6799 infiles[i].compiled = true; 7435 infiles[i].compiled = true;
6800 if (value < 0) 7436 if (value < 0)
6801 this_file_error = 1; 7437 this_file_error = 1;
7438 else if (compare_debug && debug_check_temp_file[0])
7439 {
7440 if (verbose_flag)
7441 error ("Recompiling with -fcompare-debug");
7442
7443 compare_debug = -compare_debug;
7444 n_switches = n_switches_debug_check[1];
7445 switches = switches_debug_check[1];
7446
7447 value = do_spec (input_file_compiler->spec);
7448
7449 compare_debug = -compare_debug;
7450 n_switches = n_switches_debug_check[0];
7451 switches = switches_debug_check[0];
7452
7453 if (value < 0)
7454 {
7455 error ("during -fcompare-debug recompilation");
7456 this_file_error = 1;
7457 }
7458
7459 gcc_assert (debug_check_temp_file[1]
7460 && strcmp (debug_check_temp_file[0],
7461 debug_check_temp_file[1]));
7462
7463 if (verbose_flag)
7464 error ("Comparing final insns dumps");
7465
7466 if (compare_files (debug_check_temp_file))
7467 this_file_error = 1;
7468 }
7469
7470 if (compare_debug)
7471 {
7472 if (debug_check_temp_file[0])
7473 free (debug_check_temp_file[0]);
7474 debug_check_temp_file[0] = NULL;
7475
7476 if (debug_check_temp_file[1])
7477 free (debug_check_temp_file[1]);
7478 debug_check_temp_file[1] = NULL;
7479 }
6802 } 7480 }
6803 } 7481 }
6804 7482
6805 /* If this file's name does not contain a recognized suffix, 7483 /* If this file's name does not contain a recognized suffix,
6806 record it as explicit linker input. */ 7484 record it as explicit linker input. */
6854 /* Run ld to link all the compiler output files. */ 7532 /* Run ld to link all the compiler output files. */
6855 7533
6856 if (num_linker_inputs > 0 && error_count == 0 && print_subprocess_help < 2) 7534 if (num_linker_inputs > 0 && error_count == 0 && print_subprocess_help < 2)
6857 { 7535 {
6858 int tmp = execution_count; 7536 int tmp = execution_count;
7537 const char *fuse_linker_plugin = "fuse-linker-plugin";
6859 7538
6860 /* We'll use ld if we can't find collect2. */ 7539 /* We'll use ld if we can't find collect2. */
6861 if (! strcmp (linker_name_spec, "collect2")) 7540 if (! strcmp (linker_name_spec, "collect2"))
6862 { 7541 {
6863 char *s = find_a_file (&exec_prefixes, "collect2", X_OK, false); 7542 char *s = find_a_file (&exec_prefixes, "collect2", X_OK, false);
6864 if (s == NULL) 7543 if (s == NULL)
6865 linker_name_spec = "ld"; 7544 linker_name_spec = "ld";
6866 } 7545 }
7546
7547 if (switch_matches (fuse_linker_plugin,
7548 fuse_linker_plugin + strlen (fuse_linker_plugin), 0))
7549 {
7550 linker_plugin_file_spec = find_a_file (&exec_prefixes,
7551 "liblto_plugin.so", X_OK,
7552 false);
7553 if (!linker_plugin_file_spec)
7554 fatal ("-fuse-linker-plugin, but liblto_plugin.so not found");
7555
7556 lto_libgcc_spec = find_a_file (&startfile_prefixes, "libgcc.a",
7557 R_OK, true);
7558 if (!lto_libgcc_spec)
7559 fatal ("could not find libgcc.a");
7560 }
7561 lto_gcc_spec = argv[0];
7562
6867 /* Rebuild the COMPILER_PATH and LIBRARY_PATH environment variables 7563 /* Rebuild the COMPILER_PATH and LIBRARY_PATH environment variables
6868 for collect. */ 7564 for collect. */
6869 putenv_from_prefixes (&exec_prefixes, "COMPILER_PATH", false); 7565 putenv_from_prefixes (&exec_prefixes, "COMPILER_PATH", false);
6870 putenv_from_prefixes (&startfile_prefixes, LIBRARY_PATH_ENV, true); 7566 putenv_from_prefixes (&startfile_prefixes, LIBRARY_PATH_ENV, true);
6871 7567
7869 for (ptr = result; *value; ptr += 2) 8565 for (ptr = result; *value; ptr += 2)
7870 { 8566 {
7871 ptr[0] = '\\'; 8567 ptr[0] = '\\';
7872 ptr[1] = *value++; 8568 ptr[1] = *value++;
7873 } 8569 }
7874 8570
7875 strcpy (ptr, argv[1]); 8571 strcpy (ptr, argv[1]);
7876 8572
7877 return result; 8573 return result;
7878 } 8574 }
7879 8575
7880 /* if-exists built-in spec function. 8576 /* if-exists built-in spec function.
7881 8577
8081 printf (_("Assembler options\n=================\n\n")); 8777 printf (_("Assembler options\n=================\n\n"));
8082 printf (_("Use \"-Wa,OPTION\" to pass \"OPTION\" to the assembler.\n\n")); 8778 printf (_("Use \"-Wa,OPTION\" to pass \"OPTION\" to the assembler.\n\n"));
8083 fflush (stdout); 8779 fflush (stdout);
8084 return NULL; 8780 return NULL;
8085 } 8781 }
8782
8783 /* Compute a timestamp to initialize flag_random_seed. */
8784
8785 static unsigned
8786 get_local_tick (void)
8787 {
8788 unsigned ret = 0;
8789
8790 /* Get some more or less random data. */
8791 #ifdef HAVE_GETTIMEOFDAY
8792 {
8793 struct timeval tv;
8794
8795 gettimeofday (&tv, NULL);
8796 ret = tv.tv_sec * 1000 + tv.tv_usec / 1000;
8797 }
8798 #else
8799 {
8800 time_t now = time (NULL);
8801
8802 if (now != (time_t)-1)
8803 ret = (unsigned) now;
8804 }
8805 #endif
8806
8807 return ret;
8808 }
8809
8810 /* %:compare-debug-dump-opt spec function. Save the last argument,
8811 expected to be the last -fdump-final-insns option, or generate a
8812 temporary. */
8813
8814 static const char *
8815 compare_debug_dump_opt_spec_function (int arg,
8816 const char **argv ATTRIBUTE_UNUSED)
8817 {
8818 const char *ret;
8819 char *name;
8820 int which;
8821 static char random_seed[HOST_BITS_PER_WIDE_INT / 4 + 3];
8822
8823 if (arg != 0)
8824 fatal ("too many arguments to %%:compare-debug-dump-opt");
8825
8826 do_spec_2 ("%{fdump-final-insns=*:%*}");
8827 do_spec_1 (" ", 0, NULL);
8828
8829 if (argbuf_index > 0 && strcmp (argv[argbuf_index - 1], "."))
8830 {
8831 if (!compare_debug)
8832 return NULL;
8833
8834 name = xstrdup (argv[argbuf_index - 1]);
8835 ret = NULL;
8836 }
8837 else
8838 {
8839 const char *ext = NULL;
8840
8841 if (argbuf_index > 0)
8842 {
8843 do_spec_2 ("%{o*:%*}%{!o:%{!S:%b%O}%{S:%b.s}}");
8844 ext = ".gkd";
8845 }
8846 else if (!compare_debug)
8847 return NULL;
8848 else
8849 do_spec_2 ("%g.gkd");
8850
8851 do_spec_1 (" ", 0, NULL);
8852
8853 gcc_assert (argbuf_index > 0);
8854
8855 name = concat (argbuf[argbuf_index - 1], ext, NULL);
8856
8857 ret = concat ("-fdump-final-insns=", name, NULL);
8858 }
8859
8860 which = compare_debug < 0;
8861 debug_check_temp_file[which] = name;
8862
8863 if (!which)
8864 {
8865 unsigned HOST_WIDE_INT value = get_local_tick () ^ getpid ();
8866
8867 sprintf (random_seed, HOST_WIDE_INT_PRINT_HEX, value);
8868 }
8869
8870 if (*random_seed)
8871 ret = concat ("%{!frandom-seed=*:-frandom-seed=", random_seed, "} ",
8872 ret, NULL);
8873
8874 if (which)
8875 *random_seed = 0;
8876
8877 return ret;
8878 }
8879
8880 static const char *debug_auxbase_opt;
8881
8882 /* %:compare-debug-self-opt spec function. Expands to the options
8883 that are to be passed in the second compilation of
8884 compare-debug. */
8885
8886 static const char *
8887 compare_debug_self_opt_spec_function (int arg,
8888 const char **argv ATTRIBUTE_UNUSED)
8889 {
8890 if (arg != 0)
8891 fatal ("too many arguments to %%:compare-debug-self-opt");
8892
8893 if (compare_debug >= 0)
8894 return NULL;
8895
8896 do_spec_2 ("%{c|S:%{o*:%*}}");
8897 do_spec_1 (" ", 0, NULL);
8898
8899 if (argbuf_index > 0)
8900 debug_auxbase_opt = concat ("-auxbase-strip ",
8901 argbuf[argbuf_index - 1],
8902 NULL);
8903 else
8904 debug_auxbase_opt = NULL;
8905
8906 return concat ("\
8907 %<o %<MD %<MMD %<MF* %<MG %<MP %<MQ* %<MT* \
8908 %<fdump-final-insns=* -w -S -o %j \
8909 %{!fcompare-debug-second:-fcompare-debug-second} \
8910 ", compare_debug_opt, NULL);
8911 }
8912
8913 /* %:compare-debug-auxbase-opt spec function. Expands to the auxbase
8914 options that are to be passed in the second compilation of
8915 compare-debug. It expects, as an argument, the basename of the
8916 current input file name, with the .gk suffix appended to it. */
8917
8918 static const char *
8919 compare_debug_auxbase_opt_spec_function (int arg,
8920 const char **argv)
8921 {
8922 char *name;
8923 int len;
8924
8925 if (arg == 0)
8926 fatal ("too few arguments to %%:compare-debug-auxbase-opt");
8927
8928 if (arg != 1)
8929 fatal ("too many arguments to %%:compare-debug-auxbase-opt");
8930
8931 if (compare_debug >= 0)
8932 return NULL;
8933
8934 len = strlen (argv[0]);
8935 if (len < 3 || strcmp (argv[0] + len - 3, ".gk") != 0)
8936 fatal ("argument to %%:compare-debug-auxbase-opt does not end in .gk");
8937
8938 if (debug_auxbase_opt)
8939 return debug_auxbase_opt;
8940
8941 #define OPT "-auxbase "
8942
8943 len -= 3;
8944 name = (char*) xmalloc (sizeof (OPT) + len);
8945 memcpy (name, OPT, sizeof (OPT) - 1);
8946 memcpy (name + sizeof (OPT) - 1, argv[0], len);
8947 name[sizeof (OPT) - 1 + len] = '\0';
8948
8949 #undef OPT
8950
8951 return name;
8952 }