Skip to content

Commit 6ba0f08

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 4ee2a50 commit 6ba0f08

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
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
@@ -276,13 +276,15 @@ void AArch64TargetMachine::reset() { SubtargetMap.clear(); }
276276
//===----------------------------------------------------------------------===//
277277
// AArch64 Lowering public interface.
278278
//===----------------------------------------------------------------------===//
279-
static std::unique_ptr<TargetLoweringObjectFile> createTLOF(const Triple &TT) {
279+
static std::unique_ptr<TargetLoweringObjectFile>
280+
createTLOF(const Triple &TT, const TargetOptions &Options) {
280281
if (TT.isOSBinFormatMachO())
281282
return std::make_unique<AArch64_MachoTargetObjectFile>();
282283
if (TT.isOSBinFormatCOFF())
283284
return std::make_unique<AArch64_COFFTargetObjectFile>();
284285

285-
return std::make_unique<AArch64_ELFTargetObjectFile>();
286+
return std::make_unique<AArch64_ELFTargetObjectFile>(
287+
Options.SupportIndirectSymViaGOTPCRel_AArch64_ELF);
286288
}
287289

288290
// Helper function to build a DataLayout string
@@ -362,7 +364,7 @@ AArch64TargetMachine::AArch64TargetMachine(const Target &T, const Triple &TT,
362364
computeDefaultCPU(TT, CPU), FS, Options,
363365
getEffectiveRelocModel(TT, RM),
364366
getEffectiveAArch64CodeModel(TT, CM, JIT), OL),
365-
TLOF(createTLOF(getTargetTriple())), isLittle(LittleEndian) {
367+
TLOF(createTLOF(getTargetTriple(), Options)), isLittle(LittleEndian) {
366368
initAsmInfo();
367369

368370
if (TT.isOSBinFormatMachO()) {

llvm/lib/Target/AArch64/AArch64TargetObjectFile.h

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

2222
public:
23-
AArch64_ELFTargetObjectFile() {
23+
AArch64_ELFTargetObjectFile(bool SupportIndirectSymViaGOTPCRel) {
2424
PLTRelativeSpecifier = MCSymbolRefExpr::VK_PLT;
25-
SupportIndirectSymViaGOTPCRel = true;
25+
this->SupportIndirectSymViaGOTPCRel = SupportIndirectSymViaGOTPCRel;
2626
}
2727

2828
const MCExpr *getIndirectSymViaGOTPCRel(const GlobalValue *GV,

0 commit comments

Comments
 (0)