Skip to content

Commit e0a5089

Browse files
Rollup merge of rust-lang#158568 - liza371:llvm-23-compat, r=nikic
llvm-wrapper: use accessors for private fields in LLVM 23+ In LLVM, FeatureKV/SubtargetKV pointers are now private: llvm/llvm-project#206237 This change fixes compiler errors when building rustc with ToT LLVM by using the key() and desc() accessors.
2 parents 4774e2c + a60be48 commit e0a5089

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,11 @@ extern "C" void LLVMRustPrintTargetCPUs(LLVMTargetMachineRef TM,
288288
// Just print a bare list of target CPU names, and let Rust-side code handle
289289
// the full formatting of `--print=target-cpus`.
290290
for (auto &CPU : CPUTable) {
291+
#if LLVM_VERSION_GE(23, 0)
292+
OS << CPU.key() << "\n";
293+
#else
291294
OS << CPU.Key << "\n";
295+
#endif
292296
}
293297
}
294298

@@ -315,9 +319,15 @@ extern "C" void LLVMRustGetTargetFeature(LLVMTargetMachineRef TM, size_t Index,
315319
#endif
316320
const ArrayRef<SubtargetFeatureKV> FeatTable =
317321
MCInfo.getAllProcessorFeatures();
322+
#if LLVM_VERSION_GE(23, 0)
323+
const SubtargetFeatureKV &Feat = FeatTable[Index];
324+
*Feature = Feat.key();
325+
*Desc = Feat.desc();
326+
#else
318327
const SubtargetFeatureKV Feat = FeatTable[Index];
319328
*Feature = Feat.Key;
320329
*Desc = Feat.Desc;
330+
#endif
321331
}
322332

323333
extern "C" const char *LLVMRustGetHostCPUName(size_t *OutLen) {

0 commit comments

Comments
 (0)