xref: /llvm-project/lld/test/wasm/whole-archive.test (revision fd1c894a4a3690b2e500bfdf71194e9cc3f1b399)
1RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown %p/Inputs/start.s -o %t.o
2RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown %p/Inputs/ret32.s -o %t.ret32.o
3RUN: rm -f %t.a
4RUN: llvm-ar rcs %t.a %t.ret32.o
5
6Should not add symbols from the archive by default as they are not required
7RUN: wasm-ld --no-gc-sections -o %t.wasm %t.o %t.a
8RUN: obj2yaml %t.wasm | FileCheck --check-prefix=NOTADDED %s
9NOTADDED: FunctionNames:
10NOTADDED-NOT: Name: ret32
11NOTADDED: ...
12
13Should add symbols from the archive if --whole-archive is used
14RUN: wasm-ld --no-gc-sections -o %t.wasm %t.o --whole-archive %t.a
15RUN: obj2yaml %t.wasm | FileCheck --check-prefix=ADDED %s
16ADDED: FunctionNames:
17ADDED:   Name: ret32
18ADDED: ...
19
20--no-whole-archive should restore default behaviour
21RUN: wasm-ld --no-gc-sections -o %t.wasm %t.o --whole-archive --no-whole-archive %t.a
22RUN: obj2yaml %t.wasm | FileCheck --check-prefix=NOTADDED %s
23
24--whole-archive and --no-whole-archive should affect only archives which follow them
25RUN: wasm-ld --no-gc-sections -o %t.wasm %t.o %t.a --whole-archive --no-whole-archive
26RUN: obj2yaml %t.wasm | FileCheck --check-prefix=NOTADDED %s
27RUN: wasm-ld --no-gc-sections -o %t.wasm %t.o --whole-archive %t.a --no-whole-archive
28RUN: obj2yaml %t.wasm | FileCheck --check-prefix=ADDED %s
29
30--whole-archive should also work with thin archives
31RUN: rm -f %tthin.a
32RUN: llvm-ar --format=gnu rcsT %tthin.a %t.ret32.o
33RUN: wasm-ld --no-gc-sections -o %t.wasm %t.o --whole-archive %tthin.a
34RUN: obj2yaml %t.wasm | FileCheck --check-prefix=ADDED %s
35