Skip to content

Commit 7708d30

Browse files
committed
Target: Add target option for disabling AArch64_ELFTargetObjectFile::SupportIndirectSymViaGOTPCRel
The Swift compiler needs to disable this option in order for the standard library to link successfully on Linux. See: - #9339 - llvm#78003
1 parent 5bea56e commit 7708d30

File tree

4 files changed

+14
-4
lines changed

4 files changed

+14
-4
lines changed

llvm/include/llvm/Target/TargetOptions.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ namespace llvm {
154154
XRayFunctionIndex(true), DebugStrictDwarf(false), Hotpatch(false),
155155
PPCGenScalarMASSEntries(false), JMCInstrument(false),
156156
EnableCFIFixup(false), MisExpect(false), XCOFFReadOnlyPointers(false),
157+
SupportIndirectSymViaGOTPCRel_AArch64_ELF(true),
157158
VerifyArgABICompliance(true),
158159
FPDenormalMode(DenormalMode::IEEE, DenormalMode::IEEE) {}
159160

@@ -389,6 +390,10 @@ namespace llvm {
389390
/// into the RO data section.
390391
unsigned XCOFFReadOnlyPointers : 1;
391392

393+
/// When set to true, enables indirect symbol replacement with GOTPCREL for
394+
/// AArch64/ELF.
395+
unsigned SupportIndirectSymViaGOTPCRel_AArch64_ELF : 1;
396+
392397
/// When set to true, call/return argument extensions of narrow integers
393398
/// are verified in the target backend if it cares about them. This is
394399
/// not done with internal tools like llc that run many tests that ignore

llvm/lib/Target/AArch64/AArch64TargetMachine.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -278,13 +278,15 @@ void AArch64TargetMachine::reset() { SubtargetMap.clear(); }
278278
//===----------------------------------------------------------------------===//
279279
// AArch64 Lowering public interface.
280280
//===----------------------------------------------------------------------===//
281-
static std::unique_ptr<TargetLoweringObjectFile> createTLOF(const Triple &TT) {
281+
static std::unique_ptr<TargetLoweringObjectFile>
282+
createTLOF(const Triple &TT, const TargetOptions &Options) {
282283
if (TT.isOSBinFormatMachO())
283284
return std::make_unique<AArch64_MachoTargetObjectFile>();
284285
if (TT.isOSBinFormatCOFF())
285286
return std::make_unique<AArch64_COFFTargetObjectFile>();
286287

287-
return std::make_unique<AArch64_ELFTargetObjectFile>();
288+
return std::make_unique<AArch64_ELFTargetObjectFile>(
289+
Options.SupportIndirectSymViaGOTPCRel_AArch64_ELF);
288290
}
289291

290292
// Helper function to build a DataLayout string
@@ -365,7 +367,7 @@ AArch64TargetMachine::AArch64TargetMachine(const Target &T, const Triple &TT,
365367
computeDefaultCPU(TT, CPU), FS, Options,
366368
getEffectiveRelocModel(TT, RM),
367369
getEffectiveAArch64CodeModel(TT, CM, JIT), OL),
368-
TLOF(createTLOF(getTargetTriple())), isLittle(LittleEndian) {
370+
TLOF(createTLOF(getTargetTriple(), Options)), isLittle(LittleEndian) {
369371
initAsmInfo();
370372

371373
if (TT.isOSBinFormatMachO()) {

llvm/lib/Target/AArch64/AArch64TargetObjectFile.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ void AArch64_ELFTargetObjectFile::Initialize(MCContext &Ctx,
2727
const TargetMachine &TM) {
2828
TargetLoweringObjectFileELF::Initialize(Ctx, TM);
2929
PLTRelativeSpecifier = AArch64MCExpr::VK_PLT;
30-
SupportIndirectSymViaGOTPCRel = true;
3130

3231
// AARCH64 ELF ABI does not define static relocation type for TLS offset
3332
// within a module. Do not generate AT_location for TLS variables.

llvm/lib/Target/AArch64/AArch64TargetObjectFile.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ class AArch64_ELFTargetObjectFile : public TargetLoweringObjectFileELF {
2020
void Initialize(MCContext &Ctx, const TargetMachine &TM) override;
2121

2222
public:
23+
AArch64_ELFTargetObjectFile(bool SupportIndirectSymViaGOTPCRel) {
24+
this->SupportIndirectSymViaGOTPCRel = SupportIndirectSymViaGOTPCRel;
25+
}
26+
2327
const MCExpr *getIndirectSymViaGOTPCRel(const GlobalValue *GV,
2428
const MCSymbol *Sym,
2529
const MCValue &MV, int64_t Offset,

0 commit comments

Comments
 (0)