Files
static-site-pipeline/hugo/content/posts/2023-10-08-guix-bootstrap.md
2023-10-08 12:27:58 +01:00

3.6 KiB

lastmod, author, categories, date, title, summary
lastmod author categories date title summary
2023-10-08T11:43:00.0000000+01:00 patrick
programming
2023-10-18T11:43:00.0000000+01:00 The GUIX bootstrap Notes for a talk I gave at work on the GUIX bootstrap.

This is simply an outline, with no actual content.

Why bootstrap?

How is a system normally installed?

  • Massive binary blob (250MB of gcc, binutils etc) to start a bootstrap
  • Or an even massiver blob (Windows installer)

Necessary tools

  • A C compiler e.g. TCC
  • Text manipulation e.g. sed

GUIX Full-Source Bootstrap

Official docs.

Stage-0

Main repo; kaemfile.

The kernel is trusted; eventually they would like to make no syscalls at all and run on bare metal. (GNU Guix bootstrap kernel is still 25MB.)

  • Base: a tiny self-hosted assembler of 357 bytes, incredibly strict language, human-verifiable
  • hex1: a slightly more powerful assembler, better hex parsing, single-character labels and some jumps
  • hex2: an assembler with labels and absolute memory addresses
  • catm: an implementation of cat
  • M0: a C-style preprocessor and a bona-fide assembler which recognises a language you might recognise
  • cc-x86: a C compiler! (only a subset of C though)
  • M2-Planet: a slightly better C compiler
  • blood-elf-0: writes DWARF stubs for debug tables (but no actual implementation of those stubs)
  • M1: a better C compiler which is debuggable and implements some optimisations (TODO: example?)
  • Rebuild earlier inputs now that we have an optimising compiler
  • blood-elf again: provides implementations for the stubs blood-elf-0 wrote (TODO: is that true? Understand the nature of the stubs and implementation)
  • A variety of nice things like sha256sum, mkdir, untar, primitive cp, chmod
  • kaem: a tiny build system (anagram of make)

GNU Mes

Mes is an intertwined pair of a C compiler and Scheme interpreter; its source is mirrored on GitHub. It can be built with kaem, and the resulting C compiler can build TCC, which can then build early GCC, which can bootstrap later GCCs and hence support for other languages and architectures.

As of a few years ago, they were experimenting with using the Mes Scheme compiler to compile Gash, an interpreted Scheme POSIX shell which could replace some of the binary blob.