[PATCH] D39831: [Driver] Make the use of relax relocations a per target option
Petr Hosek via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Nov 9 00:33:14 PST 2017
phosek created this revision.
Herald added a subscriber: mgorny.
The support for relax relocations is dependent on the linker and
different toolchains within the same compiler can be using different
linkers some of which may or may not support relax relocations.
Give toolchains the option to control whether they want to use relax
relocations in addition to the existing (global) build system option.
Repository:
rL LLVM
https://reviews.llvm.org/D39831
Files:
cmake/caches/Fuchsia-stage2.cmake
include/clang/Driver/ToolChain.h
lib/Driver/ToolChain.cpp
lib/Driver/ToolChains/Clang.cpp
lib/Driver/ToolChains/Fuchsia.h
Index: lib/Driver/ToolChains/Fuchsia.h
===================================================================
--- lib/Driver/ToolChains/Fuchsia.h
+++ lib/Driver/ToolChains/Fuchsia.h
@@ -43,6 +43,7 @@
bool HasNativeLLVMSupport() const override { return true; }
bool IsIntegratedAssemblerDefault() const override { return true; }
bool IsMathErrnoDefault() const override { return false; }
+ bool useRelaxRelocations() const override { return true; };
RuntimeLibType GetDefaultRuntimeLibType() const override {
return ToolChain::RLT_CompilerRT;
}
Index: lib/Driver/ToolChains/Clang.cpp
===================================================================
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -1885,7 +1885,7 @@
// arg after parsing the '-I' arg.
bool TakeNextArg = false;
- bool UseRelaxRelocations = ENABLE_X86_RELAX_RELOCATIONS;
+ bool UseRelaxRelocations = C.getDefaultToolChain().useRelaxRelocations();
const char *MipsTargetFeature = nullptr;
for (const Arg *A :
Args.filtered(options::OPT_Wa_COMMA, options::OPT_Xassembler)) {
Index: lib/Driver/ToolChain.cpp
===================================================================
--- lib/Driver/ToolChain.cpp
+++ lib/Driver/ToolChain.cpp
@@ -90,6 +90,10 @@
IsIntegratedAssemblerDefault());
}
+bool ToolChain::useRelaxRelocations() const {
+ return ENABLE_X86_RELAX_RELOCATIONS;
+}
+
const SanitizerArgs& ToolChain::getSanitizerArgs() const {
if (!SanitizerArguments.get())
SanitizerArguments.reset(new SanitizerArgs(*this, Args));
Index: include/clang/Driver/ToolChain.h
===================================================================
--- include/clang/Driver/ToolChain.h
+++ include/clang/Driver/ToolChain.h
@@ -310,6 +310,9 @@
/// mixed dispatch method be used?
virtual bool UseObjCMixedDispatch() const { return false; }
+ /// \brief Check whether to enable x86 relax relocations by default.
+ virtual bool useRelaxRelocations() const;
+
/// GetDefaultStackProtectorLevel - Get the default stack protector level for
/// this tool chain (0=off, 1=on, 2=strong, 3=all).
virtual unsigned GetDefaultStackProtectorLevel(bool KernelOrKext) const {
Index: cmake/caches/Fuchsia-stage2.cmake
===================================================================
--- cmake/caches/Fuchsia-stage2.cmake
+++ cmake/caches/Fuchsia-stage2.cmake
@@ -18,13 +18,6 @@
set(CLANG_DEFAULT_LINKER lld CACHE STRING "")
endif()
-# This is a "Does your linker support it?" option that only applies
-# to x86-64 ELF targets. All Fuchsia target linkers do support it.
-# For x86-64 Linux, it's supported by LLD and by GNU linkers since
-# binutils 2.27, so one can hope that all Linux hosts in use handle it.
-# Ideally this would be settable as a per-target option.
-set(ENABLE_X86_RELAX_RELOCATIONS ON CACHE BOOL "")
-
if(APPLE)
set(LLDB_CODESIGN_IDENTITY "" CACHE STRING "")
endif()
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D39831.122204.patch
Type: text/x-patch
Size: 2958 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20171109/7b22a838/attachment.bin>
More information about the cfe-commits
mailing list