this post was submitted on 23 Oct 2026
41 points (100.0% liked)

Linux

15383 readers
145 users here now

A community for everything relating to the GNU/Linux operating system (except the memes!)

Also, check out:

Original icon base courtesy of lewing@isc.tamu.edu and The GIMP

founded 3 years ago
MODERATORS
 

Miguel Ojeda sent out his pull request of the new Rust kernel code slated for introduction in Linux 7.4. It's a big one this round due to updating the Zerocopy vendored library plus updating other Rust crates for the kernel.

The Zerocopy crate update is a big one in jumping eight versions ahead. This is the code providing traits and macros to safely convert between raw byte sequences and structured types. Rust for Linux 7.4 also has other toolchain and infrastructure updates, enabling the unstable proc_macro_span feature for better diagnostics of all procedural macros, and more.

The Rust kernel create adds new "mem" and "ratelimit" modules while improving some of the existing modules. The pin-init crate is adding support for tuple structs as well as allowing for the safe creation of self-references. There is also much improved diagnostics.

More details on these central Rust code changes for Linux 7.4 can be found via this pull request. Via individual subsystem pull requests will also be more Rust code for Linux 7.4, like the NVIDIA Nova driver improvements for Linux 7.4 and the other Rust DRM infrastructure work that brings.

you are viewing a single comment's thread
view the rest of the comments
[–] refalo@programming.dev 1 points 6 days ago (1 children)

you need to build the kernel with clang to build the kernel with the rust support

I believe this statement is incompatible with how C works. The kernel can load modules written in any language as long as it outputs a .ko, so there can be no technical requirement for building the rest of the kernel itself with clang.

[–] groche@lemmy.rochegmr.com 0 points 3 days ago (1 children)

You can't load modules built with a different compiler. The modules aren't external programs, the modules are literally part of the kernel. And if you want to use a module wrote in rust you also need to have built in the rust support in the kernel

[–] refalo@programming.dev 1 points 2 days ago* (last edited 23 hours ago) (1 children)

You can’t load modules built with a different compiler.

Sure you can. There's even multiple guides for how to write C++ kernel modules, which inherently is going to use a different compiler than what was used for the kernel itself. BOSS Linux even writes C++ kernel modules.

if you want to use a module wrote in rust you also need to have built in the rust support in the kernel

Only if the module uses rust-specific interfaces in the kernel, otherwise it can be assembled into a .ko to have plain C-style symbols loaded by the kernel like normal.

[–] groche@lemmy.rochegmr.com 0 points 1 day ago (1 children)

The C and C++ compilers use the same backends (and rust to, llvm), just try to build a module with clang for a kernel build with GCC, or it fails in compile phase or when you try to load the module. You can write a module in the lenguaje that you want if you use the same backend, but if we are talking about avoiding to use a kernel with rust, man is the default in the kernel, just read the config, rust is disabled

[–] refalo@programming.dev 1 points 22 hours ago

just try to build a module with clang for a kernel build with GCC

I did just now, and it worked fine.