2018-01-24 11:29:47 +08:00
|
|
|
; RUN: llc -filetype=obj %s -o %t.o
|
|
|
|
; RUN: llc -filetype=obj %S/Inputs/archive1.ll -o %t.a1.o
|
|
|
|
; RUN: llc -filetype=obj %S/Inputs/archive2.ll -o %t.a2.o
|
2018-07-19 05:46:09 +08:00
|
|
|
; RUN: llc -filetype=obj %S/Inputs/archive3.ll -o %t.a3.o
|
|
|
|
; RUN: llc -filetype=obj %S/Inputs/hello.ll -o %t.hello.o
|
2018-08-02 19:33:54 +08:00
|
|
|
; RUN: rm -f %t.a
|
2018-07-19 05:46:09 +08:00
|
|
|
; RUN: llvm-ar rcs %t.a %t.a1.o %t.a2.o %t.a3.o %t.hello.o
|
2018-01-12 06:31:35 +08:00
|
|
|
; RUN: rm -f %t.imports
|
2018-05-05 09:23:07 +08:00
|
|
|
; RUN: not wasm-ld %t.a %t.o -o %t.wasm 2>&1 | FileCheck -check-prefix=CHECK-UNDEFINED %s
|
2018-01-12 06:31:35 +08:00
|
|
|
|
|
|
|
; CHECK-UNDEFINED: undefined symbol: missing_func
|
|
|
|
|
|
|
|
; RUN: echo 'missing_func' > %t.imports
|
2018-05-05 09:23:07 +08:00
|
|
|
; RUN: wasm-ld -r %t.a %t.o -o %t.wasm
|
2018-01-12 06:31:35 +08:00
|
|
|
|
2017-11-18 02:14:09 +08:00
|
|
|
; RUN: llvm-nm -a %t.wasm | FileCheck %s
|
|
|
|
|
2018-05-11 01:59:41 +08:00
|
|
|
target triple = "wasm32-unknown-unknown"
|
2018-01-24 11:29:47 +08:00
|
|
|
|
2017-11-18 02:14:09 +08:00
|
|
|
declare i32 @foo() local_unnamed_addr #1
|
2018-01-12 06:31:35 +08:00
|
|
|
declare i32 @missing_func() local_unnamed_addr #1
|
2017-11-18 02:14:09 +08:00
|
|
|
|
2018-02-02 08:30:03 +08:00
|
|
|
define void @_start() local_unnamed_addr #0 {
|
2017-11-18 02:14:09 +08:00
|
|
|
entry:
|
2018-01-12 06:31:35 +08:00
|
|
|
%call1 = call i32 @foo() #2
|
|
|
|
%call2 = call i32 @missing_func() #2
|
2018-02-02 08:30:03 +08:00
|
|
|
ret void
|
2017-11-18 02:14:09 +08:00
|
|
|
}
|
|
|
|
|
2018-02-23 13:08:53 +08:00
|
|
|
; Verify that mutually dependant object files in an archive is handled
|
|
|
|
; correctly. Since we're using llvm-nm, we must link with --relocatable.
|
|
|
|
;
|
|
|
|
; TODO(ncw): Update LLD so that the symbol table is written out for
|
|
|
|
; non-relocatable output (with an option to strip it)
|
2017-12-16 06:17:15 +08:00
|
|
|
|
2019-01-18 02:30:35 +08:00
|
|
|
; CHECK: 00000016 T _start
|
|
|
|
; CHECK-NEXT: 0000000a T archive2_symbol
|
2018-01-12 06:31:35 +08:00
|
|
|
; CHECK-NEXT: 00000001 T bar
|
2019-01-18 02:30:35 +08:00
|
|
|
; CHECK-NEXT: 0000000d T foo
|
2018-02-23 13:08:53 +08:00
|
|
|
; CHECK-NEXT: U missing_func
|
2017-12-16 06:17:15 +08:00
|
|
|
|
|
|
|
; Verify that symbols from unused objects don't appear in the symbol table
|
|
|
|
; CHECK-NOT: hello
|
|
|
|
|
|
|
|
; Specifying the same archive twice is allowed.
|
2018-05-05 09:23:07 +08:00
|
|
|
; RUN: wasm-ld %t.a %t.a %t.o -o %t.wasm
|
2018-07-19 05:46:09 +08:00
|
|
|
|
|
|
|
; Verfiy errors include library name
|
|
|
|
; 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
|
2019-04-09 13:41:52 +08:00
|
|
|
; And that this also works with --whole-archive
|
|
|
|
; 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
|
2018-07-19 05:46:09 +08:00
|
|
|
; CHECK-DUP: error: duplicate symbol: bar
|
|
|
|
; CHECK-DUP: >>> defined in {{.*}}.a({{.*}}.a2.o)
|
|
|
|
; CHECK-DUP: >>> defined in {{.*}}.a({{.*}}.a3.o)
|