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