Zero-sysroot hermetic LLVM cross-compilation using Bazel
- Track: LLVM
- Room: UD6.215
- Day: Saturday
- Start: 18:45
- End: 19:00
- Video only: ud6215
- Chat: Join the conversation!
Cross-compiling C and C++ is still a tedious process. It usually involves carefully crafted sysroots, Docker images and specific CI machine setups. The process becomes even more complex when supporting multiple libcs and libc versions, or architectures whose sysroots are hard or impossible to generate.
In this talk, we present toolchains_llvm_bootstrapped, an open-source Bazel module that replaces sysroots with a fully hermetic, self-bootstrapping C/C++ cross-compilation toolchain based on LLVM.
We dive into how the project wires together three Bazel toolchains: * A raw LLVM toolchain based on prebuilt LLVM binaries that cross-compiles all target runtimes from source: CRT objects, libc (glibc or musl), libstdc++/libc++, libunwind, compiler-rt, etc. * A runtime-enabled toolchain that uses those freshly built runtimes to hermetically compile your application code. * An optional self-hosted toolchain used to build LLVM entirely from source (pre-release, patched, or local branches), which is then used for the two previous stages; all in a single Bazel invocation.
We also showcase unique use cases enabled by this approach: * Cross-compiling to any target, entirely from source, with little to no configuration. * Whole-program sanitizer setups that are almost impossible with prebuilt sysroots. * Targeting arbitrary versions of the glibc. * Setup-free remote execution for cross compilation tasks. * Applying patches to LLVM, building a new toolchain and testing it against real-world projects, without manual bootstrapping steps.
Project source code: https://github.com/cerisier/toolchains_llvm_bootstrapped
Speakers
| Corentin Kerisit | |
| David Zbarsky |