Funtoo:Evolved Bootstrap/CLFS Bootstrap Process

From Funtoo
< Funtoo:Evolved Bootstrap
Revision as of 04:33, February 15, 2022 by Drobbins (talk | contribs) (Created page with "The purpose of this page is to document the bootstrap process used by [https://trac.clfs.org/ CLFS]. It's interesting and deserves some explanation as if you are coming from t...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

The purpose of this page is to document the bootstrap process used by CLFS. It's interesting and deserves some explanation as if you are coming from the Gentoo or Funtoo world may seem a bit unusual.

Host System

First, of course, you must start with a host Linux or Linux-like system that you can use as a starting point. The host system need not be the same architecture as the final target system.

The Various Components of a Cross Build

Next, CLFS wants you to locate where you will install your 'final' system to, and set the $CLFS environment variable to point to this location. The CLFS book instructs you to create a new partition for this location, which is not strictly necessary and really any directory will do -- up until the point where you might want to actually boot into the new system, at which point of course you will want to copy its contents to a real root filesystem.

Within $CLFS, the build process has two separate directory trees, housed at $CLFS/tools and $CLFS/cross-tools. We'll explain the purpose of these directories in the following paragraph, but before we do, it's worth noting that the CLFS book instructs you to create two symbolic links at the root of your host file system -- /tools and /clfs-tools -- which point to these directories. This is kind of unfortunate as it means that the CLFS instructions won't work as-is on a system where you may not have root access, as to create these symlinks you will need superuser permissions on the host.

OK, now on to those two directories. The cross-tools directory (living at $CLFS/cross-tools) is designed to contain programs that run on the native architecture of your host system, but contain the cross-compiler and associated tooling to build the non-native target binaries, libraries, and kernel.

The tools directory (living at $CLFS/tools is an interesting one and is somewhat counter-intuitive -- it will contain binaries and libraries that are built for the instruction set of the target architecture, so they will not directly run on the host system. You may think that, therefore, $CLFS/tools contains the final binaries and libraries for your target system -- ie. the target rootfs -- but you would be incorrect. $CLFS contains the target rootfs, which is what you will eventually boot into or fchroot into. So what, then, is this tools directory? Well, when you chroot, it will exist at /tools, and it's meant to contain a primitive environment that will allow you to install your final things to / and /usr. Think of it sort of like an /opt directory containing your temporary toolchain that works on your target architecture until you get all your perfect, final packages built and installed to their official locations.

I hope that helps people to understand the CLFS build process and how it all fits together. This larger context is important to make sense of how it all works but I found that these various components and their inter-relationships are not described sufficiently in the main CLFS book.