Skip to content

Commit 7e143e9

Browse files
authored
Rollup merge of #110755 - TimNN:exp-tls, r=durin42
[LLVM17] Adapt to `ExplicitEmulatedTLS` removal. llvm/llvm-project@0d333bf removed the `ExplicitEmulatedTLS` field from `TargetOptions`. Before that commit, `TargetMachine::useEmulatedTLS()` fell back to `TheTriple.hasDefaultEmulatedTLS()` if `ExplicitEmulatedTLS` was `false`/unset. After that commit, `TargetMachine::useEmulatedTLS()` directly returns `Options.EmulatedTLS`, and the fallback to `TheTriple.hasDefaultEmulatedTLS()` was moved to `InitTargetOptionsFromCodeGenFlags`. Since `rustc` does not use `InitTargetOptionsFromCodeGenFlags` (AFAICT) and instead manually builds `TargetOptions`, this PR initializes `EmulatedTLS` to `TheTriple.hasDefaultEmulatedTLS()`. (I'm not really familiar with the details of what this option does, or if there are any tests that depend on `hasDefaultEmulatedTLS` being used correctly, so this PR is mostly untested (it does compile against LLVM17, though)). `@rustbot` label: +llvm-main
2 parents 5f33a8c + 047ed32 commit 7e143e9

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -410,10 +410,15 @@ extern "C" LLVMTargetMachineRef LLVMRustCreateTargetMachine(
410410
}
411411
Options.RelaxELFRelocations = RelaxELFRelocations;
412412
Options.UseInitArray = UseInitArray;
413+
414+
#if LLVM_VERSION_LT(17, 0)
413415
if (ForceEmulatedTls) {
414416
Options.ExplicitEmulatedTLS = true;
415417
Options.EmulatedTLS = true;
416418
}
419+
#else
420+
Options.EmulatedTLS = ForceEmulatedTls || Trip.hasDefaultEmulatedTLS();
421+
#endif
417422

418423
if (TrapUnreachable) {
419424
// Tell LLVM to codegen `unreachable` into an explicit trap instruction.

0 commit comments

Comments
 (0)