1## This test checks that -l and -L options work correctly. 2 3# RUN: yaml2obj %S/Inputs/input1.yaml -o %t-input1.o 4# RUN: yaml2obj %S/Inputs/input2.yaml -o %t-input2.o 5 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 12 13# CHECK-NAMES: [[PREFIX]]-input1.o 14# CHECK-NAMES-NEXT: [[PREFIX]]-input2.o 15 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: 20 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 24 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 30 31# SINGLE-NAMES: [[PREFIX]]-input2.o 32 33# SINGLE-SYMBOLS: Archive map 34# SINGLE-SYMBOLS-NEXT: _symbol2 in [[PREFIX]]-input2.o 35# SINGLE-SYMBOLS-EMPTY: 36 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 40 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 46 47## Check it is possible to pass arguments to -l and -L separated from the option 48## and the options specified multiple times: 49# RUN: rm -rf %t/otherDirname && mkdir -p %t/otherDirname 50# RUN: llvm-ar cr %t/otherDirname/libinput1.a %t-input1.o 51 52# RUN: llvm-libtool-darwin -static -o %t.lib -l input2 -l input1 -L %t/dirname -L %t/otherDirname 53# RUN: llvm-ar t %t.lib | \ 54# RUN: FileCheck %s --check-prefix=OTHER-NAMES --implicit-check-not={{.}} -DPREFIX=%basename_t.tmp 55# RUN: llvm-nm --print-armap %t.lib | \ 56# RUN: FileCheck %s --check-prefix=OTHER-SYMBOLS -DPREFIX=%basename_t.tmp --match-full-lines 57 58# OTHER-NAMES: [[PREFIX]]-input2.o 59# OTHER-NAMES-NEXT: [[PREFIX]]-input1.o 60 61# OTHER-SYMBOLS: Archive map 62# OTHER-SYMBOLS-NEXT: _symbol2 in [[PREFIX]]-input2.o 63# OTHER-SYMBOLS-NEXT: _symbol1 in [[PREFIX]]-input1.o 64# OTHER-SYMBOLS-EMPTY: 65 66## Check that if multiple directories specified with -L have the same named file 67## in them, the file from the first directory is selected. 68# RUN: llvm-ar cr %t/otherDirname/libinput2.a %t-input1.o 69 70# RUN: llvm-libtool-darwin -static -o %t.lib -linput2 -L%t/dirname -L%t/otherDirname 71# RUN: llvm-ar t %t.lib | \ 72# RUN: FileCheck %s --check-prefix=SINGLE-NAMES --implicit-check-not={{.}} -DPREFIX=%basename_t.tmp 73# RUN: llvm-nm --print-armap %t.lib | \ 74# RUN: FileCheck %s --check-prefix=SINGLE-SYMBOLS -DPREFIX=%basename_t.tmp --match-full-lines 75 76## Check that if two different files with the same names are explicitly 77## specified, the command gives a warning. 78# RUN: cp %t-input2.o %t/dirname 79# RUN: llvm-libtool-darwin -static -o %t.lib \ 80# RUN: %t/dirname/%basename_t.tmp-input2.o %t-input2.o 2>&1 | \ 81# RUN: FileCheck %s --check-prefix=DUPLICATE-INPUT \ 82# RUN: -DFILE=%basename_t.tmp-input2.o \ 83# RUN: -DINPUTA=%t/dirname/%basename_t.tmp-input2.o \ 84# RUN: -DINPUTB=%t-input2.o 85 86# DUPLICATE-INPUT: warning: file '[[FILE]]' was specified multiple times. 87# DUPLICATE-INPUT-DAG: [[INPUTA]] 88# DUPLICATE-INPUT-DAG: [[INPUTB]] 89 90## -l option combined with an input file: 91# RUN: llvm-libtool-darwin -static -o %t.lib %t-input1.o -linput2 -L%t/dirname 92# RUN: llvm-ar t %t.lib | \ 93# RUN: FileCheck %s --check-prefix=CHECK-NAMES --implicit-check-not={{.}} -DPREFIX=%basename_t.tmp 94# RUN: llvm-nm --print-armap %t.lib | \ 95# RUN: FileCheck %s --check-prefix=CHECK-SYMBOLS -DPREFIX=%basename_t.tmp --match-full-lines 96 97## Specify the same file with a -l option and an input file: 98# RUN: rm -rf %t/copy 99# RUN: mkdir -p %t/copy 100# RUN: cp %t-input1.o %t/copy 101# RUN: llvm-libtool-darwin -static -o %t.lib \ 102# RUN: %t/copy/%basename_t.tmp-input1.o -l%basename_t.tmp-input1.o -L%t/copy 2>&1 | \ 103# RUN: FileCheck %s --check-prefix=DUPLICATE-L-INPUT -DFILE=%basename_t.tmp-input1.o 104 105## Specify same -l option twice: 106# RUN: llvm-libtool-darwin -static -o %t.lib -l%basename_t.tmp-input1.o \ 107# RUN: -l%basename_t.tmp-input1.o -L%t/copy 2>&1 | \ 108# RUN: FileCheck %s --check-prefix=DUPLICATE-L-INPUT \ 109# RUN: -DFILE=%basename_t.tmp-input1.o 110 111# DUPLICATE-L-INPUT: warning: file '[[FILE]]' was specified multiple times. 112 113## Check that an error is thrown when the input library cannot be found: 114# RUN: not llvm-libtool-darwin -static -o %t.lib -lfile-will-not-exist.o 2>&1 | \ 115# RUN: FileCheck %s --check-prefix=NOT-FOUND -DFILE=file-will-not-exist.o 116 117# NOT-FOUND: error: cannot locate file '[[FILE]]' 118 119## Check that an error is thrown when the input library cannot be found 120## (for a file prepended with 'lib' and appended with '.a'): 121# RUN: not llvm-libtool-darwin -static -o %t.lib -lfile-will-not-exist 2>&1 | \ 122# RUN: FileCheck %s --check-prefix=NOT-FOUND -DFILE=libfile-will-not-exist.a 123 124## Check that an error is thrown when the input library cannot be found 125## (since 'lib' and '.a' are added): 126# RUN: llvm-ar cr %t/dirname/file-does-exist %t-input1.o 127# RUN: not llvm-libtool-darwin -static -o %t.lib -lfile-does-exist -L%t/dirname 2>&1 | \ 128# RUN: FileCheck %s --check-prefix=NOT-FOUND -DFILE=libfile-does-exist.a 129 130# RUN: llvm-ar cr %t/dirname/libfile-does-exist.a %t-input1.o 131# RUN: not llvm-libtool-darwin -static -o %t.lib -llibfile-does-exist.a -L%t/dirname 2>&1 | \ 132# RUN: FileCheck %s --check-prefix=NOT-FOUND -DFILE=liblibfile-does-exist.a.a 133 134## Check that an error is thrown when the input library is not valid: 135# RUN: touch %t/dirname/not-valid.o 136# RUN: not llvm-libtool-darwin -static -o %t.lib -lnot-valid.o -L%t/dirname 2>&1 | \ 137# RUN: FileCheck %s --check-prefix=NOT-VALID -DFILE=not-valid.o 138 139# NOT-VALID: error: '[[FILE]]': The file was not recognized as a valid object file 140 141## Check that an error is thrown when the input library is not valid: 142## (for a file prepended with 'lib' and appended with '.a'): 143# RUN: touch %t/dirname/libnot-valid.a 144# RUN: not llvm-libtool-darwin -static -o %t.lib -lnot-valid -L%t/dirname 2>&1 | \ 145# RUN: FileCheck %s --check-prefix=NOT-VALID -DFILE=libnot-valid.a 146 147## Check that 'lib' and '.a' are not added to a file ending in '.o': 148# RUN: llvm-ar cr %t/dirname/libfoo.o.a %t-input1.o 149# RUN: not llvm-libtool-darwin -static -o %t.lib -lfoo.o -L%t/dirname 2>&1 | \ 150# RUN: FileCheck %s --check-prefix=NOT-FOUND -DFILE=foo.o 151 152## Check that 'lib' and '.a' are added to a file ending in any other extension 153## beside '.o' (e.g. '.ext'): 154# RUN: llvm-ar cr %t/dirname/libbar.ext.a %t-input2.o 155# RUN: llvm-libtool-darwin -static -o %t.lib -lbar.ext -L%t/dirname 156# RUN: llvm-ar t %t.lib | \ 157# RUN: FileCheck %s --check-prefix=SINGLE-NAMES --implicit-check-not={{.}} -DPREFIX=%basename_t.tmp 158# RUN: llvm-nm --print-armap %t.lib | \ 159# RUN: FileCheck %s --check-prefix=SINGLE-SYMBOLS -DPREFIX=%basename_t.tmp --match-full-lines 160