Skip to content

Commit ae71255

Browse files
ojedafbq
authored andcommitted
rust: start supporting several compiler versions
It is time to start supporting several Rust compiler versions and thus establish a minimum Rust version. We may still want to upgrade the minimum sometimes in the beginning since there may be important features coming into the language that improve how we write code (e.g. field projections), which may or may not make sense to support conditionally. We will start with a window of two stable releases, and widen it over time. Thus this patch does not move the current minimum (1.78.0), but instead adds support for the recently released 1.79.0. This should already be enough for kernel developers in distributions that provide recent Rust compiler versions routinely, such as Arch Linux, Debian Unstable (outside the freeze period), Fedora Linux, Gentoo Linux (especially the testing channel), Nix (unstable) and openSUSE Tumbleweed. See the documentation patch about it later in this series. In addition, Rust for Linux is now being built-tested in Rust's pre-merge CI [1]. That is, every change that is attempting to land into the Rust compiler is tested against the kernel, and it is merged only if it passes -- thanks to the Rust project for that! Thus, with the pre-merge CI in place, both projects hope to avoid unintentional changes to Rust that break the kernel. This means that, in general, apart from intentional changes on their side (that we will need to workaround conditionally on our side), the upcoming Rust compiler versions should generally work. For instance, currently, the beta (1.80.0) and nightly (1.81.0) branches work as well. Of course, the Rust for Linux CI job in the Rust toolchain may still need to be temporarily disabled for different reasons, but the intention is to help bring Rust for Linux into stable Rust. Link: rust-lang/rust#125209 [1] Signed-off-by: Miguel Ojeda <ojeda@kernel.org> Link: https://lore.kernel.org/r/20240701183625.665574-7-ojeda@kernel.org
1 parent 480fe54 commit ae71255

File tree

4 files changed

+5
-21
lines changed

4 files changed

+5
-21
lines changed

Documentation/process/changes.rst

+1-3
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,7 @@ docs on :ref:`Building Linux with Clang/LLVM <kbuild_llvm>`.
8888
Rust (optional)
8989
---------------
9090

91-
A particular version of the Rust toolchain is required. Newer versions may or
92-
may not work because the kernel depends on some unstable Rust features, for
93-
the moment.
91+
A recent version of the Rust compiler is required.
9492

9593
Each Rust toolchain comes with several "components", some of which are required
9694
(like ``rustc``) and some that are optional. The ``rust-src`` component (which

Documentation/rust/quick-start.rst

+4-5
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,15 @@ if that is the case.
3636
rustc
3737
*****
3838

39-
A particular version of the Rust compiler is required. Newer versions may or
40-
may not work because, for the moment, the kernel depends on some unstable
41-
Rust features.
39+
A recent version of the Rust compiler is required.
4240

4341
If ``rustup`` is being used, enter the kernel build directory (or use
44-
``--path=<build-dir>`` argument to the ``set`` sub-command) and run::
42+
``--path=<build-dir>`` argument to the ``set`` sub-command) and run,
43+
for instance::
4544

4645
rustup override set $(scripts/min-tool-version.sh rustc)
4746

48-
This will configure your working directory to use the correct version of
47+
This will configure your working directory to use the given version of
4948
``rustc`` without affecting your default toolchain.
5049

5150
Note that the override applies to the current working directory (and its

scripts/rust_is_available.sh

-8
Original file line numberDiff line numberDiff line change
@@ -117,14 +117,6 @@ if [ "$rust_compiler_cversion" -lt "$rust_compiler_min_cversion" ]; then
117117
echo >&2 "***"
118118
exit 1
119119
fi
120-
if [ "$rust_compiler_cversion" -gt "$rust_compiler_min_cversion" ]; then
121-
echo >&2 "***"
122-
echo >&2 "*** Rust compiler '$RUSTC' is too new. This may or may not work."
123-
echo >&2 "*** Your version: $rust_compiler_version"
124-
echo >&2 "*** Expected version: $rust_compiler_min_version"
125-
echo >&2 "***"
126-
warning=1
127-
fi
128120

129121
# Check that the Rust bindings generator is suitable.
130122
#

scripts/rust_is_available_test.py

-5
Original file line numberDiff line numberDiff line change
@@ -193,11 +193,6 @@ def test_rustc_old_version(self):
193193
result = self.run_script(self.Expected.FAILURE, { "RUSTC": rustc })
194194
self.assertIn(f"Rust compiler '{rustc}' is too old.", result.stderr)
195195

196-
def test_rustc_new_version(self):
197-
rustc = self.generate_rustc("rustc 1.999.0 (a8314ef7d 2099-06-27)")
198-
result = self.run_script(self.Expected.SUCCESS_WITH_WARNINGS, { "RUSTC": rustc })
199-
self.assertIn(f"Rust compiler '{rustc}' is too new. This may or may not work.", result.stderr)
200-
201196
def test_bindgen_nonexecutable(self):
202197
result = self.run_script(self.Expected.FAILURE, { "BINDGEN": self.nonexecutable })
203198
self.assertIn(f"Running '{self.nonexecutable}' to check the Rust bindings generator version failed with", result.stderr)

0 commit comments

Comments
 (0)