|
|
Log in / Subscribe / Register

Rustaceans at the border

Rustaceans at the border

Posted Apr 15, 2022 6:47 UTC (Fri) by qyliss (subscriber, #131684)
Parent article: Rustaceans at the border

I'd expect one of the big problems here to be the build system. Right now, Rust for Linux integrates Rust into the kernel build system, rather than using Cargo. I think the attraction of using lots of third-party crates would quickly fade if developers had to write Makefiles for any dependency they wanted to add (very few Rust libraries build without a build.rs file doing something fancy somewhere in their dependency graph), but Cargo really does not like co-operating with other build systems. This has made life difficult for any sort of generic build or meta-build system to add Rust support — Meson, gn, Soong, Bazel, Nix, etc.

It comes up over and over when big established projects try to adopt Rust, but no progress has been made on it yet as far as I'm aware. I think it would require some very fundamental changes to how Cargo works.


to post comments

Rustaceans at the border

Posted Apr 15, 2022 11:46 UTC (Fri) by LoganDark (guest, #158019) [Link]

If this were my project (and maybe 0.1% the size), I'd migrate the rest of the existing codebase to use Cargo and Rust build scripts, rather than the other way around (trying to get Cargo to fit into makefiles/something else), since other parts of the kernel are probably going to eventually be rewritten in Rust as well.

That doesn't exactly sound feasible here, but it's a nice thought. imho, it would be an almost-all-around win for Cargo to become more interoperable with existing build systems, but it could also encourage laziness or tricky setups.

Rustaceans at the border

Posted Apr 16, 2022 7:16 UTC (Sat) by pkolloch (subscriber, #21709) [Link] (2 responses)

One thing that would helped me immensely: Have a cargo sub command that builds a crate in isolation. With a command line option for the directory of the output artifacts. And being able to specify all the dependency outputs as input.

Rustaceans at the border

Posted Apr 16, 2022 8:35 UTC (Sat) by atnot (guest, #124910) [Link] (1 responses)

What would that provide over just using rustc directly?

Rustaceans at the border

Posted Apr 16, 2022 17:45 UTC (Sat) by pkolloch (subscriber, #21709) [Link]

There is a lot of plumbing that cargo does:

  • setting env variables
  • running build scripts
  • setting features
  • setting something like a symbol prefix to avoid clashes
  • linker flags
  • ... and a lot of other details

It's surprisingly hard to replicate. I know because I helped doing it for nix with contributions to buildRustCrate in nixpkgs and creating crate2nix.


Copyright © 2026, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds