Skip to content

Commit 7ab26eb

Browse files
committed
Merge patch series "rust: bump minimum Rust and bindgen versions"
As proposed in the past in e.g. LPC 2025 and the Maintainers Summit [1], we are going to follow Debian Stable's Rust versions as our minimum supported version. Debian Trixie was released with a Rust 1.85.0 toolchain [2], which it still uses to this day [3] (i.e. no update to Rust 1.85.1). Debian Trixie was released with `bindgen` 0.71.1, which it also still uses to this day [4]. Debian Trixie's release happened on 2025-08-09 [5], which means that a fair amount of time has passed since its release for kernel developers to upgrade. Thus bump the minimum to the new versions, i.e. - Rust: 1.78.0 -> 1.85.0 - bindgen: 0.65.1 -> 0.71.1 There are a few main parts to the series, in this order: - A few cleanups that can be performed before the bumps. - The Rust bump (and its cleanups). - The `bindgen` bump (and its cleanups). - Documentation updates. - The `cfi_encoding` patch, added here, which needs the bump. - The per-version flags support and a Clippy cleanup on top. Link: https://lwn.net/Articles/1050174/ [1] Link: https://www.debian.org/releases/trixie/release-notes/whats-new.en.html#desktops-and-well-known-packages [2] Link: https://packages.debian.org/trixie/rustc [3] Link: https://packages.debian.org/trixie/bindgen [4] Link: https://www.debian.org/releases/trixie/ [5] Link: https://patch.msgid.link/20260405235309.418950-1-ojeda@kernel.org Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2 parents 36f5a2b + 2e2f8b5 commit 7ab26eb

39 files changed

Lines changed: 88 additions & 451 deletions

.clippy.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# SPDX-License-Identifier: GPL-2.0
22

3-
msrv = "1.78.0"
3+
msrv = "1.85.0"
44

55
check-private-items = true
66

Documentation/process/changes.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ you probably needn't concern yourself with pcmciautils.
3131
====================== =============== ========================================
3232
GNU C 8.1 gcc --version
3333
Clang/LLVM (optional) 15.0.0 clang --version
34-
Rust (optional) 1.78.0 rustc --version
35-
bindgen (optional) 0.65.1 bindgen --version
34+
Rust (optional) 1.85.0 rustc --version
35+
bindgen (optional) 0.71.1 bindgen --version
3636
GNU make 4.0 make --version
3737
bash 4.2 bash --version
3838
binutils 2.30 ld -v

Documentation/rust/general-information.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,5 +157,5 @@ numerical comparisons, one may define a new Kconfig symbol:
157157

158158
.. code-block:: kconfig
159159
160-
config RUSTC_VERSION_MIN_107900
161-
def_bool y if RUSTC_VERSION >= 107900
160+
config RUSTC_HAS_SPAN_FILE
161+
def_bool RUSTC_VERSION >= 108800

Documentation/rust/quick-start.rst

Lines changed: 20 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ of the box, e.g.::
5757
Gentoo Linux
5858
************
5959

60-
Gentoo Linux (and especially the testing branch) provides recent Rust releases
61-
and thus it should generally work out of the box, e.g.::
60+
Gentoo Linux provides recent Rust releases and thus it should generally work out
61+
of the box, e.g.::
6262

6363
USE='rust-src rustfmt clippy' emerge dev-lang/rust dev-util/bindgen
6464

@@ -68,8 +68,8 @@ and thus it should generally work out of the box, e.g.::
6868
Nix
6969
***
7070

71-
Nix (unstable channel) provides recent Rust releases and thus it should
72-
generally work out of the box, e.g.::
71+
Nix provides recent Rust releases and thus it should generally work out of the
72+
box, e.g.::
7373

7474
{ pkgs ? import <nixpkgs> {} }:
7575
pkgs.mkShell {
@@ -84,16 +84,13 @@ openSUSE
8484
openSUSE Slowroll and openSUSE Tumbleweed provide recent Rust releases and thus
8585
they should generally work out of the box, e.g.::
8686

87-
zypper install rust rust1.79-src rust-bindgen clang
87+
zypper install rust rust-src rust-bindgen clang
8888

8989

9090
Ubuntu
9191
******
9292

93-
25.04
94-
~~~~~
95-
96-
The latest Ubuntu releases provide recent Rust releases and thus they should
93+
Ubuntu 25.10 and 26.04 LTS provide recent Rust releases and thus they should
9794
generally work out of the box, e.g.::
9895

9996
apt install rustc rust-src bindgen rustfmt rust-clippy
@@ -112,33 +109,33 @@ Though Ubuntu 24.04 LTS and older versions still provide recent Rust
112109
releases, they require some additional configuration to be set, using
113110
the versioned packages, e.g.::
114111

115-
apt install rustc-1.80 rust-1.80-src bindgen-0.65 rustfmt-1.80 \
116-
rust-1.80-clippy
117-
ln -s /usr/lib/rust-1.80/bin/rustfmt /usr/bin/rustfmt-1.80
118-
ln -s /usr/lib/rust-1.80/bin/clippy-driver /usr/bin/clippy-driver-1.80
112+
apt install rustc-1.85 rust-1.85-src bindgen-0.71 rustfmt-1.85 \
113+
rust-1.85-clippy
114+
ln -s /usr/lib/rust-1.85/bin/rustfmt /usr/bin/rustfmt-1.85
115+
ln -s /usr/lib/rust-1.85/bin/clippy-driver /usr/bin/clippy-driver-1.85
119116

120117
None of these packages set their tools as defaults; therefore they should be
121118
specified explicitly, e.g.::
122119

123-
make LLVM=1 RUSTC=rustc-1.80 RUSTDOC=rustdoc-1.80 RUSTFMT=rustfmt-1.80 \
124-
CLIPPY_DRIVER=clippy-driver-1.80 BINDGEN=bindgen-0.65
120+
make LLVM=1 RUSTC=rustc-1.85 RUSTDOC=rustdoc-1.85 RUSTFMT=rustfmt-1.85 \
121+
CLIPPY_DRIVER=clippy-driver-1.85 BINDGEN=bindgen-0.71
125122

126-
Alternatively, modify the ``PATH`` variable to place the Rust 1.80 binaries
123+
Alternatively, modify the ``PATH`` variable to place the Rust 1.85 binaries
127124
first and set ``bindgen`` as the default, e.g.::
128125

129-
PATH=/usr/lib/rust-1.80/bin:$PATH
126+
PATH=/usr/lib/rust-1.85/bin:$PATH
130127
update-alternatives --install /usr/bin/bindgen bindgen \
131-
/usr/bin/bindgen-0.65 100
132-
update-alternatives --set bindgen /usr/bin/bindgen-0.65
128+
/usr/bin/bindgen-0.71 100
129+
update-alternatives --set bindgen /usr/bin/bindgen-0.71
133130

134-
``RUST_LIB_SRC`` needs to be set when using the versioned packages, e.g.::
131+
``RUST_LIB_SRC`` may need to be set when using the versioned packages, e.g.::
135132

136-
RUST_LIB_SRC=/usr/src/rustc-$(rustc-1.80 --version | cut -d' ' -f2)/library
133+
RUST_LIB_SRC=/usr/src/rustc-$(rustc-1.85 --version | cut -d' ' -f2)/library
137134

138135
For convenience, ``RUST_LIB_SRC`` can be exported to the global environment.
139136

140-
In addition, ``bindgen-0.65`` is available in newer releases (24.04 LTS and
141-
24.10), but it may not be available in older ones (20.04 LTS and 22.04 LTS),
137+
In addition, ``bindgen-0.71`` is available in newer releases (24.04 LTS),
138+
but it may not be available in older ones (20.04 LTS and 22.04 LTS),
142139
thus ``bindgen`` may need to be built manually (please see below).
143140

144141

@@ -355,12 +352,3 @@ Hacking
355352
To dive deeper, take a look at the source code of the samples
356353
at ``samples/rust/``, the Rust support code under ``rust/`` and
357354
the ``Rust hacking`` menu under ``Kernel hacking``.
358-
359-
If GDB/Binutils is used and Rust symbols are not getting demangled, the reason
360-
is the toolchain does not support Rust's new v0 mangling scheme yet.
361-
There are a few ways out:
362-
363-
- Install a newer release (GDB >= 10.2, Binutils >= 2.36).
364-
365-
- Some versions of GDB (e.g. vanilla GDB 10.1) are able to use
366-
the pre-demangled names embedded in the debug info (``CONFIG_DEBUG_INFO``).

Makefile

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -486,6 +486,7 @@ export rust_common_flags := --edition=2021 \
486486
-Wclippy::as_underscore \
487487
-Wclippy::cast_lossless \
488488
-Wclippy::ignored_unit_patterns \
489+
-Aclippy::incompatible_msrv \
489490
-Wclippy::mut_mut \
490491
-Wclippy::needless_bitwise_bool \
491492
-Aclippy::needless_lifetimes \
@@ -505,7 +506,7 @@ KBUILD_HOSTCFLAGS := $(KBUILD_USERHOSTCFLAGS) $(HOST_LFS_CFLAGS) \
505506
KBUILD_HOSTCXXFLAGS := -Wall -O2 $(HOST_LFS_CFLAGS) $(HOSTCXXFLAGS) \
506507
-I $(srctree)/scripts/include
507508
KBUILD_HOSTRUSTFLAGS := $(rust_common_flags) -O -Cstrip=debuginfo \
508-
-Zallow-features= $(HOSTRUSTFLAGS)
509+
-Zallow-features=
509510
KBUILD_HOSTLDFLAGS := $(HOST_LFS_LDFLAGS) $(HOSTLDFLAGS)
510511
KBUILD_HOSTLDLIBS := $(HOST_LFS_LIBS) $(HOSTLDLIBS)
511512
KBUILD_PROCMACROLDFLAGS := $(or $(PROCMACROLDFLAGS),$(KBUILD_HOSTLDFLAGS))
@@ -835,6 +836,20 @@ endif # CONFIG_TRACEPOINTS
835836

836837
export WARN_ON_UNUSED_TRACEPOINTS
837838

839+
# Per-version Rust flags. These are like `rust_common_flags`, but may
840+
# depend on the Rust compiler version (e.g. using `rustc-min-version`).
841+
#
842+
# `-Aclippy::precedence`: the lint was extended in Rust 1.85.0 to
843+
# include bitmasking and shift operations. However, because it generated
844+
# many hits, in Rust 1.86.0 it was split into a new `precedence_bits`
845+
# lint which is not enabled by default.
846+
rust_common_flags_per_version := \
847+
$(if $(call rustc-min-version,108600),,-Aclippy::precedence)
848+
849+
rust_common_flags += $(rust_common_flags_per_version)
850+
KBUILD_HOSTRUSTFLAGS += $(rust_common_flags_per_version) $(HOSTRUSTFLAGS)
851+
KBUILD_RUSTFLAGS += $(rust_common_flags_per_version)
852+
838853
include $(srctree)/arch/$(SRCARCH)/Makefile
839854

840855
ifdef need-config

arch/Kconfig

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -968,10 +968,9 @@ config HAVE_CFI_ICALL_NORMALIZE_INTEGERS
968968
config HAVE_CFI_ICALL_NORMALIZE_INTEGERS_RUSTC
969969
def_bool y
970970
depends on HAVE_CFI_ICALL_NORMALIZE_INTEGERS
971-
depends on RUSTC_VERSION >= 107900
972971
depends on ARM64 || X86_64
973972
# With GCOV/KASAN we need this fix: https://github.com/rust-lang/rust/pull/129373
974-
depends on (RUSTC_LLVM_VERSION >= 190103 && RUSTC_VERSION >= 108200) || \
973+
depends on RUSTC_LLVM_VERSION >= 190103 || \
975974
(!GCOV_KERNEL && !KASAN_GENERIC && !KASAN_SW_TAGS)
976975

977976
config CFI_PERMISSIVE

arch/arm64/Kconfig

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -291,14 +291,6 @@ config ARM64
291291
config RUSTC_SUPPORTS_ARM64
292292
def_bool y
293293
depends on CPU_LITTLE_ENDIAN
294-
# Shadow call stack is only supported on certain rustc versions.
295-
#
296-
# When using the UNWIND_PATCH_PAC_INTO_SCS option, rustc version 1.80+ is
297-
# required due to use of the -Zfixed-x18 flag.
298-
#
299-
# Otherwise, rustc version 1.82+ is required due to use of the
300-
# -Zsanitizer=shadow-call-stack flag.
301-
depends on !SHADOW_CALL_STACK || RUSTC_VERSION >= 108200 || RUSTC_VERSION >= 108000 && UNWIND_PATCH_PAC_INTO_SCS
302294

303295
config CLANG_SUPPORTS_DYNAMIC_FTRACE_WITH_ARGS
304296
def_bool CC_IS_CLANG

arch/riscv/Kconfig

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -232,9 +232,6 @@ config RISCV
232232
config RUSTC_SUPPORTS_RISCV
233233
def_bool y
234234
depends on 64BIT
235-
# Shadow call stack requires rustc version 1.82+ due to use of the
236-
# -Zsanitizer=shadow-call-stack flag.
237-
depends on !SHADOW_CALL_STACK || RUSTC_VERSION >= 108200
238235

239236
config CLANG_SUPPORTS_DYNAMIC_FTRACE
240237
def_bool CC_IS_CLANG

drivers/android/binder/Makefile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,4 @@ obj-$(CONFIG_ANDROID_BINDER_IPC_RUST) += rust_binder.o
55
rust_binder-y := \
66
rust_binder_main.o \
77
rust_binderfs.o \
8-
rust_binder_events.o \
9-
page_range_helper.o
8+
rust_binder_events.o

drivers/android/binder/page_range.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -642,15 +642,15 @@ unsafe extern "C" fn rust_shrink_scan(
642642
unsafe {
643643
bindings::list_lru_walk(
644644
list_lru,
645-
Some(bindings::rust_shrink_free_page_wrap),
645+
Some(rust_shrink_free_page),
646646
ptr::null_mut(),
647647
nr_to_scan,
648648
)
649649
}
650650
}
651651

652-
const LRU_SKIP: bindings::lru_status = bindings::lru_status_LRU_SKIP;
653-
const LRU_REMOVED_ENTRY: bindings::lru_status = bindings::lru_status_LRU_REMOVED_RETRY;
652+
const LRU_SKIP: bindings::lru_status = bindings::lru_status::LRU_SKIP;
653+
const LRU_REMOVED_ENTRY: bindings::lru_status = bindings::lru_status::LRU_REMOVED_RETRY;
654654

655655
/// # Safety
656656
/// Called by the shrinker.

0 commit comments

Comments
 (0)