Skip to content

Commit c33f0b3

Browse files
authored
Rollup merge of #147446 - durin42:llvm-22-lookupTarget-deprecation, r=Zalathar
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
2 parents bd34871 + eb20c6a commit c33f0b3

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,11 @@ extern "C" LLVMTargetMachineRef LLVMRustCreateTargetMachine(
283283
std::string Error;
284284
auto Trip = Triple(Triple::normalize(TripleStr));
285285
const llvm::Target *TheTarget =
286+
#if LLVM_VERSION_GE(21, 0)
287+
TargetRegistry::lookupTarget(Trip, Error);
288+
#else
286289
TargetRegistry::lookupTarget(Trip.getTriple(), Error);
290+
#endif
287291
if (TheTarget == nullptr) {
288292
LLVMRustSetLastError(Error.c_str());
289293
return nullptr;

0 commit comments

Comments
 (0)