Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion compiler/rustc_codegen_llvm/src/diagnostics.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::ffi::CString;
use std::ffi::{CString, c_uint};
use std::path::Path;

use rustc_data_structures::small_c_str::SmallCStr;
Expand Down Expand Up @@ -265,3 +265,15 @@ pub(crate) struct IntrinsicWrongArch<'a> {
pub(crate) struct UnknownLlvmTargetFeaturePrefix<'a> {
pub feature: &'a str,
}

#[derive(Diagnostic)]
#[diag(
"LLVM version mismatch: this compiler was built for LLVM {$expected_version}, but LLVM {$llvm_major}.{$llvm_minor}.{$llvm_patch} was found{$dll_loc}"
)]
pub(crate) struct LlvmVersionMismatch<'a> {
pub expected_version: c_uint,
pub llvm_major: c_uint,
pub llvm_minor: c_uint,
pub llvm_patch: c_uint,
pub dll_loc: &'a str,
}
13 changes: 5 additions & 8 deletions compiler/rustc_codegen_llvm/src/llvm_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,20 +56,17 @@ unsafe fn configure_llvm(sess: &Session) {
llvm::LLVMGetVersion(&mut llvm_major, &mut llvm_minor, &mut llvm_patch);
let expected_version = llvm::LLVMRustVersionMajor();
if llvm_major != expected_version {
panic!(
concat!(
"LLVM version mismatch: this compiler was built for LLVM {}, ",
"but LLVM {}.{}.{} was found{}"
),
sess.dcx().emit_fatal(diagnostics::LlvmVersionMismatch {
expected_version,
llvm_major,
llvm_minor,
llvm_patch,
match rustc_session::filesearch::dll_path(llvm::LLVMGetVersion as *mut _) {
dll_loc: &match rustc_session::filesearch::dll_path(llvm::LLVMGetVersion as *mut _)
{
Ok(path) => format!(" at {}", path.display()),
Err(_) => String::new(),
}
);
},
})
}
}

Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_macros/src/diagnostics/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ const ALLOWED_CAPITALIZED_WORDS: &[&str] = &[
"Cargo",
"Ferris",
"GCC",
"LLVM",
"MIR",
"NaNs",
"OK",
Expand Down
Loading