Skip to content

Commit acc0bac

Browse files
committed
Merge tag 'rust-fixes-6.16-2' of git://git.kernel.org/pub/scm/linux/kernel/git/ojeda/linux
Pull Rust fixes from Miguel Ojeda: "Toolchain and infrastructure: - Fix build and modpost confusion for the upcoming Rust 1.89.0 release - Clean objtool warning for the upcoming Rust 1.89.0 release by adding one more noreturn function 'kernel' crate: - Fix build error when using generics in the 'try_{,pin_}init!' macros" * tag 'rust-fixes-6.16-2' of git://git.kernel.org/pub/scm/linux/kernel/git/ojeda/linux: rust: use `#[used(compiler)]` to fix build and `modpost` with Rust >= 1.89.0 objtool/rust: add one more `noreturn` Rust function for Rust 1.89.0 rust: init: Fix generics in *_init! macros
2 parents 1c6aa11 + 7498159 commit acc0bac

File tree

8 files changed

+18
-12
lines changed

8 files changed

+18
-12
lines changed

rust/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@ quiet_cmd_rustdoc_test = RUSTDOC T $<
194194
RUST_MODFILE=test.rs \
195195
OBJTREE=$(abspath $(objtree)) \
196196
$(RUSTDOC) --test $(rust_common_flags) \
197+
-Zcrate-attr='feature(used_with_arg)' \
197198
@$(objtree)/include/generated/rustc_cfg \
198199
$(rustc_target_flags) $(rustdoc_test_target_flags) \
199200
$(rustdoc_test_quiet) \

rust/kernel/firmware.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ macro_rules! module_firmware {
202202
};
203203

204204
#[link_section = ".modinfo"]
205-
#[used]
205+
#[used(compiler)]
206206
static __MODULE_FIRMWARE: [u8; $($builder)*::create(__MODULE_FIRMWARE_PREFIX)
207207
.build_length()] = $($builder)*::create(__MODULE_FIRMWARE_PREFIX).build();
208208
};

rust/kernel/init.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -231,14 +231,14 @@ macro_rules! try_init {
231231
($(&$this:ident in)? $t:ident $(::<$($generics:ty),* $(,)?>)? {
232232
$($fields:tt)*
233233
}) => {
234-
::pin_init::try_init!($(&$this in)? $t $(::<$($generics),* $(,)?>)? {
234+
::pin_init::try_init!($(&$this in)? $t $(::<$($generics),*>)? {
235235
$($fields)*
236236
}? $crate::error::Error)
237237
};
238238
($(&$this:ident in)? $t:ident $(::<$($generics:ty),* $(,)?>)? {
239239
$($fields:tt)*
240240
}? $err:ty) => {
241-
::pin_init::try_init!($(&$this in)? $t $(::<$($generics),* $(,)?>)? {
241+
::pin_init::try_init!($(&$this in)? $t $(::<$($generics),*>)? {
242242
$($fields)*
243243
}? $err)
244244
};
@@ -291,14 +291,14 @@ macro_rules! try_pin_init {
291291
($(&$this:ident in)? $t:ident $(::<$($generics:ty),* $(,)?>)? {
292292
$($fields:tt)*
293293
}) => {
294-
::pin_init::try_pin_init!($(&$this in)? $t $(::<$($generics),* $(,)?>)? {
294+
::pin_init::try_pin_init!($(&$this in)? $t $(::<$($generics),*>)? {
295295
$($fields)*
296296
}? $crate::error::Error)
297297
};
298298
($(&$this:ident in)? $t:ident $(::<$($generics:ty),* $(,)?>)? {
299299
$($fields:tt)*
300300
}? $err:ty) => {
301-
::pin_init::try_pin_init!($(&$this in)? $t $(::<$($generics),* $(,)?>)? {
301+
::pin_init::try_pin_init!($(&$this in)? $t $(::<$($generics),*>)? {
302302
$($fields)*
303303
}? $err)
304304
};

rust/kernel/kunit.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ macro_rules! kunit_unsafe_test_suite {
302302
is_init: false,
303303
};
304304

305-
#[used]
305+
#[used(compiler)]
306306
#[allow(unused_unsafe)]
307307
#[cfg_attr(not(target_os = "macos"), link_section = ".kunit_test_suites")]
308308
static mut KUNIT_TEST_SUITE_ENTRY: *const ::kernel::bindings::kunit_suite =

rust/kernel/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@
3434
// Expected to become stable.
3535
#![feature(arbitrary_self_types)]
3636
//
37+
// To be determined.
38+
#![feature(used_with_arg)]
39+
//
3740
// `feature(derive_coerce_pointee)` is expected to become stable. Before Rust
3841
// 1.84.0, it did not exist, so enable the predecessor features.
3942
#![cfg_attr(CONFIG_RUSTC_HAS_COERCE_POINTEE, feature(derive_coerce_pointee))]

rust/macros/module.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ impl<'a> ModInfoBuilder<'a> {
5757
{cfg}
5858
#[doc(hidden)]
5959
#[cfg_attr(not(target_os = \"macos\"), link_section = \".modinfo\")]
60-
#[used]
60+
#[used(compiler)]
6161
pub static __{module}_{counter}: [u8; {length}] = *{string};
6262
",
6363
cfg = if builtin {
@@ -249,7 +249,7 @@ pub(crate) fn module(ts: TokenStream) -> TokenStream {
249249
// key or a new section. For the moment, keep it simple.
250250
#[cfg(MODULE)]
251251
#[doc(hidden)]
252-
#[used]
252+
#[used(compiler)]
253253
static __IS_RUST_MODULE: () = ();
254254
255255
static mut __MOD: ::core::mem::MaybeUninit<{type_}> =
@@ -273,7 +273,7 @@ pub(crate) fn module(ts: TokenStream) -> TokenStream {
273273
274274
#[cfg(MODULE)]
275275
#[doc(hidden)]
276-
#[used]
276+
#[used(compiler)]
277277
#[link_section = \".init.data\"]
278278
static __UNIQUE_ID___addressable_init_module: unsafe extern \"C\" fn() -> i32 = init_module;
279279
@@ -293,7 +293,7 @@ pub(crate) fn module(ts: TokenStream) -> TokenStream {
293293
294294
#[cfg(MODULE)]
295295
#[doc(hidden)]
296-
#[used]
296+
#[used(compiler)]
297297
#[link_section = \".exit.data\"]
298298
static __UNIQUE_ID___addressable_cleanup_module: extern \"C\" fn() = cleanup_module;
299299
@@ -303,7 +303,7 @@ pub(crate) fn module(ts: TokenStream) -> TokenStream {
303303
#[cfg(not(CONFIG_HAVE_ARCH_PREL32_RELOCATIONS))]
304304
#[doc(hidden)]
305305
#[link_section = \"{initcall_section}\"]
306-
#[used]
306+
#[used(compiler)]
307307
pub static __{ident}_initcall: extern \"C\" fn() ->
308308
::kernel::ffi::c_int = __{ident}_init;
309309

scripts/Makefile.build

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,10 +312,11 @@ $(obj)/%.lst: $(obj)/%.c FORCE
312312
# - Stable since Rust 1.82.0: `feature(asm_const)`, `feature(raw_ref_op)`.
313313
# - Stable since Rust 1.87.0: `feature(asm_goto)`.
314314
# - Expected to become stable: `feature(arbitrary_self_types)`.
315+
# - To be determined: `feature(used_with_arg)`.
315316
#
316317
# Please see https://github.com/Rust-for-Linux/linux/issues/2 for details on
317318
# the unstable features in use.
318-
rust_allowed_features := asm_const,asm_goto,arbitrary_self_types,lint_reasons,raw_ref_op
319+
rust_allowed_features := asm_const,asm_goto,arbitrary_self_types,lint_reasons,raw_ref_op,used_with_arg
319320

320321
# `--out-dir` is required to avoid temporaries being created by `rustc` in the
321322
# current working directory, which may be not accessible in the out-of-tree

tools/objtool/check.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,7 @@ static bool is_rust_noreturn(const struct symbol *func)
224224
str_ends_with(func->name, "_4core9panicking14panic_explicit") ||
225225
str_ends_with(func->name, "_4core9panicking14panic_nounwind") ||
226226
str_ends_with(func->name, "_4core9panicking18panic_bounds_check") ||
227+
str_ends_with(func->name, "_4core9panicking18panic_nounwind_fmt") ||
227228
str_ends_with(func->name, "_4core9panicking19assert_failed_inner") ||
228229
str_ends_with(func->name, "_4core9panicking30panic_null_pointer_dereference") ||
229230
str_ends_with(func->name, "_4core9panicking36panic_misaligned_pointer_dereference") ||

0 commit comments

Comments
 (0)