[memprof] Remove an unused using directive (#117004)
[llvm-project.git] / lld / test / ELF / deplibs.s
blob5da483f25ade8b46f81632228458577cc2fe93ce
1 # REQUIRES: x86
3 # RUN: llvm-mc -filetype=obj -triple=x86_64 %s -o %t.o
4 # RUN: echo ".global foo; foo:" | \
5 # RUN: llvm-mc -filetype=obj -triple=x86_64 - -o %tfoo.o
6 # RUN: rm -rf %t.dir %t.cwd
7 # RUN: mkdir -p %t.dir
9 ## Error if dependent libraries cannot be found.
10 # RUN: not ld.lld %t.o -o /dev/null 2>&1 | FileCheck %s -DOBJ=%t.o --check-prefix MISSING
11 # MISSING: error: [[OBJ]]: unable to find library from dependent library specifier: foo.a
12 # MISSING-NEXT: error: [[OBJ]]: unable to find library from dependent library specifier: bar
14 ## Can ignore dependent libraries.
15 # RUN: not ld.lld %t.o -o /dev/null --no-dependent-libraries 2>&1 | FileCheck %s --check-prefix IGNORE
16 # IGNORE: error: undefined symbol: foo
18 ## -r links preserve dependent libraries.
19 # RUN: ld.lld %t.o %t.o -r -o %t-r.o
20 # RUN: not ld.lld %t-r.o -o /dev/null 2>&1 | sort | FileCheck %s -DOBJ=%t-r.o --check-prefixes MINUSR
21 # MINUSR: error: [[OBJ]]: unable to find library from dependent library specifier: bar
22 # MINUSR-NEXT: error: [[OBJ]]: unable to find library from dependent library specifier: foo.a
23 # MINUSR-NOT: unable to find library from dependent library specifier
25 ## Dependent libraries searched for symbols after libraries on the command line.
26 # RUN: mkdir -p %t.cwd
27 # RUN: cd %t.cwd
28 # RUN: llvm-ar rc %t.dir/foo.a %tfoo.o
29 # RUN: touch %t.dir/libbar.so
30 # RUN: cp %t.dir/foo.a %t.cwd/libcmdline.a
31 # RUN: ld.lld %t.o libcmdline.a -o /dev/null -L %t.dir --trace 2>&1 | \
32 # RUN: FileCheck %s -DOBJ=%t.o -DSO=%t.dir --check-prefix CMDLINE \
33 # RUN: --implicit-check-not=foo.a --implicit-check-not=libbar.so
34 # CMDLINE: [[OBJ]]
35 # CMDLINE-NEXT: {{^libcmdline\.a}}
37 ## LLD tries to resolve dependent library specifiers in the following order:
38 ## 1) The name, prefixed with "lib" and suffixed with ".so" or ".a" in a
39 ## library search path. This means that a directive of "foo.a" could lead
40 ## to a library named "libfoo.a.a" being linked in.
41 ## 2) The literal name in a library search path.
42 ## 3) The literal name in the current working directory.
43 ## When using library search paths for dependent libraries, LLD follows the same
44 ## rules as for libraries specified on the command line.
45 # RUN: cp %t.dir/foo.a %t.cwd/foo.a
46 # RUN: cp %t.dir/foo.a %t.dir/libfoo.a.a
48 # RUN: ld.lld %t.o -o /dev/null -L %t.dir --trace 2>&1 | \
49 # RUN: FileCheck %s -DOBJ=%t.o -DDIR=%t.dir --check-prefix=LIBA-DIR \
50 # RUN: --implicit-check-not=foo.a --implicit-check-not=libbar.so
52 # LIBA-DIR: [[OBJ]]
53 # LIBA-DIR-NEXT: [[DIR]]{{[\\/]}}libfoo.a.a
55 # RUN: rm %t.dir/libfoo.a.a
56 # RUN: ld.lld %t.o -o /dev/null -L %t.dir --trace 2>&1 | \
57 # RUN: FileCheck %s -DOBJ=%t.o -DDIR=%t.dir --check-prefix=PLAIN-DIR \
58 # RUN: --implicit-check-not=foo.a --implicit-check-not=libbar.so
60 # PLAIN-DIR: [[OBJ]]
61 # PLAIN-DIR-NEXT: [[DIR]]{{[\\/]}}foo.a
63 # RUN: rm %t.dir/foo.a
64 # RUN: ld.lld %t.o -o /dev/null -L %t.dir --trace 2>&1 | \
65 # RUN: FileCheck %s -DOBJ=%t.o -DDIR=%t.dir --check-prefix=CWD \
66 # RUN: --implicit-check-not=foo.a --implicit-check-not=libbar.so
68 # CWD: [[OBJ]]
69 # CWD-NEXT: {{^foo\.a}}
71 call foo
72 .section ".deplibs","MS",@llvm_dependent_libraries,1
73 .asciz "foo.a"
74 ## Show that an unneeded archive must be present but may not be linked in.
75 .asciz "bar"