aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Driver/ToolChain.cpp
diff options
context:
space:
mode:
authorRainer Orth <ro@gcc.gnu.org>2020-08-13 22:42:58 +0200
committerRainer Orth <ro@gcc.gnu.org>2020-08-13 22:42:58 +0200
commitf59bec7acb8228fc215fca3ee1e524c38083c50b (patch)
tree4da3f9daa8c9cf6b7ca7d41f5885620e55a12dfb /clang/lib/Driver/ToolChain.cpp
parent18910c4cb5d4e59ef25f4b8b48fcbd3146833645 (diff)
downloadllvm-f59bec7acb8228fc215fca3ee1e524c38083c50b.zip
llvm-f59bec7acb8228fc215fca3ee1e524c38083c50b.tar.gz
llvm-f59bec7acb8228fc215fca3ee1e524c38083c50b.tar.bz2
[clang][Driver] Default to /usr/bin/ld on Solaris
`clang` currently requires the native linker on Solaris: - It passes `-C` to `ld` which GNU `ld` doesn't understand. - To use `gld`, one needs to pass the correct `-m EMU` option to select the right emulation. Solaris `ld` cannot handle that option. So far I've worked around this by passing `-DCLANG_DEFAULT_LINKER=/usr/bin/ld` to `cmake`. However, if someone forgets this, it depends on the user's `PATH` whether or not `clang` finds the correct linker, which doesn't make for a good user experience. While it would be nice to detect the linker flavor at runtime, this is more involved. Instead, this patch defaults to `/usr/bin/ld` on Solaris. This doesn't work on its own, however: a link fails with clang-12: error: unable to execute command: Executable "x86_64-pc-solaris2.11-/usr/bin/ld" doesn't exist! I avoid this by leaving absolute paths alone in `ToolChain::GetLinkerPath`. Tested on `amd64-pc-solaris2.11`, `sparcv9-sun-solaris2.11`, and `x86_64-pc-linux-gnu`. Differential Revision: https://reviews.llvm.org/D84029
Diffstat (limited to 'clang/lib/Driver/ToolChain.cpp')
-rw-r--r--clang/lib/Driver/ToolChain.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp
index 2984537..7be83ca 100644
--- a/clang/lib/Driver/ToolChain.cpp
+++ b/clang/lib/Driver/ToolChain.cpp
@@ -568,8 +568,13 @@ std::string ToolChain::GetLinkerPath() const {
}
// If we're passed -fuse-ld= with no argument, or with the argument ld,
// then use whatever the default system linker is.
- if (UseLinker.empty() || UseLinker == "ld")
- return GetProgramPath(getDefaultLinker());
+ if (UseLinker.empty() || UseLinker == "ld") {
+ const char *DefaultLinker = getDefaultLinker();
+ if (llvm::sys::path::is_absolute(DefaultLinker))
+ return std::string(DefaultLinker);
+ else
+ return GetProgramPath(DefaultLinker);
+ }
// Extending -fuse-ld= to an absolute or relative path is unexpected. Checking
// for the linker flavor is brittle. In addition, prepending "ld." or "ld64."