Linux 7.0 Lands Improvements To Deal With Upcoming Rust Changes, Build Reproducibility
#Rust

Linux 7.0 Lands Improvements To Deal With Upcoming Rust Changes, Build Reproducibility

Hardware Reporter
2 min read

Linux 7.0-rc4 brings critical Rust toolchain updates preparing for Rust 1.95/1.96 releases, improving build reproducibility and fixing soundness issues in kernel Rust code.

Linux 7.0-rc4 has landed with significant Rust toolchain and infrastructure updates that prepare the kernel for upcoming Rust releases while improving build reproducibility and addressing soundness concerns in the kernel's Rust code.

Preparing for Rust 1.95 and 1.96

The most substantial changes focus on preparing for the upcoming Rust 1.95.0 and 1.96.0 releases. Miguel Ojeda's toolchain updates include path remapping to avoid absolute paths starting with Rust 1.95.0, which improves build reproducibility and prevents leaking exact build paths. This approach carefully avoids remapping debug information to prevent breaking tools that rely on source file paths - a previous attempt that required reverting.

For Rust 1.96.0, the changes allow 'unused_features' lint, acknowledging that while well-intentioned, this new lint doesn't provide significant benefits for the kernel's use case.

Build Reproducibility Enhancements

A key improvement involves emitting dependency information directly into '$(depfile)' rather than using temporary '.d' files. This eliminates an older approach that created unnecessary intermediate files during the build process, streamlining the kernel compilation workflow.

Kernel Rust Module Updates

The kernel's Rust modules received several targeted fixes:

  • The 'str' module now fixes a warning under '!CONFIG_BLOCK' by making 'NullTerminatedFormatter' public
  • The 'cpufreq' module suppresses a false positive Clippy warning

Pin-Init Crate Soundness Fixes

The 'pin-init' crate underwent significant restructuring to address soundness issues. The '#[disable_initialized_field_access]' attribute was removed as it was unsound, which also means removing support for structs with unaligned fields through 'repr(packed)' for now. The changes document the critical requirement that field accessors are necessary for soundness.

Additionally, the code replaces shadowed return tokens with 'unsafe'-to-create tokens to maintain soundness in light of the likely upcoming Type Alias Impl Trait (TAIT) and the next trait solver in upstream Rust.

Impact on Kernel Development

These changes represent the ongoing maturation of Rust in the Linux kernel. As Rust becomes more deeply integrated into kernel development, toolchain compatibility and build reproducibility become increasingly critical. The careful approach to path remapping and debug information preservation shows the kernel team's commitment to maintaining developer tooling compatibility while improving build processes.

For developers building the kernel with Rust components, these changes should result in more reproducible builds and better compatibility with upcoming Rust releases. The soundness fixes in the 'pin-init' crate also improve the overall reliability of Rust code in the kernel.

Linux 7.0-rc4 is now available, incorporating all these Rust-related improvements as the kernel continues its transition to supporting Rust as a first-class language alongside C.

Comments

Loading comments...