Skip to content

Commit 2915d3a

Browse files
committed
IRGen: Work around rdar://problem/53836960
On i386 Darwin, the linker appears to garble indirect symbolic references.
1 parent f0e5e19 commit 2915d3a

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

lib/IRGen/GenDecl.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
#include "llvm/Support/ConvertUTF.h"
4848
#include "llvm/Support/Path.h"
4949
#include "llvm/Support/SaveAndRestore.h"
50+
#include "llvm/Target/TargetMachine.h"
5051
#include "llvm/Transforms/Utils/ModuleUtils.h"
5152

5253
#include "Callee.h"
@@ -2570,7 +2571,11 @@ static llvm::GlobalVariable *createGOTEquivalent(IRGenModule &IGM,
25702571
// rdar://problem/50968433: Unnamed_addr constants appear to get emitted
25712572
// with incorrect alignment by the LLVM JIT in some cases. Don't use
25722573
// unnamed_addr as a workaround.
2573-
if (!IGM.getOptions().UseJIT) {
2574+
// rdar://problem/53836960: i386 ld64 also mis-links relative references
2575+
// to GOT entries.
2576+
if (!IGM.getOptions().UseJIT
2577+
&& (!IGM.Triple.isOSDarwin()
2578+
|| IGM.Triple.getArch() != llvm::Triple::x86)) {
25742579
gotEquivalent->setUnnamedAddr(llvm::GlobalValue::UnnamedAddr::Global);
25752580
} else {
25762581
ApplyIRLinkage(IRLinkage::InternalLinkOnceODR)

0 commit comments

Comments
 (0)