brintos

brintos / llvm-project-archived public Read only

0
0
Text · 7.0 KiB · e8a5885 Raw
161 lines · plain
1## This test checks that -l and -L options work correctly.2 3# RUN: mkdir -p %t.dir4# RUN: yaml2obj %S/Inputs/input1.yaml -o %t.dir/input1.o5# RUN: yaml2obj %S/Inputs/input2.yaml -o %t.dir/input2.o6 7## Check that the library is recognised when it ends with '.o':8# RUN: llvm-libtool-darwin -static -o %t.lib -linput1.o -linput2.o -L%t.dir9# RUN: llvm-ar t %t.lib | \10# RUN:   FileCheck %s --check-prefix=CHECK-NAMES --implicit-check-not={{.}}11# RUN: llvm-nm --print-armap %t.lib | \12# RUN:   FileCheck %s --check-prefix=CHECK-SYMBOLS --match-full-lines13 14# CHECK-NAMES:      input1.o15# CHECK-NAMES-NEXT: input2.o16 17# CHECK-SYMBOLS:      Archive map18# CHECK-SYMBOLS-NEXT: _symbol1 in input1.o19# CHECK-SYMBOLS-NEXT: _symbol2 in input2.o20# CHECK-SYMBOLS-EMPTY:21 22## Check that the library is recognised when prepended with 'lib' and appended with '.a':23# RUN: rm -rf %t/dirname && mkdir -p %t/dirname24# RUN: llvm-ar cr %t/dirname/libinput2.a %t.dir/input2.o25 26# RUN: llvm-libtool-darwin -static -o %t.lib -linput2 -L%t/dirname27# RUN: llvm-ar t %t.lib | \28# RUN:   FileCheck %s --check-prefix=SINGLE-NAMES --implicit-check-not={{.}}29# RUN: llvm-nm --print-armap %t.lib | \30# RUN:   FileCheck %s --check-prefix=SINGLE-SYMBOLS --match-full-lines31 32# SINGLE-NAMES: input2.o33 34# SINGLE-SYMBOLS:      Archive map35# SINGLE-SYMBOLS-NEXT: _symbol2 in input2.o36# SINGLE-SYMBOLS-EMPTY:37 38## -l and -L option specified multiple times:39# RUN: rm -rf %t/otherDirname && mkdir -p %t/otherDirname40# RUN: llvm-ar cr %t/otherDirname/libinput1.a %t.dir/input1.o41 42# RUN: llvm-libtool-darwin -static -o %t.lib -linput2 -linput1 -L%t/dirname -L%t/otherDirname43# RUN: llvm-ar t %t.lib | \44# RUN:   FileCheck %s --check-prefix=OTHER-NAMES --implicit-check-not={{.}}45# RUN: llvm-nm --print-armap %t.lib | \46# RUN:   FileCheck %s --check-prefix=OTHER-SYMBOLS --match-full-lines47 48## Check it is possible to pass arguments to -l and -L separated from the option49## and the options specified multiple times:50# RUN: rm -rf %t/otherDirname && mkdir -p %t/otherDirname51# RUN: llvm-ar cr %t/otherDirname/libinput1.a %t.dir/input1.o52 53# RUN: llvm-libtool-darwin -static -o %t.lib -l input2 -l input1 -L %t/dirname -L %t/otherDirname54# RUN: llvm-ar t %t.lib | \55# RUN:   FileCheck %s --check-prefix=OTHER-NAMES --implicit-check-not={{.}}56# RUN: llvm-nm --print-armap %t.lib | \57# RUN:   FileCheck %s --check-prefix=OTHER-SYMBOLS --match-full-lines58 59# OTHER-NAMES:      input2.o60# OTHER-NAMES-NEXT: input1.o61 62# OTHER-SYMBOLS:      Archive map63# OTHER-SYMBOLS-NEXT: _symbol2 in input2.o64# OTHER-SYMBOLS-NEXT: _symbol1 in input1.o65# OTHER-SYMBOLS-EMPTY:66 67## Check that if multiple directories specified with -L have the same named file68## in them, the file from the first directory is selected.69# RUN: llvm-ar cr %t/otherDirname/libinput2.a %t.dir/input1.o70 71# RUN: llvm-libtool-darwin -static -o %t.lib -linput2 -L%t/dirname -L%t/otherDirname72# RUN: llvm-ar t %t.lib | \73# RUN:   FileCheck %s --check-prefix=SINGLE-NAMES --implicit-check-not={{.}}74# RUN: llvm-nm --print-armap %t.lib | \75# RUN:   FileCheck %s --check-prefix=SINGLE-SYMBOLS --match-full-lines76 77## Check that if two different files with the same names are explicitly78## specified, the command gives a warning.79# RUN: cp %t.dir/input2.o %t/dirname80# RUN: llvm-libtool-darwin -static -o %t.lib \81# RUN:   %t/dirname/input2.o %t.dir/input2.o 2>&1 | \82# RUN:   FileCheck %s --check-prefix=DUPLICATE-INPUT \83# RUN:     -DFILE=input2.o \84# RUN:     -DINPUTA=%t/dirname/input2.o \85# RUN:     -DINPUTB=%t.dir/input2.o86 87# DUPLICATE-INPUT:     warning: file '[[FILE]]' was specified multiple times.88# DUPLICATE-INPUT-DAG: [[INPUTA]]89# DUPLICATE-INPUT-DAG: [[INPUTB]]90 91## -l option combined with an input file:92# RUN: llvm-libtool-darwin -static -o %t.lib %t.dir/input1.o -linput2 -L%t/dirname93# RUN: llvm-ar t %t.lib | \94# RUN:   FileCheck %s --check-prefix=CHECK-NAMES --implicit-check-not={{.}}95# RUN: llvm-nm --print-armap %t.lib | \96# RUN:   FileCheck %s --check-prefix=CHECK-SYMBOLS --match-full-lines97 98## Specify the same file with a -l option and an input file:99# RUN: rm -rf %t/copy100# RUN: mkdir -p %t/copy101# RUN: cp %t.dir/input1.o %t/copy102# RUN: llvm-libtool-darwin -static -o %t.lib \103# RUN:   %t/copy/input1.o -linput1.o -L%t/copy 2>&1 | \104# RUN:   FileCheck %s --check-prefix=DUPLICATE-L-INPUT -DFILE=input1.o105 106## Specify same -l option twice:107# RUN: llvm-libtool-darwin -static -o %t.lib -linput1.o \108# RUN:  -linput1.o -L%t/copy 2>&1 | \109# RUN:   FileCheck %s --check-prefix=DUPLICATE-L-INPUT \110# RUN:     -DFILE=input1.o111 112# DUPLICATE-L-INPUT:     warning: file '[[FILE]]' was specified multiple times.113 114## Check that an error is thrown when the input library cannot be found:115# RUN: not llvm-libtool-darwin -static -o %t.lib -lfile-will-not-exist.o 2>&1 | \116# RUN:   FileCheck %s --check-prefix=NOT-FOUND -DFILE=file-will-not-exist.o117 118# NOT-FOUND: error: cannot locate file '[[FILE]]'119 120## Check that an error is thrown when the input library cannot be found121## (for a file prepended with 'lib' and appended with '.a'):122# RUN: not llvm-libtool-darwin -static -o %t.lib -lfile-will-not-exist 2>&1 | \123# RUN:   FileCheck %s --check-prefix=NOT-FOUND -DFILE=libfile-will-not-exist.a124 125## Check that an error is thrown when the input library cannot be found126## (since 'lib' and '.a' are added):127# RUN: llvm-ar cr %t/dirname/file-does-exist %t.dir/input1.o128# RUN: not llvm-libtool-darwin -static -o %t.lib -lfile-does-exist -L%t/dirname 2>&1 | \129# RUN:   FileCheck %s --check-prefix=NOT-FOUND -DFILE=libfile-does-exist.a130 131# RUN: llvm-ar cr %t/dirname/libfile-does-exist.a %t.dir/input1.o132# RUN: not llvm-libtool-darwin -static -o %t.lib -llibfile-does-exist.a -L%t/dirname 2>&1 | \133# RUN:   FileCheck %s --check-prefix=NOT-FOUND -DFILE=liblibfile-does-exist.a.a134 135## Check that an error is thrown when the input library is not valid:136# RUN: touch %t/dirname/not-valid.o137# RUN: not llvm-libtool-darwin -static -o %t.lib -lnot-valid.o -L%t/dirname 2>&1 | \138# RUN:   FileCheck %s --check-prefix=NOT-VALID -DFILE=not-valid.o139 140# NOT-VALID: error: '[[FILE]]': The file was not recognized as a valid object file141 142## Check that an error is thrown when the input library is not valid:143## (for a file prepended with 'lib' and appended with '.a'):144# RUN: touch %t/dirname/libnot-valid.a145# RUN: not llvm-libtool-darwin -static -o %t.lib -lnot-valid -L%t/dirname 2>&1 | \146# RUN:   FileCheck %s --check-prefix=NOT-VALID -DFILE=libnot-valid.a147 148## Check that 'lib' and '.a' are not added to a file ending in '.o':149# RUN: llvm-ar cr %t/dirname/libfoo.o.a %t.dir/input1.o150# RUN: not llvm-libtool-darwin -static -o %t.lib -lfoo.o -L%t/dirname 2>&1 | \151# RUN:   FileCheck %s --check-prefix=NOT-FOUND -DFILE=foo.o152 153## Check that 'lib' and '.a' are added to a file ending in any other extension154## beside '.o' (e.g. '.ext'):155# RUN: llvm-ar cr %t/dirname/libbar.ext.a %t.dir/input2.o156# RUN: llvm-libtool-darwin -static -o %t.lib -lbar.ext -L%t/dirname157# RUN: llvm-ar t %t.lib | \158# RUN:   FileCheck %s --check-prefix=SINGLE-NAMES --implicit-check-not={{.}} -DPREFIX=%basename_t.tmp159# RUN: llvm-nm --print-armap %t.lib | \160# RUN:   FileCheck %s --check-prefix=SINGLE-SYMBOLS -DPREFIX=%basename_t.tmp --match-full-lines161