88 lines · plain
1# RUN: rm -rf %t && split-file %s %t2# RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown %t/main.s -o %t/main.o3# RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown %t/a.s -o %t/a.o4# RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown %t/a_b.s -o %t/a_b.o5# RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown %t/b.s -o %t/b.o6# RUN: llvm-ar rc %t/a.a %t/a.o7# RUN: llvm-ar rc %t/a_b.a %t/a_b.o8# RUN: llvm-ar rc %t/b.a %t/b.o9# RUN: cd %t10 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.txt13# RUN: FileCheck %s --input-file=why1.txt --check-prefix=CHECK1 --match-full-lines --strict-whitespace14 15# CHECK1:reference extracted symbol16# 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.txt20# RUN: FileCheck %s --input-file=why2.txt --check-prefix=CHECK2 --match-full-lines --strict-whitespace21 22# CHECK2:reference extracted symbol23# CHECK2-NEXT:main.o a_b.a(a_b.o) a24# 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.txt28# RUN: FileCheck %s --input-file=why3.txt --check-prefix=CHECK3 --match-full-lines --strict-whitespace29 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=CHECK433 34# CHECK3:reference extracted symbol35# CHECK3-NEXT:main.o a_b.a(a_b.o) a36 37# CHECK4:reference extracted symbol38# CHECK4-NEXT:a_b.a(a_b.o) b.a(b.o) b()39# CHECK4-NEXT:main.o a_b.a(a_b.o) a40 41# RUN: wasm-ld main.o a_b.a b.a -o /dev/null --no-demangle --why-extract=- | FileCheck %s --check-prefix=MANGLED42 43# MANGLED: a_b.a(a_b.o) b.a(b.o) _Z1bv44 45# RUN: wasm-ld main.o a.a b.a -o /dev/null -u _Z1bv --why-extract=- | FileCheck %s --check-prefix=UNDEFINED46 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=ENTRY52 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=ERR58 59# ERR: error: cannot open --why-extract= file /: {{.*}}60 61#--- main.s62.globl _start63.functype a () -> ()64_start:65 .functype _start () -> ()66 call a67 end_function68 69#--- a.s70.globl a71a:72 .functype a () -> ()73 end_function74 75#--- a_b.s76.functype _Z1bv () -> ()77.globl a78a:79 .functype a () -> ()80 call _Z1bv81 end_function82 83#--- b.s84.globl _Z1bv85_Z1bv:86 .functype _Z1bv () -> ()87 end_function88