[lfs-support] LFS bootstrap, shall we use GCC's --with-glibc-version configure option?

Explorer explorer09 at gmail.com
Mon Mar 30 01:20:14 PDT 2015

In Linux From Scratch chapter 5.5 (GCC-4.9.2 - Pass 1), building a GCC that is
used to build glibc, we uses a hack in GCC's configure script to tell GCC that
stack protection will be available (gcc_cv_libc_provides_ssp=yes). However
when I tried to bootstrap a cross-toolchain, I found recent versions of GCC
introduced the '--with-glibc-version' configure option just for this purpose,
and so the hack is not needed anymore.

I also verified that the configure option is indeed present in GCC 4.9.0 (not
in 4.8.x or before).

See also <https://gcc.gnu.org/ml/gcc-patches/2013-11/msg00619.html>.
Thanks to GCC and glibc developers.

A quick Google search shows that '--with-glibc-version' is already used in
Linaro toolchain in its bootstrapping

So LFS can use it too.

By the way, the '--with-newlib' option may be still needed (along with
'--without-headers'), for defining GCC's internal 'inhibit_libc' constant.
This may sound confusing when used together with '--with-glibc-version', so
something should be noted to clarify the usage.

P.S. (2015-03-30) I've tried building a cross-toolchain for my own use - not
for LFS, and experimented with 2-compiler bootstrap [1] and 3-compiler
bootstrap [2], and found out the libc binaries between two methods are not
necessary bit-identical. In particular, two symbol names are different,
like this:

  completed.3589 , completed.6241
  dtor_idx.3591 , dtor_idx.6243

Other parts (text, data sections, etc) are all the same. Just for your
reference. Tested on a i686-linux-gnu (Ubuntu 12.04 in Virtualbox) building a
cross-toolchain with x86_64-linux-gnu target.

[1] For the 2-compiler bootstrap here I mean the method similar to LFS, but
with '--with-glibc-version' instead of configure script hack. My steps are
Build first GCC (with '--with-glibc-version=2.19 --without-headers
--with-newlib' and disable all support libraries) --> Use first GCC to build
glibc --> Build second GCC and all its support libraries.
[2] For 3-compiler bootstrap I mean the method similar to
My steps are roughly:
Build first GCC (--without-headers --with-newlib and disable all support
libraries) --> Build glibc but only headers and crt*.o --> Build second GCC
(--enable-shared=libgcc but no other targer libraries) --> Build glibc
--> Build third GCC and all its support libraries.

Kang-Che Sung ("Explorer")

More information about the lfs-support mailing list