Skip to content

Commit dc77806

Browse files
committed
Merge tag 'rust-fixes-6.18' of git://git.kernel.org/pub/scm/linux/kernel/git/ojeda/linux
Pull rust fixes from Miguel Ojeda: - Fix/workaround a couple Rust 1.91.0 build issues when sanitizers are enabled due to extra checking performed by the compiler and an upstream issue already fixed for Rust 1.93.0 - Fix future Rust 1.93.0 builds by supporting the stabilized name for the 'no-jump-tables' flag - Fix a couple private/broken intra-doc links uncovered by the future move of pin-init to 'syn' * tag 'rust-fixes-6.18' of git://git.kernel.org/pub/scm/linux/kernel/git/ojeda/linux: rust: kbuild: support `-Cjump-tables=n` for Rust 1.93.0 rust: kbuild: workaround `rustdoc` doctests modifier bug rust: kbuild: treat `build_error` and `rustdoc` as kernel objects rust: condvar: fix broken intra-doc link rust: devres: fix private intra-doc link
2 parents 5624d4c + 789521b commit dc77806

File tree

5 files changed

+18
-5
lines changed

5 files changed

+18
-5
lines changed

arch/loongarch/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ endif
109109
ifdef CONFIG_RUSTC_HAS_ANNOTATE_TABLEJUMP
110110
KBUILD_RUSTFLAGS += -Cllvm-args=--loongarch-annotate-tablejump
111111
else
112-
KBUILD_RUSTFLAGS += -Zno-jump-tables # keep compatibility with older compilers
112+
KBUILD_RUSTFLAGS += $(if $(call rustc-min-version,109300),-Cjump-tables=n,-Zno-jump-tables) # keep compatibility with older compilers
113113
endif
114114
ifdef CONFIG_LTO_CLANG
115115
# The annotate-tablejump option can not be passed to LLVM backend when LTO is enabled.

arch/x86/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ ifeq ($(CONFIG_X86_KERNEL_IBT),y)
9898
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104816
9999
#
100100
KBUILD_CFLAGS += $(call cc-option,-fcf-protection=branch -fno-jump-tables)
101-
KBUILD_RUSTFLAGS += -Zcf-protection=branch -Zno-jump-tables
101+
KBUILD_RUSTFLAGS += -Zcf-protection=branch $(if $(call rustc-min-version,109300),-Cjump-tables=n,-Zno-jump-tables)
102102
else
103103
KBUILD_CFLAGS += $(call cc-option,-fcf-protection=none)
104104
endif

rust/Makefile

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ core-edition := $(if $(call rustc-min-version,108700),2024,2021)
6969
# the time being (https://github.com/rust-lang/rust/issues/144521).
7070
rustdoc_modifiers_workaround := $(if $(call rustc-min-version,108800),-Cunsafe-allow-abi-mismatch=fixed-x18)
7171

72+
# Similarly, for doctests (https://github.com/rust-lang/rust/issues/146465).
73+
doctests_modifiers_workaround := $(rustdoc_modifiers_workaround)$(if $(call rustc-min-version,109100),$(comma)sanitizer)
74+
7275
# `rustc` recognizes `--remap-path-prefix` since 1.26.0, but `rustdoc` only
7376
# since Rust 1.81.0. Moreover, `rustdoc` ICEs on out-of-tree builds since Rust
7477
# 1.82.0 (https://github.com/rust-lang/rust/issues/138520). Thus workaround both
@@ -127,9 +130,14 @@ rustdoc-core: private rustc_target_flags = --edition=$(core-edition) $(core-cfgs
127130
rustdoc-core: $(RUST_LIB_SRC)/core/src/lib.rs rustdoc-clean FORCE
128131
+$(call if_changed,rustdoc)
129132

133+
# Even if `rustdoc` targets are not kernel objects, they should still be
134+
# treated as such so that we pass the same flags. Otherwise, for instance,
135+
# `rustdoc` will complain about missing sanitizer flags causing an ABI mismatch.
136+
rustdoc-compiler_builtins: private is-kernel-object := y
130137
rustdoc-compiler_builtins: $(src)/compiler_builtins.rs rustdoc-core FORCE
131138
+$(call if_changed,rustdoc)
132139

140+
rustdoc-ffi: private is-kernel-object := y
133141
rustdoc-ffi: $(src)/ffi.rs rustdoc-core FORCE
134142
+$(call if_changed,rustdoc)
135143

@@ -147,6 +155,7 @@ rustdoc-pin_init: $(src)/pin-init/src/lib.rs rustdoc-pin_init_internal \
147155
rustdoc-macros FORCE
148156
+$(call if_changed,rustdoc)
149157

158+
rustdoc-kernel: private is-kernel-object := y
150159
rustdoc-kernel: private rustc_target_flags = --extern ffi --extern pin_init \
151160
--extern build_error --extern macros \
152161
--extern bindings --extern uapi
@@ -230,7 +239,7 @@ quiet_cmd_rustdoc_test_kernel = RUSTDOC TK $<
230239
--extern bindings --extern uapi \
231240
--no-run --crate-name kernel -Zunstable-options \
232241
--sysroot=/dev/null \
233-
$(rustdoc_modifiers_workaround) \
242+
$(doctests_modifiers_workaround) \
234243
--test-builder $(objtree)/scripts/rustdoc_test_builder \
235244
$< $(rustdoc_test_kernel_quiet); \
236245
$(objtree)/scripts/rustdoc_test_gen
@@ -522,6 +531,10 @@ $(obj)/pin_init.o: $(src)/pin-init/src/lib.rs $(obj)/compiler_builtins.o \
522531
$(obj)/$(libpin_init_internal_name) $(obj)/$(libmacros_name) FORCE
523532
+$(call if_changed_rule,rustc_library)
524533

534+
# Even if normally `build_error` is not a kernel object, it should still be
535+
# treated as such so that we pass the same flags. Otherwise, for instance,
536+
# `rustc` will complain about missing sanitizer flags causing an ABI mismatch.
537+
$(obj)/build_error.o: private is-kernel-object := y
525538
$(obj)/build_error.o: private skip_gendwarfksyms = 1
526539
$(obj)/build_error.o: $(src)/build_error.rs $(obj)/compiler_builtins.o FORCE
527540
+$(call if_changed_rule,rustc_library)

rust/kernel/devres.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ struct Inner<T: Send> {
103103
///
104104
/// # Invariants
105105
///
106-
/// [`Self::inner`] is guaranteed to be initialized and is always accessed read-only.
106+
/// `Self::inner` is guaranteed to be initialized and is always accessed read-only.
107107
#[pin_data(PinnedDrop)]
108108
pub struct Devres<T: Send> {
109109
dev: ARef<Device>,

rust/kernel/sync/condvar.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ pub use new_condvar;
3636
/// spuriously.
3737
///
3838
/// Instances of [`CondVar`] need a lock class and to be pinned. The recommended way to create such
39-
/// instances is with the [`pin_init`](crate::pin_init!) and [`new_condvar`] macros.
39+
/// instances is with the [`pin_init`](pin_init::pin_init!) and [`new_condvar`] macros.
4040
///
4141
/// # Examples
4242
///

0 commit comments

Comments
 (0)