Skip to content

Commit fa68daf

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 fa68daf

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

llvm/include/llvm/Target/TargetOptions.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,10 @@ namespace llvm {
389389
/// into the RO data section.
390390
unsigned XCOFFReadOnlyPointers : 1;
391391

392+
/// When set to true, enables indirect symbol replacement with GOTPCREL for
393+
/// AArch64/ELF.
394+
unsigned SupportIndirectSymViaGOTPCRel_AArch64_ELF : 1;
395+
392396
/// When set to true, call/return argument extensions of narrow integers
393397
/// are verified in the target backend if it cares about them. This is
394398
/// 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)