aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Driver/ToolChain.cpp
diff options
context:
space:
mode:
authorNico Weber <thakis@chromium.org>2020-11-20 13:57:44 -0500
committerNico Weber <thakis@chromium.org>2020-11-24 08:51:58 -0500
commite16c0a9a689719f379e49d0a05cb58774cce4adb (patch)
treea5a467839745523b51d03b11a7f026e0c1b34287 /clang/lib/Driver/ToolChain.cpp
parent32d9a386bf8f447dbbfaf55f6fef4fea4463205b (diff)
downloadllvm-e16c0a9a689719f379e49d0a05cb58774cce4adb.zip
llvm-e16c0a9a689719f379e49d0a05cb58774cce4adb.tar.gz
llvm-e16c0a9a689719f379e49d0a05cb58774cce4adb.tar.bz2
clang+lld: Improve clang+ld.darwinnew.lld interaction, pass -demangle
This patch: - adds an ld64.lld.darwinnew symlink for lld, to go with f2710d4b576, so that `clang -fuse-ld=lld.darwinnew` can be used to test new Mach-O lld while it's in bring-up. (The expectation is that we'll remove this again once new Mach-O lld is the defauld and only Mach-O lld.) - lets the clang driver know if the linker is lld (currently only triggered if `-fuse-ld=lld` or `-fuse-ld=lld.darwinnew` is passed). Currently only used for the next point, but could be used to implement other features that need close coordination between compiler and linker, e.g. having a diag for calling `clang++` instead of `clang` when link errors are caused by a missing C++ stdlib. - lets the clang driver pass `-demangle` to Mach-O lld (both old and new), in addition to ld64 - implements -demangle for new Mach-O lld - changes demangleItanium() to accept _Z, __Z, ___Z, ____Z prefixes (and updates one test added in D68014). Mach-O has an extra underscore for symbols, and the three (or, on Mach-O, four) underscores are used for block names. Differential Revision: https://reviews.llvm.org/D91884
Diffstat (limited to 'clang/lib/Driver/ToolChain.cpp')
-rw-r--r--clang/lib/Driver/ToolChain.cpp11
1 files changed, 9 insertions, 2 deletions
diff --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp
index d2a2652..ae1838a 100644
--- a/clang/lib/Driver/ToolChain.cpp
+++ b/clang/lib/Driver/ToolChain.cpp
@@ -548,7 +548,10 @@ std::string ToolChain::GetProgramPath(const char *Name) const {
return D.GetProgramPath(Name, *this);
}
-std::string ToolChain::GetLinkerPath() const {
+std::string ToolChain::GetLinkerPath(bool *LinkerIsLLD) const {
+ if (LinkerIsLLD)
+ *LinkerIsLLD = false;
+
// 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);
@@ -599,8 +602,12 @@ std::string ToolChain::GetLinkerPath() const {
LinkerName.append(UseLinker);
std::string LinkerPath(GetProgramPath(LinkerName.c_str()));
- if (llvm::sys::fs::can_execute(LinkerPath))
+ if (llvm::sys::fs::can_execute(LinkerPath)) {
+ if (LinkerIsLLD)
+ // FIXME: Remove lld.darwinnew here once it's the only MachO lld.
+ *LinkerIsLLD = UseLinker == "lld" || UseLinker == "lld.darwinnew";
return LinkerPath;
+ }
}
if (A)