[x86_64, herecy] Bootstrap gcc or not?
Alexander E. Patrakov
patrakov at ums.usu.ru
Tue Aug 7 23:13:49 MDT 2007
Hello,
I was trying to find a way to build some LFS-like x86_64 system from
Debian Lenny x86 (which has 32-bit userspace, a patched compiler that
accepts -m64 to produce 64-bit binaries, some multilib setup, and an
option to install a 64-bit kernel). The current x86_64 branch fails due
to ld not recognizing the host's glibc, so I upgraded binutils to HJL
version. Also, I replaced all instances of "gcc -B/usr/bin" with "gcc
-m64 -B/usr/bin" in the book. Even then, the build failed with "specs:
invalid argument" while bootstrapping gcc pass1.
In order to build /tools to the end, I had to make the following extra
adjustments: add --disable-libmudflap to gcc pass1, and replace "make
bootstrap" with just "make" there (presumably, there is some mismatch
with 64-bit glibc or headers and toolchain on the host). So a question
naturally arises: is it really true that bootstrapping gcc pass1
improves the range of hosts that are capable to build LFS? (accepted
answers: "no", "yes, build from host XXX version XXX fails without
bootstrapping")
More thoughts: assuming that the host gcc does its job properly (i.e.,
given some C code, produces some possibly suboptimal machine code that,
nevertheless, does what the programmer intended), the bootstrap stages
in gcc should behave as follows:
Host gcc compiles stage1, that translates C into x86 or x86_64 assembly
according to the rules that can be found in the gcc sources (they may be
different from the rules in host's gcc). Features: correct (definition:
"according to gcc sources") output.
stage1 compiles stage2, that produces _exactly_ the same machine code,
because it is produced by compiling the same source code. stage2 may
contain different (but functionally exactly equivalent) code from
stage1, because stage1 was compiled by the host's gcc, while stage2 was
compiled by stage1, and they use different rules for translation of C
into assembly. Features: correct output (same as produced by stage1),
compiled by "itself".
stage2 compiles stage3. The result should be exactly the same, because
these two stages were produced by translating the same C source into
assembly according to the same rules. Features: correct output (same as
produced by stage1), compiled by "itself", proves the correctness of the
bootstrap.
But, for the purpose of compiling glibc and testsuite tools (and these
the only things we compile with gcc pass1), we care only about the
correct output. So even stage1 is good enough, so again - why bootstrap?
--
Alexander E. Patrakov
More information about the lfs-dev
mailing list