mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-24 11:59:56 +00:00
Introducing llvm-libtool-darwin
This diff starts the implementation of llvm-libtool-darwin (an llvm based replacement of cctool's libtool). Libtool is used for creating static and dynamic libraries from a bunch of object files given as input. Reviewed by alexshap, smeenai, jhenderson, MaskRay Differential Revision: https://reviews.llvm.org/D82923
This commit is contained in:
parent
02ac158b95
commit
4336e89619
@ -14,25 +14,26 @@ Basic Commands
|
||||
.. toctree::
|
||||
:maxdepth: 1
|
||||
|
||||
llvm-as
|
||||
llvm-dis
|
||||
opt
|
||||
dsymutil
|
||||
llc
|
||||
lli
|
||||
llvm-link
|
||||
llvm-lib
|
||||
llvm-lipo
|
||||
llvm-as
|
||||
llvm-config
|
||||
llvm-cov
|
||||
llvm-cxxmap
|
||||
llvm-diff
|
||||
llvm-cov
|
||||
llvm-dis
|
||||
llvm-dwarfdump
|
||||
llvm-lib
|
||||
llvm-libtool-darwin
|
||||
llvm-link
|
||||
llvm-lipo
|
||||
llvm-mca
|
||||
llvm-profdata
|
||||
llvm-readobj
|
||||
llvm-stress
|
||||
llvm-symbolizer
|
||||
llvm-dwarfdump
|
||||
dsymutil
|
||||
llvm-mca
|
||||
llvm-readobj
|
||||
opt
|
||||
|
||||
GNU binutils replacements
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
59
docs/CommandGuide/llvm-libtool-darwin.rst
Normal file
59
docs/CommandGuide/llvm-libtool-darwin.rst
Normal file
@ -0,0 +1,59 @@
|
||||
llvm-libtool-darwin - LLVM tool for creating libraries for Darwin
|
||||
=================================================================
|
||||
|
||||
.. program:: llvm-libtool-darwin
|
||||
|
||||
SYNOPSIS
|
||||
--------
|
||||
|
||||
:program:`llvm-libtool-darwin` [*options*] *<input files>*
|
||||
|
||||
DESCRIPTION
|
||||
-----------
|
||||
|
||||
:program:`llvm-libtool-darwin` is a tool for creating static and dynamic
|
||||
libraries for Darwin.
|
||||
|
||||
For most scenarios, it works as a drop-in replacement for cctools'
|
||||
:program:`libtool`.
|
||||
|
||||
OPTIONS
|
||||
--------
|
||||
:program:`llvm-libtool-darwin` supports the following options:
|
||||
|
||||
.. option:: -h, -help
|
||||
|
||||
Show help and usage for this command.
|
||||
|
||||
.. option:: -help-list
|
||||
|
||||
Show help and usage for this command without grouping the options
|
||||
into categories.
|
||||
|
||||
.. option:: -color
|
||||
|
||||
Use colors in output.
|
||||
|
||||
.. option:: -version
|
||||
|
||||
Display the version of this program.
|
||||
|
||||
.. option:: -o <filename>
|
||||
|
||||
Specify the output file name. Must be specified exactly once.
|
||||
|
||||
EXIT STATUS
|
||||
-----------
|
||||
|
||||
:program:`llvm-libtool-darwin` exits with a non-zero exit code if there is an error.
|
||||
Otherwise, it exits with code 0.
|
||||
|
||||
BUGS
|
||||
----
|
||||
|
||||
To report bugs, please visit <https://bugs.llvm.org/>.
|
||||
|
||||
SEE ALSO
|
||||
--------
|
||||
|
||||
:manpage:`llvm-ar(1)`
|
@ -83,6 +83,7 @@ set(LLVM_TEST_DEPENDS
|
||||
llvm-install-name-tool
|
||||
llvm-jitlink
|
||||
llvm-lib
|
||||
llvm-libtool-darwin
|
||||
llvm-link
|
||||
llvm-lipo
|
||||
llvm-locstats
|
||||
|
56
test/tools/llvm-libtool-darwin/Inputs/input1.yaml
Normal file
56
test/tools/llvm-libtool-darwin/Inputs/input1.yaml
Normal file
@ -0,0 +1,56 @@
|
||||
# int symbol1() {
|
||||
# return 0;
|
||||
# }
|
||||
--- !mach-o
|
||||
FileHeader:
|
||||
magic: 0xFEEDFACF
|
||||
cputype: 0x01000007
|
||||
cpusubtype: 0x00000003
|
||||
filetype: 0x00000001
|
||||
ncmds: 2
|
||||
sizeofcmds: 176
|
||||
flags: 0x00002000
|
||||
reserved: 0x00000000
|
||||
LoadCommands:
|
||||
- cmd: LC_SEGMENT_64
|
||||
cmdsize: 152
|
||||
segname: ''
|
||||
vmaddr: 0
|
||||
vmsize: 8
|
||||
fileoff: 312
|
||||
filesize: 8
|
||||
maxprot: 7
|
||||
initprot: 7
|
||||
nsects: 1
|
||||
flags: 0
|
||||
Sections:
|
||||
- sectname: __text
|
||||
segname: __TEXT
|
||||
addr: 0x0000000000000000
|
||||
size: 8
|
||||
offset: 0x00000138
|
||||
align: 4
|
||||
reloff: 0x00000000
|
||||
nreloc: 0
|
||||
flags: 0x80000400
|
||||
reserved1: 0x00000000
|
||||
reserved2: 0x00000000
|
||||
reserved3: 0x00000000
|
||||
content: 554889E531C05DC3
|
||||
- cmd: LC_SYMTAB
|
||||
cmdsize: 24
|
||||
symoff: 320
|
||||
nsyms: 1
|
||||
stroff: 336
|
||||
strsize: 8
|
||||
LinkEditData:
|
||||
NameList:
|
||||
- n_strx: 1
|
||||
n_type: 0x0F
|
||||
n_sect: 1
|
||||
n_desc: 0
|
||||
n_value: 0
|
||||
StringTable:
|
||||
- ''
|
||||
- _symbol1
|
||||
...
|
57
test/tools/llvm-libtool-darwin/Inputs/input2.yaml
Normal file
57
test/tools/llvm-libtool-darwin/Inputs/input2.yaml
Normal file
@ -0,0 +1,57 @@
|
||||
# int symbol2() {
|
||||
# return 0;
|
||||
# }
|
||||
--- !mach-o
|
||||
FileHeader:
|
||||
magic: 0xFEEDFACF
|
||||
cputype: 0x01000007
|
||||
cpusubtype: 0x00000003
|
||||
filetype: 0x00000001
|
||||
ncmds: 2
|
||||
sizeofcmds: 176
|
||||
flags: 0x00002000
|
||||
reserved: 0x00000000
|
||||
LoadCommands:
|
||||
- cmd: LC_SEGMENT_64
|
||||
cmdsize: 152
|
||||
segname: ''
|
||||
vmaddr: 0
|
||||
vmsize: 15
|
||||
fileoff: 312
|
||||
filesize: 15
|
||||
maxprot: 7
|
||||
initprot: 7
|
||||
nsects: 1
|
||||
flags: 0
|
||||
Sections:
|
||||
- sectname: __text
|
||||
segname: __TEXT
|
||||
addr: 0x0000000000000000
|
||||
size: 15
|
||||
offset: 0x00000138
|
||||
align: 4
|
||||
reloff: 0x00000000
|
||||
nreloc: 0
|
||||
flags: 0x80000400
|
||||
reserved1: 0x00000000
|
||||
reserved2: 0x00000000
|
||||
reserved3: 0x00000000
|
||||
content: 554889E531C0C745FC000000005DC3
|
||||
- cmd: LC_SYMTAB
|
||||
cmdsize: 24
|
||||
symoff: 328
|
||||
nsyms: 1
|
||||
stroff: 344
|
||||
strsize: 8
|
||||
LinkEditData:
|
||||
NameList:
|
||||
- n_strx: 1
|
||||
n_type: 0x0F
|
||||
n_sect: 1
|
||||
n_desc: 0
|
||||
n_value: 0
|
||||
StringTable:
|
||||
- ''
|
||||
- _symbol2
|
||||
- ''
|
||||
...
|
10
test/tools/llvm-libtool-darwin/basic.test
Normal file
10
test/tools/llvm-libtool-darwin/basic.test
Normal file
@ -0,0 +1,10 @@
|
||||
## This test checks that main exits normally (error code 0) for correct input/output args.
|
||||
|
||||
# RUN: yaml2obj %S/Inputs/input1.yaml -o %t-input1.o
|
||||
# RUN: yaml2obj %S/Inputs/input2.yaml -o %t-input2.o
|
||||
|
||||
## Pass single input:
|
||||
# RUN: llvm-libtool-darwin -o %t.lib %t-input1.o
|
||||
|
||||
## Pass multiple inputs:
|
||||
# RUN: llvm-libtool-darwin -o %t.lib %t-input1.o %t-input2.o
|
23
test/tools/llvm-libtool-darwin/help-message.test
Normal file
23
test/tools/llvm-libtool-darwin/help-message.test
Normal file
@ -0,0 +1,23 @@
|
||||
## This test checks that the help message is displayed correctly.
|
||||
|
||||
# RUN: llvm-libtool-darwin -h | FileCheck --check-prefixes=LIBTOOL-USAGE,CATEG %s --match-full-lines
|
||||
# RUN: llvm-libtool-darwin -help | FileCheck --check-prefixes=LIBTOOL-USAGE,CATEG %s --match-full-lines
|
||||
# RUN: llvm-libtool-darwin --help | FileCheck --check-prefixes=LIBTOOL-USAGE,CATEG %s --match-full-lines
|
||||
# RUN: llvm-libtool-darwin --help-list | \
|
||||
# RUN: FileCheck -check-prefixes=LIBTOOL-USAGE,LIST %s --match-full-lines
|
||||
|
||||
# RUN: not llvm-libtool-darwin -abcabc 2>&1 | FileCheck --check-prefix=UNKNOWN-ARG %s
|
||||
# RUN: not llvm-libtool-darwin --abcabc 2>&1 | FileCheck --check-prefix=UNKNOWN-ARG %s
|
||||
|
||||
# LIBTOOL-USAGE: OVERVIEW: llvm-libtool-darwin
|
||||
# LIBTOOL-USAGE: USAGE: llvm-libtool-darwin{{(\.exe)?}} [options] <input files>
|
||||
# LIBTOOL-USAGE: OPTIONS:
|
||||
|
||||
# CATEG: Color Options:
|
||||
# LIST-NOT: Color Options:
|
||||
# CATEG: Generic Options:
|
||||
# LIST-NOT: Generic Options:
|
||||
# CATEG: llvm-libtool-darwin Options:
|
||||
# LIST-NOT: llvm-libtool-darwin Options:
|
||||
|
||||
# UNKNOWN-ARG: Unknown command line argument '{{-+}}abcabc'
|
@ -0,0 +1,25 @@
|
||||
## 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: 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: 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: 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: FileCheck %s --check-prefix=DOUBLE-OUTPUT
|
||||
|
||||
# DOUBLE-OUTPUT: for the -o option: must occur exactly one time!
|
7
tools/llvm-libtool-darwin/CMakeLists.txt
Normal file
7
tools/llvm-libtool-darwin/CMakeLists.txt
Normal file
@ -0,0 +1,7 @@
|
||||
set(LLVM_LINK_COMPONENTS
|
||||
Support
|
||||
)
|
||||
|
||||
add_llvm_tool(llvm-libtool-darwin
|
||||
llvm-libtool-darwin.cpp
|
||||
)
|
20
tools/llvm-libtool-darwin/LLVMBuild.txt
Normal file
20
tools/llvm-libtool-darwin/LLVMBuild.txt
Normal file
@ -0,0 +1,20 @@
|
||||
;===- ./tools/llvm-libtool-darwin/LVMBuild.txt -----------------*- Conf -*--===;
|
||||
;
|
||||
; Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
; See https://llvm.org/LICENSE.txt for license information.
|
||||
; SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
;
|
||||
;===------------------------------------------------------------------------===;
|
||||
;
|
||||
; This is an LLVMBuild description file for the components in this subdirectory.
|
||||
;
|
||||
; For more information on the LLVMBuild system, please see:
|
||||
;
|
||||
; http://llvm.org/docs/LLVMBuild.html
|
||||
;
|
||||
;===------------------------------------------------------------------------===;
|
||||
[component_0]
|
||||
type = Tool
|
||||
name = llvm-libtool-darwin
|
||||
parent = Tools
|
||||
required_libraries = Support
|
34
tools/llvm-libtool-darwin/llvm-libtool-darwin.cpp
Normal file
34
tools/llvm-libtool-darwin/llvm-libtool-darwin.cpp
Normal file
@ -0,0 +1,34 @@
|
||||
//===-- llvm-libtool-darwin.cpp - a tool for creating libraries -----------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// A utility for creating static and dynamic libraries for Darwin.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "llvm/Support/CommandLine.h"
|
||||
#include "llvm/Support/InitLLVM.h"
|
||||
#include "llvm/Support/WithColor.h"
|
||||
|
||||
using namespace llvm;
|
||||
|
||||
cl::OptionCategory LibtoolCategory("llvm-libtool-darwin Options");
|
||||
|
||||
static cl::opt<std::string> OutputFile("o", cl::desc("Specify output filename"),
|
||||
cl::value_desc("filename"), cl::Required,
|
||||
cl::cat(LibtoolCategory));
|
||||
|
||||
static cl::list<std::string> InputFiles(cl::Positional,
|
||||
cl::desc("<input files>"),
|
||||
cl::OneOrMore,
|
||||
cl::cat(LibtoolCategory));
|
||||
|
||||
int main(int Argc, char **Argv) {
|
||||
InitLLVM X(Argc, Argv);
|
||||
cl::HideUnrelatedOptions({&LibtoolCategory, &ColorCategory});
|
||||
cl::ParseCommandLineOptions(Argc, Argv, "llvm-libtool-darwin\n");
|
||||
}
|
Loading…
Reference in New Issue
Block a user