[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Package for development of out-of-tree kernel modules written in Rust



Hi kernel team!


I know this is early to say the least, but I would like to ask your opinion on the naming of a package that could eventually end up in the official Debian kernel packaging.

As is the case for C, building out-of-tree kernel modules written in Rust [1] requires some extra files to be installed alongside the kernel. For C modules this is covered by linux-headers and dependencies. For Rust, one needs to have installed the *.rmeta and *.so files which are generated in the rust/ directory during the build. The first of these contain metadata like the version of rustc used for the build, information on exported types/items/etc., bindings and so on [2][3]. They do not contain compiled code but are ultimately dependent (among other things such as the compiler) on the .config used to build them, so they are arch- and flavor-specific. The only *.so file generated at this time is a proc macro, and that, to my understanding, is a regular shared library.

Needless to say, Rust must be enabled in the kernel for these files to be generated, meaning the Debian kernel cannot currently support this. However, there is at least one fork of the Debian kernel being built with Rust enabled at present, namely, the Asahi kernel which we are maintaining in the Bananas Team [4] (which needs Rust for the Apple AGX GPU driver), so I started experimenting with the idea of having a package to provide these files. Following the scheme of having a metapackage + an actual versioned package I added two packages, linux-librust@source_suffix@@localversion@-dev [5] and linux-librust-@abiname@ [6], the first of which has the second as a dependency, while the second contains the actual files and links needed to build out-of-tree Rust modules. I tested it with [1] and it worked (modulo a small change needed to build [1] outside of mainline). You can find a draft at [7].

I would like to include the new linux-librust-* packages in the next version of our fork (6.13), but first I would like to ask your opinion on the naming I chose, whether you have suggestions (beyond the naming too!) and so on. If (when? ;-)) Rust is enabled in the Debian kernel, it would be nice to have a package like this to go with linux-headers, so I thought I could as well start this conversation to see if I can work on something that can eventually end up in src:linux.


One disclaimer: Miguel Ojeda (whom I cc'ed in case something interesting comes out of this discussion) told me he wouldn't recommend people to do out-of-tree Rust development e.g. because the kernel crate (which lives in rust/kernel) may need to be rebuilt to enable or accommodate new abstractions. I use this recommendation to clarify that general development is not what a linux-librust package aims to enable. The problem it tries to solve is "how do I build out-of-tree kernel modules written in Rust that work with the kernel installed by my distribution?" (this is why it's packaged from the same source!) If your distribution does not provide the abstractions you need then your distribution's kernel is not good enough for your use-case and you need to rebuild the kernel from source, in which case you don't need a linux-librust package (you already have the files you need). On the other hand, if your distribution does not provide those files, you will not be able to build such modules even if your distribution's kernel is good enough for you.


Cheers!


P.S.: Also cc'ing waldi personally since he recently expressed interest in enabling Rust in the Debian kernel, and the Rust Team in case someone is interested.



[1] https://github.com/Rust-for-Linux/rust-out-of-tree-module
[2] https://rustc-dev-guide.rust-lang.org/backend/libs-and-metadata.html#rmeta [3] https://rustc-dev-guide.rust-lang.org/backend/libs-and-metadata.html#metadata
[4] https://salsa.debian.org/bananas-team/wip/linux-asahi
[5] For us this would be linux-librust-asahi-dev, since we renamed our source as linux-asahi. For src:linux this would be linux-librust-dev. I've been consistent with metapackages such as linux-headers@source_suffix@@localversion@ and linux-image@source_suffix@@localversion@-dbg and kept @source_suffix@ in the package's name. [6] For us this is linux-librust-$version-asahi, where "asahi" here is the flavour name (src:linux-asahi contains an additional asahi flavour to enable the configs needed for apple silicon and make it clear to users they have to install the -asahi packages instead of the -arm64 ones). For src:linux this would be linux-librust-$version-amd64, -arm64, -arm64-16k, etc. [7] https://salsa.debian.org/bananas-team/wip/linux-asahi/-/commit/7a3873463600bc85781e4683a38d6e510c154937


Reply to: