External Publication
Visit Post

[Pre-RFC] target-glibc: Proposal to add native support for GLIBC versions for the -gnu targets

Rust Internals [Unofficial] May 6, 2026
Source

Summary

Add first-class support to rustc and cargo for declaring a binary's glibc deployment target โ€” the oldest glibc release the binary is required to run on. Users opt in via either a target-tuple suffix (--target x86_64-unknown-linux-gnu.2.28), a Cargo config field ([target.x86_64-unknown-linux-gnu] libc = "2.28"), or a tracked codegen flag (-C target-libc=glibc:2.28). At build time, rustc synthesizes versioned glibc stub shared libraries containing only symbols introduced at or before the requested version, and points the linker at them; the resulting ELF's VERNEED entries cannot exceed the deployment target. The binary then loads on any host with that glibc version or newer.

This is exactly the shape of macOS MACOSX_DEPLOYMENT_TARGET: a single declared value with a build-time consequence ("don't use APIs introduced after this release") and a runtime consequence ("requires at least this OS version installed"). Today, accomplishing the same thing for glibc requires out-of-tree tooling such as cargo-zigbuild โ€” typically because someone is building on Ubuntu 24.04 (glibc 2.39) but needs to ship a binary that runs on Ubuntu 18.04 (glibc 2.27) or RHEL 7 (glibc 2.17).

Rendered

Discussion in the ATmosphere

Loading comments...