1# REQUIRES: x86
2# UNSUPPORTED: system-windows
3
4# RUN: mkdir -p %t.dir
5# RUN: rm -f %t.dir/libxyz.a
6# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
7# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux \
8# RUN:   %p/Inputs/libsearch-st.s -o %t2.o
9# RUN: llvm-ar rcs %t.dir/libxyz.a %t2.o
10
11# RUN: echo "GROUP(\"%t\")" > %t.script
12# RUN: ld.lld -o %t2 %t.script
13# RUN: llvm-readobj %t2 > /dev/null
14
15# RUN: echo "INPUT(\"%t\")" > %t.script
16# RUN: ld.lld -o %t2 %t.script
17# RUN: llvm-readobj %t2 > /dev/null
18
19# RUN: echo "GROUP(\"%t\" libxyz.a )" > %t.script
20# RUN: not ld.lld -o /dev/null %t.script 2>/dev/null
21# RUN: ld.lld -o %t2 %t.script -L%t.dir
22# RUN: llvm-readobj %t2 > /dev/null
23
24# RUN: echo "GROUP(\"%t\" =libxyz.a )" > %t.script
25# RUN: not ld.lld -o /dev/null %t.script  2>/dev/null
26# RUN: ld.lld -o %t2 %t.script --sysroot=%t.dir
27# RUN: llvm-readobj %t2 > /dev/null
28
29# RUN: echo "GROUP(\"%t\" -lxyz )" > %t.script
30# RUN: not ld.lld -o /dev/null %t.script  2>/dev/null
31# RUN: ld.lld -o %t2 %t.script -L%t.dir
32# RUN: llvm-readobj %t2 > /dev/null
33
34# RUN: echo "GROUP(\"%t\" libxyz.a )" > %t.script
35# RUN: not ld.lld -o /dev/null %t.script  2>/dev/null
36# RUN: ld.lld -o %t2 %t.script -L%t.dir
37# RUN: llvm-readobj %t2 > /dev/null
38
39# RUN: echo "GROUP(\"%t\" /libxyz.a )" > %t.script
40# RUN: echo "GROUP(\"%t\" /libxyz.a )" > %t.dir/xyz.script
41# RUN: not ld.lld -o /dev/null %t.script 2>&1 | FileCheck %s --check-prefix=CANNOT_OPEN -DFILE=/libxyz.a
42# RUN: not ld.lld -o /dev/null %t.script --sysroot=%t.dir 2>&1 | FileCheck %s --check-prefix=CANNOT_OPEN -DFILE=/libxyz.a
43
44## Since %t.dir/%t does not exist, report an error, instead of falling back to %t
45## without the syroot prefix.
46# RUN: not ld.lld -o /dev/null %t.dir/xyz.script --sysroot=%t.dir 2>&1 | FileCheck %s --check-prefix=CANNOT_FIND_SYSROOT -DTMP=%t
47
48# CANNOT_FIND_SYSROOT:      error: {{.*}}xyz.script:1: cannot find [[TMP]] inside [[TMP]].dir
49# CANNOT_FIND_SYSROOT-NEXT: >>> GROUP({{.*}}
50
51# RUN: echo "GROUP(\"%t.script2\")" > %t.script1
52# RUN: echo "GROUP(\"%t\")" > %t.script2
53# RUN: ld.lld -o %t2 %t.script1
54# RUN: llvm-readobj %t2 > /dev/null
55
56# RUN: echo "GROUP(AS_NEEDED(\"%t\"))" > %t.script
57# RUN: ld.lld -o %t2 %t.script
58# RUN: llvm-readobj %t2 > /dev/null
59
60# CANNOT_OPEN: error: cannot open [[FILE]]: {{.*}}
61
62.globl _start
63_start:
64  ret
65