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 6; RUN: rm -f %t.a 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 10 11; CHECK-UNDEFINED: undefined symbol: missing_func 12 13; RUN: echo 'missing_func' > %t.imports 14; RUN: wasm-ld -r %t.a %t.o -o %t.wasm 15 16; RUN: llvm-nm -a %t.wasm | FileCheck %s 17 18target triple = "wasm32-unknown-unknown" 19 20declare i32 @foo() local_unnamed_addr #1 21declare i32 @missing_func() local_unnamed_addr #1 22 23define void @_start() local_unnamed_addr #0 { 24entry: 25 %call1 = call i32 @foo() #2 26 %call2 = call i32 @missing_func() #2 27 ret void 28} 29 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. 32; 33; TODO(ncw): Update LLD so that the symbol table is written out for 34; non-relocatable output (with an option to strip it) 35 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 41 42; Verify that symbols from unused objects don't appear in the symbol table 43; CHECK-NOT: hello 44 45; Specifying the same archive twice is allowed. 46; RUN: wasm-ld %t.a %t.a %t.o -o %t.wasm 47 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) 55