[lld] r357966 - [WebAssembly] Ensure ArchiveName is set even in the presence of --whole-archive.
Sam Clegg via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 8 22:41:52 PDT 2019
Author: sbc
Date: Mon Apr 8 22:41:52 2019
New Revision: 357966
URL: http://llvm.org/viewvc/llvm-project?rev=357966&view=rev
Log:
[WebAssembly] Ensure ArchiveName is set even in the presence of --whole-archive.
Differential Revision: https://reviews.llvm.org/D60431
Modified:
lld/trunk/test/wasm/archive.ll
lld/trunk/wasm/Driver.cpp
lld/trunk/wasm/InputFiles.cpp
lld/trunk/wasm/InputFiles.h
lld/trunk/wasm/SymbolTable.cpp
lld/trunk/wasm/SymbolTable.h
Modified: lld/trunk/test/wasm/archive.ll
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/wasm/archive.ll?rev=357966&r1=357965&r2=357966&view=diff
==============================================================================
--- lld/trunk/test/wasm/archive.ll (original)
+++ lld/trunk/test/wasm/archive.ll Mon Apr 8 22:41:52 2019
@@ -47,6 +47,8 @@ entry:
; Verfiy errors include library name
; RUN: not wasm-ld -u archive2_symbol -u archive3_symbol %t.a %t.o -o %t.wasm 2>&1 | FileCheck -check-prefix=CHECK-DUP %s
+; And that this also works with --whole-archive
+; RUN: not wasm-ld -u archive2_symbol -u archive3_symbol --whole-archive %t.a %t.o -o %t.wasm 2>&1 | FileCheck -check-prefix=CHECK-DUP %s
; CHECK-DUP: error: duplicate symbol: bar
; CHECK-DUP: >>> defined in {{.*}}.a({{.*}}.a2.o)
; CHECK-DUP: >>> defined in {{.*}}.a({{.*}}.a3.o)
Modified: lld/trunk/wasm/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/wasm/Driver.cpp?rev=357966&r1=357965&r2=357966&view=diff
==============================================================================
--- lld/trunk/wasm/Driver.cpp (original)
+++ lld/trunk/wasm/Driver.cpp Mon Apr 8 22:41:52 2019
@@ -226,7 +226,7 @@ void LinkerDriver::addFile(StringRef Pat
// Handle -whole-archive.
if (InWholeArchive) {
for (MemoryBufferRef &M : getArchiveMembers(MBRef))
- Files.push_back(createObjectFile(M));
+ Files.push_back(createObjectFile(M, Path));
return;
}
Modified: lld/trunk/wasm/InputFiles.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/wasm/InputFiles.cpp?rev=357966&r1=357965&r2=357966&view=diff
==============================================================================
--- lld/trunk/wasm/InputFiles.cpp (original)
+++ lld/trunk/wasm/InputFiles.cpp Mon Apr 8 22:41:52 2019
@@ -42,18 +42,19 @@ Optional<MemoryBufferRef> lld::wasm::rea
return MBRef;
}
-InputFile *lld::wasm::createObjectFile(MemoryBufferRef MB) {
+InputFile *lld::wasm::createObjectFile(MemoryBufferRef MB,
+ StringRef ArchiveName) {
file_magic Magic = identify_magic(MB.getBuffer());
if (Magic == file_magic::wasm_object) {
std::unique_ptr<Binary> Bin = check(createBinary(MB));
auto *Obj = cast<WasmObjectFile>(Bin.get());
if (Obj->isSharedObject())
return make<SharedFile>(MB);
- return make<ObjFile>(MB);
+ return make<ObjFile>(MB, ArchiveName);
}
if (Magic == file_magic::bitcode)
- return make<BitcodeFile>(MB);
+ return make<BitcodeFile>(MB, ArchiveName);
fatal("unknown file type: " + MB.getBufferIdentifier());
}
@@ -435,8 +436,7 @@ void ArchiveFile::addMember(const Archiv
"could not get the buffer for the member defining symbol " +
Sym->getName());
- InputFile *Obj = createObjectFile(MB);
- Obj->ArchiveName = getName();
+ InputFile *Obj = createObjectFile(MB, getName());
Symtab->addFile(Obj);
}
Modified: lld/trunk/wasm/InputFiles.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/wasm/InputFiles.h?rev=357966&r1=357965&r2=357966&view=diff
==============================================================================
--- lld/trunk/wasm/InputFiles.h (original)
+++ lld/trunk/wasm/InputFiles.h Mon Apr 8 22:41:52 2019
@@ -82,7 +82,10 @@ private:
// .o file (wasm object file)
class ObjFile : public InputFile {
public:
- explicit ObjFile(MemoryBufferRef M) : InputFile(ObjectKind, M) {}
+ explicit ObjFile(MemoryBufferRef M, StringRef ArchiveName)
+ : InputFile(ObjectKind, M) {
+ this->ArchiveName = ArchiveName;
+ }
static bool classof(const InputFile *F) { return F->kind() == ObjectKind; }
void parse() override;
@@ -144,7 +147,10 @@ public:
// .bc file
class BitcodeFile : public InputFile {
public:
- explicit BitcodeFile(MemoryBufferRef M) : InputFile(BitcodeKind, M) {}
+ explicit BitcodeFile(MemoryBufferRef M, StringRef ArchiveName)
+ : InputFile(BitcodeKind, M) {
+ this->ArchiveName = ArchiveName;
+ }
static bool classof(const InputFile *F) { return F->kind() == BitcodeKind; }
void parse() override;
@@ -153,7 +159,7 @@ public:
// Will report a fatal() error if the input buffer is not a valid bitcode
// or wasm object file.
-InputFile *createObjectFile(MemoryBufferRef MB);
+InputFile *createObjectFile(MemoryBufferRef MB, StringRef ArchiveName = "");
// Opens a given file.
llvm::Optional<MemoryBufferRef> readFile(StringRef Path);
Modified: lld/trunk/wasm/SymbolTable.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/wasm/SymbolTable.cpp?rev=357966&r1=357965&r2=357966&view=diff
==============================================================================
--- lld/trunk/wasm/SymbolTable.cpp (original)
+++ lld/trunk/wasm/SymbolTable.cpp Mon Apr 8 22:41:52 2019
@@ -58,7 +58,7 @@ void SymbolTable::addCombinedLTOObject()
LTO->add(*F);
for (StringRef Filename : LTO->compile()) {
- auto *Obj = make<ObjFile>(MemoryBufferRef(Filename, "lto.tmp"));
+ auto *Obj = make<ObjFile>(MemoryBufferRef(Filename, "lto.tmp"), "");
Obj->parse();
ObjectFiles.push_back(Obj);
}
Modified: lld/trunk/wasm/SymbolTable.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/wasm/SymbolTable.h?rev=357966&r1=357965&r2=357966&view=diff
==============================================================================
--- lld/trunk/wasm/SymbolTable.h (original)
+++ lld/trunk/wasm/SymbolTable.h Mon Apr 8 22:41:52 2019
@@ -39,7 +39,7 @@ public:
void addCombinedLTOObject();
std::vector<ObjFile *> ObjectFiles;
- std::vector<InputFile *> SharedFiles;
+ std::vector<SharedFile *> SharedFiles;
std::vector<BitcodeFile *> BitcodeFiles;
std::vector<InputFunction *> SyntheticFunctions;
std::vector<InputGlobal *> SyntheticGlobals;
More information about the llvm-commits
mailing list