Bootstrapping an environment

March 16, 2026 ยท View on GitHub

Bootstrapping is the process of creating an environment which allows the cross-compilation of packages.

./init.sh builds a cross-compilation toolchain in sysroot/ by default. The path to the sysroot can be changed by setting the SYSROOT environment variable.

Note: one should not build several toolchains for different targets in the same sysroot

The following packages are built by init.sh:

PackageHost tripletTarget tripletNotes
binutilsABbinutils stage 1, used to link by gcc stage 1
gcc (and libgcc)ABgcc stage 1, used to compile the next step only
linux headersn/an/arequired by libc
muslBn/alibc, used by gcc stage 2
zlibBn/azlib, used by binutils stage 2 while running
libstdc++Bn/aused by gcc stage 2, requires libc
binutilsBBbinutils stage 2
gcc (with libgcc and libstdc++)BBgcc stage 2, used to cross-compile packages

Note: one last compilation of gcc (stage 3) will be necessary for a final system, but it is treated as a casual package and not discussed here.

Once built, the second gcc can be used to cross-compile packages on the target.

Using the toolchain

A toolchain can be used by updating PATH:

PATH="$(pwd)/sysroot/tools/bin:$PATH"

The above command assumes we are in the boostrap/ directory.