Please use GitHub pull requests for new patches. Avoid migrating existing patches. Phabricator shutdown timeline
Changeset View
Standalone View
llvm/test/tools/llvm-libtool-darwin/L-and-l.test
- This file was added.
## This test checks that -l and -L options work correctly. | ||||||||||
sameerarora101: It doesn't make sense to test `-L` option individually as the directory specified under that… | ||||||||||
I don't think so. Other tools have options (like --sysroot) to re-root the search, but it doesn't appear that libtool has anything like that, so I don't think we'll be able to test that case. smeenai: I don't think so. Other tools have options (like `--sysroot`) to re-root the search, but it… | ||||||||||
# RUN: yaml2obj %S/Inputs/input1.yaml -o %t-input1.o | ||||||||||
# RUN: yaml2obj %S/Inputs/input2.yaml -o %t-input2.o | ||||||||||
## Check that the library is recognised when it ends with '.o': | ||||||||||
# RUN: llvm-libtool-darwin -static -o %t.lib -l%basename_t.tmp-input1.o -l%basename_t.tmp-input2.o -L%T | ||||||||||
# RUN: llvm-ar t %t.lib | \ | ||||||||||
Not Done ReplyInline ActionsI'd prefer for a file ending in .o to actually be an object file and not an archive :) smeenai: I'd prefer for a file ending in `.o` to actually be an object file and not an archive :) | ||||||||||
I just wanted to check that a library ending in .o is not prepended/appended with some additional string lol. How about the name archive-object.o? sameerarora101: I just wanted to check that a library ending in `.o` is not prepended/appended with some… | ||||||||||
Not Done ReplyInline ActionsI think the intent is, even though the option is -l (with the l presumably standing for library), you can still use it to specify input object files (so that you don't have to specify their full path). What I meant was to just have an object file and use -l to add that, instead of creating an archive and giving it a .o extension. smeenai: I think the intent is, even though the option is `-l` (with the l presumably standing for… | ||||||||||
Ah I see. Ok, I'll update it. sameerarora101: Ah I see. Ok, I'll update it. | ||||||||||
You should place lines like this that are tied to an individual test-case, below the comment that goes with the case, as that explains the purpose of the line. jhenderson: You should place lines like this that are tied to an individual test-case, below the comment… | ||||||||||
# RUN: FileCheck %s --check-prefix=CHECK-NAMES --implicit-check-not={{.}} -DPREFIX=%basename_t.tmp | ||||||||||
# RUN: llvm-nm --print-armap %t.lib | \ | ||||||||||
# RUN: FileCheck %s --check-prefix=CHECK-SYMBOLS -DPREFIX=%basename_t.tmp --match-full-lines | ||||||||||
# CHECK-NAMES: [[PREFIX]]-input1.o | ||||||||||
# CHECK-NAMES-NEXT: [[PREFIX]]-input2.o | ||||||||||
# CHECK-SYMBOLS: Archive map | ||||||||||
# CHECK-SYMBOLS-NEXT: _symbol1 in [[PREFIX]]-input1.o | ||||||||||
# CHECK-SYMBOLS-NEXT: _symbol2 in [[PREFIX]]-input2.o | ||||||||||
# CHECK-SYMBOLS-EMPTY: | ||||||||||
## Check that the library is recognised when prepended with 'lib' and appended with '.a': | ||||||||||
# RUN: rm -rf %t/dirname && mkdir -p %t/dirname | ||||||||||
# RUN: llvm-ar cr %t/dirname/libinput2.a %t-input2.o | ||||||||||
Maybe worth naming archives with a single member in them after the member's name, e.g. here libinput2.a I think that helps readability, also possibly reusability (see below). jhenderson: Maybe worth naming archives with a single member in them after the member's name, e.g. here… | ||||||||||
# RUN: llvm-libtool-darwin -static -o %t.lib -linput2 -L%t/dirname | ||||||||||
# RUN: llvm-ar t %t.lib | \ | ||||||||||
# RUN: FileCheck %s --check-prefix=SINGLE-NAMES --implicit-check-not={{.}} -DPREFIX=%basename_t.tmp | ||||||||||
jhenderson: | ||||||||||
# RUN: llvm-nm --print-armap %t.lib | \ | ||||||||||
# RUN: FileCheck %s --check-prefix=SINGLE-SYMBOLS -DPREFIX=%basename_t.tmp --match-full-lines | ||||||||||
# SINGLE-NAMES: [[PREFIX]]-input2.o | ||||||||||
# SINGLE-SYMBOLS: Archive map | ||||||||||
# SINGLE-SYMBOLS-NEXT: _symbol2 in [[PREFIX]]-input2.o | ||||||||||
# SINGLE-SYMBOLS-EMPTY: | ||||||||||
## -l and -L option specified multiple times: | ||||||||||
# RUN: rm -rf %t/otherDirname && mkdir -p %t/otherDirname | ||||||||||
# RUN: llvm-ar cr %t/otherDirname/libinput1.a %t-input1.o | ||||||||||
# RUN: llvm-libtool-darwin -static -o %t.lib -linput2 -linput1 -L%t/dirname -L%t/otherDirname | ||||||||||
# RUN: llvm-ar t %t.lib | \ | ||||||||||
# RUN: FileCheck %s --check-prefix=OTHER-NAMES --implicit-check-not={{.}} -DPREFIX=%basename_t.tmp | ||||||||||
# RUN: llvm-nm --print-armap %t.lib | \ | ||||||||||
# RUN: FileCheck %s --check-prefix=OTHER-SYMBOLS -DPREFIX=%basename_t.tmp --match-full-lines | ||||||||||
# OTHER-NAMES: [[PREFIX]]-input2.o | ||||||||||
# OTHER-NAMES-NEXT: [[PREFIX]]-input1.o | ||||||||||
# OTHER-SYMBOLS: Archive map | ||||||||||
# OTHER-SYMBOLS-NEXT: _symbol2 in [[PREFIX]]-input2.o | ||||||||||
# OTHER-SYMBOLS-NEXT: _symbol1 in [[PREFIX]]-input1.o | ||||||||||
# OTHER-SYMBOLS-EMPTY: | ||||||||||
## Check that if multiple directories specified with -L have the same named file | ||||||||||
## in them, the file from the first directory is selected. | ||||||||||
# RUN: llvm-ar cr %t/otherDirname/libinput2.a %t-input1.o | ||||||||||
# RUN: llvm-libtool-darwin -static -o %t.lib -linput2 -L%t/dirname -L%t/otherDirname | ||||||||||
Rather than create two new archives here, you could just create one, in otherDirname, containing input1.o. You already have a library in dirname containing input2.o, so if you name the new one the same, you can use that one too. jhenderson: Rather than create two new archives here, you could just create one, in `otherDirname`… | ||||||||||
# RUN: llvm-ar t %t.lib | \ | ||||||||||
# RUN: FileCheck %s --check-prefix=SINGLE-NAMES --implicit-check-not={{.}} -DPREFIX=%basename_t.tmp | ||||||||||
# RUN: llvm-nm --print-armap %t.lib | \ | ||||||||||
# RUN: FileCheck %s --check-prefix=SINGLE-SYMBOLS -DPREFIX=%basename_t.tmp --match-full-lines | ||||||||||
## -l option combined with an input file: | ||||||||||
# RUN: llvm-libtool-darwin -static -o %t.lib %t-input1.o -linput2 -L%t/dirname | ||||||||||
# RUN: llvm-ar t %t.lib | \ | ||||||||||
# RUN: FileCheck %s --check-prefix=CHECK-NAMES --implicit-check-not={{.}} -DPREFIX=%basename_t.tmp | ||||||||||
# RUN: llvm-nm --print-armap %t.lib | \ | ||||||||||
# RUN: FileCheck %s --check-prefix=CHECK-SYMBOLS -DPREFIX=%basename_t.tmp --match-full-lines | ||||||||||
## Specify same -l option twice: | ||||||||||
## cctools' libtool raises a warning in this case. | ||||||||||
## The warning is not yet implemented for llvm-libtool-darwin. | ||||||||||
# RUN: llvm-libtool-darwin -static -o %t.lib -l%basename_t.tmp-input2.o -l%basename_t.tmp-input2.o -L%T | ||||||||||
# RUN: llvm-ar t %t.lib | \ | ||||||||||
# RUN: FileCheck %s --check-prefix=DOUBLE-NAMES --implicit-check-not={{.}} -DPREFIX=%basename_t.tmp | ||||||||||
# RUN: llvm-nm --print-armap %t.lib | \ | ||||||||||
# RUN: FileCheck %s --check-prefix=DOUBLE-SYMBOLS -DPREFIX=%basename_t.tmp --match-full-lines | ||||||||||
# DOUBLE-NAMES: [[PREFIX]]-input2.o | ||||||||||
# DOUBLE-NAMES-NEXT: [[PREFIX]]-input2.o | ||||||||||
# DOUBLE-SYMBOLS: Archive map | ||||||||||
# DOUBLE-SYMBOLS-NEXT: _symbol2 in [[PREFIX]]-input2.o | ||||||||||
# DOUBLE-SYMBOLS-NEXT: _symbol2 in [[PREFIX]]-input2.o | ||||||||||
Other test ideas:
smeenai: Other test ideas:
- If multiple directories specified with `-L` have the same named file in… | ||||||||||
Thanks, added now. For the second test case, I assumed you meant passing in a library with -l along with a normal input file? Or did you mean prepending -l to an input file name? For the third case, libtool throws a warning (similar to what it does when we specify the same input file twice). I have added a comment about that in my test case above now. sameerarora101: Thanks, added now.
For the second test case, I assumed you meant passing in a library with `… | ||||||||||
Not Done ReplyInline ActionsYup, that's what I meant for the second case. smeenai: Yup, that's what I meant for the second case. | ||||||||||
# DOUBLE-SYMBOLS-EMPTY: | ||||||||||
## Check that an error is thrown when the input library cannot be found: | ||||||||||
# RUN: not llvm-libtool-darwin -static -o %t.lib -lfile-will-not-exist.o 2>&1 | \ | ||||||||||
# RUN: FileCheck %s --check-prefix=NOT-FOUND -DFILE=file-will-not-exist.o | ||||||||||
# NOT-FOUND: error: cannot locate file '[[FILE]]' | ||||||||||
## Check that an error is thrown when the input library cannot be found | ||||||||||
## (for a file prepended with 'lib' and appended with '.a'): | ||||||||||
# RUN: not llvm-libtool-darwin -static -o %t.lib -lfile-will-not-exist 2>&1 | \ | ||||||||||
# RUN: FileCheck %s --check-prefix=NOT-FOUND -DFILE=libfile-will-not-exist.a | ||||||||||
One more test for this area: a file called something like file, and show that -lfile doesn't find it (since lib and .a are added). Relatedly, maybe also show that -llibfile.a looks for liblibfile.a not libfile.a? jhenderson: One more test for this area: a file called something like `file`, and show that `-lfile`… | ||||||||||
Added now, thanks. sameerarora101: Added now, thanks. | ||||||||||
Not Done ReplyInline ActionsThis doesn't work if you do have a libfile.a, which is a real library that exists; on FreeBSD it comes as part of schilybase, and so having that package installed breaks this test. jrtc27: This doesn't work if you do have a libfile.a, which is a real library that exists; on FreeBSD… | ||||||||||
Not Done ReplyInline ActionsHeh, fixed in rG22b5fe74782a smeenai: Heh, fixed in rG22b5fe74782a | ||||||||||
Not Done ReplyInline ActionsGreat, thanks for the quick follow-up jrtc27: Great, thanks for the quick follow-up | ||||||||||
## Check that an error is thrown when the input library cannot be found | ||||||||||
## (since 'lib' and '.a' are added): | ||||||||||
Can you test this for a name ending with .a as well? smeenai: Can you test this for a name ending with `.a` as well? | ||||||||||
Did you mean for a file to which '.a' is appended, right? (The name itself doesn't end in '.a' but since the name doesn't end in '.o', 'lib' and '.a' are added to it)? If that is what you meant, added a test for it now. Thanks. sameerarora101: Did you mean for a file to which `'.a'` is **appended**, right? (The name itself doesn't end in… | ||||||||||
# RUN: llvm-ar cr %t/dirname/file %t-input1.o | ||||||||||
# RUN: not llvm-libtool-darwin -static -o %t.lib -lfile -L%t/dirname 2>&1 | \ | ||||||||||
This one too? smeenai: This one too? | ||||||||||
# RUN: FileCheck %s --check-prefix=NOT-FOUND -DFILE=libfile.a | ||||||||||
# RUN: llvm-ar cr %t/dirname/libfile.a %t-input1.o | ||||||||||
# RUN: not llvm-libtool-darwin -static -o %t.lib -llibfile.a -L%t/dirname 2>&1 | \ | ||||||||||
# RUN: FileCheck %s --check-prefix=NOT-FOUND -DFILE=liblibfile.a.a | ||||||||||
## Check that an error is thrown when the input library is not valid: | ||||||||||
Let's also add a test case with a file extension other than these two, e.g. .ext and show that the behaviour is specific to '.o'. jhenderson: Let's also add a test case with a file extension other than these two, e.g. `.ext` and show… | ||||||||||
# RUN: touch %t/dirname/not-valid.o | ||||||||||
# RUN: not llvm-libtool-darwin -static -o %t.lib -lnot-valid.o -L%t/dirname 2>&1 | \ | ||||||||||
You need the -L%t/dirname as well, right? smeenai: You need the `-L%t/dirname` as well, right? | ||||||||||
yup, added. thanks sameerarora101: yup, added. thanks | ||||||||||
# RUN: FileCheck %s --check-prefix=NOT-VALID -DFILE=not-valid.o | ||||||||||
# NOT-VALID: error: '[[FILE]]': The file was not recognized as a valid object file | ||||||||||
## Check that an error is thrown when the input library is not valid: | ||||||||||
I might suggest changing the -l file's name here to something even more arbitrary such as "-lfile-will-not-exist". Since libtool searches certain directories by default, there's a (small) chance the file being searched for is in one of those directories. The weirder we make the name, the smaller this chance, and therefore the less likely this test case will fail on somebody's system. jhenderson: I might suggest changing the `-l` file's name here to something even more arbitrary such as "… | ||||||||||
## (for a file prepended with 'lib' and appended with '.a'): | ||||||||||
# RUN: touch %t/dirname/libnot-valid.a | ||||||||||
# RUN: not llvm-libtool-darwin -static -o %t.lib -lnot-valid -L%t/dirname 2>&1 | \ | ||||||||||
# RUN: FileCheck %s --check-prefix=NOT-VALID -DFILE=libnot-valid.a | ||||||||||
## Check that 'lib' and '.a' are not added to a file ending in '.o': | ||||||||||
# RUN: llvm-ar cr %t/dirname/libfoo.o.a %t-input1.o | ||||||||||
# RUN: not llvm-libtool-darwin -static -o %t.lib -lfoo.o -L%t/dirname 2>&1 | \ | ||||||||||
# RUN: FileCheck %s --check-prefix=NOT-FOUND -DFILE=foo.o | ||||||||||
## Check that 'lib' and '.a' are added to a file ending in any other extension | ||||||||||
## beside '.o' (e.g. '.ext'): | ||||||||||
# RUN: llvm-ar cr %t/dirname/libbar.ext.a %t-input2.o | ||||||||||
# RUN: llvm-libtool-darwin -static -o %t.lib -lbar.ext -L%t/dirname | ||||||||||
# RUN: llvm-ar t %t.lib | \ | ||||||||||
# RUN: FileCheck %s --check-prefix=SINGLE-NAMES --implicit-check-not={{.}} -DPREFIX=%basename_t.tmp | ||||||||||
# RUN: llvm-nm --print-armap %t.lib | \ | ||||||||||
# RUN: FileCheck %s --check-prefix=SINGLE-SYMBOLS -DPREFIX=%basename_t.tmp --match-full-lines |
It doesn't make sense to test -L option individually as the directory specified under that option is used (prepended) only if some library is also specified with option -l.
To test -l individually, I would need to create a library in one of the standard directories (/lib/, /usr/lib, /usr/local/lib). Is there a way I can do that in a test file? Thanks.