1 ; RUN: llc -filetype=obj %s -o %t.o
2 ; RUN: llc -filetype=obj %S/Inputs/archive1.ll -o %t.a1.o
3 ; RUN: llc -filetype=obj %S/Inputs/archive2.ll -o %t.a2.o
4 ; RUN: llc -filetype=obj %S/Inputs/archive3.ll -o %t.a3.o
5 ; RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown %p/Inputs/hello.s -o %t.hello.o
7 ; RUN: llvm-ar rcs %t.a %t.a1.o %t.a2.o %t.a3.o %t.hello.o
8 ; RUN: rm -f %t.imports
9 ; RUN: not wasm-ld %t.a %t.o -o %t.wasm 2>&1 | FileCheck -check-prefix=CHECK-UNDEFINED %s
11 ; CHECK-UNDEFINED: undefined symbol: missing_func
13 ; RUN: echo 'missing_func' > %t.imports
14 ; RUN: wasm-ld -r %t.a %t.o -o %t.wasm
16 ; RUN: llvm-nm -a %t.wasm | FileCheck %s
18 target triple = "wasm32-unknown-unknown"
20 declare i32 @foo() local_unnamed_addr #1
21 declare i32 @missing_func() local_unnamed_addr #1
23 define void @_start() local_unnamed_addr #0 {
25 %call1 = call i32 @foo() #2
26 %call2 = call i32 @missing_func() #2
30 ; Verify that mutually dependant object files in an archive is handled
31 ; correctly. Since we're using llvm-nm, we must link with --relocatable.
33 ; TODO(ncw): Update LLD so that the symbol table is written out for
34 ; non-relocatable output (with an option to strip it)
36 ; CHECK: 00000016 T _start
37 ; CHECK-NEXT: 0000000a T archive2_symbol
38 ; CHECK-NEXT: 00000001 T bar
39 ; CHECK-NEXT: 0000000d T foo
40 ; CHECK-NEXT: U missing_func
42 ; Verify that symbols from unused objects don't appear in the symbol table
45 ; Specifying the same archive twice is allowed.
46 ; RUN: wasm-ld %t.a %t.a %t.o -o %t.wasm
48 ; Verfiy errors include library name
49 ; 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
50 ; And that this also works with --whole-archive
51 ; 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
52 ; CHECK-DUP: error: duplicate symbol: bar
53 ; CHECK-DUP: >>> defined in {{.*}}.a({{.*}}.a2.o)
54 ; CHECK-DUP: >>> defined in {{.*}}.a({{.*}}.a3.o)