1.4 Inputs, -x and temporary files: from suffix to compiler
GCC 15.2.0. To run the commands: an installed compiler with g++.
You rename start.S to start.s, and every #define in it stops having any
effect. You compile foo.cpp with gcc -c and it works, but when you link the
same file with gcc, the link fails on undefined std:: symbols. Nobody changed
a flag in either case.
The driver gives every input file a language before it runs anything, and it
reads that language from the end of the file name, never from the contents. The
language selects a spec, and the spec selects the programs. The specs also name
the temporary files that carry one program's output to the next, and the driver
deletes those files when the run ends unless -save-temps keeps them.
This chapter assumes Chapter 1.1, for -###, the .c
row of the compiler table (Listing 1.1-1) and the invoke_as spec (Listing
1.1-2), and Chapter 1.3, for the spec language and its
directives.
-x and add_infile: each input stored with its language
The driver stores every input file together with the language that -x set
before it, or with none. The compiler lookup reads that pair, so the position of
-x on the command line decides which files it covers. The driver reads its
command line in one pass, from left to right, and the input branch in Listing
1.4-1 hands add_infile whatever spec_lang holds at that moment:
for (j = 1; j < decoded_options_count; j++)
{
if (decoded_options[j].opt_index == OPT_SPECIAL_input_file)
{
const char *arg = decoded_options[j].arg;
...
add_infile (arg, spec_lang);
continue;
}
read_cmdline_option (&global_options, &global_options_set,
decoded_options + j, UNKNOWN_LOCATION,
CL_DRIVER, &handlers, global_dc);
}
Listing 1.4-1: inputs and options in one pass (gcc/gcc.cc:5009-5026).
spec_lang is one static variable (gcc.cc:3975), and the
OPT_x case is the one option handler that writes it:
case OPT_x:
spec_lang = arg;
if (!strcmp (spec_lang, "none"))
/* Suppress the warning if -xnone comes after the last input
file, because alternate command interfaces like g++ might
find it useful to place -xnone after each input file. */
spec_lang = 0;
else
last_language_n_infiles = n_infiles;
do_save = false;
break;
Listing 1.4-2: -x (gcc/gcc.cc:4625-4635).
-x therefore applies to every input file after it, up to the next -x, and to
no file before it. -x none clears the language, so later files go back to
their suffixes. The GCC manual documents both rules, with the suffixes and the
language names, under Overall Options. do_save = false
keeps -x off the switch list (gcc.cc:4707-4710), so no spec and
no sub-program sees it, and its only effect is the language stored next to each
file.
A -x with no input file after it has no effect, and the driver warns about it
(gcc.cc:5563-5564). -x none is exempt, because the g++ wrapper
in Listing 1.4-6 puts a -x none after each input file that it wraps, as the
comment in Listing 1.4-2 explains.
The input list holds more than input files. -Wl,, -Xlinker and -l go in
with the language "*", which means "linker input"
(gcc.cc:4429-4471), so a -lfoo keeps its position among your
object files. Chapter 1.7 shows where that position
ends up.
default_compilers[] and lookup_compiler: the last matching row wins
default_compilers[] is the table that maps an input file to a spec, and
lookup_compiler searches it from the last row back, so the last matching row
wins. The lookup decides what a -x name means, what a suffix means, and what
happens to a file that matches nothing. The comment on struct compiler states
the two rules: a file with no matching suffix "will be passed unchanged to the
loader", and "If multiple entries match a file, the last matching one is used"
(gcc.cc:1410-1417).
The table has two kinds of row. A suffix row such as {".c", "@c", ...} maps a
suffix to a language name. A language row such as {"@c", "<spec>", ...} holds
that language's spec. Listing 1.1-1 showed both rows for C. In lookup_compiler,
watch the two for loops, which start at the last row, and the recursive call at
the end, which follows a suffix row to its language row:
/* If this was specified by the user to be a linker input, indicate that. */
if (language != 0 && language[0] == '*')
return 0;
/* Otherwise, look for the language, if one is spec'd. */
if (language != 0)
{
for (cp = compilers + n_compilers - 1; cp >= compilers; cp--)
if (cp->suffix[0] == '@' && !strcmp (cp->suffix + 1, language))
...
error ("language %s not recognized", language);
return 0;
}
/* Look for a suffix. */
for (cp = compilers + n_compilers - 1; cp >= compilers; cp--)
...
if (cp >= compilers)
{
if (cp->spec[0] != '@')
/* A non-alias entry: return it. */
return cp;
/* An alias entry maps a suffix to a language.
Search for the language; pass 0 for NAME and LENGTH
to avoid infinite recursion if language not found. */
return lookup_compiler (NULL, 0, cp->spec + 1);
}
return 0;
Listing 1.4-3: lookup_compiler, abridged (gcc/gcc.cc:9364-9432).
Followed for one file, the function makes its decisions in this order:
- A linker input (
"*") gets no compiler. - A
-xlanguage wins.-x csearches for the row named@c, and the suffix is never examined. - Otherwise the suffix decides. Both loops start at the last row and go backwards, which is how "the last matching one is used" is implemented.
- A suffix row whose spec starts with
@is an alias, so the lookup starts again with the language name.
The argument to -x is therefore a row name without its @, and the valid
languages are the @ rows in your driver, not a list in the manual.
When nothing matches, the driver records the file "as explicit linker input"
(gcc.cc:9131-9135), so a file with no known suffix goes
straight to the linker. With -c nothing links, and the driver only warns that
the linker input is unused (gcc.cc:9293-9308). Two commands
show both branches:
$ gcc -### -c foo.txt # no cc1 line, only the warning
$ gcc -### -x c foo.txt # the suffix no longer decides
The first prints no cc1 line, only the warning. In the second, -x c takes
the language branch of Listing 1.4-3, so the suffix no longer decides.
.s against .S: the suffix decides where the pipeline starts
.s and .S map to different language rows, and each row starts the pipeline
at a different program. Of the two, only the .S row runs the preprocessor, so
a file renamed from start.S to start.s goes straight to as, and its
#define lines stop having any effect. Listing 1.4-4 shows both rows:
{".s", "@assembler", 0, 0, 0},
{"@assembler",
"%{!M:%{!MM:%{!E:%{!S:as %(asm_debug) %(asm_options) %i %A }}}}", 0, 0, 0},
{".sx", "@assembler-with-cpp", 0, 0, 0},
{".S", "@assembler-with-cpp", 0, 0, 0},
{"@assembler-with-cpp",
...
"%(trad_capable_cpp) -lang-asm %(cpp_options) -fno-directives-only\
%{E|M|MM:%(cpp_debug_options)}\
%{!M:%{!MM:%{!E:%{!S:-o %|.s |\n\
as %(asm_debug) %(asm_options) %m.s %A }}}}"
...
Listing 1.4-4: assembly with and without the preprocessor
(gcc/gcc.cc:1493-1510). The omitted #ifdef uses %|.s instead of
%m.s for assemblers that need - to read a pipe.
@assembler runs one program, as, on %i, the input file itself.
@assembler-with-cpp runs the preprocessor first, writes %|.s, and then runs
as on that file. The other rows read the same way, by the first program that
each one runs:
| Suffix | Language row | First program | Source |
|---|---|---|---|
.c | @c | cc1, which preprocesses internally | Listing 1.1-1 |
.i | @cpp-output | cc1 -fpreprocessed | gcc.cc:1490-1492 |
.h | @c-header | cc1, writing %i.gch | gcc.cc:1472-1489 |
.S, .sx | @assembler-with-cpp | the preprocessor, then as | Listing 1.4-4 |
.s | @assembler | as | Listing 1.4-4 |
- | none | the preprocessor, and only with -E | gcc.cc:1469-1471 |
The last row matches only the file name -, and its spec refuses to run without
-E:
%{!E:%e-E or -x required when input is from standard input}
The message names the other way out. With -x c, the lookup takes the language
branch of Listing 1.4-3 and never reaches the - row, so gcc -E -x c - works.
lang-specs.h: the C++ rows and their #C++ placeholders
The C++ rows of the compiler table come from the C++ front end's
lang-specs.h, which the build adds at the end of default_compilers[].
Placeholder rows at the start of the table stand in for a front end that was not
built. That layout decides what gcc foo.cpp does on any driver: it runs
cc1plus where C++ was built, and reports a missing C++ compiler where it was
not.
The C rows live in gcc.cc, and every other language's rows come from its front
end. The table ends with #include "specs.h" (gcc.cc:1512),
a file generated at build time with one #include per front end's
lang-specs.h (gcc/Makefile.in:2619-2625). configure lists a
front end's file only if that language is in --enable-languages
(gcc/configure.ac:7321-7327). C++ contributes suffix rows
such as {".cpp", "@c++", 0, 0, 0} and an @c++ row whose spec runs cc1plus
and then %(invoke_as) (gcc/cp/lang-specs.h:27-121). The same
suffixes also appear at the top of default_compilers[], with a spec that
starts with #:
/* 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++", 0, 0, 0}, {".cxx", "#C++", 0, 0, 0},
{".cpp", "#C++", 0, 0, 0}, {".cp", "#C++", 0, 0, 0},
Listing 1.4-5: the placeholder rows (gcc/gcc.cc:1429-1437).
specs.h comes last and the search runs backwards, so a built front end's rows
match first and hide the placeholders. On a driver built without C++, .cpp
reaches the #C++ row, and the driver reports "%s: %s compiler not installed on this system" (gcc.cc:9062-9067). There is no @c++
placeholder, so -x c++ on that driver fails with "language %s not recognized" instead.
Both drivers use this one table, so gcc foo.cpp runs cc1plus just as
g++ foo.cpp does:
$ gcc -### foo.cpp ; g++ -### foo.cpp # same input, different link
The compile lines name the same program, and the link lines differ, because
g++ adds -lstdc++ before the specs run. The missing -lstdc++ is the gcc
link failure in the opening, and Chapter 1.11
shows how g++ adds it. The GCC manual documents both halves under
Invoking G++.
g++ and -x c++: wrapping .c, .i and .h inputs
g++ wraps every .c, .i and .h input in a -x option for the matching
C++ language, with a -x none after it, so the generic driver compiles those
files as C++. The wrapping, and the rule for when g++ skips it, explain why your
own -x before a list of C files covers only the first one. The GCC manual says
under Invoking G++ that g++ treats .c, .h and .i files as C++ "unless -x
is used", and the lang_specific_driver of g++ does the wrapping:
/* Wrap foo.[chi] files in a language specification to
force the gcc compiler driver to run cc1plus on them. */
if (args[i] & LANGSPEC)
{
...
case 'c':
generate_option (OPT_x, "c++", 1, CL_DRIVER,
&new_decoded_options[j++]);
break;
...
new_decoded_options[j++] = decoded_options[i];
generate_option (OPT_x, "none", 1, CL_DRIVER,
&new_decoded_options[j]);
}
Listing 1.4-6: g++ puts -x c++ before a C file and -x none after it
(gcc/cp/g++spec.cc:340-365).
g++ foo.c therefore reaches the generic driver as -x c++ foo.c -x none. A
.i file gets -x c++-cpp-output and a .h file gets -x c++-header. The
-x none stops the wrapper from leaking onto the next file, and Listing 1.4-2
exempts it from the "after last input file" warning.
A comment says the wrapping is skipped "if a specified -x option is currently
active" (g++spec.cc:264-265), but the code does less.
Any -x sets a flag (:204), and the next input file clears
it (:258-262), so only the first file after your -x is
exempt.
%g, %u, %U and %j: temporary names as spec directives
Spec directives name the temporary files that pass between programs: %g,
%u, %U and %j, from the list in Chapter 1.3. The
directive that a spec uses decides whether two commands share a file name, which
is why all inputs in one run share a .s file but not a .o file. %| and %m
act as %g unless -pipe is in effect, and the GCC manual documents all six
under Spec Files. The spec that names each input's object file
shows them at work:
"%a %Y %{c:%W{o*}%{!o*:-o %w%b%O}}%{!c:-o %d%w%u%O}";
Listing 1.4-7: where the object file gets its name (gcc/gcc.cc:1311).
With -c the object is the output you asked for: your -o, or %b%O, the input
base name plus .o. Without -c it is a temporary: %u%O creates a new name
with the object suffix, and %d marks it for deletion. %w marks the same name
as this input's output, so %o passes it to the link.
The .s file uses %|.s and %m.s (Listing 1.1-2), which act as %g.s. The
difference between %g and %u is one test in the code that hands out names:
for (t = temp_names; t; t = t->next)
if (t->length == suffix_length
&& strncmp (t->suffix, suffix, suffix_length) == 0
&& t->unique == (c == 'u' || c == 'U' || c == 'j'))
break;
/* Make a new association if needed. %u and %j
require one. */
if (t == 0 || c == 'u' || c == 'j')
{
...
temp_filename = make_temp_file (t->suffix);
...
Listing 1.4-8: one name per suffix, or a new one each time
(gcc/gcc.cc:6492-6528).
The list temp_names keeps one entry per suffix for %g, and one per suffix for
the %u family. %g reuses its entry, %u puts a new name in its entry each
time, and %U reads the name that the last %u with that suffix wrote. The
default ASM_FINAL_SPEC shows why %U exists: with -gsplit-dwarf it runs
objcopy on %U%O, the object that %u%O named a moment before
(gcc.cc:711-720).
Only driver::finalize resets temp_names (gcc.cc:11349), so
nothing clears it during a run. "Chosen once per compilation", in the comment on
%g (gcc.cc:500-502), therefore means once per driver run. All
inputs in one command share one .s name, and each input gets its own .o
name:
$ gcc -### a.c b.c 2>&1 | grep -o '/tmp/cc[A-Za-z0-9]*\.[so]'
The same .s path appears for both inputs, and the two .o paths differ.
Sharing is safe because execute waits for every command it starts
(gcc.cc:3458-3467). The .o files must all exist when the
linker runs, so they cannot share.
%j usually names no real file. It expands to the host's bit bucket, /dev/null
by default (gcc/system.h:740-742), when that is writable and
-save-temps is off (gcc.cc:6319-6339). cc1_options uses it for
-fsyntax-only, which still needs an -o (gcc.cc:1296).
The name itself comes from libiberty's make_temp_file. It takes the directory
from TMPDIR, TMP or TEMP, then tries P_tmpdir, /var/tmp, /tmp and .
(libiberty/make-temp-file.c:131-147). It adds cc, six random
characters and the suffix, and creates the file with mkstemps
(:203-222). Of those variables, the GCC manual documents only
TMPDIR, under Environment Variables.
%d, %w and the delete queues: cleanup on success and failure
The driver deletes the names that %g, %u and %d mark at the end of every
run, whether or not a step failed. After a failure it also deletes the outputs
that %w marks, so a failed compile leaves neither its temporaries nor a
half-written output behind. To keep the intermediate files, ask for them with
-save-temps.
Each marked name goes into one of two queues. The comment above store_arg says
that a DELETE_ALWAYS file "should be deleted eventually" and a
DELETE_FAILURE file "should be deleted if this compilation fails"
(gcc.cc:2191-2196). %g, %u and %d feed the first queue, and
%w, the output mark, feeds the second (gcc.cc:5774). At the
end of the run the driver empties both:
if (seen_error ())
delete_failure_queue ();
delete_temp_files ();
Listing 1.4-9: cleanup in driver::final_actions (gcc/gcc.cc:9318-9320).
delete_temp_files runs whether or not a step failed, and
delete_failure_queue runs only when seen_error () is true. The driver does
not always wait for the end of the run. When the commands for one input fail, it
deletes that input's outputs at once (gcc.cc:9137-9146),
and a fatal signal empties both queues too (gcc.cc:8133-8138).
-pipe: %| and %m replace the temporary file with a pipe
-pipe changes two directives, %| and %m, so that cc1 writes to a pipe and
as reads its standard input, with no temporary .s file between them. The GCC
manual documents the option under Overall Options as using
"pipes rather than temporary files" between the stages. When it is in effect,
%| expands to - and %m expands to nothing (gcc.cc:6340-6367).
The | that Chapter 1.1 pointed out in invoke_as
becomes a pipe only under -pipe, as the code that reads it says: "A `|' before
the newline means use a pipe here, but only if -pipe was specified. Otherwise,
execute now and don't pass the `|' as an arg" (gcc.cc:6157-6166).
cc1 gets -o -, and on the as line %m.s leaves nothing, while %|.s
leaves a - on targets that define AS_NEEDS_DASH_FOR_PIPED_INPUT. -###
shows the result:
$ gcc -### -pipe -c foo.c
Each command that feeds the next one ends in a | in that output
(gcc.cc:3369-3372). -save-temps wins over -pipe: the driver
warns that -pipe is ignored and turns pipes off
(gcc.cc:5472-5478).
-save-temps: the same directives, predictable names
-save-temps adds no new directive. It changes what %g, %u and %U produce,
so the temporaries stay on disk under names you can predict. In that mode the
driver builds each name from the auxiliary-output prefix, the base name and the
suffix, and clears the deletion mark (gcc.cc:6408-6490).
The prefix is the one that cc1 receives as -dumpdir. The GCC manual documents
-save-temps, and its =cwd and =obj forms, under
Developer Options.
-save-temps also changes the C pipeline, and the comment over the @c spec
explains the part that Listing 1.1-1 left out:
/* cc1 has an integrated ISO C preprocessor. We should invoke the
external preprocessor if -save-temps is given. */
...
%{save-temps*|traditional-cpp|no-integrated-cpp:%(trad_capable_cpp) \
%(cpp_options) -o %{save-temps*:%b.i} %{!save-temps*:%g.i} \n\
cc1 -fpreprocessed %{save-temps*:%b.i} %{!save-temps*:%g.i} \
%(cc1_options)}\
Listing 1.4-10: -save-temps splits the preprocessor out
(gcc/gcc.cc:1456-1465).
-save-temps therefore runs one more process per C file: the preprocessor writes
%b.i, and cc1 -fpreprocessed reads it. The C++ row does the same with %b.ii
(cp/lang-specs.h:111-114).
$ gcc -save-temps -c foo.c && ls foo.* # the temporaries, kept
foo.i and foo.s appear next to foo.o. With -c and no -o, the driver sets
no prefix, so each name is the input's base name plus a suffix.
A predictable name can collide with the input. Compile foo.s with
-x assembler-with-cpp -save-temps, and the preprocessed output from %|.s would
also be foo.s. When the name the driver built is the input file, by name or by
device and inode number, it uses a random temporary name instead
(gcc.cc:6448-6489). The GCC manual calls this "sensible
enough to avoid overwriting an input source file"
(invoke.texi:21304-21306).
-dumpdir and -dumpbase: the a- prefix on kept files
The driver names each kept file from a prefix and a base name, which -dumpdir
and -dumpbase set. Since GCC 11, a run that links takes the prefix from the
output's base name, so plain gcc -save-temps foo.c keeps a-foo.i rather than
foo.i. Run the -save-temps command again without -c:
$ gcc -save-temps foo.c && ls a-foo.*
The kept files are a-foo.i, a-foo.s and a-foo.o, because when the driver
links, "the .o outputs that would have been temporary become aux outputs"
(gcc.cc:5152-5154). Each auxiliary output, such as a
kept temporary or a .dwo file, gets the base name of the link output and a
dash as a prefix, and with no -o that base name is a
(gcc.cc:5325-5326). The GCC manual documents this naming at
length under Overall Options, in the entries for -o,
-dumpbase and -dumpdir.
The comment that specifies the scheme shows the same prefix without
-save-temps, on the .dwo files that -gsplit-dwarf writes:
When compiling and linking, no -dump* nor -save-temps=*, .o
outputs are temporary, aux outputs land in the dir of the output,
prefixed with the basename of the linker output:
...
# gcc b.c d.c [-o a.out] -gsplit-dwarf
-> cc1 -dumpdir a- -dumpbase b.c -dumpbase-ext .c # a-b.dwo
&& cc1 -dumpdir a- -dumpbase d.c -dumpbase-ext .c # a-d.dwo
&& link ... [-o a.out]
Listing 1.4-11: from the comment that specifies the naming scheme
(gcc/gcc.cc:5123-5135). The whole comment is
:5093-5224.
cc1 and cc1plus receive the result as -dumpdir, -dumpbase and
-dumpbase-ext, which a spec function, %:dumps, writes into cc1_options
(gcc.cc:1273-1288). The driver also appends -dumpdir to
COLLECT_GCC_OPTIONS (gcc.cc:5666-5684), so
'-dumpdir' 'a-' shows up in that environment variable too, where
Chapter 1.9 reads it.
$ gcc -### foo.c 2>&1 | grep -o -- '-dumpdir [^ ]*'
The -dumpdir argument is a-, because the command links and names no
output. %b, and %g in -save-temps mode, read this prefix
(gcc.cc:489-497), and three cases change it:
- When the output has the same base name as the single input, there is no prefix.
gcc -save-temps foo.c -o fookeepsfoo.iandfoo.s(gcc.cc:5358-5376). -dumpdir PFXsets the prefix.-save-temps=cwdand-save-temps=objset it too, and "the one that appears last prevails" (gcc.cc:5093-5094).-dumpbase NAMEsets the base name. With several inputs, the driver adds it to the prefix instead (gcc.cc:5094-5096).
Before GCC 11.
-save-tempsnamed every file after the input and put it in the current directory. In GCC 10.5.0, plain-save-tempssetSAVE_TEMPS_CWD(gcc/gcc.c:4149-4152), and%bwas the input base name unless-save-temps=objand-osupplied a prefix (gcc/gcc.c:5370-5378, and the GCC 10 manual atinvoke.texi:16320-16328). In GCC 15.2.0,gcc -save-temps foo.cwritesa-foo.*, andgcc -save-temps -c src/foo.c -o build/foo.owritesbuild/foo.iwhere GCC 10 wrote./foo.i. A script that collects.ifiles from the current directory breaks across that boundary.
-fno-rtti on a C file: the driver passes it and cc1 warns
The driver accepts an option if any front end knows it, and leaves the language
check to the compiler that the suffix chose. -fno-rtti on a C file therefore
gets a warning from cc1 and nothing from the driver. The split matters because
the suffix chooses the compiler, so an option can reach a compiler that does not
understand it.
The driver reads every option against the full option table, which the build
generates from each front end's .opt files
(Chapter 2.4 shows how). An option that is not a
driver option goes to a callback with this policy:
/* At this point, non-driver options are accepted (and expected to
be passed down by specs) unless marked to be rejected by the
driver. Options to be rejected by the driver but accepted by the
compilers proper are treated just like completely unknown
options. */
Listing 1.4-12: the driver accepts every front end's options
(gcc/gcc.cc:3959-3963).
After that, the driver checks only that some spec mentions the option
(gcc.cc:9463-9476), and rejects the rest as unrecognized
(gcc.cc:8770-8787). -fno-rtti on a C file passes, because
cc1_options passes %{f*} (gcc.cc:1290). cc1 then checks the
option against its own language, and only warns:
else if (ok_langs[0] != '\0')
/* Eventually this should become a hard error IMO. */
warning (0, "command-line option %qs is valid for %s but not for %s",
text, ok_langs, bad_lang);
Listing 1.4-13: the wrong-language warning (gcc/opts-global.cc:111-114).
$ gcc -c -fno-rtti foo.c # cc1 warns, the driver does not
The warning names the languages from the option's entry, C++ ObjC++ for
frtti (gcc/c-family/c.opt:2296-2297). The exception is .S: when
cc1 preprocesses assembly with -lang-asm, it accepts every C-family option
with no diagnostic, "since the driver may pass them through"
(gcc/c-family/c-opts.cc:267-274).
Three things to carry away
The suffix picks a row, and the row picks the programs. -x replaces the
suffix for every later file until -x none, and a name with no known suffix goes
to the linker.
Temporary files are spec directives. %g gives one name per suffix for the
whole run, %u a new name each time, and %U the last %u. The driver deletes
them at the end, even after a failure.
-save-temps and -dumpdir decide the kept names. Since GCC 11, a
compile-and-link run prefixes them with the output's base name, a- by default.
Things that surprise people
gcc -save-temps foo.c writes a-foo.i, not foo.i. Add -c, or name the
output foo, to get foo.i.
g++ -x c a.c b.c compiles b.c as C++. g++ skips its -x c++ wrapper
only for the first file after your -x. Check it with g++ -### -x c a.c b.c.
gcc -c notes.txt compiles nothing and does not fail. If the file exists, the
driver only warns that a linker input is unused.
A driver without C++ gives two different errors. gcc foo.cpp says the C++
compiler is not installed. gcc -x c++ foo.cpp says the language is not
recognized.
Documentation coverage
The suffix list and -x are in Overall Options
(gcc/doc/invoke.texi:1549, -x at :1700). Auxiliary output names are
documented at length under -o (:1768), -dumpbase (:1839) and
-dumpdir (:1962). -pipe is at :2251 and -save-temps at :21299. The
Spec Files node (gcc/doc/invoke.texi:37290) documents %d,
%g, %u, %U, %j, %| and %m (:37457-37505), and Environment Variables
documents TMPDIR (:38043).
What is not documented:
- That the compiler table is searched from its last row, and that its first rows are placeholders that turn a missing front end into "compiler not installed".
- That
-x LANGlooks up a row named@LANG, so the valid languages are the ones your driver was built with. - That "once per compilation" for
%gmeans once per driver run, so every input shares the%g.sfile. - That temporaries are deleted when a step fails. The Spec Files node says
%dfiles are deleted "if GCC exits successfully" (invoke.texi:37458-37460). The code deletes them in both cases. - That
-save-tempsruns the preprocessor as a separate process for C and C++. - That a missing
-ocounts asawhen the driver builds the prefix. The manual states the rule in terms of the output name, and thea-prefix appears only in the source comment (gcc.cc:5161-5164). - That
g++wraps.c,.iand.hinputs in-x c++…-x none, and that your own-xexempts only the next file. The manual says these files are C++ "unless -x is used" (invoke.texi:2364-2365), as if one-xcovered them all. - That the driver accepts any front end's option and leaves the language check to the compiler.
Next: Chapter 1.5, How the driver builds its search lists: -B and --sysroot,
how the driver finds cc1, as and the other programs that these rows name,
and every file that a spec asks for with %s.