3ed03f4da0
This is the first upgrade to the Rust toolchain since the initial Rust
merge, from 1.62.0 to 1.68.2 (i.e. the latest).
# Context
The kernel currently supports only a single Rust version [1] (rather
than a minimum) given our usage of some "unstable" Rust features [2]
which do not promise backwards compatibility.
The goal is to reach a point where we can declare a minimum version for
the toolchain. For instance, by waiting for some of the features to be
stabilized. Therefore, the first minimum Rust version that the kernel
will support is "in the future".
# Upgrade policy
Given we will eventually need to reach that minimum version, it would be
ideal to upgrade the compiler from time to time to be as close as
possible to that goal and find any issues sooner. In the extreme, we
could upgrade as soon as a new Rust release is out. Of course, upgrading
so often is in stark contrast to what one normally would need for GCC
and LLVM, especially given the release schedule: 6 weeks for Rust vs.
half a year for LLVM and a year for GCC.
Having said that, there is no particular advantage to updating slowly
either: kernel developers in "stable" distributions are unlikely to be
able to use their distribution-provided Rust toolchain for the kernel
anyway [3]. Instead, by routinely upgrading to the latest instead,
kernel developers using Linux distributions that track the latest Rust
release may be able to use those rather than Rust-provided ones,
especially if their package manager allows to pin / hold back /
downgrade the version for some days during windows where the version may
not match. For instance, Arch, Fedora, Gentoo and openSUSE all provide
and track the latest version of Rust as they get released every 6 weeks.
Then, when the minimum version is reached, we will stop upgrading and
decide how wide the window of support will be. For instance, a year of
Rust versions. We will probably want to start small, and then widen it
over time, just like the kernel did originally for LLVM, see commit
|
||
---|---|---|
.. | ||
collections | ||
vec | ||
README.md | ||
alloc.rs | ||
boxed.rs | ||
lib.rs | ||
raw_vec.rs | ||
slice.rs |
README.md
alloc
These source files come from the Rust standard library, hosted in the https://github.com/rust-lang/rust repository, licensed under "Apache-2.0 OR MIT" and adapted for kernel use. For copyright details, see https://github.com/rust-lang/rust/blob/master/COPYRIGHT.
Please note that these files should be kept as close as possible to upstream. In general, only additions should be performed (e.g. new methods). Eventually, changes should make it into upstream so that, at some point, this fork can be dropped from the kernel tree.
The Rust upstream version on top of which these files are based matches
the output of scripts/min-tool-version.sh rustc
.
Rationale
On one hand, kernel folks wanted to keep alloc
in-tree to have more
freedom in both workflow and actual features if actually needed
(e.g. receiver types if we ended up using them), which is reasonable.
On the other hand, Rust folks wanted to keep alloc
as close as
upstream as possible and avoid as much divergence as possible, which
is also reasonable.
We agreed on a middle-ground: we would keep a subset of alloc
in-tree that would be as small and as close as possible to upstream.
Then, upstream can start adding the functions that we add to alloc
etc., until we reach a point where the kernel already knows exactly
what it needs in alloc
and all the new methods are merged into
upstream, so that we can drop alloc
from the kernel tree and go back
to using the upstream one.
By doing this, the kernel can go a bit faster now, and Rust can slowly incorporate and discuss the changes as needed.