From eb20c6abd6b7282c3636c97870ae4e8c50d76632 Mon Sep 17 00:00:00 2001 From: Augie Fackler Date: Tue, 7 Oct 2025 11:02:13 -0400 Subject: [PATCH] PassWrapper: use non-deprecated lookupTarget method This avoids an extra trip through a triple string by directly passing the Triple, and has been available since LLVM 21. The string overload was deprecated today and throws an error on our CI for HEAD due to -Werror paranoia, so we may as well clean this up now and also skip the conversion on LLVM 21 since we can. @rustbot label llvm-main --- compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp b/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp index 2e9fd6754f12..8d9c4b48b5c4 100644 --- a/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp +++ b/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp @@ -283,7 +283,11 @@ extern "C" LLVMTargetMachineRef LLVMRustCreateTargetMachine( std::string Error; auto Trip = Triple(Triple::normalize(TripleStr)); const llvm::Target *TheTarget = +#if LLVM_VERSION_GE(21, 0) + TargetRegistry::lookupTarget(Trip, Error); +#else TargetRegistry::lookupTarget(Trip.getTriple(), Error); +#endif if (TheTarget == nullptr) { LLVMRustSetLastError(Error.c_str()); return nullptr;