diff options
| -rw-r--r-- | clang/cmake/caches/Fuchsia-stage2.cmake | 7 | ||||
| -rw-r--r-- | clang/include/clang/Driver/ToolChain.h | 3 | ||||
| -rw-r--r-- | clang/lib/Driver/ToolChain.cpp | 4 | ||||
| -rw-r--r-- | clang/lib/Driver/ToolChains/Clang.cpp | 2 | ||||
| -rw-r--r-- | clang/lib/Driver/ToolChains/Fuchsia.h | 1 | ||||
| -rw-r--r-- | clang/test/Driver/fuchsia.c | 1 |
6 files changed, 10 insertions, 8 deletions
diff --git a/clang/cmake/caches/Fuchsia-stage2.cmake b/clang/cmake/caches/Fuchsia-stage2.cmake index d2f19fd6d04..b5841e257fc 100644 --- a/clang/cmake/caches/Fuchsia-stage2.cmake +++ b/clang/cmake/caches/Fuchsia-stage2.cmake @@ -18,13 +18,6 @@ if(NOT APPLE) 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() diff --git a/clang/include/clang/Driver/ToolChain.h b/clang/include/clang/Driver/ToolChain.h index 1206794e93d..bd710387980 100644 --- a/clang/include/clang/Driver/ToolChain.h +++ b/clang/include/clang/Driver/ToolChain.h @@ -316,6 +316,9 @@ public: /// 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 { diff --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp index fac0a5bbff5..741f4284cbb 100644 --- a/clang/lib/Driver/ToolChain.cpp +++ b/clang/lib/Driver/ToolChain.cpp @@ -90,6 +90,10 @@ bool ToolChain::useIntegratedAs() const { IsIntegratedAssemblerDefault()); } +bool ToolChain::useRelaxRelocations() const { + return ENABLE_X86_RELAX_RELOCATIONS; +} + const SanitizerArgs& ToolChain::getSanitizerArgs() const { if (!SanitizerArguments.get()) SanitizerArguments.reset(new SanitizerArgs(*this, Args)); diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp index 3ab28d471be..d96664cf0be 100644 --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/lib/Driver/ToolChains/Clang.cpp @@ -1869,7 +1869,7 @@ static void CollectArgsForIntegratedAssembler(Compilation &C, // 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)) { diff --git a/clang/lib/Driver/ToolChains/Fuchsia.h b/clang/lib/Driver/ToolChains/Fuchsia.h index 6d825fb8179..6f438deca7f 100644 --- a/clang/lib/Driver/ToolChains/Fuchsia.h +++ b/clang/lib/Driver/ToolChains/Fuchsia.h @@ -43,6 +43,7 @@ public: 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; } diff --git a/clang/test/Driver/fuchsia.c b/clang/test/Driver/fuchsia.c index 3f5597c36ef..eb413b7509b 100644 --- a/clang/test/Driver/fuchsia.c +++ b/clang/test/Driver/fuchsia.c @@ -5,6 +5,7 @@ // RUN: --sysroot=%S/platform 2>&1 \ // RUN: | FileCheck -check-prefixes=CHECK,CHECK-AARCH64 %s // CHECK: {{.*}}clang{{.*}}" "-cc1" +// CHECK: "--mrelax-relocations" // CHECK: "-munwind-tables" // CHECK: "-fuse-init-array" // CHECK: "-isysroot" "[[SYSROOT:[^"]+]]" |

