1 ## This test checks that -l and -L options work correctly.
3 # RUN: yaml2obj %S/Inputs/input1.yaml -o %t-input1.o
4 # RUN: yaml2obj %S/Inputs/input2.yaml -o %t-input2.o
6 ## Check that the library is recognised when it ends with '.o':
7 # RUN: llvm-libtool-darwin -static -o %t.lib -l%basename_t.tmp-input1.o -l%basename_t.tmp-input2.o -L%T
8 # RUN: llvm-ar t %t.lib | \
9 # RUN: FileCheck %s --check-prefix=CHECK-NAMES --implicit-check-not={{.}} -DPREFIX=%basename_t.tmp
10 # RUN: llvm-nm --print-armap %t.lib | \
11 # RUN: FileCheck %s --check-prefix=CHECK-SYMBOLS -DPREFIX=%basename_t.tmp --match-full-lines
13 # CHECK-NAMES: [[PREFIX]]-input1.o
14 # CHECK-NAMES-NEXT: [[PREFIX]]-input2.o
16 # CHECK-SYMBOLS: Archive map
17 # CHECK-SYMBOLS-NEXT: _symbol1 in [[PREFIX]]-input1.o
18 # CHECK-SYMBOLS-NEXT: _symbol2 in [[PREFIX]]-input2.o
19 # CHECK-SYMBOLS-EMPTY:
21 ## Check that the library is recognised when prepended with 'lib' and appended with '.a':
22 # RUN: rm -rf %t/dirname && mkdir -p %t/dirname
23 # RUN: llvm-ar cr %t/dirname/libinput2.a %t-input2.o
25 # RUN: llvm-libtool-darwin -static -o %t.lib -linput2 -L%t/dirname
26 # RUN: llvm-ar t %t.lib | \
27 # RUN: FileCheck %s --check-prefix=SINGLE-NAMES --implicit-check-not={{.}} -DPREFIX=%basename_t.tmp
28 # RUN: llvm-nm --print-armap %t.lib | \
29 # RUN: FileCheck %s --check-prefix=SINGLE-SYMBOLS -DPREFIX=%basename_t.tmp --match-full-lines
31 # SINGLE-NAMES: [[PREFIX]]-input2.o
33 # SINGLE-SYMBOLS: Archive map
34 # SINGLE-SYMBOLS-NEXT: _symbol2 in [[PREFIX]]-input2.o
35 # SINGLE-SYMBOLS-EMPTY:
37 ## -l and -L option specified multiple times:
38 # RUN: rm -rf %t/otherDirname && mkdir -p %t/otherDirname
39 # RUN: llvm-ar cr %t/otherDirname/libinput1.a %t-input1.o
41 # RUN: llvm-libtool-darwin -static -o %t.lib -linput2 -linput1 -L%t/dirname -L%t/otherDirname
42 # RUN: llvm-ar t %t.lib | \
43 # RUN: FileCheck %s --check-prefix=OTHER-NAMES --implicit-check-not={{.}} -DPREFIX=%basename_t.tmp
44 # RUN: llvm-nm --print-armap %t.lib | \
45 # RUN: FileCheck %s --check-prefix=OTHER-SYMBOLS -DPREFIX=%basename_t.tmp --match-full-lines
47 # OTHER-NAMES: [[PREFIX]]-input2.o
48 # OTHER-NAMES-NEXT: [[PREFIX]]-input1.o
50 # OTHER-SYMBOLS: Archive map
51 # OTHER-SYMBOLS-NEXT: _symbol2 in [[PREFIX]]-input2.o
52 # OTHER-SYMBOLS-NEXT: _symbol1 in [[PREFIX]]-input1.o
53 # OTHER-SYMBOLS-EMPTY:
55 ## Check that if multiple directories specified with -L have the same named file
56 ## in them, the file from the first directory is selected.
57 # RUN: llvm-ar cr %t/otherDirname/libinput2.a %t-input1.o
59 # RUN: llvm-libtool-darwin -static -o %t.lib -linput2 -L%t/dirname -L%t/otherDirname
60 # RUN: llvm-ar t %t.lib | \
61 # RUN: FileCheck %s --check-prefix=SINGLE-NAMES --implicit-check-not={{.}} -DPREFIX=%basename_t.tmp
62 # RUN: llvm-nm --print-armap %t.lib | \
63 # RUN: FileCheck %s --check-prefix=SINGLE-SYMBOLS -DPREFIX=%basename_t.tmp --match-full-lines
65 ## -l option combined with an input file:
66 # RUN: llvm-libtool-darwin -static -o %t.lib %t-input1.o -linput2 -L%t/dirname
67 # RUN: llvm-ar t %t.lib | \
68 # RUN: FileCheck %s --check-prefix=CHECK-NAMES --implicit-check-not={{.}} -DPREFIX=%basename_t.tmp
69 # RUN: llvm-nm --print-armap %t.lib | \
70 # RUN: FileCheck %s --check-prefix=CHECK-SYMBOLS -DPREFIX=%basename_t.tmp --match-full-lines
72 ## Specify same -l option twice:
73 ## cctools' libtool raises a warning in this case.
74 ## The warning is not yet implemented for llvm-libtool-darwin.
75 # RUN: llvm-libtool-darwin -static -o %t.lib -l%basename_t.tmp-input2.o -l%basename_t.tmp-input2.o -L%T
76 # RUN: llvm-ar t %t.lib | \
77 # RUN: FileCheck %s --check-prefix=DOUBLE-NAMES --implicit-check-not={{.}} -DPREFIX=%basename_t.tmp
78 # RUN: llvm-nm --print-armap %t.lib | \
79 # RUN: FileCheck %s --check-prefix=DOUBLE-SYMBOLS -DPREFIX=%basename_t.tmp --match-full-lines
81 # DOUBLE-NAMES: [[PREFIX]]-input2.o
82 # DOUBLE-NAMES-NEXT: [[PREFIX]]-input2.o
84 # DOUBLE-SYMBOLS: Archive map
85 # DOUBLE-SYMBOLS-NEXT: _symbol2 in [[PREFIX]]-input2.o
86 # DOUBLE-SYMBOLS-NEXT: _symbol2 in [[PREFIX]]-input2.o
87 # DOUBLE-SYMBOLS-EMPTY:
89 ## Check that an error is thrown when the input library cannot be found:
90 # RUN: not llvm-libtool-darwin -static -o %t.lib -lfile-will-not-exist.o 2>&1 | \
91 # RUN: FileCheck %s --check-prefix=NOT-FOUND -DFILE=file-will-not-exist.o
93 # NOT-FOUND: error: cannot locate file '[[FILE]]'
95 ## Check that an error is thrown when the input library cannot be found
96 ## (for a file prepended with 'lib' and appended with '.a'):
97 # RUN: not llvm-libtool-darwin -static -o %t.lib -lfile-will-not-exist 2>&1 | \
98 # RUN: FileCheck %s --check-prefix=NOT-FOUND -DFILE=libfile-will-not-exist.a
100 ## Check that an error is thrown when the input library cannot be found
101 ## (since 'lib' and '.a' are added):
102 # RUN: llvm-ar cr %t/dirname/file %t-input1.o
103 # RUN: not llvm-libtool-darwin -static -o %t.lib -lfile -L%t/dirname 2>&1 | \
104 # RUN: FileCheck %s --check-prefix=NOT-FOUND -DFILE=libfile.a
106 # RUN: llvm-ar cr %t/dirname/libfile.a %t-input1.o
107 # RUN: not llvm-libtool-darwin -static -o %t.lib -llibfile.a -L%t/dirname 2>&1 | \
108 # RUN: FileCheck %s --check-prefix=NOT-FOUND -DFILE=liblibfile.a.a
110 ## Check that an error is thrown when the input library is not valid:
111 # RUN: touch %t/dirname/not-valid.o
112 # RUN: not llvm-libtool-darwin -static -o %t.lib -lnot-valid.o -L%t/dirname 2>&1 | \
113 # RUN: FileCheck %s --check-prefix=NOT-VALID -DFILE=not-valid.o
115 # NOT-VALID: error: '[[FILE]]': The file was not recognized as a valid object file
117 ## Check that an error is thrown when the input library is not valid:
118 ## (for a file prepended with 'lib' and appended with '.a'):
119 # RUN: touch %t/dirname/libnot-valid.a
120 # RUN: not llvm-libtool-darwin -static -o %t.lib -lnot-valid -L%t/dirname 2>&1 | \
121 # RUN: FileCheck %s --check-prefix=NOT-VALID -DFILE=libnot-valid.a
123 ## Check that 'lib' and '.a' are not added to a file ending in '.o':
124 # RUN: llvm-ar cr %t/dirname/libfoo.o.a %t-input1.o
125 # RUN: not llvm-libtool-darwin -static -o %t.lib -lfoo.o -L%t/dirname 2>&1 | \
126 # RUN: FileCheck %s --check-prefix=NOT-FOUND -DFILE=foo.o
128 ## Check that 'lib' and '.a' are added to a file ending in any other extension
129 ## beside '.o' (e.g. '.ext'):
130 # RUN: llvm-ar cr %t/dirname/libbar.ext.a %t-input2.o
131 # RUN: llvm-libtool-darwin -static -o %t.lib -lbar.ext -L%t/dirname
132 # RUN: llvm-ar t %t.lib | \
133 # RUN: FileCheck %s --check-prefix=SINGLE-NAMES --implicit-check-not={{.}} -DPREFIX=%basename_t.tmp
134 # RUN: llvm-nm --print-armap %t.lib | \
135 # RUN: FileCheck %s --check-prefix=SINGLE-SYMBOLS -DPREFIX=%basename_t.tmp --match-full-lines