mirror of
https://kernel.googlesource.com/pub/scm/linux/kernel/git/torvalds/linux
synced 2025-09-28 19:57:53 +10:00
Rust fixes for v6.17 (2nd)
Toolchain and infrastructure: - Two changes to prepare for the future Rust 1.91.0 release (expected 2025-10-30, currently in nightly): a target specification format change and a renamed, soon-to-be-stabilized 'core' function. -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEPjU5OPd5QIZ9jqqOGXyLc2htIW0FAmi8ciYACgkQGXyLc2ht IW3Bdg/9G07hHjmW0TR+V7AExNTqaZKdCxY//1lFeIuiIIew/tasqqbMCzv6KPi0 UL/yk4f4bBp5oklRGxzvu5DKG31XCe5i1izML3zQ2Y04Klkj3lcfAG3u05OEhPZm woelfv/s3Umy1Gl5xV2QfiVrocRfWlZvsTP/K+ho05FKhM476XjErn8p8U1U3tjA KbB+EBKV5reZ14gMDwjCN5BnMpddMQleifaEX/4oRwNfw3zzKDcqB34ojOXjVcrS 0GfapPCx64FNHxSeHADQ2O9mzOSxT5cTEzcH9JBFU+p8owmjOImvvcPoYKFOn4My btQeVzoCxeDwmLBrV8peR3nQHEwjxFuWvyhBg0SQy+51DIzhPJZdy/Z8RsrSywnH qoirudXd/rchvUTk/dNxQC6NORuY1IGGi2uJAs4ZRrmC6UqbxjUdB08cyVY4gFj0 H3VMVaWlVWIGsPATrA2Oh0D1wsJBDYynf1oyG8R1NyYu4vCpYKMBAyJlVGlrGgq6 H+fU8BqV+LmXH9ogtk0vhT7sK2dHGSA64JR3q1ralOlQip1CsXVeaN9/B+wfjo+i dL1qwJXkii0yxyVElHTbnugxI60hR2cgkXRnDMgJu5fBPGDdebOGtB1xxDwLnCjH 3yNiU1Eyyer/NbsqxO9ylYPvHeg4RXETHoK0gk+/jyyR0ryfbtE= =j/MW -----END PGP SIGNATURE----- Merge tag 'rust-fixes-6.17-2' of git://git.kernel.org/pub/scm/linux/kernel/git/ojeda/linux Pull rust fixes from Miguel Ojeda: - Two changes to prepare for the future Rust 1.91.0 release (expected 2025-10-30, currently in nightly): a target specification format change and a renamed, soon-to-be-stabilized 'core' function. * tag 'rust-fixes-6.17-2' of git://git.kernel.org/pub/scm/linux/kernel/git/ojeda/linux: rust: support Rust >= 1.91.0 target spec rust: use the new name Location::file_as_c_str() in Rust >= 1.91.0
This commit is contained in:
commit
b236920731
@ -146,6 +146,9 @@ config RUSTC_HAS_UNNECESSARY_TRANSMUTES
|
|||||||
config RUSTC_HAS_FILE_WITH_NUL
|
config RUSTC_HAS_FILE_WITH_NUL
|
||||||
def_bool RUSTC_VERSION >= 108900
|
def_bool RUSTC_VERSION >= 108900
|
||||||
|
|
||||||
|
config RUSTC_HAS_FILE_AS_C_STR
|
||||||
|
def_bool RUSTC_VERSION >= 109100
|
||||||
|
|
||||||
config PAHOLE_VERSION
|
config PAHOLE_VERSION
|
||||||
int
|
int
|
||||||
default $(shell,$(srctree)/scripts/pahole-version.sh $(PAHOLE))
|
default $(shell,$(srctree)/scripts/pahole-version.sh $(PAHOLE))
|
||||||
|
@ -296,7 +296,7 @@ macro_rules! asm {
|
|||||||
|
|
||||||
/// Gets the C string file name of a [`Location`].
|
/// Gets the C string file name of a [`Location`].
|
||||||
///
|
///
|
||||||
/// If `file_with_nul()` is not available, returns a string that warns about it.
|
/// If `Location::file_as_c_str()` is not available, returns a string that warns about it.
|
||||||
///
|
///
|
||||||
/// [`Location`]: core::panic::Location
|
/// [`Location`]: core::panic::Location
|
||||||
///
|
///
|
||||||
@ -310,8 +310,8 @@ macro_rules! asm {
|
|||||||
/// let caller = core::panic::Location::caller();
|
/// let caller = core::panic::Location::caller();
|
||||||
///
|
///
|
||||||
/// // Output:
|
/// // Output:
|
||||||
/// // - A path like "rust/kernel/example.rs" if file_with_nul() is available.
|
/// // - A path like "rust/kernel/example.rs" if `file_as_c_str()` is available.
|
||||||
/// // - "<Location::file_with_nul() not supported>" otherwise.
|
/// // - "<Location::file_as_c_str() not supported>" otherwise.
|
||||||
/// let caller_file = file_from_location(caller);
|
/// let caller_file = file_from_location(caller);
|
||||||
///
|
///
|
||||||
/// // Prints out the message with caller's file name.
|
/// // Prints out the message with caller's file name.
|
||||||
@ -326,7 +326,12 @@ macro_rules! asm {
|
|||||||
/// ```
|
/// ```
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn file_from_location<'a>(loc: &'a core::panic::Location<'a>) -> &'a core::ffi::CStr {
|
pub fn file_from_location<'a>(loc: &'a core::panic::Location<'a>) -> &'a core::ffi::CStr {
|
||||||
#[cfg(CONFIG_RUSTC_HAS_FILE_WITH_NUL)]
|
#[cfg(CONFIG_RUSTC_HAS_FILE_AS_C_STR)]
|
||||||
|
{
|
||||||
|
loc.file_as_c_str()
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(all(CONFIG_RUSTC_HAS_FILE_WITH_NUL, not(CONFIG_RUSTC_HAS_FILE_AS_C_STR)))]
|
||||||
{
|
{
|
||||||
loc.file_with_nul()
|
loc.file_with_nul()
|
||||||
}
|
}
|
||||||
@ -334,6 +339,6 @@ pub fn file_from_location<'a>(loc: &'a core::panic::Location<'a>) -> &'a core::f
|
|||||||
#[cfg(not(CONFIG_RUSTC_HAS_FILE_WITH_NUL))]
|
#[cfg(not(CONFIG_RUSTC_HAS_FILE_WITH_NUL))]
|
||||||
{
|
{
|
||||||
let _ = loc;
|
let _ = loc;
|
||||||
c"<Location::file_with_nul() not supported>"
|
c"<Location::file_as_c_str() not supported>"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -225,7 +225,11 @@ fn main() {
|
|||||||
ts.push("features", features);
|
ts.push("features", features);
|
||||||
ts.push("llvm-target", "x86_64-linux-gnu");
|
ts.push("llvm-target", "x86_64-linux-gnu");
|
||||||
ts.push("supported-sanitizers", ["kcfi", "kernel-address"]);
|
ts.push("supported-sanitizers", ["kcfi", "kernel-address"]);
|
||||||
ts.push("target-pointer-width", "64");
|
if cfg.rustc_version_atleast(1, 91, 0) {
|
||||||
|
ts.push("target-pointer-width", 64);
|
||||||
|
} else {
|
||||||
|
ts.push("target-pointer-width", "64");
|
||||||
|
}
|
||||||
} else if cfg.has("X86_32") {
|
} else if cfg.has("X86_32") {
|
||||||
// This only works on UML, as i386 otherwise needs regparm support in rustc
|
// This only works on UML, as i386 otherwise needs regparm support in rustc
|
||||||
if !cfg.has("UML") {
|
if !cfg.has("UML") {
|
||||||
@ -245,7 +249,11 @@ fn main() {
|
|||||||
}
|
}
|
||||||
ts.push("features", features);
|
ts.push("features", features);
|
||||||
ts.push("llvm-target", "i386-unknown-linux-gnu");
|
ts.push("llvm-target", "i386-unknown-linux-gnu");
|
||||||
ts.push("target-pointer-width", "32");
|
if cfg.rustc_version_atleast(1, 91, 0) {
|
||||||
|
ts.push("target-pointer-width", 32);
|
||||||
|
} else {
|
||||||
|
ts.push("target-pointer-width", "32");
|
||||||
|
}
|
||||||
} else if cfg.has("LOONGARCH") {
|
} else if cfg.has("LOONGARCH") {
|
||||||
panic!("loongarch uses the builtin rustc loongarch64-unknown-none-softfloat target");
|
panic!("loongarch uses the builtin rustc loongarch64-unknown-none-softfloat target");
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user