A first look at Rust in the 6.1 kernel
A first look at Rust in the 6.1 kernel
Posted Oct 15, 2022 2:23 UTC (Sat) by geofft (subscriber, #59789)In reply to: A first look at Rust in the 6.1 kernel by amarao
Parent article: A first look at Rust in the 6.1 kernel
It's not quite "cargo build" because there are some kernel-specific postprocessing steps to get a .ko that Cargo doesn't quite know how to do. (There's also some preprocessing that's theoretically doable in a build.rs but easier if you set up Cargo to be called from the kernel Makefiles.) But you could copy the scaffolding from the hello-world directory - Makefile, Kbuild, and Cargo.toml - and get something that worked.
It's probably a good time to document how to do out-of-tree modules in Rust using the in-tree build support, because that's a lot easier for someone who wants to get started on their current running system.
I don't see a way around the Kbuild file, though... but perhaps one could write a "cargo kbuild" subcommand that dynamically generates it and lets you keep your project using Cargo-style layout, to keep things familiar for people who know userspace Rust and not kernel Makefiles.