diff options
author | Nico Weber <thakis@chromium.org> | 2020-11-20 13:57:44 -0500 |
---|---|---|
committer | Nico Weber <thakis@chromium.org> | 2020-11-24 08:51:58 -0500 |
commit | e16c0a9a689719f379e49d0a05cb58774cce4adb (patch) | |
tree | a5a467839745523b51d03b11a7f026e0c1b34287 /lld/MachO | |
parent | 32d9a386bf8f447dbbfaf55f6fef4fea4463205b (diff) | |
download | llvm-project-e16c0a9a689719f379e49d0a05cb58774cce4adb.tar.gz |
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 'lld/MachO')
-rw-r--r-- | lld/MachO/Config.h | 1 | ||||
-rw-r--r-- | lld/MachO/Driver.cpp | 1 | ||||
-rw-r--r-- | lld/MachO/Options.td | 4 | ||||
-rw-r--r-- | lld/MachO/Symbols.cpp | 4 | ||||
-rw-r--r-- | lld/MachO/Writer.cpp | 2 |
5 files changed, 6 insertions, 6 deletions
diff --git a/lld/MachO/Config.h b/lld/MachO/Config.h index 633dbb0184fc..82c017063d44 100644 --- a/lld/MachO/Config.h +++ b/lld/MachO/Config.h @@ -43,6 +43,7 @@ struct Configuration { uint32_t headerPad; llvm::StringRef installName; llvm::StringRef outputFile; + bool demangle = false; llvm::MachO::Architecture arch; PlatformInfo platform; llvm::MachO::HeaderFileType outputType; diff --git a/lld/MachO/Driver.cpp b/lld/MachO/Driver.cpp index 3b1daadf9f0a..0f5da218e80d 100644 --- a/lld/MachO/Driver.cpp +++ b/lld/MachO/Driver.cpp @@ -584,6 +584,7 @@ bool macho::link(llvm::ArrayRef<const char *> argsArr, bool canExitEarly, config->runtimePaths = args::getStrings(args, OPT_rpath); config->allLoad = args.hasArg(OPT_all_load); config->forceLoadObjC = args.hasArg(OPT_ObjC); + config->demangle = args.hasArg(OPT_demangle); if (const opt::Arg *arg = args.getLastArg(OPT_static, OPT_dynamic)) config->staticLink = (arg->getOption().getID() == OPT_static); diff --git a/lld/MachO/Options.td b/lld/MachO/Options.td index 3695bd1e2868..4aa999826fb6 100644 --- a/lld/MachO/Options.td +++ b/lld/MachO/Options.td @@ -1107,9 +1107,7 @@ def debug_snapshot : Flag<["-"], "debug_snapshot">, Flags<[HelpHidden]>, Group<grp_undocumented>; def demangle : Flag<["-"], "demangle">, - HelpText<"This option is undocumented in ld64">, - Flags<[HelpHidden]>, - Group<grp_undocumented>; + HelpText<"Demangle symbol names in diagnostics">; def dyld_env : Flag<["-"], "dyld_env">, HelpText<"This option is undocumented in ld64">, Flags<[HelpHidden]>, diff --git a/lld/MachO/Symbols.cpp b/lld/MachO/Symbols.cpp index 75c699781a61..87bbab00901f 100644 --- a/lld/MachO/Symbols.cpp +++ b/lld/MachO/Symbols.cpp @@ -33,8 +33,8 @@ void LazySymbol::fetchArchiveMember() { file->fetch(sym); } // Returns a symbol for an error message. std::string lld::toString(const Symbol &sym) { - if (Optional<std::string> s = demangleItanium(sym.getName())) - return *s; + if (config->demangle) + return demangleItanium(sym.getName()); return std::string(sym.getName()); } diff --git a/lld/MachO/Writer.cpp b/lld/MachO/Writer.cpp index c5239469ff2d..fa42c1c7e61c 100644 --- a/lld/MachO/Writer.cpp +++ b/lld/MachO/Writer.cpp @@ -379,7 +379,7 @@ void Writer::scanRelocations() { for (Reloc &r : isec->relocs) { if (auto *s = r.referent.dyn_cast<lld::macho::Symbol *>()) { if (isa<Undefined>(s)) - error("undefined symbol " + s->getName() + ", referenced from " + + error("undefined symbol " + toString(*s) + ", referenced from " + sys::path::filename(isec->file->getName())); else target->prepareSymbolRelocation(s, isec, r); |