aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Driver/ToolChain.cpp
diff options
context:
space:
mode:
authorSimon Moll <simon.moll@emea.nec.com>2021-12-06 11:00:38 +0100
committerSimon Moll <simon.moll@emea.nec.com>2021-12-06 13:31:51 +0100
commit34a43f2115af79f896c889433c57f3b400e9f2c6 (patch)
treeefffdbce78759fdae0a851dbe206004d86b39c33 /clang/lib/Driver/ToolChain.cpp
parent954582cdfc23a5dd90cb5bf6e5a0c45db300169e (diff)
downloadllvm-34a43f2115af79f896c889433c57f3b400e9f2c6.zip
llvm-34a43f2115af79f896c889433c57f3b400e9f2c6.tar.gz
llvm-34a43f2115af79f896c889433c57f3b400e9f2c6.tar.bz2
[Clang] Ignore CLANG_DEFAULT_LINKER for custom-linker toolchains
Before, the CLANG_DEFAULT_LINKER cmake option was a global override for the linker that shall be used on all toolchains. The linker binary specified that way may not be available on toolchains with custom linkers. Eg, the only linker for VE is named 'nld' - any other linker invalidates the toolchain. This patch removes the hard override and instead lets the generic toolchain implementation default to CLANG_DEFAULT_LINKER. Toolchains can now deviate with a custom linker name or deliberatly default to CLANG_DEFAULT_LINKER. Reviewed By: MaskRay, phosek Differential Revision: https://reviews.llvm.org/D115045
Diffstat (limited to 'clang/lib/Driver/ToolChain.cpp')
-rw-r--r--clang/lib/Driver/ToolChain.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp
index ac033dd..d92cbe2 100644
--- a/clang/lib/Driver/ToolChain.cpp
+++ b/clang/lib/Driver/ToolChain.cpp
@@ -541,6 +541,12 @@ std::string ToolChain::GetProgramPath(const char *Name) const {
return D.GetProgramPath(Name, *this);
}
+const char *ToolChain::getDefaultLinker() const {
+ if (CLANG_DEFAULT_LINKER[0] == '\0')
+ return "ld";
+ return CLANG_DEFAULT_LINKER;
+}
+
std::string ToolChain::GetLinkerPath(bool *LinkerIsLLD) const {
if (LinkerIsLLD)
*LinkerIsLLD = false;
@@ -548,7 +554,7 @@ std::string ToolChain::GetLinkerPath(bool *LinkerIsLLD) const {
// Get -fuse-ld= first to prevent -Wunused-command-line-argument. -fuse-ld= is
// considered as the linker flavor, e.g. "bfd", "gold", or "lld".
const Arg* A = Args.getLastArg(options::OPT_fuse_ld_EQ);
- StringRef UseLinker = A ? A->getValue() : CLANG_DEFAULT_LINKER;
+ StringRef UseLinker = A ? A->getValue() : "";
// --ld-path= takes precedence over -fuse-ld= and specifies the executable
// name. -B, COMPILER_PATH and PATH and consulted if the value does not