1# RUN: rm -rf %t && split-file %s %t 2# RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown %t/main.s -o %t/main.o 3# RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown %t/a.s -o %t/a.o 4# RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown %t/a_b.s -o %t/a_b.o 5# RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown %t/b.s -o %t/b.o 6# RUN: llvm-ar rc %t/a.a %t/a.o 7# RUN: llvm-ar rc %t/a_b.a %t/a_b.o 8# RUN: llvm-ar rc %t/b.a %t/b.o 9# RUN: cd %t 10 11## Nothing is extracted from an archive. The file is created with just a header. 12# RUN: wasm-ld main.o a.o b.a -o /dev/null --why-extract=why1.txt 13# RUN: FileCheck %s --input-file=why1.txt --check-prefix=CHECK1 --match-full-lines --strict-whitespace 14 15# CHECK1:reference extracted symbol 16# CHECK1-NOT:{{.}} 17 18## Some archive members are extracted. 19# RUN: wasm-ld main.o a_b.a b.a -o /dev/null --why-extract=why2.txt 20# RUN: FileCheck %s --input-file=why2.txt --check-prefix=CHECK2 --match-full-lines --strict-whitespace 21 22# CHECK2:reference extracted symbol 23# CHECK2-NEXT:main.o a_b.a(a_b.o) a 24# CHECK2-NEXT:a_b.a(a_b.o) b.a(b.o) b() 25 26## An undefined symbol error does not suppress the output. 27# RUN: not wasm-ld main.o a_b.a -o /dev/null --why-extract=why3.txt 28# RUN: FileCheck %s --input-file=why3.txt --check-prefix=CHECK3 --match-full-lines --strict-whitespace 29 30## Check that backward references are supported. 31## - means stdout. 32# RUN: wasm-ld b.a a_b.a main.o -o /dev/null --why-extract=- | FileCheck %s --check-prefix=CHECK4 33 34# CHECK3:reference extracted symbol 35# CHECK3-NEXT:main.o a_b.a(a_b.o) a 36 37# CHECK4:reference extracted symbol 38# CHECK4-NEXT:a_b.a(a_b.o) b.a(b.o) b() 39# CHECK4-NEXT:main.o a_b.a(a_b.o) a 40 41# RUN: wasm-ld main.o a_b.a b.a -o /dev/null --no-demangle --why-extract=- | FileCheck %s --check-prefix=MANGLED 42 43# MANGLED: a_b.a(a_b.o) b.a(b.o) _Z1bv 44 45# RUN: wasm-ld main.o a.a b.a -o /dev/null -u _Z1bv --why-extract=- | FileCheck %s --check-prefix=UNDEFINED 46 47## We insert -u symbol before processing other files, so its name is <internal>. 48## This is not ideal. 49# UNDEFINED: <internal> b.a(b.o) b() 50 51# RUN: wasm-ld main.o a.a b.a -o /dev/null -e _Z1bv --why-extract=- | FileCheck %s --check-prefix=ENTRY 52 53# ENTRY: --entry b.a(b.o) b() 54 55# SCRIPT: <internal> b.a(b.o) b() 56 57# RUN: not wasm-ld -shared main.o -o /dev/null --why-extract=/ 2>&1 | FileCheck %s --check-prefix=ERR 58 59# ERR: error: cannot open --why-extract= file /: {{.*}} 60 61#--- main.s 62.globl _start 63.functype a () -> () 64_start: 65 .functype _start () -> () 66 call a 67 end_function 68 69#--- a.s 70.globl a 71a: 72 .functype a () -> () 73 end_function 74 75#--- a_b.s 76.functype _Z1bv () -> () 77.globl a 78a: 79 .functype a () -> () 80 call _Z1bv 81 end_function 82 83#--- b.s 84.globl _Z1bv 85_Z1bv: 86 .functype _Z1bv () -> () 87 end_function 88