diff --git a/compiler/rustc_codegen_llvm/src/llvm/enzyme_ffi.rs b/compiler/rustc_codegen_llvm/src/llvm/enzyme_ffi.rs index 68ec7870811d2..94df0fc270255 100644 --- a/compiler/rustc_codegen_llvm/src/llvm/enzyme_ffi.rs +++ b/compiler/rustc_codegen_llvm/src/llvm/enzyme_ffi.rs @@ -97,7 +97,7 @@ pub(crate) mod Enzyme_AD { use rustc_session::filesearch; use super::{CConcreteType, CTypeTreeRef, Context}; - use crate::llvm::{EnzymeTypeTree, LLVMRustVersionMajor}; + use crate::llvm::{self, EnzymeTypeTree}; type EnzymeSetCLBoolFn = unsafe extern "C" fn(*mut c_void, u8); type EnzymeSetCLStringFn = unsafe extern "C" fn(*mut c_void, *const c_char); @@ -434,7 +434,7 @@ pub(crate) mod Enzyme_AD { } fn get_enzyme_path(sysroot: &Sysroot) -> Result { - let llvm_version_major = unsafe { LLVMRustVersionMajor() }; + let llvm_version_major = llvm::LLVMRustVersionMajor(); let path_buf = sysroot .all_paths() diff --git a/compiler/rustc_codegen_llvm/src/llvm/ffi.rs b/compiler/rustc_codegen_llvm/src/llvm/ffi.rs index c20b4ccd776da..abacef3710f4e 100644 --- a/compiler/rustc_codegen_llvm/src/llvm/ffi.rs +++ b/compiler/rustc_codegen_llvm/src/llvm/ffi.rs @@ -894,7 +894,11 @@ unsafe extern "C" { SLen: c_uint, ) -> MetadataKindId; - pub(crate) fn LLVMGetVersion(major: &mut c_uint, minor: &mut c_uint, patch: &mut c_uint); + /// Gets the actual version of LLVM that we are linked to at runtime. + /// + /// # Safety + /// Can be called without initializing LLVM. + pub(crate) safe fn LLVMGetVersion(major: &mut c_uint, minor: &mut c_uint, patch: &mut c_uint); pub(crate) fn LLVMDisposeTargetMachine(T: ptr::NonNull); @@ -2176,9 +2180,9 @@ unsafe extern "C" { /// Returns the LLVM major version that the compiler was built with. /// /// Note that this is hard-coded as `LLVM_VERSION_MAJOR` when `RustWrapper.cpp` is built. This - /// could be different than what the runtime LLVM library reports in `LLVMGetVersion`, so we + /// could be different than what the runtime LLVM library reports in [`LLVMGetVersion`], so we /// assert their equality in `configure_llvm`. - pub(crate) fn LLVMRustVersionMajor() -> u32; + pub(crate) safe fn LLVMRustVersionMajor() -> u32; /// Add LLVM module flags. /// diff --git a/compiler/rustc_codegen_llvm/src/llvm/offload_ffi.rs b/compiler/rustc_codegen_llvm/src/llvm/offload_ffi.rs index 7ecf450ab1dba..fecb9e40eab88 100644 --- a/compiler/rustc_codegen_llvm/src/llvm/offload_ffi.rs +++ b/compiler/rustc_codegen_llvm/src/llvm/offload_ffi.rs @@ -14,7 +14,7 @@ use rustc_fs_util::path_to_c_string; use rustc_session::config::host_tuple; use rustc_session::filesearch; -use crate::llvm::LLVMRustVersionMajor; +use crate::llvm; pub(crate) struct RustOffloadWrapper { LLVMRustBundleImages: LLVMRustBundleImagesFn, @@ -119,7 +119,7 @@ impl RustOffloadWrapper { fn get_offload_and_lld_paths( sysroot: &rustc_session::config::Sysroot, ) -> Result<(PathBuf, Option), RustOffloadLibraryError> { - let llvm_version_major = unsafe { LLVMRustVersionMajor() }; + let llvm_version_major = llvm::LLVMRustVersionMajor(); let mut searched = Vec::new(); for root in sysroot.all_paths() { diff --git a/compiler/rustc_codegen_llvm/src/llvm_util.rs b/compiler/rustc_codegen_llvm/src/llvm_util.rs index a5441b1ef1135..223cbf2aae31f 100644 --- a/compiler/rustc_codegen_llvm/src/llvm_util.rs +++ b/compiler/rustc_codegen_llvm/src/llvm_util.rs @@ -459,15 +459,13 @@ pub(crate) fn print_version() { println!("LLVM version: {major}.{minor}.{patch}"); } +/// Returns the version of LLVM that we are actually linked to at runtime. pub(crate) fn get_version() -> (u32, u32, u32) { - // Can be called without initializing LLVM - unsafe { - let mut llvm_major = 0; - let mut llvm_minor = 0; - let mut llvm_patch = 0; - llvm::LLVMGetVersion(&mut llvm_major, &mut llvm_minor, &mut llvm_patch); - (llvm_major, llvm_minor, llvm_patch) - } + let mut llvm_major = 0; + let mut llvm_minor = 0; + let mut llvm_patch = 0; + llvm::LLVMGetVersion(&mut llvm_major, &mut llvm_minor, &mut llvm_patch); + (llvm_major, llvm_minor, llvm_patch) } pub(crate) fn print_passes() { diff --git a/src/doc/rustc/src/platform-support/riscv64a23-unknown-linux-gnu.md b/src/doc/rustc/src/platform-support/riscv64a23-unknown-linux-gnu.md index df0c971f249a4..b50ee50db9b11 100644 --- a/src/doc/rustc/src/platform-support/riscv64a23-unknown-linux-gnu.md +++ b/src/doc/rustc/src/platform-support/riscv64a23-unknown-linux-gnu.md @@ -12,7 +12,7 @@ This target will enable all mandatory features of rva23u64 by default. ## Requirements -This target can be sucessfully build on the following platform: ubuntu 24.04 (Linux Kernel version 6.8.0, glibc 2.39). +This target can be successfully built on the following platform: ubuntu 24.04 (Linux Kernel version 6.8.0, glibc 2.39). Other platforms may work, but are not tested. Please contact us if you encounter any issues. diff --git a/tests/ui/associated-types/associated-types-match-despite-generic.rs b/tests/ui/associated-types/associated-types-match-despite-generic.rs new file mode 100644 index 0000000000000..04fc374e59a0c --- /dev/null +++ b/tests/ui/associated-types/associated-types-match-despite-generic.rs @@ -0,0 +1,21 @@ +//! Regression test for . +//@compile-flags: -Znext-solver=globally +//@ check-pass + +struct Outer; +struct Inner; +trait Id { + type This; +} +impl Id for T { + type This = T; +} + +fn free(x: T) -> >::This +where + >::This: Id>::This>, +{ + x +} + +fn main() {} diff --git a/tests/ui/attributes/positions/link-section.rs b/tests/ui/attributes/positions/link-section.rs new file mode 100644 index 0000000000000..a7d39b690664c --- /dev/null +++ b/tests/ui/attributes/positions/link-section.rs @@ -0,0 +1,11 @@ +//! Checks that `link_section` cannot be used on foreign statics. +#![crate_type = "lib"] + +//@ edition:2024 +//@ check-pass +// Regression test for . +unsafe extern "C" { + #[unsafe(link_section = "__DATA,__buffer")] //~ WARN attribute cannot be used on foreign statics + //~| WARN previously accepted + pub static mut a: [u8; 1024]; +} diff --git a/tests/ui/attributes/positions/link-section.stderr b/tests/ui/attributes/positions/link-section.stderr new file mode 100644 index 0000000000000..56aa525e72387 --- /dev/null +++ b/tests/ui/attributes/positions/link-section.stderr @@ -0,0 +1,12 @@ +warning: the `link_section` attribute cannot be used on foreign statics + --> $DIR/link-section.rs:8:14 + | +LL | #[unsafe(link_section = "__DATA,__buffer")] + | ^^^^^^^^^^^^ + | + = help: the `link_section` attribute can be applied to functions and statics + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: requested on the command line with `-W unused-attributes` + +warning: 1 warning emitted +