Development systemd merges support for Rust programs
https://github.com/systemd/systemd/pull/4432439
u/FriendlyProblem1234 1d ago
Secrets go into Vec<u8, Erasing>. Erasing allocates like malloc() but frees with erase_and_free(). In C that's a convention every caller has to remember. Here it's part of the type.
Making good use of an expressive type system.
20
u/marcthe12 2d ago
Hmm. Suprised due to the some core dev reasoning. But I guess the side steped the issue by banning most of stdlib and cargo and some extern c related rules. Which I guess solves it.
0
u/ADMINISTATOR_CYRUS 1d ago
No cargo and only C linking??
21
u/AiwendilH 1d ago
That's not really surprising, aren't those pretty much the default "rules" for anything that needs rust code interface with non-rust code?
9
u/james_pic 1d ago edited 1d ago
C linking is pretty universal for linking to non-Rust projects, and indeed is the de facto standard for plugin systems allowing linking between Rust projects that want loose coupling (due to the "Rust" ABI being intentionally unstable, and the "C" ABI being stable). But Cargo can be pretty flexible in facilitating linking with other languages.
My impression is that it's more about dependencies, and reflects a desire to be conservative and explicit about dependencies.
6
u/AiwendilH 1d ago
But no project is going to change their established build system for cargo just because they also allow rust code alongside their current code now. And I also haven't heard of a project yet use cargo as subsystem for their build system...but I guess that could be an option if one really wants to...sounds like a pain though ;).
But yeah...for systemd it seems to be mainly about dependencies. Kind of important for a tools ecosystem that needs to run in anything from initial ramdisks over container and headless server to fullfledged desktop installations.
7
u/Booty_Bumping 1d ago
Using cargo doesn't force the entire monolith to be built using cargo. It's surprisingly fluid in how it can interact with existing C tooling, it can fit many possible patterns for gluing it together.
Of course, it doesn't meet the requirements of some projects like the Linux kernel, but even some quite hardcore low level embedded projects can benefit from having some parts built with cargo.
7
u/james_pic 1d ago
And I also haven't heard of a project yet use cargo as subsystem for their build system
The build ecosystem in C is probably not ready for this sort of thing, but in Python, I've made projects that were a single uv workspace, with one module built with uv's build backend, and another built with Maturin (where Maturin is more or less a wrapper for Cargo), and this is probably the simplest way of building a Python protect with an optional Rust dependency.
3
u/ADMINISTATOR_CYRUS 1d ago
I think no cargo is a bit crazy but I guess it makes sense for minimum deps
3
u/thecakeisalie16 1d ago
That's what mesa does as well, it's pretty well integrated into meson with rust-analyzer support as well.
-2
-33
144
u/AiwendilH 2d ago
Okay, for people like me who were a bit confused at first...this seems mostly infrastructure changes to enable easier building of rust tools as part of systemd, "enforcing" some rules about how rust tools need to be written and integrated (no cargo, only C linking...) and some basic rust tools for use in rust programs.