[llvm-branch-commits] [lld] r369881 - Merging r366573:
Hans Wennborg via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Mon Aug 26 01:33:45 PDT 2019
Author: hans
Date: Mon Aug 26 01:33:44 2019
New Revision: 369881
URL: http://llvm.org/viewvc/llvm-project?rev=369881&view=rev
Log:
Merging r366573:
------------------------------------------------------------------------
r366573 | nico | 2019-07-19 15:29:10 +0200 (Fri, 19 Jul 2019) | 6 lines
lld-link: Demangle symbols from archives in diagnostics
Also add test coverage for thin archives (which are the only way I could
come up with to test at least some of the diagnostic changes).
Differential Revision: https://reviews.llvm.org/D64927
------------------------------------------------------------------------
Modified:
lld/branches/release_90/ (props changed)
lld/branches/release_90/COFF/Driver.cpp
lld/branches/release_90/COFF/Driver.h
lld/branches/release_90/COFF/InputFiles.cpp
lld/branches/release_90/COFF/InputFiles.h
lld/branches/release_90/COFF/SymbolTable.cpp
lld/branches/release_90/COFF/SymbolTable.h
lld/branches/release_90/COFF/Symbols.cpp
lld/branches/release_90/COFF/Symbols.h
lld/branches/release_90/test/COFF/thin-archive.s
Propchange: lld/branches/release_90/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Aug 26 01:33:44 2019
@@ -1 +1 @@
-/lld/trunk:366445,366500,366504,366780,366784,367836-367837,368041,368078,368145,369445
+/lld/trunk:366445,366500,366504,366573,366780,366784,367836-367837,368041,368078,368145,369445
Modified: lld/branches/release_90/COFF/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/branches/release_90/COFF/Driver.cpp?rev=369881&r1=369880&r2=369881&view=diff
==============================================================================
--- lld/branches/release_90/COFF/Driver.cpp (original)
+++ lld/branches/release_90/COFF/Driver.cpp Mon Aug 26 01:33:44 2019
@@ -271,13 +271,12 @@ void LinkerDriver::addArchiveBuffer(Memo
}
void LinkerDriver::enqueueArchiveMember(const Archive::Child &c,
- StringRef symName,
+ const Archive::Symbol &sym,
StringRef parentName) {
- auto reportBufferError = [=](Error &&e,
- StringRef childName) {
+ auto reportBufferError = [=](Error &&e, StringRef childName) {
fatal("could not get the buffer for the member defining symbol " +
- symName + ": " + parentName + "(" + childName + "): " +
+ toString(sym) + ": " + parentName + "(" + childName + "): " +
toString(std::move(e)));
};
@@ -288,7 +287,7 @@ void LinkerDriver::enqueueArchiveMember(
reportBufferError(mbOrErr.takeError(), check(c.getFullName()));
MemoryBufferRef mb = mbOrErr.get();
enqueueTask([=]() {
- driver->addArchiveBuffer(mb, symName, parentName, offsetInArchive);
+ driver->addArchiveBuffer(mb, toString(sym), parentName, offsetInArchive);
});
return;
}
@@ -296,15 +295,15 @@ void LinkerDriver::enqueueArchiveMember(
std::string childName = CHECK(
c.getFullName(),
"could not get the filename for the member defining symbol " +
- symName);
+ toString(sym));
auto future = std::make_shared<std::future<MBErrPair>>(
createFutureForFile(childName));
enqueueTask([=]() {
auto mbOrErr = future->get();
if (mbOrErr.second)
reportBufferError(errorCodeToError(mbOrErr.second), childName);
- driver->addArchiveBuffer(takeBuffer(std::move(mbOrErr.first)), symName,
- parentName, /* OffsetInArchive */ 0);
+ driver->addArchiveBuffer(takeBuffer(std::move(mbOrErr.first)),
+ toString(sym), parentName, /*OffsetInArchive=*/0);
});
}
Modified: lld/branches/release_90/COFF/Driver.h
URL: http://llvm.org/viewvc/llvm-project/lld/branches/release_90/COFF/Driver.h?rev=369881&r1=369880&r2=369881&view=diff
==============================================================================
--- lld/branches/release_90/COFF/Driver.h (original)
+++ lld/branches/release_90/COFF/Driver.h Mon Aug 26 01:33:44 2019
@@ -72,7 +72,7 @@ public:
void parseDirectives(InputFile *file);
// Used by ArchiveFile to enqueue members.
- void enqueueArchiveMember(const Archive::Child &c, StringRef symName,
+ void enqueueArchiveMember(const Archive::Child &c, const Archive::Symbol &sym,
StringRef parentName);
MemoryBufferRef takeBuffer(std::unique_ptr<MemoryBuffer> mb);
Modified: lld/branches/release_90/COFF/InputFiles.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/branches/release_90/COFF/InputFiles.cpp?rev=369881&r1=369880&r2=369881&view=diff
==============================================================================
--- lld/branches/release_90/COFF/InputFiles.cpp (original)
+++ lld/branches/release_90/COFF/InputFiles.cpp Mon Aug 26 01:33:44 2019
@@ -85,16 +85,15 @@ void ArchiveFile::parse() {
}
// Returns a buffer pointing to a member file containing a given symbol.
-void ArchiveFile::addMember(const Archive::Symbol *sym) {
- const Archive::Child &c =
- CHECK(sym->getMember(),
- "could not get the member for symbol " + sym->getName());
+void ArchiveFile::addMember(const Archive::Symbol &sym) {
+ const Archive::Child &c = CHECK(
+ sym.getMember(), "could not get the member for symbol " + toString(sym));
// Return an empty buffer if we have already returned the same buffer.
if (!seen.insert(c.getChildOffset()).second)
return;
- driver->enqueueArchiveMember(c, sym->getName(), getName());
+ driver->enqueueArchiveMember(c, sym, getName());
}
std::vector<MemoryBufferRef> getArchiveMembers(Archive *file) {
Modified: lld/branches/release_90/COFF/InputFiles.h
URL: http://llvm.org/viewvc/llvm-project/lld/branches/release_90/COFF/InputFiles.h?rev=369881&r1=369880&r2=369881&view=diff
==============================================================================
--- lld/branches/release_90/COFF/InputFiles.h (original)
+++ lld/branches/release_90/COFF/InputFiles.h Mon Aug 26 01:33:44 2019
@@ -96,7 +96,7 @@ public:
// Enqueues an archive member load for the given symbol. If we've already
// enqueued a load for the same archive member, this function does nothing,
// which ensures that we don't load the same member more than once.
- void addMember(const Archive::Symbol *sym);
+ void addMember(const Archive::Symbol &sym);
private:
std::unique_ptr<Archive> file;
Modified: lld/branches/release_90/COFF/SymbolTable.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/branches/release_90/COFF/SymbolTable.cpp?rev=369881&r1=369880&r2=369881&view=diff
==============================================================================
--- lld/branches/release_90/COFF/SymbolTable.cpp (original)
+++ lld/branches/release_90/COFF/SymbolTable.cpp Mon Aug 26 01:33:44 2019
@@ -179,7 +179,7 @@ void SymbolTable::loadMinGWAutomaticImpo
log("Loading lazy " + l->getName() + " from " + l->file->getName() +
" for automatic import");
l->pendingArchiveLoad = true;
- l->file->addMember(&l->sym);
+ l->file->addMember(l->sym);
}
}
@@ -363,13 +363,13 @@ Symbol *SymbolTable::addUndefined(String
if (auto *l = dyn_cast<Lazy>(s)) {
if (!s->pendingArchiveLoad) {
s->pendingArchiveLoad = true;
- l->file->addMember(&l->sym);
+ l->file->addMember(l->sym);
}
}
return s;
}
-void SymbolTable::addLazy(ArchiveFile *f, const Archive::Symbol sym) {
+void SymbolTable::addLazy(ArchiveFile *f, const Archive::Symbol &sym) {
StringRef name = sym.getName();
Symbol *s;
bool wasInserted;
@@ -382,7 +382,7 @@ void SymbolTable::addLazy(ArchiveFile *f
if (!u || u->weakAlias || s->pendingArchiveLoad)
return;
s->pendingArchiveLoad = true;
- f->addMember(&sym);
+ f->addMember(sym);
}
void SymbolTable::reportDuplicate(Symbol *existing, InputFile *newFile) {
Modified: lld/branches/release_90/COFF/SymbolTable.h
URL: http://llvm.org/viewvc/llvm-project/lld/branches/release_90/COFF/SymbolTable.h?rev=369881&r1=369880&r2=369881&view=diff
==============================================================================
--- lld/branches/release_90/COFF/SymbolTable.h (original)
+++ lld/branches/release_90/COFF/SymbolTable.h Mon Aug 26 01:33:44 2019
@@ -83,7 +83,7 @@ public:
Symbol *addAbsolute(StringRef n, uint64_t va);
Symbol *addUndefined(StringRef name, InputFile *f, bool isWeakAlias);
- void addLazy(ArchiveFile *f, const Archive::Symbol sym);
+ void addLazy(ArchiveFile *f, const Archive::Symbol &sym);
Symbol *addAbsolute(StringRef n, COFFSymbolRef s);
Symbol *addRegular(InputFile *f, StringRef n,
const llvm::object::coff_symbol_generic *s = nullptr,
Modified: lld/branches/release_90/COFF/Symbols.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/branches/release_90/COFF/Symbols.cpp?rev=369881&r1=369880&r2=369881&view=diff
==============================================================================
--- lld/branches/release_90/COFF/Symbols.cpp (original)
+++ lld/branches/release_90/COFF/Symbols.cpp Mon Aug 26 01:33:44 2019
@@ -20,18 +20,21 @@ using namespace llvm::object;
using namespace lld::coff;
+namespace lld {
+
static_assert(sizeof(SymbolUnion) <= 48,
"symbols should be optimized for memory usage");
// Returns a symbol name for an error message.
-std::string lld::toString(coff::Symbol &b) {
+static std::string demangle(StringRef symName) {
if (config->demangle)
- if (Optional<std::string> s = lld::demangleMSVC(b.getName()))
+ if (Optional<std::string> s = demangleMSVC(symName))
return *s;
- return b.getName();
+ return symName;
}
+std::string toString(coff::Symbol &b) { return demangle(b.getName()); }
+std::string toString(const Archive::Symbol &b) { return demangle(b.getName()); }
-namespace lld {
namespace coff {
StringRef Symbol::getName() {
Modified: lld/branches/release_90/COFF/Symbols.h
URL: http://llvm.org/viewvc/llvm-project/lld/branches/release_90/COFF/Symbols.h?rev=369881&r1=369880&r2=369881&view=diff
==============================================================================
--- lld/branches/release_90/COFF/Symbols.h (original)
+++ lld/branches/release_90/COFF/Symbols.h Mon Aug 26 01:33:44 2019
@@ -430,6 +430,7 @@ void replaceSymbol(Symbol *s, ArgT &&...
} // namespace coff
std::string toString(coff::Symbol &b);
+std::string toString(const coff::Archive::Symbol &b);
} // namespace lld
#endif
Modified: lld/branches/release_90/test/COFF/thin-archive.s
URL: http://llvm.org/viewvc/llvm-project/lld/branches/release_90/test/COFF/thin-archive.s?rev=369881&r1=369880&r2=369881&view=diff
==============================================================================
--- lld/branches/release_90/test/COFF/thin-archive.s (original)
+++ lld/branches/release_90/test/COFF/thin-archive.s Mon Aug 26 01:33:44 2019
@@ -11,14 +11,18 @@
# RUN: FileCheck --allow-empty %s
# RUN: lld-link /entry:main %t.main.obj %t_thin.lib /out:%t.exe 2>&1 | \
# RUN: FileCheck --allow-empty %s
-# RUN: lld-link /entry:main %t.main.obj /wholearchive:%t_thin.lib /out:%t.exe 2>&1 | \
-# RUN: FileCheck --allow-empty %s
# RUN: rm %t.lib.obj
# RUN: lld-link /entry:main %t.main.obj %t.lib /out:%t.exe 2>&1 | \
# RUN: FileCheck --allow-empty %s
+# RUN: not lld-link /entry:main %t.main.obj %t_thin.lib /out:%t.exe 2>&1 | \
+# RUN: FileCheck --check-prefix=NOOBJ %s
+# RUN: not lld-link /entry:main %t.main.obj %t_thin.lib /out:%t.exe \
+# RUN: /demangle:no 2>&1 | FileCheck --check-prefix=NOOBJNODEMANGLE %s
# CHECK-NOT: error: could not get the buffer for the member defining
+# NOOBJ: error: could not get the buffer for the member defining symbol int __cdecl f(void): {{.*}}.lib({{.*}}.lib.obj):
+# NOOBJNODEMANGLE: error: could not get the buffer for the member defining symbol ?f@@YAHXZ: {{.*}}.lib({{.*}}.lib.obj):
.text
More information about the llvm-branch-commits
mailing list