📄 gcc.c
字号:
#ifndef CC1PLUS_SPEC#define CC1PLUS_SPEC ""#endif/* config.h can define LINK_SPEC to provide extra args to the linker or extra switch-translations. */#ifndef LINK_SPEC#define LINK_SPEC ""#endif/* config.h can define LIB_SPEC to override the default libraries. */#ifndef LIB_SPEC#define LIB_SPEC "%{!shared:%{g*:-lg} %{!p:%{!pg:-lc}}%{p:-lc_p}%{pg:-lc_p}}"#endif/* config.h can define LIBGCC_SPEC to override how and when libgcc.a is included. */#ifndef LIBGCC_SPEC#if defined(LINK_LIBGCC_SPECIAL) || defined(LINK_LIBGCC_SPECIAL_1)/* Have gcc do the search for libgcc.a. */#define LIBGCC_SPEC "libgcc.a%s"#else#define LIBGCC_SPEC "-lgcc"#endif#endif/* config.h can define STARTFILE_SPEC to override the default crt0 files. */#ifndef STARTFILE_SPEC#define STARTFILE_SPEC \ "%{!shared:%{pg:gcrt0%O%s}%{!pg:%{p:mcrt0%O%s}%{!p:crt0%O%s}}}"#endif/* config.h can define SWITCHES_NEED_SPACES to control which options require spaces between the option and the argument. */#ifndef SWITCHES_NEED_SPACES#define SWITCHES_NEED_SPACES ""#endif/* config.h can define ENDFILE_SPEC to override the default crtn files. */#ifndef ENDFILE_SPEC#define ENDFILE_SPEC ""#endif/* This spec is used for telling cpp whether char is signed or not. */#ifndef SIGNED_CHAR_SPEC/* Use #if rather than ?: because MIPS C compiler rejects like ?: in initializers. */#if DEFAULT_SIGNED_CHAR#define SIGNED_CHAR_SPEC "%{funsigned-char:-D__CHAR_UNSIGNED__}"#else#define SIGNED_CHAR_SPEC "%{!fsigned-char:-D__CHAR_UNSIGNED__}"#endif#endifstatic char *cpp_spec = CPP_SPEC;static char *cpp_predefines = CPP_PREDEFINES;static char *cc1_spec = CC1_SPEC;static char *cc1plus_spec = CC1PLUS_SPEC;static char *signed_char_spec = SIGNED_CHAR_SPEC;static char *asm_spec = ASM_SPEC;static char *asm_final_spec = ASM_FINAL_SPEC;static char *link_spec = LINK_SPEC;static char *lib_spec = LIB_SPEC;static char *libgcc_spec = LIBGCC_SPEC;static char *endfile_spec = ENDFILE_SPEC;static char *startfile_spec = STARTFILE_SPEC;static char *switches_need_spaces = SWITCHES_NEED_SPACES;/* Some compilers have limits on line lengths, and the multilib_select and/or multilib_matches strings can be very long, so we build them at run time. */static struct obstack multilib_obstack;static char *multilib_select;static char *multilib_matches;static char *multilib_defaults;#include "multilib.h"/* Check whether a particular argument is a default argument. */#ifndef MULTILIB_DEFAULTS#define MULTILIB_DEFAULTS { "" }#endifstatic char *multilib_defaults_raw[] = MULTILIB_DEFAULTS;struct user_specs { struct user_specs *next; char *filename;};static struct user_specs *user_specs_head, *user_specs_tail;/* This defines which switch letters take arguments. */#define DEFAULT_SWITCH_TAKES_ARG(CHAR) \ ((CHAR) == 'D' || (CHAR) == 'U' || (CHAR) == 'o' \ || (CHAR) == 'e' || (CHAR) == 'T' || (CHAR) == 'u' \ || (CHAR) == 'I' || (CHAR) == 'm' || (CHAR) == 'x' \ || (CHAR) == 'L' || (CHAR) == 'A')#ifndef SWITCH_TAKES_ARG#define SWITCH_TAKES_ARG(CHAR) DEFAULT_SWITCH_TAKES_ARG(CHAR)#endif/* This defines which multi-letter switches take arguments. */#define DEFAULT_WORD_SWITCH_TAKES_ARG(STR) \ (!strcmp (STR, "Tdata") || !strcmp (STR, "Ttext") \ || !strcmp (STR, "Tbss") || !strcmp (STR, "include") \ || !strcmp (STR, "imacros") || !strcmp (STR, "aux-info") \ || !strcmp (STR, "idirafter") || !strcmp (STR, "iprefix") \ || !strcmp (STR, "iwithprefix") || !strcmp (STR, "iwithprefixbefore") \ || !strcmp (STR, "isystem") || !strcmp (STR, "specs"))#ifndef WORD_SWITCH_TAKES_ARG#define WORD_SWITCH_TAKES_ARG(STR) DEFAULT_WORD_SWITCH_TAKES_ARG (STR)#endif/* Record the mapping from file suffixes for compilation specs. */struct compiler{ char *suffix; /* Use this compiler for input files whose names end in this suffix. */ char *spec[4]; /* To use this compiler, concatenate these specs and pass to do_spec. */};/* Pointer to a vector of `struct compiler' that gives the spec for compiling a file, based on its suffix. A file that does not end in any of these suffixes will be passed unchanged to the loader and nothing else will be done to it. An entry containing two 0s is used to terminate the vector. If multiple entries match a file, the last matching one is used. */static struct compiler *compilers;/* Number of entries in `compilers', not counting the null terminator. */static int n_compilers;/* The default list of file name suffixes and their compilation specs. */static struct compiler default_compilers[] ={ /* Add lists of suffixes of known languages here. If those languages were not present when we built the driver, we will hit these copies and be given a more meaningful error than "file not used since linking is not done". */ {".cc", "#C++"}, {".cxx", "#C++"}, {".cpp", "#C++"}, {".c++", "#C++"}, {".C", "#C++"}, {".ads", "#Ada"}, {".adb", "#Ada"}, {".ada", "#Ada"}, {".f", "#Fortran"}, {".for", "#Fortran"}, {".F", "#Fortran"}, {".fpp", "#Fortran"}, {".p", "#Pascal"}, {".pas", "#Pascal"}, /* Next come the entries for C. */ {".c", "@c"}, {"@c", "cpp -lang-c%{ansi:89} %{nostdinc*} %{C} %{v} %{A*} %{I*} %{P} %I\ %{C:%{!E:%eGNU C does not support -C without using -E}}\ %{M} %{MM} %{MD:-MD %b.d} %{MMD:-MMD %b.d} %{MG}\ -undef -D__GNUC__=%v1 -D__GNUC_MINOR__=%v2\ %{ansi:-trigraphs -D__STRICT_ANSI__}\ %{!undef:%{!ansi:%p} %P} %{trigraphs} \ %c %{O*:%{!O0:-D__OPTIMIZE__}} %{traditional} %{ftraditional:-traditional}\ %{traditional-cpp:-traditional}\ %{g*} %{W*} %{w} %{pedantic*} %{H} %{d*} %C %{D*} %{U*} %{i*} %Z\ %i %{!M:%{!MM:%{!E:%{!pipe:%g.i}}}}%{E:%W{o*}}%{M:%W{o*}}%{MM:%W{o*}} |\n", "%{!M:%{!MM:%{!E:cc1 %{!pipe:%g.i} %1 \ %{!Q:-quiet} -dumpbase %b.c %{d*} %{m*} %{a*}\ %{g*} %{O*} %{W*} %{w} %{pedantic*} %{ansi} \ %{traditional} %{v:-version} %{pg:-p} %{p} %{f*}\ %{aux-info*}\ %{pg:%{fomit-frame-pointer:%e-pg and -fomit-frame-pointer are incompatible}}\ %{S:%W{o*}%{!o*:-o %b.s}}%{!S:-o %{|!pipe:%g.s}} |\n\ %{!S:as %a %Y\ %{c:%W{o*}%{!o*:-o %w%b%O}}%{!c:-o %d%w%u%O}\ %{!pipe:%g.s} %A\n }}}}"}, {"-", "%{E:cpp -lang-c%{ansi:89} %{nostdinc*} %{C} %{v} %{A*} %{I*} %{P} %I\ %{C:%{!E:%eGNU C does not support -C without using -E}}\ %{M} %{MM} %{MD:-MD %b.d} %{MMD:-MMD %b.d} %{MG}\ -undef -D__GNUC__=%v1 -D__GNUC_MINOR__=%v2\ %{ansi:-trigraphs -D__STRICT_ANSI__}\ %{!undef:%{!ansi:%p} %P} %{trigraphs}\ %c %{O*:%{!O0:-D__OPTIMIZE__}} %{traditional} %{ftraditional:-traditional}\ %{traditional-cpp:-traditional}\ %{g*} %{W*} %{w} %{pedantic*} %{H} %{d*} %C %{D*} %{U*} %{i*} %Z\ %i %W{o*}}\ %{!E:%e-E required when input is from standard input}"}, {".m", "@objective-c"}, {"@objective-c", "cpp -lang-objc %{nostdinc*} %{C} %{v} %{A*} %{I*} %{P} %I\ %{C:%{!E:%eGNU C does not support -C without using -E}}\ %{M} %{MM} %{MD:-MD %b.d} %{MMD:-MMD %b.d} %{MG}\ -undef -D__OBJC__ -D__GNUC__=%v1 -D__GNUC_MINOR__=%v2\ %{ansi:-trigraphs -D__STRICT_ANSI__}\ %{!undef:%{!ansi:%p} %P} %{trigraphs}\ %c %{O*:%{!O0:-D__OPTIMIZE__}} %{traditional} %{ftraditional:-traditional}\ %{traditional-cpp:-traditional}\ %{g*} %{W*} %{w} %{pedantic*} %{H} %{d*} %C %{D*} %{U*} %{i*} %Z\ %i %{!M:%{!MM:%{!E:%{!pipe:%g.i}}}}%{E:%W{o*}}%{M:%W{o*}}%{MM:%W{o*}} |\n", "%{!M:%{!MM:%{!E:cc1obj %{!pipe:%g.i} %1 \ %{!Q:-quiet} -dumpbase %b.m %{d*} %{m*} %{a*}\ %{g*} %{O*} %{W*} %{w} %{pedantic*} %{ansi} \ %{traditional} %{v:-version} %{pg:-p} %{p} %{f*} \ -lang-objc %{gen-decls} \ %{aux-info*}\ %{pg:%{fomit-frame-pointer:%e-pg and -fomit-frame-pointer are incompatible}}\ %{S:%W{o*}%{!o*:-o %b.s}}%{!S:-o %{|!pipe:%g.s}} |\n\ %{!S:as %a %Y\ %{c:%W{o*}%{!o*:-o %w%b%O}}%{!c:-o %d%w%u%O}\ %{!pipe:%g.s} %A\n }}}}"}, {".h", "@c-header"}, {"@c-header", "%{!E:%eCompilation of header file requested} \ cpp %{nostdinc*} %{C} %{v} %{A*} %{I*} %{P} %I\ %{C:%{!E:%eGNU C does not support -C without using -E}}\ %{M} %{MM} %{MD:-MD %b.d} %{MMD:-MMD %b.d} %{MG}\ -undef -D__GNUC__=%v1 -D__GNUC_MINOR__=%v2\ %{ansi:-trigraphs -D__STRICT_ANSI__}\ %{!undef:%{!ansi:%p} %P} %{trigraphs}\ %c %{O*:%{!O0:-D__OPTIMIZE__}} %{traditional} %{ftraditional:-traditional}\ %{traditional-cpp:-traditional}\ %{g*} %{W*} %{w} %{pedantic*} %{H} %{d*} %C %{D*} %{U*} %{i*} %Z\ %i %W{o*}"}, {".i", "@cpp-output"}, {"@cpp-output", "%{!M:%{!MM:%{!E:cc1 %i %1 %{!Q:-quiet} %{d*} %{m*} %{a*}\ %{g*} %{O*} %{W*} %{w} %{pedantic*} %{ansi}\ %{traditional} %{v:-version} %{pg:-p} %{p} %{f*}\ %{aux-info*}\ %{pg:%{fomit-frame-pointer:%e-pg and -fomit-frame-pointer are incompatible}}\ %{S:%W{o*}%{!o*:-o %b.s}}%{!S:-o %{|!pipe:%g.s}} |\n\ %{!S:as %a %Y\ %{c:%W{o*}%{!o*:-o %w%b%O}}%{!c:-o %d%w%u%O}\ %{!pipe:%g.s} %A\n }}}}"}, {".s", "@assembler"}, {"@assembler", "%{!M:%{!MM:%{!E:%{!S:as %a %Y\ %{c:%W{o*}%{!o*:-o %w%b%O}}%{!c:-o %d%w%u%O}\ %i %A\n }}}}"}, {".S", "@assembler-with-cpp"}, {"@assembler-with-cpp", "cpp -lang-asm %{nostdinc*} %{C} %{v} %{A*} %{I*} %{P} %I\ %{C:%{!E:%eGNU C does not support -C without using -E}}\ %{M} %{MM} %{MD:-MD %b.d} %{MMD:-MMD %b.d} %{MG} %{trigraphs}\ -undef -$ %{!undef:%p %P} -D__ASSEMBLER__ \ %c %{O*:%{!O0:-D__OPTIMIZE__}} %{traditional} %{ftraditional:-traditional}\ %{traditional-cpp:-traditional}\ %{g*} %{W*} %{w} %{pedantic*} %{H} %{d*} %C %{D*} %{U*} %{i*} %Z\ %i %{!M:%{!MM:%{!E:%{!pipe:%g.s}}}}%{E:%W{o*}}%{M:%W{o*}}%{MM:%W{o*}} |\n", "%{!M:%{!MM:%{!E:%{!S:as %a %Y\ %{c:%W{o*}%{!o*:-o %w%b%O}}%{!c:-o %d%w%u%O}\ %{!pipe:%g.s} %A\n }}}}"},#include "specs.h" /* Mark end of table */ {0, 0}};/* Number of elements in default_compilers, not counting the terminator. */static int n_default_compilers = (sizeof default_compilers / sizeof (struct compiler)) - 1;/* Here is the spec for running the linker, after compiling all files. *//* -u* was put back because both BSD and SysV seem to support it. *//* %{static:} simply prevents an error message if the target machine doesn't handle -static. *//* We want %{T*} after %{L*} and %D so that it can be used to specify linker scripts which exist in user specified directories, or in standard directories. */#ifdef LINK_LIBGCC_SPECIAL/* Don't generate -L options. */static char *link_command_spec = "\%{!fsyntax-only: \ %{!c:%{!M:%{!MM:%{!E:%{!S:ld %l %X %{o*} %{A} %{d} %{e*} %{m} %{N} %{n} \ %{r} %{s} %{t} %{u*} %{x} %{z} %{Z}\ %{!A:%{!nostdlib:%{!nostartfiles:%S}}}\ %{static:} %{L*} %o\ %{!nostdlib:%{!nodefaultlibs:%G %L %G}}\ %{!A:%{!nostdlib:%{!nostartfiles:%E}}}\ %{T*}\ \n }}}}}}";#else/* Use -L. */static char *link_command_spec = "\%{!fsyntax-only: \ %{!c:%{!M:%{!MM:%{!E:%{!S:ld %l %X %{o*} %{A} %{d} %{e*} %{m} %{N} %{n} \ %{r} %{s} %{t} %{u*} %{x} %{z} %{Z}\ %{!A:%{!nostdlib:%{!nostartfiles:%S}}}\ %{static:} %{L*} %D %o\ %{!nostdlib:%{!nodefaultlibs:%G %L %G}}\ %{!A:%{!nostdlib:%{!nostartfiles:%E}}}\ %{T*}\ \n }}}}}}";#endif/* A vector of options to give to the linker. These options are accumulated by %x, and substituted into the linker command with %X. */static int n_linker_options;static char **linker_options;/* A vector of options to give to the assembler. These options are accumulated by -Wa, and substituted into the assembler command with %Y. */static int n_assembler_options;static char **assembler_options;/* A vector of options to give to the preprocessor. These options are accumulated by -Wp, and substituted into the preprocessor command with %Z. */static int n_preprocessor_options;static char **preprocessor_options;/* Define how to map long options into short ones. *//* This structure describes one mapping. */struct option_map{ /* The long option's name. */ char *name; /* The equivalent short option. */ char *equivalent; /* Argument info. A string of flag chars; NULL equals no options. a => argument required. o => argument optional. j => join argument to equivalent, making one word. * => require other text after NAME as an argument. */ char *arg_info;};/* This is the table of mappings. Mappings are tried sequentially for each option encountered; the first one that matches, wins. */struct option_map option_map[] = { {"--all-warnings", "-Wall", 0}, {"--ansi", "-ansi", 0}, {"--assemble", "-S", 0}, {"--assert", "-A", "a"}, {"--comments", "-C", 0}, {"--compile", "-c", 0}, {"--debug", "-g", "oj"}, {"--define-macro", "-D", "aj"}, {"--dependencies", "-M", 0}, {"--dump", "-d", "a"}, {"--dumpbase", "-dumpbase", "a"}, {"--entry", "-e", 0}, {"--extra-warnings", "-W", 0}, {"--for-assembler", "-Wa", "a"}, {"--for-linker", "-Xlinker", "a"}, {"--force-link", "-u", "a"}, {"--imacros", "-imacros", "a"}, {"--include", "-include", "a"}, {"--include-barrier", "-I-", 0}, {"--include-directory", "-I", "aj"}, {"--include-directory-after", "-idirafter", "a"}, {"--include-prefix", "-iprefix", "a"}, {"--include-with-prefix", "-iwithprefix", "a"}, {"--include-with-prefix-before", "-iwithprefixbefore", "a"}, {"--include-with-prefix-after", "-iwithprefix", "a"}, {"--language", "-x", "a"}, {"--library-directory", "-L", "a"}, {"--machine", "-m", "aj"}, {"--machine-", "-m", "*j"}, {"--no-line-commands", "-P", 0}, {"--no-precompiled-includes", "-noprecomp", 0}, {"--no-standard-includes", "-nostdinc", 0}, {"--no-standard-libraries", "-nostdlib", 0}, {"--no-warnings", "-w", 0}, {"--optimize", "-O", "oj"}, {"--output", "-o", "a"}, {"--pedantic", "-pedantic", 0}, {"--pedantic-errors", "-pedantic-errors", 0}, {"--pipe", "-pipe", 0}, {"--prefix", "-B", "a"}, {"--preprocess", "-E", 0}, {"--print-search-dirs", "-print-search-dirs", 0}, {"--print-file-name", "-print-file-name=", "aj"}, {"--print-libgcc-file-name", "-print-libgcc-file-name", 0}, {"--print-missing-file-dependencies", "-MG", 0}, {"--print-multi-lib", "-print-multi-lib", 0}, {"--print-multi-directory", "-print-multi-directory", 0}, {"--print-prog-name", "-print-prog-name=", "aj"}, {"--profile", "-p", 0}, {"--profile-blocks", "-a", 0}, {"--quiet", "-q", 0}, {"--save-temps", "-save-temps", 0}, {"--shared", "-shared", 0}, {"--silent", "-q", 0}, {"--specs", "-specs=", "aj"}, {"--static", "-static", 0}, {"--symbolic", "-symbolic", 0}, {"--target", "-b", "a"}, {"--trace-includes", "-H", 0}, {"--traditional", "-traditional", 0}, {"--traditional-cpp", "-traditional-cpp", 0}, {"--trigraphs", "-trigraphs", 0}, {"--undefine-macro", "-U", "aj"}, {"--use-version", "-V", "a"}, {"--user-dependencies", "-MM", 0}, {"--verbose", "-v", 0}, {"--version", "-dumpversion", 0}, {"--warn-", "-W", "*j"}, {"--write-dependencies", "-MD", 0}, {"--write-user-dependencies", "-MMD", 0}, {"--", "-f", "*j"} };/* Translate the options described by *ARGCP and *ARGVP. Make a new vector and store it back in *ARGVP, and store its length in *ARGVC. */static voidtranslate_options (argcp, argvp) int *argcp; char ***argvp;{ int i, j, k; int argc = *argcp; char **argv = *argvp; char **newv = (char **) xmalloc ((argc + 2) * 2 * sizeof (char *)); int newindex = 0; i = 0; newv[newindex++] = argv[i++]; while (i < argc) { /* Translate -- options. */ if (argv[i][0] == '-' && argv[i][1] == '-')
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -