comparison gcc/gcc.c @ 63:b7f97abdc517 gcc-4.6-20100522

update gcc from gcc-4.5.0 to gcc-4.6
author ryoma <e075725@ie.u-ryukyu.ac.jp>
date Mon, 24 May 2010 12:47:05 +0900
parents 77e2b8dfacca
children f6334be47118
comparison
equal deleted inserted replaced
56:3c8a44c06a95 63:b7f97abdc517
1 /* Compiler driver program that can handle many languages. 1 /* Compiler driver program that can handle many languages.
2 Copyright (C) 1987, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 2 Copyright (C) 1987, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
3 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 3 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
4 2010
4 Free Software Foundation, Inc. 5 Free Software Foundation, Inc.
5 6
6 This file is part of GCC. 7 This file is part of GCC.
7 8
8 GCC is free software; you can redistribute it and/or modify it under 9 GCC is free software; you can redistribute it and/or modify it under
259 260
260 /* The compiler version. */ 261 /* The compiler version. */
261 262
262 static const char *compiler_version; 263 static const char *compiler_version;
263 264
264 /* The target version specified with -V */ 265 /* The target version. */
265 266
266 static const char *const spec_version = DEFAULT_TARGET_VERSION; 267 static const char *const spec_version = DEFAULT_TARGET_VERSION;
267 268
268 /* The target machine specified with -b. */ 269 /* The target machine. */
269 270
270 static const char *spec_machine = DEFAULT_TARGET_MACHINE; 271 static const char *spec_machine = DEFAULT_TARGET_MACHINE;
271 272
272 /* Nonzero if cross-compiling. 273 /* Nonzero if cross-compiling.
273 When -b is used, the value comes from the `specs' file. */ 274 When -b is used, the value comes from the `specs' file. */
400 static const char *if_exists_spec_function (int, const char **); 401 static const char *if_exists_spec_function (int, const char **);
401 static const char *if_exists_else_spec_function (int, const char **); 402 static const char *if_exists_else_spec_function (int, const char **);
402 static const char *replace_outfile_spec_function (int, const char **); 403 static const char *replace_outfile_spec_function (int, const char **);
403 static const char *version_compare_spec_function (int, const char **); 404 static const char *version_compare_spec_function (int, const char **);
404 static const char *include_spec_function (int, const char **); 405 static const char *include_spec_function (int, const char **);
406 static const char *find_file_spec_function (int, const char **);
405 static const char *print_asm_header_spec_function (int, const char **); 407 static const char *print_asm_header_spec_function (int, const char **);
406 static const char *compare_debug_dump_opt_spec_function (int, const char **); 408 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 **); 409 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 **); 410 static const char *compare_debug_auxbase_opt_spec_function (int, const char **);
409 411
777 %{!fsyntax-only:%{!c:%{!M:%{!MM:%{!E:%{!S:\ 779 %{!fsyntax-only:%{!c:%{!M:%{!MM:%{!E:%{!S:\
778 %(linker) \ 780 %(linker) \
779 %{fuse-linker-plugin: \ 781 %{fuse-linker-plugin: \
780 -plugin %(linker_plugin_file) \ 782 -plugin %(linker_plugin_file) \
781 -plugin-opt=%(lto_wrapper) \ 783 -plugin-opt=%(lto_wrapper) \
782 -plugin-opt=%(lto_gcc) \ 784 -plugin-opt=-fresolution=%u.res \
783 %{static|static-libgcc:-plugin-opt=-pass-through=%(lto_libgcc)} \ 785 %{static|static-libgcc:-plugin-opt=-pass-through=%(lto_libgcc)} \
784 %{static:-plugin-opt=-pass-through=-lc} \ 786 %{static:-plugin-opt=-pass-through=-lc} \
785 %{O*:-plugin-opt=-O%*} \
786 %{w:-plugin-opt=-w} \
787 %{f*:-plugin-opt=-f%*} \
788 } \ 787 } \
789 %{flto} %{fwhopr} %l " LINK_PIE_SPEC \ 788 %{flto} %{fwhopr*} %l " LINK_PIE_SPEC \
790 "%X %{o*} %{A} %{d} %{e*} %{m} %{N} %{n} %{r}\ 789 "%X %{o*} %{A} %{d} %{e*} %{m} %{N} %{n} %{r}\
791 %{s} %{t} %{u*} %{x} %{z} %{Z} %{!A:%{!nostdlib:%{!nostartfiles:%S}}}\ 790 %{s} %{t} %{u*} %{x} %{z} %{Z} %{!A:%{!nostdlib:%{!nostartfiles:%S}}}\
792 %{static:} %{L*} %(mfwrap) %(link_libgcc) %o\ 791 %{static:} %{L*} %(mfwrap) %(link_libgcc) %o\
793 %{fopenmp|ftree-parallelize-loops=*:%:include(libgomp.spec)%(link_gomp)} %(mflib)\ 792 %{fopenmp|ftree-parallelize-loops=*:%:include(libgomp.spec)%(link_gomp)} %(mflib)\
794 %{fprofile-arcs|fprofile-generate*|coverage:-lgcov}\ 793 %{fprofile-arcs|fprofile-generate*|coverage:-lgcov}\
867 %{MD:-MD %{!o:%b.d}%{o*:%.d%*}}\ 866 %{MD:-MD %{!o:%b.d}%{o*:%.d%*}}\
868 %{MMD:-MMD %{!o:%b.d}%{o*:%.d%*}}\ 867 %{MMD:-MMD %{!o:%b.d}%{o*:%.d%*}}\
869 %{M} %{MM} %{MF*} %{MG} %{MP} %{MQ*} %{MT*}\ 868 %{M} %{MM} %{MF*} %{MG} %{MP} %{MQ*} %{MT*}\
870 %{!E:%{!M:%{!MM:%{!MT:%{!MQ:%{MD|MMD:%{o*:-MQ %*}}}}}}}\ 869 %{!E:%{!M:%{!MM:%{!MT:%{!MQ:%{MD|MMD:%{o*:-MQ %*}}}}}}}\
871 %{remap} %{g3|ggdb3|gstabs3|gcoff3|gxcoff3|gvms3:-dD}\ 870 %{remap} %{g3|ggdb3|gstabs3|gcoff3|gxcoff3|gvms3:-dD}\
871 %{!iplugindir*:%{fplugin*:-iplugindir=%:find-file(plugin)}}\
872 %{H} %C %{D*&U*&A*} %{i*} %Z %i\ 872 %{H} %C %{D*&U*&A*} %{i*} %Z %i\
873 %{fmudflap:-D_MUDFLAP -include mf-runtime.h}\ 873 %{fmudflap:-D_MUDFLAP -include mf-runtime.h}\
874 %{fmudflapth:-D_MUDFLAP -D_MUDFLAPTH -include mf-runtime.h}\ 874 %{fmudflapth:-D_MUDFLAP -D_MUDFLAPTH -include mf-runtime.h}\
875 %{E|M|MM:%W{o*}}"; 875 %{E|M|MM:%W{o*}}";
876 876
889 static const char *cpp_debug_options = "%{d*}"; 889 static const char *cpp_debug_options = "%{d*}";
890 890
891 /* NB: This is shared amongst all front-ends, except for Ada. */ 891 /* NB: This is shared amongst all front-ends, except for Ada. */
892 static const char *cc1_options = 892 static const char *cc1_options =
893 "%{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}}\
894 %1 %{!Q:-quiet} -dumpbase %B %{d*} %{m*} %{a*}\ 894 %{!iplugindir*:%{fplugin*:-iplugindir=%:find-file(plugin)}}\
895 %1 %{!Q:-quiet} %{!dumpbase:-dumpbase %B} %{d*} %{m*} %{a*}\
895 %{fcompare-debug-second:%:compare-debug-auxbase-opt(%b)} \ 896 %{fcompare-debug-second:%:compare-debug-auxbase-opt(%b)} \
896 %{!fcompare-debug-second:%{c|S:%{o*:-auxbase-strip %*}%{!o*:-auxbase %b}}}%{!c:%{!S:-auxbase %b}} \ 897 %{!fcompare-debug-second:%{c|S:%{o*:-auxbase-strip %*}%{!o*:-auxbase %b}}}%{!c:%{!S:-auxbase %b}} \
897 %{g*} %{O*} %{W*&pedantic*} %{w} %{std*&ansi&trigraphs}\ 898 %{g*} %{O*} %{W*&pedantic*} %{w} %{std*&ansi&trigraphs}\
898 %{v:-version} %{pg:-p} %{p} %{f*} %{undef}\ 899 %{v:-version} %{pg:-p} %{p} %{f*} %{undef}\
899 %{Qn:-fno-ident} %{--help:--help}\ 900 %{Qn:-fno-ident} %{--help:--help}\
1186 {"--debug", "-g", "oj"}, 1187 {"--debug", "-g", "oj"},
1187 {"--define-macro", "-D", "aj"}, 1188 {"--define-macro", "-D", "aj"},
1188 {"--dependencies", "-M", 0}, 1189 {"--dependencies", "-M", 0},
1189 {"--dump", "-d", "a"}, 1190 {"--dump", "-d", "a"},
1190 {"--dumpbase", "-dumpbase", "a"}, 1191 {"--dumpbase", "-dumpbase", "a"},
1192 {"--dumpdir", "-dumpdir", "a"},
1191 {"--encoding", "-fencoding=", "aj"}, 1193 {"--encoding", "-fencoding=", "aj"},
1192 {"--entry", "-e", 0}, 1194 {"--entry", "-e", 0},
1193 {"--extra-warnings", "-W", 0}, 1195 {"--extra-warnings", "-W", 0},
1194 {"--extdirs", "-fextdirs=", "aj"}, 1196 {"--extdirs", "-fextdirs=", "aj"},
1195 {"--for-assembler", "-Wa", "a"}, 1197 {"--for-assembler", "-Wa", "a"},
1720 { "if-exists", if_exists_spec_function }, 1722 { "if-exists", if_exists_spec_function },
1721 { "if-exists-else", if_exists_else_spec_function }, 1723 { "if-exists-else", if_exists_else_spec_function },
1722 { "replace-outfile", replace_outfile_spec_function }, 1724 { "replace-outfile", replace_outfile_spec_function },
1723 { "version-compare", version_compare_spec_function }, 1725 { "version-compare", version_compare_spec_function },
1724 { "include", include_spec_function }, 1726 { "include", include_spec_function },
1727 { "find-file", find_file_spec_function },
1725 { "print-asm-header", print_asm_header_spec_function }, 1728 { "print-asm-header", print_asm_header_spec_function },
1726 { "compare-debug-dump-opt", compare_debug_dump_opt_spec_function }, 1729 { "compare-debug-dump-opt", compare_debug_dump_opt_spec_function },
1727 { "compare-debug-self-opt", compare_debug_self_opt_spec_function }, 1730 { "compare-debug-self-opt", compare_debug_self_opt_spec_function },
1728 { "compare-debug-auxbase-opt", compare_debug_auxbase_opt_spec_function }, 1731 { "compare-debug-auxbase-opt", compare_debug_auxbase_opt_spec_function },
1729 #ifdef EXTRA_SPEC_FUNCTIONS 1732 #ifdef EXTRA_SPEC_FUNCTIONS
2071 argbuf[argbuf_index] = 0; 2074 argbuf[argbuf_index] = 0;
2072 2075
2073 if (strcmp (arg, "-o") == 0) 2076 if (strcmp (arg, "-o") == 0)
2074 have_o_argbuf_index = argbuf_index; 2077 have_o_argbuf_index = argbuf_index;
2075 if (delete_always || delete_failure) 2078 if (delete_always || delete_failure)
2076 record_temp_file (arg, delete_always, delete_failure); 2079 {
2080 const char *p;
2081 /* If the temporary file we should delete is specified as
2082 part of a joined argument extract the filename. */
2083 if (arg[0] == '-'
2084 && (p = strrchr (arg, '=')))
2085 arg = p + 1;
2086 record_temp_file (arg, delete_always, delete_failure);
2087 }
2077 } 2088 }
2078 2089
2079 /* Load specs from a file name named FILENAME, replacing occurrences of 2090 /* Load specs from a file name named FILENAME, replacing occurrences of
2080 various different types of line-endings, \r\n, \n\r and just \r, with 2091 various different types of line-endings, \r\n, \n\r and just \r, with
2081 a single \n. */ 2092 a single \n. */
3001 if (verbose_only_flag) 3012 if (verbose_only_flag)
3002 { 3013 {
3003 for (j = commands[i].argv; *j; j++) 3014 for (j = commands[i].argv; *j; j++)
3004 { 3015 {
3005 const char *p; 3016 const char *p;
3006 fprintf (stderr, " \"");
3007 for (p = *j; *p; ++p) 3017 for (p = *j; *p; ++p)
3018 if (!ISALNUM ((unsigned char) *p)
3019 && *p != '_' && *p != '/' && *p != '-' && *p != '.')
3020 break;
3021 if (*p || !*j)
3008 { 3022 {
3009 if (*p == '"' || *p == '\\' || *p == '$') 3023 fprintf (stderr, " \"");
3010 fputc ('\\', stderr); 3024 for (p = *j; *p; ++p)
3011 fputc (*p, stderr); 3025 {
3026 if (*p == '"' || *p == '\\' || *p == '$')
3027 fputc ('\\', stderr);
3028 fputc (*p, stderr);
3029 }
3030 fputc ('"', stderr);
3012 } 3031 }
3013 fputc ('"', stderr); 3032 else
3033 fprintf (stderr, " %s", *j);
3014 } 3034 }
3015 } 3035 }
3016 else 3036 else
3017 for (j = commands[i].argv; *j; j++) 3037 for (j = commands[i].argv; *j; j++)
3018 fprintf (stderr, " %s", *j); 3038 fprintf (stderr, " %s", *j);
3227 is a null-terminated vector containing the following arguments. 3247 is a null-terminated vector containing the following arguments.
3228 Bits in the `live_cond' field are: 3248 Bits in the `live_cond' field are:
3229 SWITCH_LIVE to indicate this switch is true in a conditional spec. 3249 SWITCH_LIVE to indicate this switch is true in a conditional spec.
3230 SWITCH_FALSE to indicate this switch is overridden by a later switch. 3250 SWITCH_FALSE to indicate this switch is overridden by a later switch.
3231 SWITCH_IGNORE to indicate this switch should be ignored (used in %<S). 3251 SWITCH_IGNORE to indicate this switch should be ignored (used in %<S).
3252 SWITCH_IGNORE_PERMANENTLY to indicate this switch should be ignored
3253 in all do_spec calls afterwards. Used for %<S from self specs.
3232 The `validated' field is nonzero if any spec has looked at this switch; 3254 The `validated' field is nonzero if any spec has looked at this switch;
3233 if it remains zero at the end of the run, it must be meaningless. */ 3255 if it remains zero at the end of the run, it must be meaningless. */
3234 3256
3235 #define SWITCH_LIVE 0x1 3257 #define SWITCH_LIVE 0x1
3236 #define SWITCH_FALSE 0x2 3258 #define SWITCH_FALSE 0x2
3237 #define SWITCH_IGNORE 0x4 3259 #define SWITCH_IGNORE 0x4
3260 #define SWITCH_IGNORE_PERMANENTLY 0x8
3238 3261
3239 struct switchstr 3262 struct switchstr
3240 { 3263 {
3241 const char *part1; 3264 const char *part1;
3242 const char **args; 3265 const char **args;
3411 fputs (_(" -std=<standard> Assume that the input sources are for <standard>\n"), stdout); 3434 fputs (_(" -std=<standard> Assume that the input sources are for <standard>\n"), stdout);
3412 fputs (_("\ 3435 fputs (_("\
3413 --sysroot=<directory> Use <directory> as the root directory for headers\n\ 3436 --sysroot=<directory> Use <directory> as the root directory for headers\n\
3414 and libraries\n"), stdout); 3437 and libraries\n"), stdout);
3415 fputs (_(" -B <directory> Add <directory> to the compiler's search paths\n"), stdout); 3438 fputs (_(" -B <directory> Add <directory> to the compiler's search paths\n"), stdout);
3416 fputs (_(" -b <machine> Run gcc for target <machine>, if installed\n"), stdout);
3417 fputs (_(" -V <version> Run gcc version number <version>, if installed\n"), stdout);
3418 fputs (_(" -v Display the programs invoked by the compiler\n"), stdout); 3439 fputs (_(" -v Display the programs invoked by the compiler\n"), stdout);
3419 fputs (_(" -### Like -v but options quoted and commands not executed\n"), stdout); 3440 fputs (_(" -### Like -v but options quoted and commands not executed\n"), stdout);
3420 fputs (_(" -E Preprocess only; do not compile, assemble or link\n"), stdout); 3441 fputs (_(" -E Preprocess only; do not compile, assemble or link\n"), stdout);
3421 fputs (_(" -S Compile only; do not assemble or link\n"), stdout); 3442 fputs (_(" -S Compile only; do not assemble or link\n"), stdout);
3422 fputs (_(" -c Compile and assemble, but do not link\n"), stdout); 3443 fputs (_(" -c Compile and assemble, but do not link\n"), stdout);
3517 *temp1 = '\0'; 3538 *temp1 = '\0';
3518 break; 3539 break;
3519 } 3540 }
3520 } 3541 }
3521 3542
3522 /* If there is a -V or -b option (or both), process it now, before
3523 trying to interpret the rest of the command line.
3524 Use heuristic that all configuration names must have at least
3525 one dash '-'. This allows us to pass options starting with -b. */
3526 if (argc > 1 && argv[1][0] == '-'
3527 && (argv[1][1] == 'V'
3528 || (argv[1][1] == 'b'
3529 && (argv[1][2] == '\0'
3530 || NULL != strchr (argv[1] + 2, '-')))))
3531 {
3532 const char *new_version = DEFAULT_TARGET_VERSION;
3533 const char *new_machine = DEFAULT_TARGET_MACHINE;
3534 const char *progname = argv[0];
3535 char **new_argv;
3536 char *new_argv0;
3537 int baselen;
3538 int status = 0;
3539 int err = 0;
3540 const char *errmsg;
3541
3542 while (argc > 1 && argv[1][0] == '-'
3543 && (argv[1][1] == 'V'
3544 || (argv[1][1] == 'b'
3545 && (argv[1][2] == '\0'
3546 || NULL != strchr (argv[1] + 2, '-')))))
3547 {
3548 char opt = argv[1][1];
3549 const char *arg;
3550 if (argv[1][2] != '\0')
3551 {
3552 arg = argv[1] + 2;
3553 argc -= 1;
3554 argv += 1;
3555 }
3556 else if (argc > 2)
3557 {
3558 arg = argv[2];
3559 argc -= 2;
3560 argv += 2;
3561 }
3562 else
3563 fatal ("'-%c' option must have argument", opt);
3564 if (opt == 'V')
3565 new_version = arg;
3566 else
3567 new_machine = arg;
3568 }
3569
3570 for (baselen = strlen (progname); baselen > 0; baselen--)
3571 if (IS_DIR_SEPARATOR (progname[baselen-1]))
3572 break;
3573 new_argv0 = XDUPVAR (char, progname, baselen,
3574 baselen + concat_length (new_version, new_machine,
3575 "-gcc-", NULL) + 1);
3576 strcpy (new_argv0 + baselen, new_machine);
3577 strcat (new_argv0, "-gcc-");
3578 strcat (new_argv0, new_version);
3579
3580 new_argv = XDUPVEC (char *, argv, argc + 1);
3581 new_argv[0] = new_argv0;
3582
3583 errmsg = pex_one (PEX_SEARCH, new_argv0, new_argv, progname, NULL,
3584 NULL, &status, &err);
3585
3586 if (errmsg)
3587 {
3588 if (err == 0)
3589 fatal ("couldn't run '%s': %s", new_argv0, errmsg);
3590 else
3591 fatal ("couldn't run '%s': %s: %s", new_argv0, errmsg,
3592 xstrerror (err));
3593 }
3594 exit (status);
3595 }
3596
3597 /* Convert new-style -- options to old-style. */ 3543 /* Convert new-style -- options to old-style. */
3598 translate_options (&argc, 3544 translate_options (&argc,
3599 CONST_CAST2 (const char *const **, const char ***, 3545 CONST_CAST2 (const char *const **, const char ***,
3600 &argv)); 3546 &argv));
3601
3602 /* Do language-specific adjustment/addition of flags. */
3603 lang_specific_driver (&argc,
3604 CONST_CAST2 (const char *const **, const char ***,
3605 &argv),
3606 &added_libraries);
3607 3547
3608 /* Handle any -no-canonical-prefixes flag early, to assign the function 3548 /* Handle any -no-canonical-prefixes flag early, to assign the function
3609 that builds relative prefixes. This function creates default search 3549 that builds relative prefixes. This function creates default search
3610 paths that are needed later in normal option handling. */ 3550 paths that are needed later in normal option handling. */
3611 3551
3657 #else 3597 #else
3658 #endif 3598 #endif
3659 /* From this point onward, gcc_exec_prefix is non-null if the toolchain 3599 /* From this point onward, gcc_exec_prefix is non-null if the toolchain
3660 is relocated. The toolchain was either relocated using GCC_EXEC_PREFIX 3600 is relocated. The toolchain was either relocated using GCC_EXEC_PREFIX
3661 or an automatically created GCC_EXEC_PREFIX from argv[0]. */ 3601 or an automatically created GCC_EXEC_PREFIX from argv[0]. */
3602
3603 /* Do language-specific adjustment/addition of flags. */
3604 lang_specific_driver (&argc,
3605 CONST_CAST2 (const char *const **, const char ***,
3606 &argv),
3607 &added_libraries);
3662 3608
3663 if (gcc_exec_prefix) 3609 if (gcc_exec_prefix)
3664 { 3610 {
3665 int len = strlen (gcc_exec_prefix); 3611 int len = strlen (gcc_exec_prefix);
3666 3612
4085 const char *p = &argv[i][1]; 4031 const char *p = &argv[i][1];
4086 int c = *p; 4032 int c = *p;
4087 4033
4088 switch (c) 4034 switch (c)
4089 { 4035 {
4090 case 'b':
4091 if (p[1] && NULL == strchr (argv[i] + 2, '-'))
4092 goto normal_switch;
4093
4094 /* Fall through. */
4095 case 'V':
4096 fatal ("'-%c' must come at the start of the command line", c);
4097 break;
4098
4099 case 'B': 4036 case 'B':
4100 { 4037 {
4101 const char *value; 4038 const char *value;
4102 int len; 4039 int len;
4103 4040
4549 4486
4550 switches[n_switches].live_cond = 0; 4487 switches[n_switches].live_cond = 0;
4551 switches[n_switches].validated = 0; 4488 switches[n_switches].validated = 0;
4552 switches[n_switches].ordering = 0; 4489 switches[n_switches].ordering = 0;
4553 /* These are always valid, since gcc.c itself understands the 4490 /* These are always valid, since gcc.c itself understands the
4554 first four and gfortranspec.c understands -static-libgfortran. */ 4491 first four, gfortranspec.c understands -static-libgfortran
4492 and g++spec.c understands -static-libstdc++ */
4555 if (!strcmp (p, "save-temps") 4493 if (!strcmp (p, "save-temps")
4556 || !strcmp (p, "static-libgcc") 4494 || !strcmp (p, "static-libgcc")
4557 || !strcmp (p, "shared-libgcc") 4495 || !strcmp (p, "shared-libgcc")
4558 || !strcmp (p, "pipe") 4496 || !strcmp (p, "pipe")
4559 || !strcmp (p, "static-libgfortran")) 4497 || !strcmp (p, "static-libgfortran")
4498 || !strcmp (p, "static-libstdc++"))
4560 switches[n_switches].validated = 1; 4499 switches[n_switches].validated = 1;
4561 else 4500 else
4562 { 4501 {
4563 char ch = switches[n_switches].part1[0]; 4502 char ch = switches[n_switches].part1[0];
4564 if (ch == 'B') 4503 if (ch == 'B')
4566 } 4505 }
4567 n_switches++; 4506 n_switches++;
4568 } 4507 }
4569 else 4508 else
4570 { 4509 {
4571 const char *p = strchr (argv[i], '@'); 4510 const char *p = strrchr (argv[i], '@');
4572 char *fname; 4511 char *fname;
4512 long offset;
4513 int consumed;
4573 #ifdef HAVE_TARGET_OBJECT_SUFFIX 4514 #ifdef HAVE_TARGET_OBJECT_SUFFIX
4574 argv[i] = convert_filename (argv[i], 0, access (argv[i], F_OK)); 4515 argv[i] = convert_filename (argv[i], 0, access (argv[i], F_OK));
4575 #endif 4516 #endif
4576 if (!p) 4517 /* For LTO static archive support we handle input file
4577 fname = xstrdup (argv[i]); 4518 specifications that are composed of a filename and
4578 else 4519 an offset like FNAME@OFFSET. */
4579 { 4520 if (p
4521 && p != argv[i]
4522 && sscanf (p, "@%li%n", &offset, &consumed) >= 1
4523 && strlen (p) == (unsigned int)consumed)
4524 {
4580 fname = (char *)xmalloc (p - argv[i] + 1); 4525 fname = (char *)xmalloc (p - argv[i] + 1);
4581 memcpy (fname, argv[i], p - argv[i]); 4526 memcpy (fname, argv[i], p - argv[i]);
4582 fname[p - argv[i]] = '\0'; 4527 fname[p - argv[i]] = '\0';
4583 } 4528 /* Only accept non-stdin and existing FNAME parts, otherwise
4584 4529 try with the full name. */
4530 if (strcmp (fname, "-") == 0 || access (fname, F_OK) < 0)
4531 {
4532 free (fname);
4533 fname = xstrdup (argv[i]);
4534 }
4535 }
4536 else
4537 fname = xstrdup (argv[i]);
4538
4585 if (strcmp (fname, "-") != 0 && access (fname, F_OK) < 0) 4539 if (strcmp (fname, "-") != 0 && access (fname, F_OK) < 0)
4586 { 4540 {
4587 perror_with_name (fname); 4541 perror_with_name (fname);
4588 error_count++; 4542 error_count++;
4589 } 4543 }
4922 of the switches/n_switches array. */ 4876 of the switches/n_switches array. */
4923 4877
4924 static void 4878 static void
4925 do_self_spec (const char *spec) 4879 do_self_spec (const char *spec)
4926 { 4880 {
4881 int i;
4882
4927 do_spec_2 (spec); 4883 do_spec_2 (spec);
4928 do_spec_1 (" ", 0, NULL); 4884 do_spec_1 (" ", 0, NULL);
4929 4885
4886 /* Mark %<S switches processed by do_self_spec to be ignored permanently.
4887 do_self_specs adds the replacements to switches array, so it shouldn't
4888 be processed afterwards. */
4889 for (i = 0; i < n_switches; i++)
4890 if ((switches[i].live_cond & SWITCH_IGNORE))
4891 switches[i].live_cond |= SWITCH_IGNORE_PERMANENTLY;
4892
4930 if (argbuf_index > 0) 4893 if (argbuf_index > 0)
4931 { 4894 {
4932 int i;
4933
4934 switches = XRESIZEVEC (struct switchstr, switches, 4895 switches = XRESIZEVEC (struct switchstr, switches,
4935 n_switches + argbuf_index + 1); 4896 n_switches + argbuf_index + 1);
4936 4897
4937 for (i = 0; i < argbuf_index; i++) 4898 for (i = 0; i < argbuf_index; i++)
4938 { 4899 {
5232 while (*p != 0 && *p != '\n') 5193 while (*p != 0 && *p != '\n')
5233 p++; 5194 p++;
5234 buf = (char *) alloca (p - q + 1); 5195 buf = (char *) alloca (p - q + 1);
5235 strncpy (buf, q, p - q); 5196 strncpy (buf, q, p - q);
5236 buf[p - q] = 0; 5197 buf[p - q] = 0;
5237 error ("%s", buf); 5198 error ("%s", _(buf));
5238 return -1; 5199 return -1;
5239 } 5200 }
5240 break; 5201 break;
5241 case 'n': 5202 case 'n':
5242 /* %nfoo means report a notice with `foo' on stderr. */ 5203 /* %nfoo means report a notice with `foo' on stderr. */
5246 while (*p != 0 && *p != '\n') 5207 while (*p != 0 && *p != '\n')
5247 p++; 5208 p++;
5248 buf = (char *) alloca (p - q + 1); 5209 buf = (char *) alloca (p - q + 1);
5249 strncpy (buf, q, p - q); 5210 strncpy (buf, q, p - q);
5250 buf[p - q] = 0; 5211 buf[p - q] = 0;
5251 notice ("%s\n", buf); 5212 notice ("%s\n", _(buf));
5252 if (*p) 5213 if (*p)
5253 p++; 5214 p++;
5254 } 5215 }
5255 break; 5216 break;
5256 5217
6442 /* If we already processed this switch and determined if it was 6403 /* If we already processed this switch and determined if it was
6443 live or not, return our past determination. */ 6404 live or not, return our past determination. */
6444 if (switches[switchnum].live_cond != 0) 6405 if (switches[switchnum].live_cond != 0)
6445 return ((switches[switchnum].live_cond & SWITCH_LIVE) != 0 6406 return ((switches[switchnum].live_cond & SWITCH_LIVE) != 0
6446 && (switches[switchnum].live_cond & SWITCH_FALSE) == 0 6407 && (switches[switchnum].live_cond & SWITCH_FALSE) == 0
6447 && (switches[switchnum].live_cond & SWITCH_IGNORE) == 0); 6408 && (switches[switchnum].live_cond & SWITCH_IGNORE_PERMANENTLY)
6409 == 0);
6448 6410
6449 /* In the common case of {<at-most-one-letter>*}, a negating 6411 /* In the common case of {<at-most-one-letter>*}, a negating
6450 switch would always match, so ignore that case. We will just 6412 switch would always match, so ignore that case. We will just
6451 send the conflicting switches to the compiler phase. */ 6413 send the conflicting switches to the compiler phase. */
6452 if (prefix_length >= 0 && prefix_length <= 1) 6414 if (prefix_length >= 0 && prefix_length <= 1)
7217 7179
7218 if (print_version) 7180 if (print_version)
7219 { 7181 {
7220 printf (_("%s %s%s\n"), programname, pkgversion_string, 7182 printf (_("%s %s%s\n"), programname, pkgversion_string,
7221 version_string); 7183 version_string);
7222 printf ("Copyright %s 2009 Free Software Foundation, Inc.\n", 7184 printf ("Copyright %s 2010 Free Software Foundation, Inc.\n",
7223 _("(C)")); 7185 _("(C)"));
7224 fputs (_("This is free software; see the source for copying conditions. There is NO\n\ 7186 fputs (_("This is free software; see the source for copying conditions. There is NO\n\
7225 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\n"), 7187 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\n"),
7226 stdout); 7188 stdout);
7227 if (! verbose_flag) 7189 if (! verbose_flag)
7543 7505
7544 if (switch_matches (fuse_linker_plugin, 7506 if (switch_matches (fuse_linker_plugin,
7545 fuse_linker_plugin + strlen (fuse_linker_plugin), 0)) 7507 fuse_linker_plugin + strlen (fuse_linker_plugin), 0))
7546 { 7508 {
7547 linker_plugin_file_spec = find_a_file (&exec_prefixes, 7509 linker_plugin_file_spec = find_a_file (&exec_prefixes,
7548 "liblto_plugin.so", X_OK, 7510 "liblto_plugin.so", R_OK,
7549 false); 7511 false);
7550 if (!linker_plugin_file_spec) 7512 if (!linker_plugin_file_spec)
7551 fatal ("-fuse-linker-plugin, but liblto_plugin.so not found"); 7513 fatal ("-fuse-linker-plugin, but liblto_plugin.so not found");
7552 7514
7553 lto_libgcc_spec = find_a_file (&startfile_prefixes, "libgcc.a", 7515 lto_libgcc_spec = find_a_file (&startfile_prefixes, "libgcc.a",
8762 read_specs (file ? file : argv[0], FALSE); 8724 read_specs (file ? file : argv[0], FALSE);
8763 8725
8764 return NULL; 8726 return NULL;
8765 } 8727 }
8766 8728
8729 /* %:find-file spec function. This function replace its argument by
8730 the file found thru find_file, that is the -print-file-name gcc
8731 program option. */
8732 static const char *
8733 find_file_spec_function (int argc, const char**argv)
8734 {
8735 const char *file;
8736
8737 if (argc != 1)
8738 abort ();
8739
8740 file = find_file (argv[0]);
8741 return file;
8742 }
8743
8744
8767 /* %:print-asm-header spec function. Print a banner to say that the 8745 /* %:print-asm-header spec function. Print a banner to say that the
8768 following output is from the assembler. */ 8746 following output is from the assembler. */
8769 8747
8770 static const char * 8748 static const char *
8771 print_asm_header_spec_function (int arg ATTRIBUTE_UNUSED, 8749 print_asm_header_spec_function (int arg ATTRIBUTE_UNUSED,