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
This commit is contained in:
@@ -194,6 +194,7 @@ quiet_cmd_rustdoc_test = RUSTDOC T $<
|
||||
RUST_MODFILE=test.rs \
|
||||
OBJTREE=$(abspath $(objtree)) \
|
||||
$(RUSTDOC) --test $(rust_common_flags) \
|
||||
-Zcrate-attr='feature(used_with_arg)' \
|
||||
@$(objtree)/include/generated/rustc_cfg \
|
||||
$(rustc_target_flags) $(rustdoc_test_target_flags) \
|
||||
$(rustdoc_test_quiet) \
|
||||
|
||||
@@ -202,7 +202,7 @@ macro_rules! module_firmware {
|
||||
};
|
||||
|
||||
#[link_section = ".modinfo"]
|
||||
#[used]
|
||||
#[used(compiler)]
|
||||
static __MODULE_FIRMWARE: [u8; $($builder)*::create(__MODULE_FIRMWARE_PREFIX)
|
||||
.build_length()] = $($builder)*::create(__MODULE_FIRMWARE_PREFIX).build();
|
||||
};
|
||||
|
||||
+4
-4
@@ -231,14 +231,14 @@ macro_rules! try_init {
|
||||
($(&$this:ident in)? $t:ident $(::<$($generics:ty),* $(,)?>)? {
|
||||
$($fields:tt)*
|
||||
}) => {
|
||||
::pin_init::try_init!($(&$this in)? $t $(::<$($generics),* $(,)?>)? {
|
||||
::pin_init::try_init!($(&$this in)? $t $(::<$($generics),*>)? {
|
||||
$($fields)*
|
||||
}? $crate::error::Error)
|
||||
};
|
||||
($(&$this:ident in)? $t:ident $(::<$($generics:ty),* $(,)?>)? {
|
||||
$($fields:tt)*
|
||||
}? $err:ty) => {
|
||||
::pin_init::try_init!($(&$this in)? $t $(::<$($generics),* $(,)?>)? {
|
||||
::pin_init::try_init!($(&$this in)? $t $(::<$($generics),*>)? {
|
||||
$($fields)*
|
||||
}? $err)
|
||||
};
|
||||
@@ -291,14 +291,14 @@ macro_rules! try_pin_init {
|
||||
($(&$this:ident in)? $t:ident $(::<$($generics:ty),* $(,)?>)? {
|
||||
$($fields:tt)*
|
||||
}) => {
|
||||
::pin_init::try_pin_init!($(&$this in)? $t $(::<$($generics),* $(,)?>)? {
|
||||
::pin_init::try_pin_init!($(&$this in)? $t $(::<$($generics),*>)? {
|
||||
$($fields)*
|
||||
}? $crate::error::Error)
|
||||
};
|
||||
($(&$this:ident in)? $t:ident $(::<$($generics:ty),* $(,)?>)? {
|
||||
$($fields:tt)*
|
||||
}? $err:ty) => {
|
||||
::pin_init::try_pin_init!($(&$this in)? $t $(::<$($generics),* $(,)?>)? {
|
||||
::pin_init::try_pin_init!($(&$this in)? $t $(::<$($generics),*>)? {
|
||||
$($fields)*
|
||||
}? $err)
|
||||
};
|
||||
|
||||
@@ -302,7 +302,7 @@ macro_rules! kunit_unsafe_test_suite {
|
||||
is_init: false,
|
||||
};
|
||||
|
||||
#[used]
|
||||
#[used(compiler)]
|
||||
#[allow(unused_unsafe)]
|
||||
#[cfg_attr(not(target_os = "macos"), link_section = ".kunit_test_suites")]
|
||||
static mut KUNIT_TEST_SUITE_ENTRY: *const ::kernel::bindings::kunit_suite =
|
||||
|
||||
@@ -34,6 +34,9 @@
|
||||
// Expected to become stable.
|
||||
#![feature(arbitrary_self_types)]
|
||||
//
|
||||
// To be determined.
|
||||
#![feature(used_with_arg)]
|
||||
//
|
||||
// `feature(derive_coerce_pointee)` is expected to become stable. Before Rust
|
||||
// 1.84.0, it did not exist, so enable the predecessor features.
|
||||
#![cfg_attr(CONFIG_RUSTC_HAS_COERCE_POINTEE, feature(derive_coerce_pointee))]
|
||||
|
||||
@@ -57,7 +57,7 @@ impl<'a> ModInfoBuilder<'a> {
|
||||
{cfg}
|
||||
#[doc(hidden)]
|
||||
#[cfg_attr(not(target_os = \"macos\"), link_section = \".modinfo\")]
|
||||
#[used]
|
||||
#[used(compiler)]
|
||||
pub static __{module}_{counter}: [u8; {length}] = *{string};
|
||||
",
|
||||
cfg = if builtin {
|
||||
@@ -249,7 +249,7 @@ pub(crate) fn module(ts: TokenStream) -> TokenStream {
|
||||
// key or a new section. For the moment, keep it simple.
|
||||
#[cfg(MODULE)]
|
||||
#[doc(hidden)]
|
||||
#[used]
|
||||
#[used(compiler)]
|
||||
static __IS_RUST_MODULE: () = ();
|
||||
|
||||
static mut __MOD: ::core::mem::MaybeUninit<{type_}> =
|
||||
@@ -273,7 +273,7 @@ pub(crate) fn module(ts: TokenStream) -> TokenStream {
|
||||
|
||||
#[cfg(MODULE)]
|
||||
#[doc(hidden)]
|
||||
#[used]
|
||||
#[used(compiler)]
|
||||
#[link_section = \".init.data\"]
|
||||
static __UNIQUE_ID___addressable_init_module: unsafe extern \"C\" fn() -> i32 = init_module;
|
||||
|
||||
@@ -293,7 +293,7 @@ pub(crate) fn module(ts: TokenStream) -> TokenStream {
|
||||
|
||||
#[cfg(MODULE)]
|
||||
#[doc(hidden)]
|
||||
#[used]
|
||||
#[used(compiler)]
|
||||
#[link_section = \".exit.data\"]
|
||||
static __UNIQUE_ID___addressable_cleanup_module: extern \"C\" fn() = cleanup_module;
|
||||
|
||||
@@ -303,7 +303,7 @@ pub(crate) fn module(ts: TokenStream) -> TokenStream {
|
||||
#[cfg(not(CONFIG_HAVE_ARCH_PREL32_RELOCATIONS))]
|
||||
#[doc(hidden)]
|
||||
#[link_section = \"{initcall_section}\"]
|
||||
#[used]
|
||||
#[used(compiler)]
|
||||
pub static __{ident}_initcall: extern \"C\" fn() ->
|
||||
::kernel::ffi::c_int = __{ident}_init;
|
||||
|
||||
|
||||
@@ -312,10 +312,11 @@ $(obj)/%.lst: $(obj)/%.c FORCE
|
||||
# - Stable since Rust 1.82.0: `feature(asm_const)`, `feature(raw_ref_op)`.
|
||||
# - Stable since Rust 1.87.0: `feature(asm_goto)`.
|
||||
# - Expected to become stable: `feature(arbitrary_self_types)`.
|
||||
# - To be determined: `feature(used_with_arg)`.
|
||||
#
|
||||
# Please see https://github.com/Rust-for-Linux/linux/issues/2 for details on
|
||||
# the unstable features in use.
|
||||
rust_allowed_features := asm_const,asm_goto,arbitrary_self_types,lint_reasons,raw_ref_op
|
||||
rust_allowed_features := asm_const,asm_goto,arbitrary_self_types,lint_reasons,raw_ref_op,used_with_arg
|
||||
|
||||
# `--out-dir` is required to avoid temporaries being created by `rustc` in the
|
||||
# current working directory, which may be not accessible in the out-of-tree
|
||||
|
||||
@@ -224,6 +224,7 @@ static bool is_rust_noreturn(const struct symbol *func)
|
||||
str_ends_with(func->name, "_4core9panicking14panic_explicit") ||
|
||||
str_ends_with(func->name, "_4core9panicking14panic_nounwind") ||
|
||||
str_ends_with(func->name, "_4core9panicking18panic_bounds_check") ||
|
||||
str_ends_with(func->name, "_4core9panicking18panic_nounwind_fmt") ||
|
||||
str_ends_with(func->name, "_4core9panicking19assert_failed_inner") ||
|
||||
str_ends_with(func->name, "_4core9panicking30panic_null_pointer_dereference") ||
|
||||
str_ends_with(func->name, "_4core9panicking36panic_misaligned_pointer_dereference") ||
|
||||
|
||||
Reference in New Issue
Block a user