diff options
| author | salmonik <salmonik@tuta.io> | 2026-11-15 02:54:21 +0100 |
|---|---|---|
| committer | salmonik <salmonik@tuta.io> | 2026-11-15 02:54:21 +0100 |
| commit | 7175543e00caa9ce35487fa7f8b1b479c1ba00a2 (patch) | |
| tree | 10f89f85ca35d6ac7515bbe88518255788d6dc22 /docs/adr/0001-dynamic-glibc-i686.md | |
| download | agent686-7175543e00caa9ce35487fa7f8b1b479c1ba00a2.tar.gz agent686-7175543e00caa9ce35487fa7f8b1b479c1ba00a2.zip | |
M0: streaming provider, SSE decoder, mock provider, i686 build gate
Diffstat (limited to '')
| -rw-r--r-- | docs/adr/0001-dynamic-glibc-i686.md | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/docs/adr/0001-dynamic-glibc-i686.md b/docs/adr/0001-dynamic-glibc-i686.md new file mode 100644 index 0000000..df791e0 --- /dev/null +++ b/docs/adr/0001-dynamic-glibc-i686.md | |||
| @@ -0,0 +1,49 @@ | |||
| 1 | # 0001 — Ship a dynamically linked glibc i686 binary, not a static one | ||
| 2 | |||
| 3 | **Status:** accepted | ||
| 4 | |||
| 5 | ## Context | ||
| 6 | |||
| 7 | The target is a Debian 12 i386 machine: glibc 2.36, 2 cores, 4 GB RAM. The | ||
| 8 | development machine is x86-64 with `gcc-multilib` and the `i686-unknown-linux-gnu` | ||
| 9 | Rust target installed. | ||
| 10 | |||
| 11 | "Single static binary" was the original plan, on the assumption that it removes | ||
| 12 | all runtime dependencies. Two measurements on the development machine contradict | ||
| 13 | that: | ||
| 14 | |||
| 15 | 1. **Static glibc cannot use NSS modules, and crashes trying.** An i686 binary | ||
| 16 | built with `+crt-static` segfaults inside `libnss_resolve.so.2` at | ||
| 17 | `getaddrinfo()`, because the host's `nsswitch.conf` lists `resolve` before | ||
| 18 | `files`. Static glibc is documented as unable to load NSS modules; on any | ||
| 19 | systemd-resolved machine, DNS from a static glibc binary is a SIGSEGV. The | ||
| 20 | failure mode is invisible at build time and appears on the first network call. | ||
| 21 | 2. **Static musl requires a C-free dependency tree, which we do not have.** | ||
| 22 | `ring` (pulled in by `rustls`/`ureq`) compiles C and assembly; cc-rs invokes | ||
| 23 | `musl-gcc -m32` and fails because no 32-bit musl sysroot exists here. Making | ||
| 24 | musl work means adding an `i686-linux-musl` cross toolchain, or swapping the | ||
| 25 | TLS stack for a pre-1.0 pure-Rust provider. | ||
| 26 | |||
| 27 | The dynamic i686 build works unchanged: TLS handshake, DNS, JSON parse, exit 0. | ||
| 28 | Its highest required symbol version is `GLIBC_2.34`, and it runs correctly inside | ||
| 29 | `docker run --platform linux/386 debian:12` (glibc 2.36). | ||
| 30 | |||
| 31 | ## Decision | ||
| 32 | |||
| 33 | Build `i686-unknown-linux-gnu` **dynamically linked against glibc**, using the | ||
| 34 | host's 32-bit toolchain. Do not use `+crt-static`. Gate every release on a check | ||
| 35 | that the maximum required symbol version is `<= GLIBC_2.36`, and verify releases | ||
| 36 | by running them inside the `linux/386 debian:12` container before copying to the | ||
| 37 | target machine. | ||
| 38 | |||
| 39 | ## Consequences | ||
| 40 | |||
| 41 | - The binary is ~3 MB stripped and needs the target's glibc to be at least 2.34. | ||
| 42 | Debian 12 provides 2.36, so there is headroom, but a future dependency can pull | ||
| 43 | in newer symbol versions. The `readelf` ceiling check is mandatory, not | ||
| 44 | advisory — without it the failure appears only on the i686 machine. | ||
| 45 | - Distribution is a binary plus its glibc, not a single file to `scp` anywhere. | ||
| 46 | Accepted: the target is a known Debian 12 box, not an unknown fleet. | ||
| 47 | - `ring`/`rustls` stay available, so the dependency tree is unconstrained. | ||
| 48 | - If the target later turns out to be older than glibc 2.34, or a second target | ||
| 49 | appears with an older libc, this decision reopens and musl becomes the path. | ||
