Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[llvm-libtool-darwin] Add support for -static option
Add support for creating static libraries when the input includes only Mach-O binaries (and not libraries/archives themselves). Reviewed by alexshap, Ktwu, smeenai, jhenderson, MaskRay, mtrent Differential Revision: https://reviews.llvm.org/D83002
- Loading branch information
1 parent
1154689
commit 303a7f7
Showing
9 changed files
with
191 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
66 changes: 66 additions & 0 deletions
66
llvm/test/tools/llvm-libtool-darwin/create-static-lib.test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
## This test checks that a correct static library is created. | ||
|
||
# RUN: yaml2obj %S/Inputs/input1.yaml -o %t-input1.o | ||
# RUN: yaml2obj %S/Inputs/input2.yaml -o %t-input2.o | ||
|
||
# RUN: rm -rf %t.lib | ||
# RUN: llvm-libtool-darwin -static -o %t.lib %t-input1.o %t-input2.o | ||
|
||
## Check that binaries are present: | ||
# RUN: llvm-ar t %t.lib | \ | ||
# RUN: FileCheck %s --check-prefix=CHECK-NAMES --implicit-check-not={{.}} -DPREFIX=%basename_t.tmp | ||
|
||
# CHECK-NAMES: [[PREFIX]]-input1.o | ||
# CHECK-NAMES-NEXT: [[PREFIX]]-input2.o | ||
|
||
## Check that symbols are present: | ||
# RUN: llvm-nm --print-armap %t.lib | \ | ||
# RUN: FileCheck %s --check-prefix=CHECK-SYMBOLS -DPREFIX=%basename_t.tmp --match-full-lines | ||
|
||
# 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 output archive is in Darwin format: | ||
# RUN: llvm-objdump --macho --archive-headers %t.lib | \ | ||
# RUN: FileCheck %s --check-prefix=FORMAT -DPREFIX=%basename_t.tmp -DARCHIVE=%t | ||
|
||
# FORMAT: Archive : [[ARCHIVE]] | ||
# FORMAT-NEXT: __.SYMDEF | ||
# FORMAT-NEXT: [[PREFIX]]-input1.o | ||
# FORMAT-NEXT: [[PREFIX]]-input2.o | ||
# FORMAT-NOT: {{.}} | ||
|
||
## Check that the output file is overwritten: | ||
# RUN: llvm-libtool-darwin -static -o %t.lib %t-input2.o | ||
# RUN: llvm-ar t %t.lib | \ | ||
# RUN: FileCheck %s --check-prefix=OVERWRITE-NAMES --implicit-check-not={{.}} -DPREFIX=%basename_t.tmp | ||
# RUN: llvm-nm --print-armap %t.lib | \ | ||
# RUN: FileCheck %s --check-prefix=OVERWRITE-SYMBOLS -DPREFIX=%basename_t.tmp --match-full-lines | ||
|
||
# OVERWRITE-NAMES: [[PREFIX]]-input2.o | ||
|
||
# OVERWRITE-SYMBOLS: Archive map | ||
# OVERWRITE-SYMBOLS-NEXT: _symbol2 in [[PREFIX]]-input2.o | ||
# OVERWRITE-SYMBOLS-EMPTY: | ||
|
||
## Duplicate a binary: | ||
## 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 %t-input1.o %t-input2.o %t-input1.o 2>&1 | \ | ||
# RUN: FileCheck %s --allow-empty --implicit-check-not={{.}} | ||
# RUN: llvm-ar t %t.lib | \ | ||
# RUN: FileCheck %s --check-prefix=DUPLICATE-NAMES --implicit-check-not={{.}} -DPREFIX=%basename_t.tmp | ||
# RUN: llvm-nm --print-armap %t.lib | \ | ||
# RUN: FileCheck %s --check-prefix=DUPLICATE-SYMBOLS -DPREFIX=%basename_t.tmp --match-full-lines | ||
|
||
# DUPLICATE-NAMES: [[PREFIX]]-input1.o | ||
# DUPLICATE-NAMES-NEXT: [[PREFIX]]-input2.o | ||
# DUPLICATE-NAMES-NEXT: [[PREFIX]]-input1.o | ||
|
||
# DUPLICATE-SYMBOLS: Archive map | ||
# DUPLICATE-SYMBOLS-NEXT: _symbol1 in [[PREFIX]]-input1.o | ||
# DUPLICATE-SYMBOLS-NEXT: _symbol2 in [[PREFIX]]-input2.o | ||
# DUPLICATE-SYMBOLS-NEXT: _symbol1 in [[PREFIX]]-input1.o | ||
# DUPLICATE-SYMBOLS-EMPTY: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 31 additions & 4 deletions
35
llvm/test/tools/llvm-libtool-darwin/invalid-input-output-args.test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,52 @@ | ||
## This test checks that an error is thrown in case of invalid input/output args. | ||
|
||
## Missing input file: | ||
# RUN: not llvm-libtool-darwin -o %t.lib 2>&1 | \ | ||
# RUN: not llvm-libtool-darwin -static -o %t.lib 2>&1 | \ | ||
# RUN: FileCheck %s --check-prefix=NO-INPUT | ||
|
||
# NO-INPUT: Must specify at least 1 positional argument | ||
|
||
## Missing output file: | ||
# RUN: not llvm-libtool-darwin %t.input 2>&1 | \ | ||
# RUN: not llvm-libtool-darwin -static %t.input 2>&1 | \ | ||
# RUN: FileCheck %s --check-prefix=NO-OUTPUT | ||
|
||
# NO-OUTPUT: for the -o option: must be specified at least once! | ||
|
||
## Missing argument to -o: | ||
# RUN: not llvm-libtool-darwin %t.input -o 2>&1 | \ | ||
# RUN: not llvm-libtool-darwin -static %t.input -o 2>&1 | \ | ||
# RUN: FileCheck %s --check-prefix=MISSING | ||
|
||
# MISSING: for the -o option: requires a value! | ||
|
||
## Passing in two output files: | ||
# RUN: not llvm-libtool-darwin %t.input -o %t.lib1 -o %t.lib2 2>&1 | \ | ||
# RUN: not llvm-libtool-darwin -static %t.input -o %t.lib1 -o %t.lib2 2>&1 | \ | ||
# RUN: FileCheck %s --check-prefix=DOUBLE-OUTPUT | ||
|
||
# DOUBLE-OUTPUT: for the -o option: must occur exactly one time! | ||
|
||
## Input file not found: | ||
# RUN: not llvm-libtool-darwin -static -o %t.lib %t.missing 2>&1 | \ | ||
# RUN: FileCheck %s --check-prefix=NO-FILE -DFILE=%t.missing | ||
|
||
# NO-FILE: error: '[[FILE]]': {{[nN]}}o such file or directory | ||
|
||
## Input file is not an object file: | ||
# RUN: touch %t.invalid | ||
# RUN: not llvm-libtool-darwin -static -o %t.lib %t.invalid 2>&1 | \ | ||
# RUN: FileCheck %s --check-prefix=NOT-OBJECT -DFILE=%basename_t.tmp.invalid | ||
|
||
# NOT-OBJECT: error: '[[FILE]]': The file was not recognized as a valid object file | ||
|
||
## Input file is not a Mach-O object file: | ||
# RUN: yaml2obj %s -o %t.elf | ||
# RUN: not llvm-libtool-darwin -static -o %t.lib %t.elf 2>&1 | \ | ||
# RUN: FileCheck %s --check-prefix=NOT-MACHO -DFILE=%basename_t.tmp.elf | ||
|
||
# NOT-MACHO: error: '[[FILE]]': format not supported | ||
|
||
--- !ELF | ||
FileHeader: | ||
Class: ELFCLASS64 | ||
Data: ELFDATA2LSB | ||
Type: ET_REL | ||
Machine: EM_X86_64 |
5 changes: 5 additions & 0 deletions
5
llvm/test/tools/llvm-libtool-darwin/missing-library-type.test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
## Missing library type option: | ||
# RUN: not llvm-libtool-darwin -o %t.lib %t.input 2>&1 | \ | ||
# RUN: FileCheck %s --check-prefix=MISSING-OPERATION | ||
|
||
# MISSING-OPERATION: Library Type: option: must be specified at least once! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
set(LLVM_LINK_COMPONENTS | ||
Object | ||
Support | ||
) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters