1;; Test that weak undefined symbols do not fetch members from archive files.
2; RUN: llc -filetype=obj %s -o %t.o
3; RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown %p/Inputs/ret32.s -o %t.ret32.o
4; RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown %p/Inputs/hello.s -o %t.hello.o
5; RUN: rm -f %t.a
6; RUN: llvm-ar rcs %t.a %t.ret32.o %t.hello.o
7
8; RUN: wasm-ld %t.o %t.a -o %t.wasm
9; RUN: obj2yaml %t.wasm | FileCheck %s
10
11;; Also test with the library symbols being read first
12; RUN: wasm-ld %t.a %t.o -o %t2.wasm
13; RUN: obj2yaml %t2.wasm | FileCheck %s
14
15; RUN: wasm-ld -u hello_str %t.o %t.a -o %t2.wasm
16; RUN: obj2yaml %t2.wasm | FileCheck %s -check-prefix=CHECK-DATA
17
18target triple = "wasm32-unknown-unknown"
19
20; Weak external function symbol
21declare extern_weak i32 @ret32()
22
23; Weak external data symbol
24@hello_str = extern_weak global i8*, align 4
25
26define void @_start() {
27  br i1 icmp ne (i8** @hello_str, i8** null), label %if.then, label %if.end
28
29if.then:
30  %call1 = call i32 @ret32()
31  br label %if.end
32
33if.end:
34  ret void
35}
36
37; Ensure we have no data section.  If we do, would mean that hello_str was
38; pulled out of the library.
39; CHECK-NOT:  Type:            DATA
40; CHECK-DATA: Type:            DATA
41
42; CHECK: Name: 'undefined_weak:ret32'
43; CHECK-NOT: Name: ret32
44