3.5 When someone hands you a sysroot: what --with-sysroot must contain
Source references in this chapter are to GCC 15.2.0 (releases/gcc-15.2.0).
A vendor gives you a sysroot for aarch64-linux-gnu. You configure GCC with
--with-sysroot pointing at it, and configure finishes without a complaint.
make builds the compiler and libgcc. Then the configure script of the next
target library stops. It says C compiler cannot create executables, or, if you
disabled that library, libstdc++ says
Link tests are not allowed after GCC_NO_EXECUTABLES. Neither message names a
file. The second names an Autoconf macro, and it interrupts a check that has
nothing to do with your sysroot.
A prebuilt sysroot is read at four points in the build. At the last one, a
missing file can fail in silence and come back later as a different error.
That last point is the first link test of each target library. This chapter
follows the four in build
order and says which part of the sysroot each one needs: the libc headers, the
kernel headers that they include, the startfiles, and a libc to link against.
This chapter assumes Chapter 1.5, for how the
driver adds the sysroot to its search lists and why -print-file-name echoes a
name it cannot find. It assumes Chapter 1.7, for the
startfiles that a link asks for. It also assumes
Chapter 3.1, whose decision procedure sent
you here, and Chapter 3.2, for the inhibit_libc
condition.
--with-sysroot and one make: the documented path
The install manual documents this case under Building a cross
compiler. If you do not build a C library in the same tree, you
"provide the target libraries and headers before configuring GCC". You name them
with --with-sysroot, or with the older --with-headers and --with-libs
(install.texi:3313-3322). The manual documents
--with-sysroot itself under Configuration. The built compiler
acts as if --sysroot=DIR were one of its default options, and GCC does not
copy DIR into the install tree (install.texi:2709-2731).
The recipe is one configure and one make. Nobody ran it at the pin for this
book. The flags are checked against the sources, and the sequence is the one the
manual gives:
$ $GCC_SRC/configure --target=aarch64-linux-gnu --prefix=/opt/cross \
--with-sysroot=/opt/cross/aarch64-linux-gnu/sysroot \
--enable-languages=c,c++
$ make
$ make install
The cross assembler and linker must be installed first, in
$prefix/<target>/bin, as the same manual section says
(install.texi:3281-3285).
There is no make all-gcc step, because nothing has to be built between the
compiler and its libraries. The C library already exists. The price is that the
sysroot must be complete before you run configure. This configuration passes
--with-sysroot and no --without-headers, so inhibit_libc stays false
(Chapter 3.2). libgcc builds in full, and every
target library links test programs against the sysroot.
That is the whole difference from the bootstrap recipes:
| Build mode | inhibit_libc | Target headers needed | crt*.o and libc needed | Why |
|---|---|---|---|---|
Stage 1 of a bootstrap: --without-headers with its partner flag | true | no | later, from the C library you build next | libgcc leaves out the code that uses libc |
Against a prebuilt sysroot: --with-sysroot, no --without-headers | false | before configure | before make reaches libgcc | libgcc builds in full, and target libraries run link tests |
Chapter 3.2 gives the partner flag. The rest of this chapter is the second row, one reader at a time.
features.h: what gcc/configure reads before anything is built
gcc/configure runs before any compiler for the target exists. It cannot
compile or link a test program for the target, so it reads files. They come from
one directory, target_header_dir. With --with-sysroot=DIR, that is DIR
followed by the native header directory (gcc/configure.ac:2562-2563),
which is /usr/include unless you configure another one
(install.texi:2729-2731). A --with-build-sysroot takes the
place of DIR (gcc/configure.ac:2556-2557).
Chapter 3.2 covers the stdio.h test in that
directory. The other read is the glibc version:
glibc_version_major=0
glibc_version_minor=0
[if test -f $target_header_dir/features.h \
&& glibc_version_major_define=`$EGREP '^[ ]*#[ ]*define[ ]+__GLIBC__[ ]+[0-9]' $target_header_dir/features.h` \
&& glibc_version_minor_define=`$EGREP '^[ ]*#[ ]*define[ ]+__GLIBC_MINOR__[ ]+[0-9]' $target_header_dir/features.h`; then
glibc_version_major=`echo "$glibc_version_major_define" | sed -e 's/.*__GLIBC__[ ]*//'`
glibc_version_minor=`echo "$glibc_version_minor_define" | sed -e 's/.*__GLIBC_MINOR__[ ]*//'`
fi]])
Listing 3.5-1: the target glibc version, read from features.h
(gcc/configure.ac:6030-6037).
Two egrep calls, and no compiler. If features.h is missing, or does not
define __GLIBC__ and __GLIBC_MINOR__, the version stays 0.0. Configure
prints checking for target glibc version... 0.0
(:6020, :6038) and continues. A target with
no glibc gets the same 0.0, so nothing marks the value as a failure.
The version then sets defaults that are compiled into the driver and into cc1.
Each test goes through GCC_GLIBC_VERSION_GTE_IFELSE, a plain comparison of the
two numbers (gcc/acinclude.m4:548-556):
| glibc at least | What it sets | Where |
|---|---|---|
| 2.4 | TARGET_LIBC_PROVIDES_SSP on GNU/Linux. Without it, the driver's default LINK_SSP_SPEC adds -lssp_nonshared -lssp to every -fstack-protector link | configure.ac:6958-6961, gcc.cc:994-1002 |
| 2.4 | 128-bit long double by default on PowerPC, SPARC, s390 and Alpha GNU/Linux | configure.ac:7034-7038, :7051-7056 |
| 2.11 | the gnu_unique_object symbol type, if the assembler supports it | configure.ac:6044-6056 |
| 2.23 | TARGET_LIBC_PROVIDES_HWCAP_IN_TCB on PowerPC GNU/Linux | configure.ac:7105-7112 |
| 2.31 | TARGET_LIBC_GNUSTACK on MIPS GNU/Linux | configure.ac:7118-7127 |
The PowerPC port also reads the two numbers directly, as
TARGET_GLIBC_MAJOR and TARGET_GLIBC_MINOR, in its headers
(rs6000/linux64.h:176).
So a sysroot without features.h fails nothing, and builds a different
compiler. Take PowerPC GNU/Linux. With version 0.0, configure defines
TARGET_DEFAULT_LONG_DOUBLE_128 only if bits/wordsize.h defines
__LONG_DOUBLE_MATH_OPTIONAL (configure.ac:7051-7066).
Without that macro, the port's headers do not raise the default
(rs6000/linux64.h:536-537), and long double falls back to 64
bits, the same as double (rs6000.cc:3385-3390). That
is an ABI change, and no later step reports it.
The install manual documents --with-glibc-version=M.N under
Configuration, for a bootstrap that has no headers yet
(install.texi:2620-2630). It sets the version without
reading features.h. For a prebuilt sysroot, the better fix is the missing
features.h.
stmp-fixinc: the one check that names the directory
make builds the compiler first. Part of that step is fixincludes, which copies
the target's system headers into the include-fixed/ snapshot that
Chapter 1.8 describes. It reads
BUILD_SYSTEM_HEADER_DIR. For a cross compiler with a sysroot, that is the
sysroot's header directory, or the build sysroot's if you gave
--with-build-sysroot (gcc/configure.ac:2541-2544, :174).
The rule first checks that the directory exists:
fix_dir=include-fixed$${multi_dir}; \
if ! $(inhibit_libc) && test ! -d ${BUILD_SYSTEM_HEADER_DIR}; then \
echo "The directory (BUILD_SYSTEM_HEADER_DIR) that should contain system headers does not exist:" >&2 ; \
echo " ${BUILD_SYSTEM_HEADER_DIR}" >&2 ; \
case ${build_os} in \
darwin*) \
echo "(on Darwin this usually means you need to pass the --with-sysroot= flag to point to a valid MacOS SDK)" >&2; \
;; \
esac; \
tooldir_sysinc=`echo "${gcc_tooldir}/sys-include" | sed -e :a -e "s,[^/]*/\.\.\/,," -e ta`; \
if test "x${BUILD_SYSTEM_HEADER_DIR}" = "x$${tooldir_sysinc}"; \
then sleep 1; else exit 1; fi; \
Listing 3.5-2: the header-directory check in stmp-fixinc
(gcc/Makefile.in:3615-3626).
This is the only check in this chapter that prints the directory it looked
for. It fires when inhibit_libc is false and the directory does not exist,
which in this recipe means a wrong --with-sysroot value. It does not look inside the
directory. A usr/include that exists and has no stdio.h passes.
The listing has one exception. If the missing directory is the tool directory's
sys-include, the rule waits one second and continues. That is the directory
that --with-headers fills, and the last section returns to it.
libgcc: tsystem.h, crti.o, crtn.o and -lc
libgcc is the first target library, and every other one waits for it. The
top-level makefile template gives each target module a rule
configure-target-<module>: maybe-all-target-libgcc, unless the module is marked
no_gcc (Makefile.tpl:2108-2111). libgcc is the only module
with that mark (Makefile.def:654). So libgcc is the first
thing that compiles and links against your sysroot.
The libc headers, and the kernel headers behind them
With inhibit_libc false, libgcc compiles the code that uses the C library.
Its common header, gcc/tsystem.h, then includes <stdio.h>, <sys/types.h>,
<errno.h>, <string.h>, <stdlib.h> and <unistd.h>
(gcc/tsystem.h:85-110). The AArch64 unwinder includes <signal.h>
and <sys/ucontext.h> under the same #ifndef inhibit_libc
(libgcc/config/aarch64/linux-unwind.h:26-29). A sysroot without
the libc headers stops at the first libgcc file that includes one, with an
ordinary missing-header error.
For a hosted Linux target, "the libc headers" includes the kernel's headers too.
This crosses into the C library, but only to show what GCC expects to find in
the same usr/include. glibc's bits/local_lim.h includes <linux/limits.h>
(glibc 2.42 sysdeps/unix/sysv/linux/bits/local_lim.h:38).
GCC's own tree does the same where it needs kernel types: libsanitizer includes
a list of <linux/...> headers directly
(sanitizer_platform_limits_posix.cpp:69-87).
libgcc_s.so: crti.o, crtn.o and -lc, but no crt1.o
On GNU/Linux, libgcc also links a shared library, libgcc_s.so, through the
t-slibgcc fragment (libgcc/config.host:313-314):
SHLIB_LINK = $(CC) $(LIBGCC2_CFLAGS) -shared -nodefaultlibs \
$(SHLIB_LDFLAGS) $(LDFLAGS) \
-o $(SHLIB_DIR)/$(SHLIB_SONAME).tmp @multilib_flags@ \
$(SHLIB_OBJS) $(SHLIB_LC) && \
Listing 3.5-3: the first lines of the libgcc_s.so link
(libgcc/config/t-slibgcc:34-37). SHLIB_LC is -lc
(:29).
-nodefaultlibs removes the default libraries and keeps the startfiles
(Chapter 1.10). For a -shared link,
the GNU/Linux startfile spec selects no crt1.o variant, but it still adds
crti.o and crtn.o (Chapter 1.7). Then -lc needs
a libc to link against. The crtbeginS.o and crtendS.o in the same link are
libgcc's own, and libgcc copies them into the compiler's build directory before
this link for that reason (libgcc/Makefile.in:1106-1118).
So libgcc needs the libc headers, crti.o, crtn.o and a libc. It does not
need crt1.o.
libgcc's configure script needs even less. It calls GCC_NO_EXECUTABLES
(libgcc/configure.ac:219-220), the macro of the next section.
Its own link commands pass -nostartfiles -nodefaultlibs
(:500, :514). It configures against a sysroot
where nothing links.
GCC_NO_EXECUTABLES: the link test that fails without a word
Many target libraries do not assume that the new compiler can link a program.
They call GCC_NO_EXECUTABLES before AC_PROG_CC. The macro replaces
Autoconf's executable-suffix check with one link of its own, and puts a guard in
front of every later link test:
m4_define([_AC_COMPILER_EXEEXT],
[AC_LANG_CONFTEST([AC_LANG_PROGRAM(
[#include <stdio.h>],
[printf ("hello world\n");])])
# FIXME: Cleanup?
AS_IF([AC_TRY_EVAL(ac_link)], [gcc_no_link=no], [gcc_no_link=yes])
if test x$gcc_no_link = xyes; then
# Setting cross_compile will disable run tests; it will
# also disable AC_CHECK_FILE but that's generally
# correct if we can't link.
cross_compiling=yes
EXEEXT=
else
]m4_defn([_AC_COMPILER_EXEEXT])dnl
fi
)
m4_define([AC_LINK_IFELSE],
if test x$gcc_no_link = xyes; then
AC_MSG_ERROR([Link tests are not allowed after [[$0]].])
fi
m4_defn([AC_LINK_IFELSE]))
Listing 3.5-4: the replacement link test, and the guard on every later link
test (config/no-executables.m4:27-48).
The test program includes <stdio.h> and calls printf. To link it, the driver
needs everything that a normal link needs: the libc headers, the crt1.o
variant that the startfile spec selects, crti.o, crtn.o, a libc, and the
libgcc from the step before. Which crt1.o variant depends on how you
configured GCC. With --enable-default-pie, PIE_SPEC matches every link that
has no -no-pie (gcc/gcc.cc:1005-1006), so the spec asks for
Scrt1.o. Without it, the spec asks for crt1.o
(Chapter 1.7).
If the link fails, the macro prints nothing. It sets gcc_no_link=yes, sets
cross_compiling=yes so that no run test is tried, and configure continues.
From then on, each AC_LINK_IFELSE in the script starts with the guard at the
bottom of Listing 3.5-4. The first link test that runs stops configure with
Link tests are not allowed after GCC_NO_EXECUTABLES.
That first test is unrelated to the cause. libstdc++ calls the macro for every
cross build except Darwin to Darwin (libstdc++-v3/configure.ac:35-58).
In its generated script, for a GNU/Linux target, the first link test that runs
is libtool's probe for whether the linker sets DT_RUNPATH
(libstdc++-v3/configure:11567-11580). That probe is inside the
check that prints checking dynamic linker characteristics...
(:11141-11142). The guarded tests before it belong to SCO, Darwin,
AIX and IRIX (:7878-7895, :8470-8484,
:10246-10253, :10620-10629). So the
terminal shows a libtool check that failed. The real failure happened earlier,
at the top of the same script, with no message.
The other message: C compiler cannot create executables
Not every target library uses the macro. libgcc, libstdc++, libgfortran,
libquadmath, libssp, libobjc and zlib do. libgomp, libatomic, libitm,
libsanitizer and libbacktrace call plain AC_PROG_CC
(libgomp/configure.ac:112-115,
libatomic/configure.ac:134). For those, Autoconf's own check
runs, and a failed link stops configure at once. The script prints
checking whether the C compiler works... no, then
C compiler cannot create executables
(libgomp/configure:3882-3883, :3953-3954).
| Message | Printed by | What it means |
|---|---|---|
Link tests are not allowed after GCC_NO_EXECUTABLES. | a library that calls GCC_NO_EXECUTABLES | its link test failed earlier, with no message |
C compiler cannot create executables | a library that calls plain AC_PROG_CC | its link test failed now |
The build order decides which message you see first. Every target library waits
for libgcc. libstdc++'s configure also waits for libgomp's
(Makefile.def:675), and the top level builds libgomp by
default on GNU/Linux targets (configure.ac:529-546). So in a
default GNU/Linux build, libgomp reports C compiler cannot create executables
before libstdc++ runs at all. With make -j, libatomic can report the same
message at the same time. The two messages have the same cause.
Finding the failed link in config.log
The terminal does not show the failed link. The library's config.log does.
The generated test writes the link command, and everything the linker printed,
to file descriptor 5, which is config.log
(libstdc++-v3/configure:4261-4264). Each target library has its
own build directory, <objdir>/<target>/<library>/, where <target> is the
target name as you typed it (config/acx.m4:101). Each
multilib variant configures again in <objdir>/<target>/<multidir>/<library>/
(config-ml.in:670-701), with its own config.log.
Open the log of the library that stopped. The failed link is near the top, among the C compiler checks: a link command, the linker's own messages, and a non-zero exit status. Those linker messages are the diagnosis.
cannot compute sizeof (int): what that message means in GCC 15.2
You may have read that this failure shows itself as
cannot compute sizeof (int), and that the message means "configure compiled
but failed to link, so check crt1.o". In GCC 15.2, a missing startfile cannot
produce it.
AC_CHECK_SIZEOF(int) appears in two places at the pin. In gcc/configure.ac,
it measures the compiler that builds GCC, not the target
(gcc/configure.ac:523-527). In GCC_HEADER_STDINT, which
libatomic, libbacktrace, libgfortran, libitm and libsanitizer use, it runs only
when the macro found no header that defines the fixed-width integer types
(config/stdint.m4:140-144).
Neither can fail because a target link failed. The first one measures the build
machine's compiler. In a target library, a failed link either stopped configure
already, or GCC_NO_EXECUTABLES set cross_compiling=yes. With
cross_compiling=yes, Autoconf computes a size by compiling test programs, not
by linking or running them (libatomic/configure:1895-1914). And
the error branch has its own condition:
if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (int))" "ac_cv_sizeof_int" "$ac_includes_default"; then :
else
if test "$ac_cv_type_int" = yes; then
{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
as_fn_error 77 "cannot compute sizeof (int)
See \`config.log' for more details" "$LINENO" 5; }
else
ac_cv_sizeof_int=0
fi
Listing 3.5-5: the size check, as Autoconf 2.69 generates it for libatomic
(libatomic/configure:12344-12354).
The script stops only if ac_cv_type_int is yes. None of the generated
scripts that contain this check sets that variable: gcc/configure, and the
scripts of libatomic, libbacktrace, libgfortran, libitm and libsanitizer. A
failed measurement records 0, and configure continues. In
GCC_HEADER_STDINT, a later check then stops with
no 8-bit type, please report a bug (config/stdint.m4:146-150).
That message points at the libc headers, not at the startfiles. To get there,
the library found no integer-type header, and its size checks failed to compile
a program whose default includes start with <stdio.h>
(libatomic/configure:596-597).
If a build log shows cannot compute sizeof (int), find the config.log that
printed it before you act on it.
--with-headers and --with-libs: copying instead of pointing
Before --with-sysroot, you gave a cross build its target files with
--with-headers=DIR and --with-libs="DIR...". The install manual documents
both under Configuration as deprecated in favour of
--with-sysroot, and says that both copy their directories into the install
tree (install.texi:2751-2761,
:2768-2774). The top-level configure does the copying:
# Handle --with-headers=XXX. If the value is not "yes", the contents of
# the named directory are copied to $(tooldir)/sys-include.
if test x"${with_headers}" != x && test x"${with_headers}" != xno ; then
if test x${is_cross_compiler} = xno ; then
echo 1>&2 '***' --with-headers is only supported when cross compiling
exit 1
fi
if test x"${with_headers}" != xyes ; then
x=${gcc_cv_tool_prefix}
copy_dirs="${copy_dirs} ${with_headers} $x/${target_noncanonical}/sys-include"
fi
fi
Listing 3.5-6: --with-headers (configure.ac:2931-2942).
--with-libs follows at :2944-2960 and copies into
<target>/lib.
Three details are in the source and not in the manual.
The copy happens when you run configure. A loop after the option handling
copies each directory with tar, into <exec_prefix>/<target>/sys-include or
<exec_prefix>/<target>/lib, before make starts
(configure.ac:3005-3033). <exec_prefix> falls back to the
prefix when you give no exec prefix (config/acx.m4:260-268).
So configure writes into your install tree.
A second configure does not copy again. The loop writes the source
directory name into a COPIED file in the destination, and skips the copy when
the name matches (configure.ac:3009-3010). If you change the
headers in DIR and run configure again with the same DIR, the build keeps
the old copy. Symbolic links are copied as tar copies them. "It is the
responsibility of the user to correctly adjust all symlinks"
(:3027-3029).
gcc/configure reads the copy. With no --with-sysroot,
target_header_dir is <exec_prefix>/<target>/sys-include
(gcc/configure.ac:2558-2559). So Listing 3.5-1 reads the copied
features.h. The same directory is the fixincludes input
(:185-189), which is why Listing 3.5-2 accepts it even when
it is missing.
Both options together also change one default. Unless you pass --with-newlib,
they set --without-newlib (configure.ac:283-290). On a
native build, either option stops configure with
--with-headers is only supported when cross compiling (Listing 3.5-6), or the
same text for --with-libs.
Checking a sysroot before it fails: -print-sysroot and -print-file-name
None of the commands below were run for this book. They use only the files and options cited above.
Before configure: the files
There is no target compiler yet, so check the files. Use the directories that
your target's driver searches. Chapter 1.5 shows
how the driver forms them. Chapter 1.6 shows why a
64-bit or multiarch target can use lib64 or lib/<multiarch> in place of
lib.
$ S=/opt/cross/aarch64-linux-gnu/sysroot
$ ls $S/usr/include/features.h $S/usr/include/stdio.h
$ ls $S/usr/include/linux/limits.h
$ ls $S/usr/lib/crt1.o $S/usr/lib/Scrt1.o $S/usr/lib/crti.o $S/usr/lib/crtn.o
$ ls $S/usr/lib/libc.so
During the build: the compiler the target libraries use
The top level runs the target libraries' configure scripts with
gcc/xgcc -B<objdir>/gcc/ (configure.ac:4059). When libgcc
finishes, it copies its archives and startfiles into <objdir>/gcc/
(libgcc/Makefile.in:116-122). So after libgcc is built,
you can run the link that every GCC_NO_EXECUTABLES test will try:
$ cd $OBJDIR
$ make all-gcc all-target-libgcc
$ ./gcc/xgcc -B$PWD/gcc/ -print-sysroot
$ ./gcc/xgcc -B$PWD/gcc/ -print-file-name=crt1.o
$ ./gcc/xgcc -B$PWD/gcc/ -print-file-name=Scrt1.o
$ printf '#include <stdio.h>\nint main (void) { printf ("hello world\\n"); return 0; }\n' > t.c
$ ./gcc/xgcc -B$PWD/gcc/ t.c -o t
If you configured with --with-build-sysroot, add --sysroot= with the same
directory. The top level adds it to every target compile
(Makefile.tpl:634-637). A name that -print-file-name echoes
back unchanged was not found (Chapter 1.5).
After make install: the installed driver
$ aarch64-linux-gnu-gcc -print-sysroot
$ aarch64-linux-gnu-gcc -print-file-name=crt1.o
$ aarch64-linux-gnu-gcc -print-file-name=libc.so
$ aarch64-linux-gnu-g++ -print-file-name=libstdc++.so
The GCC manual documents both options under Developer
Options. -print-sysroot prints nothing when the compiler has no
sysroot (invoke.texi:21634-21640). The last line checks
GCC's side, not the sysroot: libstdc++.so is installed under GCC's prefix
(Chapter 1.12).
Making the failure on purpose
This recipe was not run for this book. The expected result comes from the
sources in this chapter. Copy a working sysroot, remove the crt1.o variants
from the directory where your sysroot keeps them, and build against the copy:
$ cp -a /opt/cross/aarch64-linux-gnu/sysroot /tmp/broken-sysroot
$ rm /tmp/broken-sysroot/usr/lib/crt1.o /tmp/broken-sysroot/usr/lib/Scrt1.o
$ mkdir /tmp/build && cd /tmp/build
$ $GCC_SRC/configure --target=aarch64-linux-gnu --prefix=/tmp/inst \
--with-sysroot=/tmp/broken-sysroot --enable-languages=c,c++
$ make
gcc/configure and fixincludes pass, because the headers are there. libgcc
builds, because nothing in it needs crt1.o. Then libgomp, or libatomic
beside it, stops with C compiler cannot create executables. Add
--disable-libgomp --disable-libatomic, and the failure can come instead from a
library that calls GCC_NO_EXECUTABLES, such as libstdc++, with the other
message. The failed link is in the config.log of the library that stopped,
under /tmp/build/aarch64-linux-gnu/.
Three things to carry away
A prebuilt sysroot is read four times: by gcc/configure, by fixincludes,
by libgcc, and by the first link test of every later target library.
GCC_NO_EXECUTABLES hides a failed link. The error comes later, from a
check that has nothing to do with the cause, and the cause is in that library's
config.log.
A missing features.h stops nothing and changes the compiler, because the
target glibc version falls to 0.0.
Things that surprise people
libgcc builds without crt1.o. Its configure script links nothing that
needs a startfile, and libgcc_s.so is a -shared link. The first failure
comes from the next library.
cannot compute sizeof (int) is not the missing-crt1.o message in GCC
15.2. Its error branch needs ac_cv_type_int=yes, and no GCC script sets it.
--with-headers copies when you run configure, and only once. A COPIED
stamp stops later runs from refreshing the copy.
Documentation coverage
The install manual documents the procedure under Building a cross
compiler (gcc/doc/install.texi:3247, the sysroot paragraph at
:3313-3322). It documents the options under Configuration:
--with-glibc-version (:2620), --with-sysroot (:2709),
--with-build-sysroot (:2733), --with-headers (:2751),
--without-headers (:2763) and --with-libs (:2768). The GCC manual
documents --sysroot under Directory Options
(gcc/doc/invoke.texi:19559), and -print-file-name and -print-sysroot under
Developer Options (:21571, :21635).
What is not documented:
- Which files the build reads from the sysroot, and at which step. The manual's
cross section names
crt0.oandcrtn.oas examples and sends you toSTARTFILE_SPEC. Chapter 1.7 reads that spec for GNU/Linux. - That libgcc needs
crti.o,crtn.oandlibc, and does not needcrt1.o. GCC_NO_EXECUTABLES, its silent fallback, and the two messages that a failed link produces. None of the messages in this chapter appears in the manuals.- Where a target library's
config.logis. - That the target glibc version comes from two
egrepcalls onfeatures.h, that a missing file gives0.0with no error, and which defaults depend on it. The manual says only that the version "can be detected from the C library's header files" (install.texi:2622-2623). - That the fixincludes check accepts a missing tool-directory
sys-include. - That
--with-headersand--with-libscopy when you runconfigure, and do not copy again while theCOPIEDstamp matches.
Next: newlib built in the same tree as GCC, where the top level breaks the wait
for a C library with one no_c=true.
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.