louise
The Louise language: compiler, runtime, std, tooling
Clone avec HTTPS, un jeton personnel en mot de passe, ou avec SSH, une clé ajoutée dans vos paramètres.
ADR 0042: Smaller release binaries
Status: Proposed (2026-10-13); needs engineering review (#44), in particular the use of RUSTC_BOOTSTRAP=1 for the runtime archives' standard library.
Context
A release hello world was 817 KB, and the HTTP demo 1.2 MB. What was in hello (2026-10-13):
- Symbol table and strings: about 170 KB. Release builds stripped debug information (issue #115) but kept the symbols.
- Backtrace symbolisation: 176 KB of the code. This is std's DWARF reader and demangler (gimli, addr2line, miniz_oxide, rustc_demangle), linked because the default panic hook can print a backtrace. The runtime is
panic = "abort", and its panics are bugs; the backtrace is the least useful part of their report. - The rest: std's other code (about 100 KB), the runtime (about 100 KB), mimalloc (about 95 KB), and the program.
For comparison, a stripped Rust hello world is 350 KB and GHC's 980 KB.
Decision
- Strip the symbol table of release executables (
-Wl,--strip-allinstead of--strip-debug), unless the C flags ask for debug information (LOUISE_CFLAGS=-g, which keeps both, for debugging or profiling a release build). - Fold identical functions (
-Wl,--icf=safe) when linking with lld (ThinLTO links always do).safekeeps apart functions whose address is taken. - Rebuild std without its
backtracefeature for thefastandltoruntime archives (scripts/runtime.sh):-Zbuild-std=std,panic_abort -Zbuild-std-features=. Panic messages stay; the backtrace goes.- The same stable compiler (
rust-toolchain.toml, which now listsrust-src) builds it, withRUSTC_BOOTSTRAP=1since-Zbuild-stdis unstable. - So the
ltoarchive's LLVM stays the stable rustc's, which the system's lld can read (ADR 0032). - Without
rust-src, or withLOUISE_SMALL_STD=0, the archives use the prebuilt std as before. - The
checkedruntime (tests, debug builds) is unchanged.
- The same stable compiler (
Measurements
Release builds on x86-64, clang and lld 22, best of 9 interleaved runs, one thread, main (8d6cde2) against this change.
| before | after | ||
|---|---|---|---|
| hello | 816,840 B | 395,448 B | −52% |
examples/http_demo | 1,201,104 B | 745,320 B | −38% |
a benchmark (html) | 905,440 B | 485,944 B | −46% |
Steps on hello:
- strip: 647 KB;
- folding: 638 KB;
- the std without backtraces: 395 KB.
Speed is unchanged. Every tests/bench program is within ±4% in wall clock, and html, floats, lists and dict within ±1.2% in cycles against the same runtime variant.
Rejected on the way:
- A pinned nightly (the TSan toolchain) to rebuild std. Its LLVM is newer than the system lld, which then can't read the
ltoarchive; release builds fell back tofastand lost the cross-language LTO:floats+43% andhtml+27% in cycles. - Dropping unwind tables: nothing measurable (they are std's, prebuilt).
Consequences
- Diagnosis: a Rust panic inside the runtime of a release program prints its message and location, without a backtrace. Release executables have no symbols, so
perfand debuggers need a build withLOUISE_CFLAGS=-g. Tests that read symbols (unused_runtime_functions_are_left_out,program_functions_never_keep_the_thread_pointer) build that way. - Toolchain:
RUSTC_BOOTSTRAP=1lets a stable compiler accept unstable flags. Distributions build Rust this way, but Rust doesn't promise it.- A rustc update can change the
build-stdflags. - It is confined to
scripts/runtime.sh, with a fallback.
- Build time:
scripts/runtime.shcompiles std twice more (fast and lto), about a minute on a cold cache. - Rust native dependencies (
kind = "cargo", ADR 0031) still bring their own std, linked as before.native_dependencies_of_every_kindpasses.
Alternatives considered
panic_immediate_abort: smaller still, but a runtime bug would abort without a word.- A nightly toolchain: see above. It works only where the system's lld is as new as the nightly's LLVM.
- Linking with the nightly's own
rust-lld: ties every program build to that rustup toolchain. -Osfor the runtime: slower hot paths for little gain once the backtrace code is gone.- Nothing: binaries twice the size of a stripped Rust program's.