[PATCH] D89290: [lld][WebAssembly] Don't GC library objects under `--whole-archive`
Sam Clegg via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 12 21:19:38 PDT 2020
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb3b4cda10406: [lld][WebAssembly] Don't GC library objects under `--whole-archive` (authored by sbc100).
Changed prior to commit:
https://reviews.llvm.org/D89290?vs=297751&id=297757#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D89290/new/
https://reviews.llvm.org/D89290
Files:
lld/test/wasm/ctor-gc.test
lld/wasm/Driver.cpp
lld/wasm/InputFiles.cpp
Index: lld/wasm/InputFiles.cpp
===================================================================
--- lld/wasm/InputFiles.cpp
+++ lld/wasm/InputFiles.cpp
@@ -59,8 +59,7 @@
return mbref;
}
-InputFile *createObjectFile(MemoryBufferRef mb,
- StringRef archiveName) {
+InputFile *createObjectFile(MemoryBufferRef mb, StringRef archiveName) {
file_magic magic = identify_magic(mb.getBuffer());
if (magic == file_magic::wasm_object) {
std::unique_ptr<Binary> bin =
Index: lld/wasm/Driver.cpp
===================================================================
--- lld/wasm/Driver.cpp
+++ lld/wasm/Driver.cpp
@@ -252,8 +252,15 @@
// Handle -whole-archive.
if (inWholeArchive) {
- for (MemoryBufferRef &m : getArchiveMembers(mbref))
- files.push_back(createObjectFile(m, path));
+ for (MemoryBufferRef &m : getArchiveMembers(mbref)) {
+ auto *object = createObjectFile(m, path);
+ // Mark object as live; object members are normally not
+ // live by default but -whole-archive is designed to treat
+ // them as such.
+ object->markLive();
+ files.push_back(object);
+ }
+
return;
}
Index: lld/test/wasm/ctor-gc.test
===================================================================
--- lld/test/wasm/ctor-gc.test
+++ lld/test/wasm/ctor-gc.test
@@ -7,6 +7,10 @@
; RUN: rm -f %t.lib.a
; RUN: llvm-ar rcs %t.lib.a %t.lib.o %t.ctor.o
; RUN: wasm-ld %t.start.o %t.lib.a -o %t.wasm
+; RUN: wasm-ld %t.start.o --whole-archive %t.lib.a -o %t2.wasm
; RUN: obj2yaml %t.wasm | FileCheck %s
+; RUN: obj2yaml %t2.wasm | FileCheck %s -check-prefix=WHOLEARCHIVE
; CHECK-NOT: __wasm_call_ctors
+
+; WHOLEARCHIVE: __wasm_call_ctors
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D89290.297757.patch
Type: text/x-patch
Size: 1762 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201013/f275678f/attachment.bin>
More information about the llvm-commits
mailing list