2.4 Generated sources in build/gcc/: options.cc, tm.h and insn-*
GCC 15.2.0. To run the commands: a GCC build tree, configured and built.
Chapter 1.3 quoted case OPT_dumpspecs: from gcc/gcc.cc, and Chapter 1.4
quoted OPT_SPECIAL_input_file. Search a GCC checkout for the line that defines
either name, and you find only the places that use it. The same happens with
flag_rtti, which the C++ front end tests, with insn-recog.cc, which GCC 14
and earlier generate, and with the text that gcc -v prints after
Configured with:. All of them are in files that the build writes, and none of
them is in git.
The gcc subdirectory of a build tree, written build/gcc/ in this chapter,
holds a second set of sources. configure, shell and awk scripts, and programs
compiled for the build machine write it, and gcc/Makefile.in has one rule for
each file. When you cannot find a name in the checkout, find the rule, then read
the input of its generator.
This chapter assumes Chapter 1.2, for the build
machine, the Canadian cross and the uninstalled xgcc, and
Chapter 1.3, for the spec table, -dumpspecs and the
libgcc spec. It uses specs.h and the driver's option table from
Chapter 1.4, multilib.h from
Chapter 1.6 and gcc -v from
Chapter 1.14. From Part II, it uses
config.gcc as Chapter 2.1 describes it, the file
that selects the target headers, tm_defines and the machine description for
your triple. It also uses --enable-languages and the sub-configure runs of
Chapter 2.2, and the top-level makefile
of Chapter 2.3.
generated_files: built before the first host object
Most of the generated headers are in one variable of gcc/Makefile.in,
generated_files, and make writes every file in it before it compiles any host
object of the compiler. A broken generator for one of those files therefore
stops the build of gcc/ before the first host object compiles. Listing 2.4-1
is the list:
generated_files = config.h tm.h $(TM_P_H) $(TM_D_H) $(TM_H) multilib.h \
$(simple_generated_h) specs.h \
tree-check.h genrtl.h insn-modes.h insn-modes-inline.h \
tm-preds.h tm-constrs.h \
$(ALL_GTFILES_H) gtype-desc.cc gtype-desc.h version.h \
options.h target-hooks-def.h insn-opinit.h \
common/common-target-hooks-def.h pass-instances.def \
$(GIMPLE_MATCH_PD_SEQ_SRC) $(GENERIC_MATCH_PD_SEQ_SRC) \
gimple-match-auto.h generic-match-auto.h \
c-family/c-target-hooks-def.h d/d-target-hooks-def.h \
$(TM_RUST_H) rust/rust-target-hooks-def.h \
case-cfn-macros.h \
cfn-operators.pd omp-device-properties.h
Listing 2.4-1: generated_files (gcc/Makefile.in:3140-3152).
Every object of the compiler waits for that list, and the comment above the rule gives the reason:
# In order for parallel make to really start compiling the expensive
# objects from $(OBJS) as early as possible, build all their
# prerequisites strictly before all objects.
$(ALL_HOST_OBJS) : | $(generated_files)
Listing 2.4-2: generation before compilation (gcc/Makefile.in:4823-4826).
The | makes the list an order-only prerequisite, so no host object compiles
until every file in the list exists. A newer generated header does not by itself
force a rebuild through this rule, because the real header dependencies come
from the .Po files that the next lines include
(Makefile.in:4828-4832). The generated .cc files, such as
insn-attrtab.cc, are not in the list: make runs their generators when it
needs the objects.
Producers of build/gcc/ files: configure, scripts and build/gen*
A small number of producers write the files in build/gcc/: configure, the
script mkconfig.sh, shell commands and awk scripts in the makefile, and
programs that the build compiles and runs. The table gives each producer's
input, which is the file in the checkout to read when a generated name is
missing from it:
Files in build/gcc/ | Producer | Input |
|---|---|---|
auto-host.h, configargs.h | configure | config.in, the configure command line |
config.h, bconfig.h, tm.h, tm_p.h | mkconfig.sh | header lists from config.gcc |
specs.h, multilib.h | shell commands in Makefile.in | lang-specs.h files, MULTILIB_* variables |
optionlist, options.h, options.cc | awk scripts | every .opt file |
insn-*.h, insn-*.cc | build/gen* | the machine description |
insn-modes.h, insn-modes.cc | build/genmodes | machmode.def and the target's modes file |
gtype-desc.cc, gt-*.h | build/gengtype | GTY markers in the sources |
specs | xgcc -dumpspecs | the driver that the build just linked |
Chapter 1.4 showed specs.h (Makefile.in:2619-2625) and Chapter 1.6
showed multilib.h. The checkout's gcc/ directory has config.in,
the .opt files, the awk scripts and the generators' sources, but none of their
outputs.
build/gen* and GENERATOR_FILE: generators for the build machine
The gen* programs are C++ sources in gcc/ that the build compiles for the
build machine, because they must run on the machine that does the build. In
the Canadian cross of Chapter 1.2, they run on the build machine, and the cc1 that they help to make
runs on the host. A comment in gcc/Makefile.in states the rule:
# Compile the programs that generate insn-* from the machine description.
# They are compiled with $(COMPILER_FOR_BUILD), and associated libraries,
# since they need to run on this machine
# even if GCC is being compiled to run on some other machine.
Listing 2.4-3: why the generators use the build compiler
(gcc/Makefile.in:3296-3299).
COMPILER_FOR_BUILD is CXX_FOR_BUILD (Makefile.in:863).
The generic rule puts the objects under build/ (:3155-3159), so the
programs are build/gcc/build/gencodes, build/gcc/build/genrecog and so on.
The generators' flags add -DGENERATOR_FILE (Makefile.in:860),
and a generator includes bconfig.h, the build machine's configuration header
(gencodes.cc:23). The host's config.h stops a generator
that includes it by mistake: mkconfig.sh writes #error config.h is for the host, not build, machine. into it under GENERATOR_FILE
(mkconfig.sh:43-49).
s-* stamp files: move-if-change and ; @true
Most generator rules write to a temporary file, replace the real output only
when its text has changed, and record the run in an s-* stamp file. The stamp
idiom decides how much a regeneration recompiles, and which file to delete when
you want one generator to run again. A comment in gcc/Makefile.in works
through the problem with tree-check.h as its example, and ends with the form
that the makefile uses:
# The problem with this solution is that make thinks that tree-check.h is
# always unchanged. Make must be deceived into thinking that tree-check.h is
# rebuild by the "tree-check.h: s-check" rule. To do this, add a dummy command:
# tree-check.h: s-check; @true
# s-check : build/gencheck$(build_exeext)
# $(RUN_GEN) build/gencheck$(build_exeext) > tmp-check.h
# $(SHELL) $(srcdir)/../move-if-change tmp-check.h tree-check.h
# $(STAMP) s-check
#
# This is what is done in this makefile. Note that mkconfig.sh has a
# move-if-change built-in
Listing 2.4-4: the stamp idiom (gcc/Makefile.in:2060-2070). The
whole comment starts at :2036.
Read the rule from the bottom:
- The generator writes a temporary file,
tmp-check.h. move-if-changereplacestree-check.honly if the new text is different. If the text is the same, the old file keeps its old timestamp.$(STAMP) s-checkwrites the stamp.STAMPisecho timestamp >(Makefile.in:365). The stamp records that the generator ran.- The
; @truerecipe tells make that the rule fortree-check.hran, so make reads the timestamp oftree-check.hagain.
A change to the machine description therefore runs every generator that reads
it. Only the outputs with new text get a new timestamp, so only the objects that
include those outputs compile again. To make one generator run again, delete its
stamp, for example build/gcc/s-options, and run make.
mkconfig.sh does the same comparison with cmp and writes its own stamp,
cs-tm.h for tm.h (mkconfig.sh:115-125). The rule for
options.cc has no stamp of its own: it writes straight to its target
(Makefile.in:2634-2638), and the stamp s-options belongs to
its input, optionlist.
options.cc and options.h: awk over every .opt file
options.cc and options.h are the output of three awk scripts that read every
.opt file in the build. They define OPT_dumpspecs, flag_rtti and the other
option names that a grep of the checkout cannot find, so the source to read is
the .opt record behind each name.
The inputs are common.opt, c-family/c.opt, params.opt and
analyzer/analyzer.opt on every build (Makefile.in:632), the
lang.opt of each front end, and the target's files (:1287).
config.gcc adds config/<cpu>/<cpu>.opt when that file exists
(config.gcc:629-631). Three awk steps turn the files into C++:
opt-gather.awkreads all the files and writes one sorted list,optionlist, behind the stamps-options(Makefile.in:2627-2632).optc-gen.awkwritesoptions.cc, the option table that the driver andcc1search, fromoptionlist(Makefile.in:2634-2638).opth-gen.awkwritesoptions.h, with theOPT_codes and the option variables (Makefile.in:2652-2659).
One record from c-family/c.opt shows the input:
frtti
C++ ObjC++ Optimization Var(flag_rtti) Init(1)
Generate run time type descriptor information.
Listing 2.4-5: the record for -frtti
(gcc/c-family/c.opt:2296-2298).
A record is a name, a line of properties and a line of help text, and two parts
of it make names that the checkout never defines. The record name becomes the
enumerator OPT_frtti: opt_enum adds OPT_ in front and changes each
character that is not a letter or a digit to _
(opt-functions.awk:355-365). Var(flag_rtti) becomes a structure
field and a macro:
var_seen[name] = 1;
print "#ifdef GENERATOR_FILE"
print "extern " var_type(flags[i]) name ";"
print "#else"
print " " var_type(flags[i]) "x_" name ";"
print "#define " name " global_options.x_" name
print "#endif"
Listing 2.4-6: how Var() becomes a macro
(gcc/opth-gen.awk:88-94).
flag_rtti is therefore a macro for global_options.x_flag_rtti. When
c-cppbuiltin.cc tests it to define __GXX_RTTI
(c-cppbuiltin.cc:941-944), it reads a field of a structure that
options.h declares.
OPT_dumpspecs comes from a two-line record in common.opt, the name
dumpspecs and the property Driver (common.opt:964-965).
OPT_SPECIAL_input_file and the other four OPT_SPECIAL_ codes after the real
options come from print statements in the script itself
(opth-gen.awk:570-575). To find the variable behind an option,
grep the .opt files for its record, because a grep of the .cc files for a
declaration finds nothing.
Every front end's lang.opt, whatever --enable-languages says
configure adds the lang.opt of each front end it reads to the option table,
whatever --enable-languages says, but adds a front end's lang-specs.h only
when you build that language. A compiler built from a full checkout with
--enable-languages=c therefore has the C++, Fortran and Ada options in its
option table. This is why the driver in
Chapter 1.4 can accept an option for a
language that it cannot compile.
The install manual documents --enable-languages under
Configuration as the subset of compilers and runtime
libraries to build. In configure, the language list gates lang-specs.h
(configure.ac:7321-7327), but lang.opt goes in for every front
end whose config-lang.in it reads (:7364-7367). A front end that
is not in the list is skipped only when a directory that the front end requires
is missing (configure.ac:7344-7355).
tm.h and tm_p.h: mkconfig.sh writes #include lines
tm.h has almost no text of its own, because mkconfig.sh writes it as guarded
#define lines and a list of #include lines. Reading it is the quickest way to
see which target headers config.gcc chose for your triple, and in what order.
The rule cs-tm.h runs the script with two lists from configure: HEADERS,
the include list, and DEFINES, the tm_defines from config.gcc
(Makefile.in:2101-2107). In Listing 2.4-7, the for def loop writes
the defines and the IN_GCC block writes the includes:
# Provide defines for other macros set in config.gcc for this file.
for def in $DEFINES; do
echo "#ifndef $def" | sed 's/=.*//' >> ${output}T
echo "# define $def" | sed 's/=/ /' >> ${output}T
echo "#endif" >> ${output}T
done
...
if [ $# -ge 1 ]; then
echo '#ifdef IN_GCC' >> ${output}T
for file in "$@"; do
if test x"$file" = x"defaults.h"; then
postpone_defaults_h="yes"
else
echo "# include \"$file\"" >> ${output}T
fi
done
echo '#endif' >> ${output}T
fi
Listing 2.4-7: mkconfig.sh, abridged (gcc/mkconfig.sh:57-62
and :77-87).
configure makes the include list. It starts with options.h and
insn-constants.h, then adds each file in tm_file under config/
(configure.ac:2419-2437). Before that, it appends
defaults.h to tm_file (:2209), and mkconfig.sh holds that
one back and writes it after insn-flags.h and insn-modes.h
(mkconfig.sh:90-110). tm.h is therefore a guard,
TARGET_CPU_DEFAULT when the target sets one, the tm_defines, options.h and
insn-constants.h, the target headers in the order that config.gcc gave, and
defaults.h last. To see that list for your triple, print the file:
$ cat build/gcc/tm.h
The order of the #include lines matters, because a later header can #undef
and redefine a macro from an earlier one. gnu-user.h does that to
LINK_GCC_C_SEQUENCE_SPEC, for example (gnu-user.h:116-117).
tm_p.h is the same for prototypes. Its list is the target's -protos.h files
and the generated tm-preds.h (configure.ac:2210 and
:2439-2451). config.h, bconfig.h and tconfig.h come from the
same script, with the lists for the host, the build machine and the target
(Makefile.in:2086-2099).
-dumpspecs text from tm.h, auto-host.h and DRIVER_DEFINES
The spec text that -dumpspecs prints is fixed when gcc.o compiles, by target
macros from the headers that tm.h names and by configure results in
auto-host.h. A third route, DRIVER_DEFINES, reaches gcc.o through no file
at all. Because configure tested the linker that you had when you built GCC,
the linker options in the spec do not change if you install a different binutils
later.
gcc.cc includes multilib.h and then tm.h (gcc.cc:37-38).
It fills its spec slots from macros, with link_spec = LINK_SPEC,
lib_spec = LIB_SPEC and startfile_spec = STARTFILE_SPEC
(gcc.cc:1214-1219), and the target headers in tm.h define
those macros.
Some of that text also depends on what configure found when it tested your
tools. configure writes its findings to auto-host.h, from the template
config.in, which is in the repository (configure.ac:29), and
make updates the header through config.status
(Makefile.in:2183-2187). The --as-needed in the libgcc spec of
Chapter 1.3 shows the full path from a configure test to a spec:
configurestarts with--as-neededand--no-as-needed(configure.ac:6560-6564). For a linker that is not built in the same tree, it runs the linker with--helpand searches the output foras-needed. If the linker is GNU ld 2.28 or later and also listspush-stateandpop-state, the two options become--push-state --as-neededand--pop-state(:6574-6587).- It defines
HAVE_LD_AS_NEEDED,LD_AS_NEEDED_OPTIONandLD_NO_AS_NEEDED_OPTION(:6617-6624).config.inhas an#undefline for each of them, andconfig.statuswrites the values intoauto-host.h(config.in:1727-1729,:2380and:2398). - On GNU/Linux targets,
gnu-user.h, one of the headers intm.h, turns the configure result into a target decision. Listing 2.4-8 shows the four lines. init_gcc_specsputsLD_AS_NEEDED_OPTIONbetween the static and the shared libgcc when the target definesUSE_LD_AS_NEEDED(gcc.cc:1811-1829).
/* Use --as-needed -lgcc_s for eh support. */
#ifdef HAVE_LD_AS_NEEDED
#define USE_LD_AS_NEEDED 1
#endif
Listing 2.4-8: USE_LD_AS_NEEDED
(gcc/config/gnu-user.h:119-122).
Chapter 1.3 gave the libgcc spec as "roughly" --as-needed -lgcc_s --no-as-needed. The exact options in your -dumpspecs output are the ones that
configure chose when it ran your linker with --help.
DRIVER_DEFINES, the route with no file, gives gcc.o the install prefixes,
DEFAULT_TARGET_MACHINE, ENABLE_SHARED_LIBGCC and CONFIGURE_SPECS as -D
options on its compile command (Makefile.in:2599-2616). The
--with-specs text of Listing 1.3-15 reaches the driver this way, so no
generated file holds it. Like the --with-cpu default below, it changes the
command line, so -dumpspecs does not show it.
specs: the generated file that -dumpspecs writes
The build does not make the driver from the specs file in build/gcc/: it
makes specs from the driver, with xgcc -dumpspecs. A specs file can
override the table compiled into a driver, so it matters which specs file the
build-tree driver reads and what make install does with it. Listing 2.4-9 is
the rule that writes the file:
# Dump a specs file to make -B./ read these specs over installed ones.
$(SPECS): xgcc$(exeext)
$(GCC_FOR_TARGET) -dumpspecs > tmp-specs
mv tmp-specs $(SPECS)
Listing 2.4-9: specs (gcc/Makefile.in:2441-2444).
The GCC manual documents -dumpspecs under Developer Options, and
says that "This is used when GCC itself is being built". Listing 2.4-9 is that
use, and its GCC_FOR_TARGET is ./xgcc -B./ (Makefile.in:496).
The driver reads a file named specs from the first startfile prefix that has
one (gcc.cc:8496-8501), and -B./, which the GCC manual
documents under Directory Options, puts the build directory first.
The driver in the build tree therefore reads its own dump, and not a specs file
that an older installation left in the install directory. The comment in
Listing 2.4-9 gives this as the rule's purpose.
-dumpspecs itself never reads a specs file. The driver handles the option in
process_command, which set_up_specs calls (gcc.cc:8481)
before it looks for the file. The dump that wrote specs and a new dump from the
same driver therefore print the same compiled-in table, and this cmp should
report no difference:
$ cd build/gcc
$ ./xgcc -B./ -dumpspecs | cmp - specs
make install does not copy specs into the installation, and it deletes any
old copy there. A specs file that the ls from Chapter 1.3 finds next to an
installed libgcc.a was therefore put there by something other than
make install. The comment in the install-common rule gives the reasons:
# We no longer install the specs file because its presence makes the
# driver slower, and because people who need it can recreate it by
# using -dumpspecs. We remove any old version because it would
# otherwise override the specs built into the driver.
rm -f $(DESTDIR)$(libsubdir)/specs
Listing 2.4-10: install-common deletes specs
(gcc/Makefile.in:4141-4145).
configargs.h: the line that gcc -v prints
configargs.h holds the configure command line that gcc -v prints after
Configured with:, and the thread model that it can print after
Thread model:. The way configure writes the header explains the
(reconfigured) that the line can contain, and the header also carries the
--with-cpu and --with-arch defaults to the driver. configure writes it
itself, with a here-document:
cat > configargs.h <<EOF
/* Generated automatically. */
static const char configuration_arguments[] = "$gcc_config_arguments_str";
static const char thread_model[] = "$thread_file";
static const struct {
const char *name, *value;
} configure_default_options[] = $configure_default_options;
EOF
Listing 2.4-11: configargs.h (gcc/configure.ac:2242-2250).
configuration_arguments is the command line of the top-level configure,
which collects it in TOPLEVEL_CONFIGURE_ARGUMENTS. The list starts with $0,
the path you typed to run the script, and each argument that has a shell
metacharacter gets quotes (configure.ac:38 and
:44-63). The top-level makefile exports the variable to each
sub-configure (Makefile.tpl:242).
The driver prints the string after Configured with:
(gcc.cc:7710), and prints thread_model after
Thread model: unless the target defines THREAD_MODEL_SPEC
(:7712-7724). To compare the header with what the driver
prints, run:
$ grep configuration_arguments build/gcc/configargs.h
$ build/gcc/xgcc -v 2>&1 | grep '^Configured with'
The two lines carry the same string, because gcc.cc includes configargs.h
(gcc.cc:225) and prints the array that it declares. If
configargs.h already exists, configure keeps the old string and appends
: (reconfigured) and the new arguments
(configure.ac:2223-2232). The comparison on line 2227 only
stops configure from adding the same arguments twice in a row.
You do not have to run configure by hand for the string to grow. When
gcc/configure or gcc/config.gcc is newer than build/gcc/config.status, for
example after a git pull, make runs config.status --recheck, which runs
configure again (Makefile.in:2200-2206).
configure_default_options holds the --with-cpu, --with-arch and similar
values, which the install manual documents under
Configuration as the defaults for -mcpu=, -march=
and the like. config.gcc checks each one against the options the target
supports and writes the initializer (config.gcc:6114-6144).
The driver reads the array in do_option_spec, which puts each value into the
target's OPTION_DEFAULT_SPECS and applies the result as a self spec
(gcc.cc:5877-5920).
On AArch64, --with-cpu=X becomes -mcpu=X unless you give -march or -mcpu
(aarch64.h:1499-1507). Like --with-specs in
Chapter 1.3, the default changes the command line, so -dumpspecs does not show
it. The cc1 line of -### shows the added -mcpu=, because cc1_options
passes %{m*} (gcc.cc:1288).
insn-* files: generators that read the machine description
The largest group of files in build/gcc/ comes from the machine description,
and most of them follow one naming rule: build/genX writes insn-X. When an
insn- file is missing from the checkout, the rule names the generator to read.
md_file, the description that the generators read, is common.md and
config/<cpu>/<cpu>.md, unless config.gcc names another file
(Makefile.in:608 and configure.ac:1943-1944).
configure prints the choice as it runs: Using `.../config/aarch64/aarch64.md' as machine description file. (configure.ac:1964). Most outputs
get their names from one pair of static pattern rules:
$(simple_generated_c): insn-%.cc: s-%; @true
$(simple_generated_c:insn-%.cc=s-%): s-%: build/gen%$(build_exeext)
$(RUN_GEN) build/gen$*$(build_exeext) $(md_file) \
$(filter insn-conditions.md,$^) > tmp-$*.cc
$(SHELL) $(srcdir)/../move-if-change tmp-$*.cc insn-$*.cc
$(STAMP) s-$*
Listing 2.4-12: one generator, one output, one stamp
(gcc/Makefile.in:2748-2753). The comment above the rules is at
:2716-2721.
The headers follow the same pattern, so gencodes writes insn-codes.h,
genflags writes insn-flags.h and genconfig writes insn-config.h
(Makefile.in:2723-2746). The generators that write more than one
file have their own rules: genattrtab writes insn-attrtab.cc,
insn-dfatab.cc and insn-latencytab.cc (:2787-2796), and
genopinit writes insn-opinit.cc and insn-opinit.h (:2798-2805).
What each generator reads in the .md file, and how its output becomes an
instruction, is the subject of Chapter 5.6.
insn-recog.cc and insn-emit.cc do not exist in GCC 15.2
In GCC 15.2, genrecog and genemit split their output into numbered files, so
a build tree has no insn-recog.cc and no insn-emit.cc to search. The file
names changed in GCC 12, 14 and 15, and the table gives the names that each
release uses:
| Output | GCC 11 | GCC 12, 13 | GCC 14 | GCC 15 |
|---|---|---|---|---|
| recogniser | insn-recog.c | insn-recog.cc | insn-recog.cc | insn-recog-1.cc … insn-recog-10.cc, insn-recog.h |
| emitters | insn-emit.c | insn-emit.cc | insn-emit-1.cc … insn-emit-10.cc | insn-emit-1.cc … insn-emit-10.cc |
| options | options.c | options.cc | options.cc | options.cc |
The .c to .cc change in GCC 12 applied to generated names too, so a note that
names insn-recog.c is from GCC 11 or earlier. The sources for the table are
lines of gcc/Makefile.in at five tags:
releases/gcc-11.4.0: lines 2395-2397 and 2306.releases/gcc-12.1.0: lines 2415-2417 and 2332.releases/gcc-13.3.0: lines 2447-2449 and 2363.releases/gcc-14.1.0: line 242 and lines 2545-2547.releases/gcc-15.2.0: lines 235-246, 2755-2764 and 2766-2776.
The number of files is --with-insnemit-partitions, with a default of 10
(configure.ac:933-943). The numbers come from
one_to_9999, which starts at 1 (Makefile.in:217-225), so
the files are insn-emit-1.cc to insn-emit-10.cc, although the comment above
the genemit rule says tmp-emit-01.cc. match.pd is split the same way into
gimple-match-N.cc and generic-match-N.cc, under
--with-matchpd-partitions (Makefile.in:227-233).
genmodes and gengtype: generators that do not read the .md file
genmodes and gengtype write insn-modes.cc and gtype-desc.cc from inputs
other than the .md file. The mode files carry the insn- prefix but come from
a .def file that genmodes includes when it is compiled, so build/genmodes
is a different program for each target.
genmodes writes insn-modes.cc, insn-modes.h, insn-modes-inline.h and
min-insn-modes.cc (Makefile.in:2831-2855). It reads no input file
at run time: create_modes includes machmode.def at compile time
(genmodes.cc:833-835), and machmode.def includes the
target's EXTRA_MODES_FILE (machmode.def:261-264).
config.gcc sets that file to config/<cpu>/<cpu>-modes.def when it exists
(config.gcc:624-628).
gengtype reads the GTY markers in the files listed in GTFILES. It writes
gtype-desc.cc, gtype-desc.h, one gt-*.h per source file and a state file,
gtype.state (Makefile.in:3117 and
:3128-3138).
Three things to carry away
A GCC name that the checkout uses but never defines is usually in a file under
build/gcc/. Find the rule in gcc/Makefile.in, then read the generator's
input: an .opt record, a target header list or the .md file.
An s-* stamp records that a generator ran. move-if-change keeps the
output's timestamp when its text is the same, so a regeneration recompiles only
what changed.
The build fixed what gcc -v and gcc -dumpspecs print.
configargs.h holds the configure line, and tm.h and auto-host.h hold the
spec text and what configure found in your linker.
Things that surprise people
make install deletes specs. The build-tree specs file is
xgcc -dumpspecs output. An installed one came from somewhere else.
gcc -v can print (reconfigured). A second run of gcc/configure in the
same build directory keeps the old arguments and appends the new ones after
: (reconfigured). make can start that run without you.
-dumpspecs ignores a specs file. It prints the table compiled into the
driver, before the driver looks for the file.
Documentation coverage
The internals manual describes some of these files:
- Configuration Files (
gcc/doc/configfiles.texi:5) listsauto-host.h,configargs.h,config.h,bconfig.h,tconfig.handtm_p.h, and says thatmkconfig.shwrites the configuration headers. It does not listtm.h. It says that these headers "also contain the typedefs forrtx,rtvecandtree" (configfiles.texi:48-49), but in GCC 15.2.0mkconfig.shwrites no typedefs. - Target Macros (
gcc/doc/tm.texi:17-19) says that "tm.hshould be a link tomachine.h" and that "config.hincludestm.h". In GCC 15.2.0,tm.his a generated list of#includelines, andconfig.hholds the host headers only (configure.ac:2494-2511).gcc.ccincludestm.hitself. - Option file format (
gcc/doc/options.texi:19) documents the.optrecords and their properties. - RTL passes (
gcc/doc/passes.texi:890-892) namesinsn-emit.ccas the output ofgenemit. GCC 15.2 has no file with that name. RTL is the representation in whichcc1describes the target's instructions, and Chapter 5.1 introduces it. - Files (
gcc/doc/gty.texi:644) documentsgtype-desc.ccand thegt-*.hheaders. - Configuration (
gcc/doc/sourcebuild.texi:240-245) says that Autoheader makesconfig.infromconfigure.acandacconfig.h. GCC 15.2.0 has nogcc/acconfig.h. - Build (
gcc/doc/sourcebuild.texi:303-309) is a FIXME: "describe the build system, including what is built in what stages".
The install manual's Configuration page describes
--enable-generated-files-in-srcdir (gcc/doc/install.texi:1955-1967). It says
that Bison and flex output and the manuals are not in the repository. It does
not mention the generated files in build/gcc/.
What is not documented:
- That the
gcc/build directory holds files that are not in the repository at all. No manual tells a newcomer to look inbuild/gcc/foroptions.horinsn-codes.h. - The stamp idiom. Its only description is the comment in
gcc/Makefile.in. - That every front end's
lang.optgoes into the option table, whatever--enable-languagessays. - That the build-tree
specsfile is-dumpspecsoutput, and thatmake installdeletesspecs. The-dumpspecsentry says only that the option "is used when GCC itself is being built" (invoke.texi:21668-21670). - The numbered
insn-emit-N.ccandinsn-recog-N.ccfiles, and the configure options--with-insnemit-partitionsand--with-matchpd-partitions. - That a second run of
gcc/configure, including the one thatconfig.status --recheckstarts, appends to the string thatgcc -vprints.
Next: Chapter 2.5, make bootstrap: the three-stage native
build, why a native make compiles the
compiler three times, and what make compare checks between the last two.