6.2 The manuals are source: reading gcc/doc

Source references in this chapter are to GCC 15.2.0 (releases/gcc-15.2.0).

A warning ends in [-Wunused-variable]. Compile with -fdiagnostics-urls=always in a terminal that shows links, and that text links to https://gcc.gnu.org/onlinedocs/gcc-15.2.0/gcc/Warning-Options.html#index-Wno-unused-variable. The compiler knows the address of its own manual, down to the release and the anchor. The anchor comes from one line in the GCC tree: @opindex Wno-unused-variable, at gcc/doc/invoke.texi:7846.

Every Documentation coverage section in this book gave you the same pair: a page on gcc.gnu.org and a gcc/doc/*.texi:LINE citation. They are one text in two forms. A script in the tree runs makeinfo over the .texi files at a release tag, and the pages are its output. The files come with every checkout, grep reads them, and their line numbers belong to the same tag as the code. This chapter shows how a file becomes a page and which file owns which subject. Then it shows how to get from a symptom to the right node, and the one manual file that you must not edit: tm.texi.

This chapter assumes Chapter 2.1, for the layout of a checkout, and Chapter 2.4, for generated files and the s-* stamp rules that remake them.

From .texi to page: maintainer-scripts/update_web_docs_git

The pages under onlinedocs/ come from maintainer-scripts/update_web_docs_git. Its first comment states the job: "Generate HTML documentation from GCC Texinfo docs" (:3). Its -r option names a release (:65-79), and the script clones that release's tag:

if [ "$RELEASE" = "master" ]; then
  git clone -q $GITROOT gcc
else
  git clone -q -b releases/gcc-$RELEASE $GITROOT gcc
fi
rm -rf gcc/.git

Listing 6.2-1: the docs are built from a tag (maintainer-scripts/update_web_docs_git:133-138).

With -r 15.2.0, that is releases/gcc-15.2.0, the pin of this book. The script then deletes every file that is not a .texi file, except a short list of helpers (:147-160), and puts what is left in docs-sources.tar (:163). It writes a gcc-vers.texi with the version number and the bug URL (:169-180). It runs makeinfo --html once for each manual (:186-203) and copies the pages and the tar files to the web directory (:279-295). On 2026-10-22, onlinedocs/gcc-15.2.0/ listed docs-sources.tar, gcc.pdf and gcc-html.tar beside the gcc/, gccint/ and cpp/ directories.

So the 15.2.0 pages and this book's citations read the same files at the same tag. That is why the book can put a line number next to each page.

The deletion step has two consequences.

Nothing is built. The script never runs configure or make. A .texi file that the build generates cannot reach the web unless it is also in the repository. The internals manual states the rule: "All Texinfo files that are parts of manuals must be version-controlled, even if they are generated files, for the generation of online manuals to work" (sourcebuild.texi:429-431). tm.texi is such a file, and the tm.texi section below shows what that costs a contributor.

The install manual has one copy. The script builds it only from master:

# Finally, generate the installation documentation
if [ "$RELEASE" = "master" ]; then
  SOURCEDIR=$WORKDIR/gcc/gcc/doc
  DESTDIR=$WWWBASE_PREFORMATTED/install
  export SOURCEDIR
  export DESTDIR
  $WORKDIR/gcc/gcc/doc/install.texi2html

Listing 6.2-2: the install manual comes from master only (maintainer-scripts/update_web_docs_git:314-320).

That is why https://gcc.gnu.org/install/ has no gcc-15.2.0 form, and why this book cites install.texi:LINE for the install manual. The line at the tag is the only pinned copy. install.texi2html also names the install pages itself. It runs makeinfo ten times, each time with a -D flag that selects one part of install.texi, and writes configure.html, build.html, test.html and seven others (install.texi2html:49-59). The Configuration node becomes configure.html because install.texi wraps it in @ifset configurehtml (install.texi:729), not because of its node name.

Page names: from @node to .html

For the other manuals, makeinfo writes one HTML file per node, and the file name comes from the node name. The Texinfo manual documents the rule under HTML Xref Node Name Expansion. ASCII letters and digits stay. Each space becomes -. Every other ASCII character becomes _00 and its hexadecimal code, so - becomes _002d and + becomes _002b. GCC's script then changes every _002d back to -, in the contents and in the file names (update_web_docs_git:251-262). The result:

NodePage
Environment VariablesEnvironment-Variables.html
Invoking G++Invoking-G_002b_002b.html
Gcov-toolGcov-tool.html, not Gcov_002dtool.html
poly_int (internals manual)poly_005fint.html

With the rule, you can write the URL of any node: https://gcc.gnu.org/onlinedocs/gcc-15.2.0/, the manual's directory, a /, and the page.

Which manual owns what: gcc.texi, gccint.texi, cpp.texi, install.texi

gcc/doc/ holds 58 .texi files, plus tm.texi.in, install.texi2html and two directories (gcc/doc/). Only a few of the files are manuals. A manual is a root file that starts with \input texinfo, names its Info file with @setfilename (gcc.texi:1-3), and includes the other files as its chapters. The internals manual documents the layout under Texinfo Manuals. The manuals for GCC and for C and C++ are in doc/*.texi. Other front ends keep theirs in their own directories, and doc/include/ holds the files that several manuals share (sourcebuild.texi:387-391).

ManualRoot fileRendered underRead it for
Using GCCgcc/doc/gcc.texionlinedocs/gcc-15.2.0/gcc/options (invoke.texi), extensions, attributes and built-ins (extend.texi)
GCC Internalsgcc/doc/gccint.texionlinedocs/gcc-15.2.0/gccint/source tree and testsuite (sourcebuild.texi), .opt files (options.texi), passes, GENERIC, GIMPLE, RTL, md.texi, tm.texi, libgcc
The C Preprocessorgcc/doc/cpp.texionlinedocs/gcc-15.2.0/cpp/directives, predefined macros
cpplib internalsgcc/doc/cppinternals.texionlinedocs/gcc-15.2.0/cppinternals/libcpp
Installing GCCgcc/doc/install.texigcc.gnu.org/install/prerequisites, configure flags, build, test

The root files list their chapters. gcc.texi includes invoke.texi and 20 other chapters (gcc.texi:172-199). gccint.texi includes sourcebuild.texi, md.texi and tm.texi among its own (gccint.texi:140-177). Front ends and runtime libraries have their own roots, for example gcc/fortran/gfortran.texi, gcc/ada/gnat_ugn.texi, gcc/d/gdc.texi and libgomp/libgomp.texi. The web script's MANUALS list names every root that it renders (update_web_docs_git:32-50).

One file, two manuals: @set INTERNALS

A file can be a chapter of more than one manual. contribute.texi is the plainest case. Both gcc.texi and gccint.texi include it (gcc.texi:187, gccint.texi:140). Its 24 lines send you to https://gcc.gnu.org/contribute.html, which is not in the tree (contribute.texi:13-19). Chapter 6.3 and Chapter 6.4 take you to that page.

md.texi is in both manuals too, and a flag decides how much of it each one gets:

@c INTERNALS is used by md.texi to determine whether to include the
@c whole of that file, in the internals manual, or only the part
@c dealing with constraints, in the user manual.
@clear INTERNALS

Listing 6.2-3: the user manual clears the flag (gcc/doc/gcc.texi:4-7).

gccint.texi sets it (:7), and the user manual reaches md.texi through extend.texi (:12620). The preprocessor options work the same way, without a flag. cppopts.texi, cppdiropts.texi, cppwarnopts.texi and cppenv.texi are chapters of the cpp manual (cpp.texi:4715-4736) and of the GCC manual (invoke.texi:9459, :19004, :19494, :38155).

So one grep hit can be two rendered pages, and a patch to cppopts.texi changes two manuals. When this book cites one of these shared files, it links the page in the manual that the chapter was reading.

From a symptom to a node: @opindex, @defmac, @item

The Texinfo commands make the sources easy to search. Almost everything a user can name has one next to it: an index entry such as @opindex or @vindex, a definition such as @defmac, or the @item of a table. An index entry also makes an HTML anchor, named index- and the entry. The compiler's own URL code expects that form (gcc/opts.cc:3803-3805). The table gives one grep for each kind of name:

You havegrep forHit at the pin
an option or a warning@opindex Wunused-variableinvoke.texi:7845
a configure flag@item --with-sysrootinstall.texi:2709
a target macro@defmac BIGGEST_ALIGNMENTtm.texi.in:987 (and tm.texi:1110)
a target hook@hook TARGET_ASM_FILE_ENDtm.texi.in:5173
a built-in@defbuiltin{long __builtin_expectextend.texi:17578
a function attribute@cindex @code{noinline} function attributeextend.texi:2795
an environment variable@vindex GCC_EXEC_PREFIXinvoke.texi:38056

@defbuiltin is a GCC macro for @deftypefn {Built-in Function}, defined in doc/include/gcc-common.texi (:69-71). The other commands are plain Texinfo.

A hit gives you a line. To get the page, find the last @node above it. In a checkout of releases/gcc-15.2.0:

$ grep -n '@opindex Wunused-variable' gcc/doc/*.texi
gcc/doc/invoke.texi:7845:@opindex Wunused-variable
$ grep -n '^@node' gcc/doc/invoke.texi | awk -F: '$1 < 7845' | tail -1
6122:@node Warning Options

The node Warning Options becomes Warning-Options.html, in the manual whose root includes invoke.texi, which is gcc. The anchor is #index-Wunused-variable from line 7845, or #index-Wno-unused-variable from line 7846. That is the URL from the start of this chapter.

The compiler does the same lookup: .opt.urls

The compiler does not grep at run time. A developer runs the lookup once, and the result is in the source tree. Next to each .opt file is a .opt.urls file:

Wunused-variable
UrlSuffix(gcc/Warning-Options.html#index-Wno-unused-variable)

Listing 6.2-4: one entry (gcc/c-family/c.opt.urls:936-937).

The first line of the file says "Autogenerated by regenerate-opt-urls.py from gcc/c-family/c.opt and generated HTML" (:1). The make regenerate-opt-urls target runs that script over the pages that make html wrote (gcc/Makefile.in:3830-3839). The internals manual documents UrlSuffix and the target under Option properties, and says to run it "when adding new options" (options.texi:600-616).

When a diagnostic names an option, make_option_url joins the suffix to DOCUMENTATION_ROOT_URL (gcc/opts.cc:3816-3828). configure sets that root:

     docroot_url_suffix=
changequote(,)dnl
     case "$gcc_version" in
       *.[123456].0) docroot_url_suffix="gcc-$gcc_version/";;
       *.[123456].1) docroot_url_suffix="gcc-`echo $gcc_version | sed 's/1$/0/'`/";;
     esac
changequote([,])dnl
     DOCUMENTATION_ROOT_URL="https://gcc.gnu.org/onlinedocs/$docroot_url_suffix"

Listing 6.2-5: the default documentation root (gcc/configure.ac:1104-1111).

gcc_version is the content of gcc/BASE-VER (configure.ac:31), which is 15.2.0 at the pin (BASE-VER). So a 15.2.0 compiler links to onlinedocs/gcc-15.2.0/. A trunk version such as 16.0.0 matches neither pattern and links to the unversioned pages. The install manual documents this default, and --with-documentation-root-url, which replaces it, under Configuration. The GCC manual documents -fdiagnostics-urls, and the environment variables that can turn it off, under Diagnostic Message Formatting Options.

tm.texi is generated from tm.texi.in and target.def

Grep for a target hook by its full name:

$ grep -n 'TARGET_ASM_FILE_END' gcc/doc/*.texi
gcc/doc/tm.texi:8383:@deftypefn {Target Hook} void TARGET_ASM_FILE_END (void)
gcc/doc/tm.texi:8392:should define @code{TARGET_ASM_FILE_END} to this function.  If you

Both hits are in tm.texi, the Target Macros chapter of the internals manual. You should edit neither line. tm.texi is the output of a generator, and the glob *.texi does not match its input, tm.texi.in. Nothing in tm.texi says so. It has no "generated" header, and no .texi file names tm.texi.in, target.def or the generator.

The generator is genhooks. Its first comment says that it processes "target.def to create initialization macros definition in target-hooks-def.h and documentation in target-hooks.texi" (gcc/genhooks.cc:1-2). The output file is tm.texi now, but the job is the same. With -d and a file name, it writes the documentation (:317-327). The text has three places.

The hook and its text are in target.def. Each DEFHOOK gives a name, a documentation string in Texinfo, a type, the parameters and the default:

/* Output any boilerplate text needed at the end of a translation unit.  */
DEFHOOK
(file_end,
 "Output to @code{asm_out_file} any text which the assembler expects\n\
to find at the end of a file.  The default is to output nothing.",
 void, (void),
 hook_void_void)

Listing 6.2-6: a hook and its documentation (gcc/target.def:710-716).

The full name is not on those lines. HOOK_PREFIX is "TARGET_ASM_" from target.def:32. genhooks compiles target.def into a table, joins the prefix to file_end, and makes the result upper case (genhooks.cc:24-38, :42-50). So grep TARGET_ASM_FILE_END gcc/target.def finds nothing. Grep for (file_end,.

The position is in tm.texi.in. An @hook line says where the hook's text goes. The text around it is ordinary Texinfo:

@hook TARGET_ASM_FILE_END

@deftypefun void file_end_indicate_exec_stack ()
Some systems use a common convention, the @samp{.note.GNU-stack}
special section, to indicate whether or not an object file relies on
the stack being executable.  If your system uses this convention, you
should define @code{TARGET_ASM_FILE_END} to this function.  If you
need to do other things in that hook, have your hook function call
this function.
@end deftypefun

Listing 6.2-7: the hook's place, and hand-written text after it (gcc/doc/tm.texi.in:5173-5182).

The result is in tm.texi. genhooks -d copies tm.texi.in and replaces each @hook line with a @deftypefn or @deftypevr block that it makes from the hook's fields (genhooks.cc:201-248):

@deftypefn {Target Hook} void TARGET_ASM_FILE_END (void)
Output to @code{asm_out_file} any text which the assembler expects
to find at the end of a file.  The default is to output nothing.
@end deftypefn

@deftypefun void file_end_indicate_exec_stack ()
Some systems use a common convention, the @samp{.note.GNU-stack}
special section, to indicate whether or not an object file relies on
the stack being executable.  If your system uses this convention, you
should define @code{TARGET_ASM_FILE_END} to this function.  If you
need to do other things in that hook, have your hook function call
this function.
@end deftypefun

Listing 6.2-8: the generated text (gcc/doc/tm.texi:8383-8395), rendered as part of File Framework.

Target macros such as BIGGEST_ALIGNMENT have no DEFHOOK. Their @defmac text is in tm.texi.in, and genhooks copies it unchanged. That is why the table above shows two hits for it.

The split between target.def and tm.texi.in has a reason, and genhooks gives it. A hook whose documentation string is empty gets only its signature, and its text can then live in tm.texi.in:

   When the doc field is "", @deftypefn/@deftypevr and the hook signature
   is emitted, but not the matching @end.  This allows all the free-form
   documentation to be placed in IN_FNAME, to work around GPL/GFDL
   licensing incompatibility issues.  */

Listing 6.2-9: why some text is not in target.def (gcc/genhooks.cc:93-96).

target.def is C source under the GPL (target.def:4-7). The internals manual is under the GFDL (gccint.texi:31-33). A program copies each documentation string from one licence into the other, and the build asks you to confirm that you may do that.

genhooks also checks that its inputs agree. A documented hook with no @hook line stops it with "No place specified to document hook" (genhooks.cc:148-149). An @hook line for a hook it does not know stops it with "No documentation for hook" (:183-184). Two @hook lines for one hook stop it with "Duplicate placement" (:126-127). The comment above the function says that a hook with no @hook line "is emitted after the hook that precedes it in target.def" (:76-78). The code does not do that. It stops.

The s-tm-texi check

The gcc/Makefile.in rule s-tm-texi runs genhooks -d on tm.texi.in, writes the result to tm.texi in the build directory, and compares it with the copy in the source tree (gcc/Makefile.in:2951-2959):

	@if cmp -s $(srcdir)/doc/tm.texi tm.texi; then \
	  $(STAMP) $@; \
	elif test $(srcdir)/doc/tm.texi -nt $(srcdir)/doc/tm.texi.in \
	  && ( test $(srcdir)/doc/tm.texi -nt $(srcdir)/target.def \
	    || test $(srcdir)/doc/tm.texi -nt $(srcdir)/c-family/c-target.def \
	    || test $(srcdir)/doc/tm.texi -nt $(srcdir)/common/common-target.def \
	    || test $(srcdir)/doc/tm.texi -nt $(srcdir)/d/d-target.def \
	    || test $(srcdir)/doc/tm.texi -nt $(srcdir)/rust/rust-target.def \
	  ); then \
	  echo >&2 ; \
	  echo You should edit $(srcdir)/doc/tm.texi.in rather than $(srcdir)/doc/tm.texi . >&2 ; \
	  false; \
	else \
	  echo >&2 ; \
	  echo Verify that you have permission to grant a GFDL license for all >&2 ; \
	  echo new text in $(objdir)/tm.texi, then copy it to $(srcdir)/doc/tm.texi. >&2 ; \
	  false; \
	fi

Listing 6.2-10: the check (gcc/Makefile.in:2960-2977).

The check has three results, and two of them stop the build:

  1. The two files are the same. The rule writes its stamp, and the build continues.
  2. The source tm.texi is newer than tm.texi.in and newer than one of the .def files. The rule concludes that you edited tm.texi by hand, and tells you to edit tm.texi.in.
  3. In all other cases, the rule assumes that the inputs changed and the source tm.texi did not. It asks you to confirm the GFDL permission and to copy the new file into the source tree.

The check runs in every build of gcc/, also on a machine with no makeinfo. all.internal and all.cross depend on doc (Makefile.in:2217-2220). When configure finds no usable makeinfo (configure.ac:1258-1271), doc still depends on info, so that the prerequisites of the Info files are checked (Makefile.in:3679-3686). doc/gccint.info depends on the source tm.texi (:3711-3714), and that file depends on s-tm-texi (:2897-2898). build/genhooks.o depends on target.def and the other .def files (:3284-3286), so a changed documentation string rebuilds genhooks and runs the check again.

So the procedure for a new hook is:

  1. Write the DEFHOOK in target.def, with its documentation string.
  2. Add an @hook line at the right place in tm.texi.in, and any free text around it.
  3. Build. Because you changed tm.texi.in, the source tm.texi is not newer than it, and the build stops with the GFDL message.
  4. Copy tm.texi from the gcc build directory to gcc/doc/tm.texi, and commit all three files.

For a changed documentation string, the last step is the same: commit the tm.texi that the build wrote. tm.texi is a generated file that you commit. The web script needs it in the repository, because the script never builds anything.

Building the manuals yourself: make html, makeinfo, man gcc

In a build tree, the gcc directory has the usual targets. When configure found makeinfo, make info writes doc/gcc.info, doc/gccint.info, doc/cpp.info, doc/gccinstall.info and doc/cppinternals.info (Makefile.in:3688-3691, :3750-3754). make html writes one directory per manual under HTML/gcc-15.2.0/ (:770, :3814-3820), and it builds the install manual with install.texi2html here too (:3823-3828). The internals manual documents these targets under Texinfo Manuals. The install manual lists the Texinfo and TeX versions that they need under Prerequisites.

One sentence in the internals manual is out of date. It says that make info "generates the manuals in the source directory" (sourcebuild.texi:411-414). At the pin, the Info files stay in the build directory. The srcinfo target copies them into the source tree (Makefile.in:3693-3694), and info depends on srcinfo only when you configure with --enable-generated-files-in-srcdir (gcc/configure.ac:306-329). The install manual documents that flag under Configuration, and says that it is mainly for release tarballs.

You do not need a build tree to read a manual as Info. Each manual includes gcc-common.texi, which includes gcc-vers.texi (gcc-common.texi:11), and only the build writes that file (Makefile.in:3726-3738). Write it yourself, as the web script does. Then call makeinfo with the flags and the include paths of the doc/%.info rule (Makefile.in:356, :3750-3754). From the top of a checkout:

$ src=$PWD
$ mkdir -p /tmp/gccdoc && cd /tmp/gccdoc
$ printf '%s\n' "@set version-GCC $(cat $src/gcc/BASE-VER)" \
    '@clear DEVELOPMENT' "@set srcdir $src/gcc" \
    '@set BUGURL @uref{https://gcc.gnu.org/bugs/}' > gcc-vers.texi
$ makeinfo --no-split -I . -I $src/gcc/doc -I $src/gcc/doc/include \
    -o gcc.info $src/gcc/doc/gcc.texi
$ info ./gcc.info -n 'Environment Variables'

Nobody ran this recipe at the pin. The machine that this chapter was written on has no makeinfo. Each line comes from GCC's own scripts. The four @set lines copy update_web_docs_git:169-180, and the makeinfo options copy Makefile.in:3752-3753. @set srcdir is necessary, because invoke.texi includes @value{srcdir}/../libiberty/at-file.texi (invoke.texi:2339). The info syntax is from the Invoking Info node of the Info manual. Use gccint.texi in place of gcc.texi for the internals manual.

man gcc is invoke.texi

The gcc(1) man page is a third form of the same file. The build makes gcc.pod from invoke.texi with contrib/texi2pod.pl, then runs pod2man on it (Makefile.in:3891-3893, :360, :3869-3873). Comments in the source select the parts. @c man begin OPTIONS at invoke.texi:179 and @c man end at :37288 put every option section in the man page. The section ends just before the Spec Files node, so man gcc has no spec language. The internals manual documents the @c man comments under Man Page Generation. A man page has no nodes and no anchors. When man gcc and a web page seem to disagree, compare the invoke.texi line that both came from.

Documentation outside Texinfo: libstdc++, jit, libgdiagnostics

Three parts of the tree use other systems. The libstdc++ manual is DocBook XML under libstdc++-v3/doc/xml/. Its HTML is in the repository under libstdc++-v3/doc/html/, and make doc-html-docbook-regenerate rewrites it (libstdc++-v3/doc/Makefile.am:557-561). Its API reference comes from Doxygen, with make doc-html-doxygen (documentation_hacking.xml:297-307). The libstdc++ manual documents both under Documentation Hacking. The jit and libgdiagnostics manuals use Sphinx (update_web_docs_git:233-249). The internals manual says nothing about any of them. Its Documentation node ends with "FIXME: document the documentation for runtime libraries somewhere" (sourcebuild.texi:375-376).

Three things to carry away

The rendered manual is makeinfo run over gcc/doc/*.texi at a release tag. A .texi:LINE at the same tag is the most exact citation that you can give.

Grep the Texinfo command, then find the @node above it. The node name gives the page, and an index entry gives the anchor.

Never edit tm.texi by hand. Edit target.def and tm.texi.in, build, then commit the tm.texi that the build wrote.

Things that surprise people

grep gcc/doc/*.texi finds the generated file and misses its source. The glob matches tm.texi and not tm.texi.in, and the full hook names are not in target.def.

The install manual has no versioned copy. The web script builds it only from master. For a release, read install.texi at the release tag.

A build with no makeinfo still checks tm.texi. It writes no Info files, but s-tm-texi runs and can stop the build.

Documentation coverage

The internals manual documents the manuals' layout, the make targets and the web script under Texinfo Manuals (gcc/doc/sourcebuild.texi:384). That node is part of Documentation (:366). The same manual documents man pages under Man Page Generation (:437), and .opt.urls under Option properties (gcc/doc/options.texi:600). The install manual documents the Texinfo prerequisite under Prerequisites (gcc/doc/install.texi:613), and --with-documentation-root-url (:819) and --enable-generated-files-in-srcdir (:1955) under Configuration. The GCC manual documents -fdiagnostics-urls under Diagnostic Message Formatting Options (gcc/doc/invoke.texi:5515). The Texinfo manual documents the node-name rule under HTML Xref Node Name Expansion.

What is not documented:

  • That tm.texi is generated from tm.texi.in and the hook .def files by genhooks. No .texi file names any of them, and tm.texi has no "generated" header.
  • The s-tm-texi check, its two messages, and that it runs in every build, with or without makeinfo.
  • That the genhooks header comment describes an unplaced hook that the code rejects.
  • That onlinedocs/gcc-X.Y.Z/ is built from the release tag with every non-Texinfo file deleted, and that the install manual is built only from master.
  • GCC's _002d rewrite, which makes its page names differ from plain makeinfo output.
  • That the anchors in .opt.urls come from @opindex lines.
  • That make info writes to the source directory only with --enable-generated-files-in-srcdir. The Texinfo Manuals node says otherwise (sourcebuild.texi:411-414).

Next: the conventions that a patch is judged against, from GNU formatting to the ChangeLog entry that now goes in the commit message, and the contrib/ scripts that check both.


All source references in this chapter are to GCC 15.2.0 (releases/gcc-15.2.0). Line numbers in other releases will differ; the surrounding code rarely does. Where behaviour itself changed across a major version, it is flagged inline.