Systemd Merges Optional Rust Support for New Leaf Components
Systemd has introduced support for writing new leaf components in Rust, utilizing a no_std, no-alloc approach to ensure memory safety and maintain binary compatibility.
Christian Brauner merged a 19-commit pull request into systemd on October 24, 2026, adding optional Rust support for new leaf components. Existing C code remains untouched.
You build via meson without cargo. The configuration needs rustc 1.85, bindgen 0.71.1, and meson 1.4.0. Debian 13 ships these versions. The -Drust= option defaults to auto. Cross-compilation is currently unsupported. bindgen 0.72.0 is blocked due to compilation errors, and configure-time probes check for libclang compatibility.
Rust code is no_std, omits external crates, and avoids the alloc crate. Static linking keeps the standard library out of binaries and libsystemd-shared. LTO produces a 32 KB test-cli-rust binary against a 20 KB C version.
A build-time bindgen step generates raw bindings for libsystemd-shared exports. The systemd_shared crate maps C conventions, providing errno errors, command-line parsing, and byte-for-byte parity on --help and --introspect-cli output. Without alloc, custom Box and Vec implementations return -ENOMEM on failure. Vec<u8, Erasing> calls erase_and_free() for secrets. Panics log critical errors and abort. Lints require kernel-style SAFETY comments on unsafe blocks, documentation on public items, overflow checks, and panic=abort.
Open issues include packaging failures on Arch, openSUSE, and CentOS. The first planned program is systemd-keyring-setup.
