Skip to content

Commit 2aedfdd

Browse files
committed
[CodeGen] Default TargetOptions::RelaxELFRelocations to true
MC and lld/ELF defaults were flipped in 2016. For Clang: CMake ENABLE_X86_RELAX_RELOCATIONS defaults to on in 2020. It makes sense for the TargetOptions default to be true now. R_X86_64_GOTPCRELX/R_X86_64_REX_GOTPCRELX require GNU ld newer than 2015-10 (subsumed by the current requirement of -fbinutils-version=). This should fix `rustc -Z plt=no` PIC relocatable files with GNU ld. (See rust-lang/rust#106380)
1 parent 5751c43 commit 2aedfdd

File tree

5 files changed

+4
-5
lines changed

5 files changed

+4
-5
lines changed

Diff for: lld/ELF/LTO.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ static lto::Config createConfig() {
7777

7878
// LLD supports the new relocations and address-significance tables.
7979
c.Options = initTargetOptionsFromCodeGenFlags();
80-
c.Options.RelaxELFRelocations = true;
8180
c.Options.EmitAddrsig = true;
8281
for (StringRef C : config->mllvmOpts)
8382
c.MllvmArgs.emplace_back(C.str());

Diff for: llvm/include/llvm/Target/TargetOptions.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ namespace llvm {
131131
GuaranteedTailCallOpt(false), StackSymbolOrdering(true),
132132
EnableFastISel(false), EnableGlobalISel(false), UseInitArray(false),
133133
LowerGlobalDtorsViaCxaAtExit(false), DisableIntegratedAS(false),
134-
RelaxELFRelocations(false), FunctionSections(false),
134+
RelaxELFRelocations(true), FunctionSections(false),
135135
DataSections(false), IgnoreXCOFFVisibility(false),
136136
XCOFFTracebackTable(true), UniqueSectionNames(true),
137137
UniqueBasicBlockSectionNames(false), TrapUnreachable(false),

Diff for: llvm/lib/CodeGen/CommandFlags.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ codegen::RegisterCodeGenFlags::RegisterCodeGenFlags() {
359359
"relax-elf-relocations",
360360
cl::desc(
361361
"Emit GOTPCRELX/REX_GOTPCRELX instead of GOTPCREL on x86-64 ELF"),
362-
cl::init(false));
362+
cl::init(true));
363363
CGBINDOPT(RelaxELFRelocations);
364364

365365
static cl::opt<bool> DataSections(

Diff for: llvm/test/LTO/Resolution/X86/not-prevailing-variables.ll

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
; CHECK-NEXT: retq
1414
; CHECK: <testVar2>:
1515
; CHECK-NEXT: movq (%rip), %rax
16-
; CHECK-NEXT: R_X86_64_GOTPCREL var2-0x4
16+
; CHECK-NEXT: R_X86_64_REX_GOTPCRELX var2-0x4
1717
; CHECK-NEXT: movl (%rax), %eax
1818
; CHECK-NEXT: retq
1919

Diff for: llvm/test/ThinLTO/X86/cache-config.ll

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
; RUN: llvm-lto2 run -o %t.o %t.bc -cache-dir %t.cache -r=%t.bc,globalfunc,plx
55
; RUN: llvm-lto2 run -o %t.o %t.bc -cache-dir %t.cache -r=%t.bc,globalfunc,plx -mcpu=core2
6-
; RUN: llvm-lto2 run -o %t.o %t.bc -cache-dir %t.cache -r=%t.bc,globalfunc,plx -relax-elf-relocations
6+
; RUN: llvm-lto2 run -o %t.o %t.bc -cache-dir %t.cache -r=%t.bc,globalfunc,plx -relax-elf-relocations=0
77
; RUN: llvm-lto2 run -o %t.o %t.bc -cache-dir %t.cache -r=%t.bc,globalfunc,plx -function-sections
88
; RUN: llvm-lto2 run -o %t.o %t.bc -cache-dir %t.cache -r=%t.bc,globalfunc,plx -data-sections
99
; RUN: llvm-lto2 run -o %t.o %t.bc -cache-dir %t.cache -r=%t.bc,globalfunc,plx -debugger-tune=sce

0 commit comments

Comments
 (0)