Urgent.News

What's breaking now, across thousands of outlets.

Tech

A C++ toolchain from 357 bytes in Bazel

The C++ toolchain described spans just 357 bytes and can be built from source, beginning with a minuscule program. This seed enables the creation of a recent GCC compiler, through which any C/C++ program and complex projects can be constructed. The adoption of this approach by distributions like NixOS simplifies the process of incorporating new architectures and platforms.

However, for Bazel and similar systems, a hermetic C++ toolchain remains elusive, with the upstream rules_cc ruleset merely pointing to external solutions.

The author, frustrated by this, had previously attempted to construct a stage0 hermetic C++ toolchain in October 2024, though progress was limited. Despite the apparent lack of community interest, the author resumed efforts, leveraging an LLM to complete the toolchain. The resulting toolchain, built from the 357-byte seed, can compile Bazel's cc_binary and demonstrates its efficacy by compiling Abseil and GoogleTest from the Bazel Central Registry, without any modifications.

The toolchain's hermetic nature is verified through an audit report generated by Bazel’s aspects, ensuring that all actions in the build graph only execute programs built by the toolchain itself. This approach, while not prioritized by companies with full control over the build environment, aligns with the growing trend of prioritizing reproducibility and hermeticity in open-source build systems.

Written by urgent.news from Lobsters's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at fzakaria.com →

More in Tech

More from Monday 10 August →