Files
systemd/tools
Christian Brauner 8d0c48fe98 meson: support programs written in Rust
Programs written in Rust are declared just like the C ones, in the
same executables list. The crate root comes first and that's how the
loop tells them apart. 'conditions' and 'type' work the same way. Names
starting with 'test-' become unit tests and are installed next to the C
ones with -Dinstall-tests. Installed programs take part in the --help
and --version checks of the dist suite and go into the mkosi images
like the C ones. There are no .standalone variants as Rust programs
always link libsystemd-shared dynamically. They take part in
test-link-abi like every other program.

Nothing from the crates is exported and the programs link with
--exclude-libs ALL. The linker exports a symbol of the program when a
DSO in the link defines it too and a stub of the crates would then
preempt the real one for every library the program loads later.

meson keeps rustc's own library directory in the runpath of Rust
programs that link a shared library. It's only needed for Rust dylibs
which we don't use. meson can't grow a runpath at install time so with
a long pkglibdir such as Debian's multiarch one the install fails. So
give the build-time runpath a padding entry of the right length so the
install always succeeds and drop the leftover entry afterwards with
tools/fix-rust-rpath.py which rewrites the runpath string in place.
Both become no-ops once meson stops adding the directory. The fix is
proposed upstream (cf. [1]).

A rustfmt check over every program source runs in the dist suite and
ninja clippy covers everything.

[1]: https://github.com/mesonbuild/meson/pull/16287

Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
2026-10-23 16:34:47 +02:00
..
2026-05-18 12:17:23 +01:00
2026-05-18 02:44:47 +09:00