From 4e4bed8684a7144c82ea95aa013e7911dd9fe20d Mon Sep 17 00:00:00 2001 From: Zequan Wu Date: Thu, 6 Mar 2025 16:24:40 -0800 Subject: [PATCH 1/2] setTargetTriple now accepts Triple rather than string --- compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp b/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp index aea2a8dd09787..6d01095cccad6 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) { From 8814679a5410b8d9ce8385094ec8ec888395b1a5 Mon Sep 17 00:00:00 2001 From: Zequan Wu Date: Thu, 6 Mar 2025 22:52:20 -0800 Subject: [PATCH 2/2] rename Triple to Target --- compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp b/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp index 6d01095cccad6..53df59930f4fd 100644 --- a/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp +++ b/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp @@ -152,11 +152,11 @@ extern "C" LLVMContextRef LLVMRustContextCreate(bool shouldDiscardNames) { } extern "C" void LLVMRustSetNormalizedTarget(LLVMModuleRef M, - const char *Triple) { + const char *Target) { #if LLVM_VERSION_GE(21, 0) - unwrap(M)->setTargetTriple(llvm::Triple(Triple::normalize(Triple))); + unwrap(M)->setTargetTriple(Triple(Triple::normalize(Target))); #else - unwrap(M)->setTargetTriple(Triple::normalize(Triple)); + unwrap(M)->setTargetTriple(Triple::normalize(Target)); #endif }