1# RUN: split-file %s %t 2# RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown -o %t_main.o %t/main.s 3# RUN: llvm-as %S/Inputs/foo.ll -o %t_foo.o 4# RUN: llvm-as %S/Inputs/libcall.ll -o %t_libcall.o 5# RUN: wasm-ld -mllvm -mattr=-bulk-memory,-bulk-memory-opt %t_main.o %t_libcall.o %t_foo.o %p/Inputs/stub.so -o %t.wasm 6# RUN: obj2yaml %t.wasm | FileCheck %s 7 8# The function `func_with_libcall` will generate an undefined reference to 9# `memcpy` at LTO time. `memcpy` itself also declared in stub.so and depends 10# on `foo` 11 12# If %t_foo.o is not included in the link we get an undefined symbol reported 13# to the dependency of memcpy on the foo export: 14 15# RUN: not wasm-ld -mllvm -mattr=-bulk-memory,-bulk-memory-opt %t_main.o %t_libcall.o %p/Inputs/stub.so -o %t.wasm 2>&1 | FileCheck --check-prefix=MISSING %s 16# MISSING: stub.so: undefined symbol: foo. Required by memcpy 17 18#--- main.s 19.functype func_with_libcall (i32, i32) -> () 20.globl _start 21_start: 22 .functype _start () -> () 23 i32.const 0 24 i32.const 0 25 call func_with_libcall 26 end_function 27 28# CHECK: Imports: 29# CHECK-NEXT: - Module: env 30# CHECK-NEXT: Field: memcpy 31# CHECK-NEXT: Kind: FUNCTION 32# CHECK-NEXT: SigIndex: 0 33 34# CHECK: Exports: 35# CHECK-NEXT: - Name: memory 36# CHECK-NEXT: Kind: MEMORY 37# CHECK-NEXT: Index: 0 38# CHECK-NEXT: - Name: _start 39# CHECK-NEXT: Kind: FUNCTION 40# CHECK-NEXT: Index: 1 41# CHECK-NEXT: - Name: foo 42# CHECK-NEXT: Kind: FUNCTION 43# CHECK-NEXT: Index: 3 44