Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

+23 -7
+3
init/Kconfig
··· 146 146 config RUSTC_HAS_FILE_WITH_NUL 147 147 def_bool RUSTC_VERSION >= 108900 148 148 149 + config RUSTC_HAS_FILE_AS_C_STR 150 + def_bool RUSTC_VERSION >= 109100 151 + 149 152 config PAHOLE_VERSION 150 153 int 151 154 default $(shell,$(srctree)/scripts/pahole-version.sh $(PAHOLE))
+10 -5
rust/kernel/lib.rs
··· 296 296 297 297 /// Gets the C string file name of a [`Location`]. 298 298 /// 299 - /// If `file_with_nul()` is not available, returns a string that warns about it. 299 + /// If `Location::file_as_c_str()` is not available, returns a string that warns about it. 300 300 /// 301 301 /// [`Location`]: core::panic::Location 302 302 /// ··· 310 310 /// let caller = core::panic::Location::caller(); 311 311 /// 312 312 /// // Output: 313 - /// // - A path like "rust/kernel/example.rs" if file_with_nul() is available. 314 - /// // - "<Location::file_with_nul() not supported>" otherwise. 313 + /// // - A path like "rust/kernel/example.rs" if `file_as_c_str()` is available. 314 + /// // - "<Location::file_as_c_str() not supported>" otherwise. 315 315 /// let caller_file = file_from_location(caller); 316 316 /// 317 317 /// // Prints out the message with caller's file name. ··· 326 326 /// ``` 327 327 #[inline] 328 328 pub fn file_from_location<'a>(loc: &'a core::panic::Location<'a>) -> &'a core::ffi::CStr { 329 - #[cfg(CONFIG_RUSTC_HAS_FILE_WITH_NUL)] 329 + #[cfg(CONFIG_RUSTC_HAS_FILE_AS_C_STR)] 330 + { 331 + loc.file_as_c_str() 332 + } 333 + 334 + #[cfg(all(CONFIG_RUSTC_HAS_FILE_WITH_NUL, not(CONFIG_RUSTC_HAS_FILE_AS_C_STR)))] 330 335 { 331 336 loc.file_with_nul() 332 337 } ··· 339 334 #[cfg(not(CONFIG_RUSTC_HAS_FILE_WITH_NUL))] 340 335 { 341 336 let _ = loc; 342 - c"<Location::file_with_nul() not supported>" 337 + c"<Location::file_as_c_str() not supported>" 343 338 } 344 339 }
+10 -2
scripts/generate_rust_target.rs
··· 225 225 ts.push("features", features); 226 226 ts.push("llvm-target", "x86_64-linux-gnu"); 227 227 ts.push("supported-sanitizers", ["kcfi", "kernel-address"]); 228 - ts.push("target-pointer-width", "64"); 228 + if cfg.rustc_version_atleast(1, 91, 0) { 229 + ts.push("target-pointer-width", 64); 230 + } else { 231 + ts.push("target-pointer-width", "64"); 232 + } 229 233 } else if cfg.has("X86_32") { 230 234 // This only works on UML, as i386 otherwise needs regparm support in rustc 231 235 if !cfg.has("UML") { ··· 249 245 } 250 246 ts.push("features", features); 251 247 ts.push("llvm-target", "i386-unknown-linux-gnu"); 252 - ts.push("target-pointer-width", "32"); 248 + if cfg.rustc_version_atleast(1, 91, 0) { 249 + ts.push("target-pointer-width", 32); 250 + } else { 251 + ts.push("target-pointer-width", "32"); 252 + } 253 253 } else if cfg.has("LOONGARCH") { 254 254 panic!("loongarch uses the builtin rustc loongarch64-unknown-none-softfloat target"); 255 255 } else {