diff --git a/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp b/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp index aea2a8dd0978..6d01095cccad 100644 --- a/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp +++ b/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp @@ -153,7 +153,11 @@ extern "C" LLVMContextRef LLVMRustContextCreate(bool shouldDiscardNames) { extern "C" void LLVMRustSetNormalizedTarget(LLVMModuleRef M, const char *Triple) { +#if LLVM_VERSION_GE(21, 0) + unwrap(M)->setTargetTriple(llvm::Triple(Triple::normalize(Triple))); +#else unwrap(M)->setTargetTriple(Triple::normalize(Triple)); +#endif } extern "C" void LLVMRustPrintPassTimings(RustStringRef OutBuf) {