[lld] [lld][WebAssembly] Don't export deps for unused stub symbols (PR #173422)
Heejin Ahn via llvm-commits
llvm-commits at lists.llvm.org
Tue Dec 23 16:24:21 PST 2025
================
@@ -16,6 +16,23 @@
# RUN: wasm-ld %t.o %t/libfoo.a %p/Inputs/stub.so -o %t2.wasm
# RUN: obj2yaml %t2.wasm | FileCheck %s
+## The function `foo` is declared in stub2.so and depends on `baz`, and both
+## `foo` and `baz` are defined in an LTO object. When `foo` and `baz` are
+## DCE'd and become undefined in the LTO process, wasm-ld should not try to
+## export the (nonexistent) `baz`.
+
+# RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown -o %t.o %s
+# RUN: mkdir -p %t
+# RUN: llvm-as %S/Inputs/foobaz.ll -o %t/foobaz.o
+# RUN: wasm-ld %t.o %t/foobaz.o %p/Inputs/stub2.so -o %t.wasm
+# RUN: obj2yaml %t.wasm | FileCheck %s --check-prefix=UNUSED
+
+## Run the same test but with foobaz.o inside of an archive file.
+# RUN: rm -f %t/libfoobaz.a
+# RUN: llvm-ar rcs %t/libfoobaz.a %t/foobaz.o
+# RUN: wasm-ld %t.o %t/libfoobaz.a %p/Inputs/stub2.so -o %t2.wasm
+# RUN: obj2yaml %t2.wasm | FileCheck %s --check-prefix=UNUSED
----------------
aheejin wrote:
Then it can't be `foo` because `foo` is already being used in `stub.so` and I need a symbol that's not used anywhere. Anyway, I will remove `foo.ll` and create another file that contains all functions we need then.
https://github.com/llvm/llvm-project/pull/173422
More information about the llvm-commits
mailing list