r/linuxfromscratch • u/chief-dvrsty-officer • Dec 09 '23
Why are the temporary tools needed?
I'm trying to understand the point of the temporary tools beyond the cross compiling toolchain. Specifically, why are any of the temporary tools in Chapter 6 or 7 necessary before compiling them natively in Chapter 8? Thanks in advance.
3
Upvotes
1
u/codeasm Dec 09 '23
Great question and good to understand what the rationale is for building a "crosscompiler" first. basicly its answered in the book: https://www.linuxfromscratch.org/lfs/view/stable/partintro/toolchaintechnotes.html
But a small recap with my own words, your host may contain host distribution quirks or commodities, may use totally different libraries or compiler. and thus we want to first get the proper tools checked (the Prerequisites) to be there, and then, we want to build a crosscompiler to be sure to have a compiler and supporting set of libraries and tools in a known state. this way, the LFS system is build from a known state, without HOST leaked variables, links or incorporated configurations that may interfere with the LFS system once it set to run on its own.
In theory, you could go without (from a similair version LFS preferably) or compile from a different Unix based host, like a BSD variant, or even Darwin (Apple).with WSL2 (Linux under windows) its also possible, but I have no idea what their custom kernel does to build results.
But, one could also try build the Kernel and any other package without crosscompile and (hope) it just works for you. compile busy-box and make it the init system and you got a pretty small and independent system already
more, better worded arguments: https://stackoverflow.com/questions/39883865/why-multiple-passes-for-building-linux-from-scratch-lfs
2
u/Jeff-J Dec 10 '23
Back in the day... Gentoo used to do this as well (stage1). It was a sad day when this choice was removed. To compensate, some will rebuild everything twice. I take a little shortcut and rebuild the tool chain immediately after installing stage3. Then, I rebuild everything after the base install.
The basic idea was you want your tool chain built with the correct compiler flags. Then, you want everything built with the tool chain that was built with the correct flags.