mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2024-11-24 22:30:13 +00:00
[llvm-driver] Add various tools to the llvm-driver
The llvm-driver, enabled with LLVM_TOOL_LLVM_DRIVER_BUILD combines many llvm executables into one to save overall toolchain size. This patch adds a few more llvm tools to the llvm-driver. Differential Revision: https://reviews.llvm.org/D135281
This commit is contained in:
parent
7cbc920669
commit
d5090cd94a
@ -1,6 +1,6 @@
|
||||
set(LLVM_LINK_COMPONENTS
|
||||
BinaryFormat
|
||||
InterfaceStub
|
||||
InterfaceStub
|
||||
Object
|
||||
Support
|
||||
TextAPI
|
||||
@ -18,4 +18,6 @@ add_llvm_tool(llvm-ifs
|
||||
|
||||
DEPENDS
|
||||
IFSOptsTableGen
|
||||
|
||||
GENERATE_DRIVER
|
||||
)
|
||||
|
@ -376,7 +376,7 @@ static DriverConfig parseArgs(int argc, char *const *argv) {
|
||||
return Config;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
int llvm_ifs_main(int argc, char *argv[]) {
|
||||
DriverConfig Config = parseArgs(argc, argv);
|
||||
|
||||
if (Config.InputFilePaths.empty())
|
||||
|
@ -16,6 +16,7 @@ add_llvm_tool(llvm-lipo
|
||||
llvm-lipo.cpp
|
||||
DEPENDS
|
||||
LipoOptsTableGen
|
||||
GENERATE_DRIVER
|
||||
)
|
||||
|
||||
if(LLVM_INSTALL_CCTOOLS_SYMLINKS)
|
||||
|
@ -719,7 +719,7 @@ replaceSlices(LLVMContext &LLVMCtx,
|
||||
exit(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
int llvm_lipo_main(int argc, char **argv) {
|
||||
InitLLVM X(argc, argv);
|
||||
llvm::InitializeAllTargetInfos();
|
||||
llvm::InitializeAllTargetMCs();
|
||||
|
@ -11,4 +11,5 @@ add_public_tablegen_target(MtTableGen)
|
||||
|
||||
add_llvm_tool(llvm-mt
|
||||
llvm-mt.cpp
|
||||
GENERATE_DRIVER
|
||||
)
|
||||
|
@ -79,7 +79,7 @@ static void error(Error EC) {
|
||||
});
|
||||
}
|
||||
|
||||
int main(int Argc, const char **Argv) {
|
||||
int llvm_mt_main(int Argc, char **Argv) {
|
||||
InitLLVM X(Argc, Argv);
|
||||
|
||||
CvtResOptTable T;
|
||||
|
@ -21,6 +21,7 @@ add_llvm_tool(llvm-nm
|
||||
DEPENDS
|
||||
NmOptsTableGen
|
||||
intrinsics_gen
|
||||
GENERATE_DRIVER
|
||||
)
|
||||
|
||||
if(LLVM_INSTALL_BINUTILS_SYMLINKS)
|
||||
|
@ -2297,7 +2297,7 @@ exportSymbolNamesFromFiles(const std::vector<std::string> &InputFilenames) {
|
||||
printExportSymbolList(SymbolList);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
int llvm_nm_main(int argc, char **argv) {
|
||||
InitLLVM X(argc, argv);
|
||||
BumpPtrAllocator A;
|
||||
StringSaver Saver(A);
|
||||
@ -2474,4 +2474,5 @@ int main(int argc, char **argv) {
|
||||
|
||||
if (HadError)
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
@ -11,4 +11,5 @@ add_llvm_tool(llvm-profdata
|
||||
|
||||
DEPENDS
|
||||
intrinsics_gen
|
||||
GENERATE_DRIVER
|
||||
)
|
||||
|
@ -2826,7 +2826,8 @@ static int show_main(int argc, const char *argv[]) {
|
||||
return showMemProfProfile(Filename, ProfiledBinary, OS);
|
||||
}
|
||||
|
||||
int main(int argc, const char *argv[]) {
|
||||
int llvm_profdata_main(int argc, char **argvNonConst) {
|
||||
const char **argv = const_cast<const char **>(argvNonConst);
|
||||
InitLLVM X(argc, argv);
|
||||
|
||||
StringRef ProgName(sys::path::filename(argv[0]));
|
||||
|
@ -19,6 +19,7 @@ add_llvm_tool(llvm-rc
|
||||
ResourceScriptParser.cpp
|
||||
ResourceScriptStmt.cpp
|
||||
ResourceScriptToken.cpp
|
||||
GENERATE_DRIVER
|
||||
)
|
||||
|
||||
add_llvm_tool_symlink(llvm-windres llvm-rc)
|
||||
|
@ -724,12 +724,12 @@ void doCvtres(std::string Src, std::string Dest, std::string TargetTriple) {
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
int main(int Argc, const char **Argv) {
|
||||
int llvm_rc_main(int Argc, char **Argv) {
|
||||
InitLLVM X(Argc, Argv);
|
||||
ExitOnErr.setBanner("llvm-rc: ");
|
||||
|
||||
const char **DashDash = std::find_if(
|
||||
Argv + 1, Argv + Argc, [](StringRef Str) { return Str == "--"; });
|
||||
char **DashDash = std::find_if(Argv + 1, Argv + Argc,
|
||||
[](StringRef Str) { return Str == "--"; });
|
||||
ArrayRef<const char *> ArgsArr = makeArrayRef(Argv + 1, DashDash);
|
||||
ArrayRef<const char *> FileArgsArr;
|
||||
if (DashDash != Argv + Argc)
|
||||
|
@ -27,6 +27,7 @@ add_llvm_tool(llvm-readobj
|
||||
Win64EHDumper.cpp
|
||||
WindowsResourceDumper.cpp
|
||||
XCOFFDumper.cpp
|
||||
GENERATE_DRIVER
|
||||
)
|
||||
|
||||
add_llvm_tool_symlink(llvm-readelf llvm-readobj)
|
||||
|
@ -613,7 +613,7 @@ std::unique_ptr<ScopedPrinter> createWriter() {
|
||||
return std::make_unique<ScopedPrinter>(fouts());
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
int llvm_readobj_main(int argc, char *argv[]) {
|
||||
InitLLVM X(argc, argv);
|
||||
BumpPtrAllocator A;
|
||||
StringSaver Saver(A);
|
||||
|
@ -12,6 +12,7 @@ add_llvm_tool(llvm-size
|
||||
llvm-size.cpp
|
||||
DEPENDS
|
||||
SizeOptsTableGen
|
||||
GENERATE_DRIVER
|
||||
)
|
||||
|
||||
if(LLVM_INSTALL_BINUTILS_SYMLINKS)
|
||||
|
@ -866,7 +866,7 @@ static void printBerkeleyTotals() {
|
||||
<< "(TOTALS)\n";
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
int llvm_size_main(int argc, char **argv) {
|
||||
InitLLVM X(argc, argv);
|
||||
BumpPtrAllocator A;
|
||||
StringSaver Saver(A);
|
||||
@ -941,4 +941,5 @@ int main(int argc, char **argv) {
|
||||
|
||||
if (HadError)
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,11 +1,12 @@
|
||||
import("//llvm/utils/TableGen/tablegen.gni")
|
||||
import("//llvm/utils/gn/build/driver_executable.gni")
|
||||
|
||||
tablegen("Opts") {
|
||||
visibility = [ ":llvm-ifs" ]
|
||||
args = [ "-gen-opt-parser-defs" ]
|
||||
}
|
||||
|
||||
executable("llvm-ifs") {
|
||||
driver_executable("llvm-ifs") {
|
||||
deps = [
|
||||
":Opts",
|
||||
"//llvm/lib/InterfaceStub",
|
||||
|
@ -1,5 +1,6 @@
|
||||
import("//llvm/tools/cctools_symlinks.gni")
|
||||
import("//llvm/utils/TableGen/tablegen.gni")
|
||||
import("//llvm/utils/gn/build/driver_executable.gni")
|
||||
import("//llvm/utils/gn/build/symlink_or_copy.gni")
|
||||
|
||||
tablegen("LipoOpts") {
|
||||
@ -23,7 +24,7 @@ group("symlinks") {
|
||||
}
|
||||
}
|
||||
|
||||
executable("llvm-lipo") {
|
||||
driver_executable("llvm-lipo") {
|
||||
deps = [
|
||||
":LipoOpts",
|
||||
"//llvm/lib/Object",
|
||||
|
@ -1,11 +1,12 @@
|
||||
import("//llvm/utils/TableGen/tablegen.gni")
|
||||
import("//llvm/utils/gn/build/driver_executable.gni")
|
||||
|
||||
tablegen("Opts") {
|
||||
visibility = [ ":llvm-mt" ]
|
||||
args = [ "-gen-opt-parser-defs" ]
|
||||
}
|
||||
|
||||
executable("llvm-mt") {
|
||||
driver_executable("llvm-mt") {
|
||||
deps = [
|
||||
":Opts",
|
||||
"//llvm/lib/Option",
|
||||
|
@ -1,5 +1,6 @@
|
||||
import("//llvm/tools/binutils_symlinks.gni")
|
||||
import("//llvm/utils/TableGen/tablegen.gni")
|
||||
import("//llvm/utils/gn/build/driver_executable.gni")
|
||||
import("//llvm/utils/gn/build/symlink_or_copy.gni")
|
||||
|
||||
tablegen("Opts") {
|
||||
@ -23,7 +24,7 @@ group("symlinks") {
|
||||
}
|
||||
}
|
||||
|
||||
executable("llvm-nm") {
|
||||
driver_executable("llvm-nm") {
|
||||
deps = [
|
||||
":Opts",
|
||||
"//llvm/lib/Bitcode/Reader",
|
||||
|
@ -1,4 +1,6 @@
|
||||
executable("llvm-profdata") {
|
||||
import("//llvm/utils/gn/build/driver_executable.gni")
|
||||
|
||||
driver_executable("llvm-profdata") {
|
||||
deps = [
|
||||
"//llvm/lib/IR",
|
||||
"//llvm/lib/ProfileData",
|
||||
|
@ -1,5 +1,6 @@
|
||||
import("//llvm/tools/binutils_symlinks.gni")
|
||||
import("//llvm/utils/TableGen/tablegen.gni")
|
||||
import("//llvm/utils/gn/build/driver_executable.gni")
|
||||
import("//llvm/utils/gn/build/symlink_or_copy.gni")
|
||||
|
||||
tablegen("Opts") {
|
||||
@ -33,7 +34,7 @@ group("symlinks") {
|
||||
}
|
||||
}
|
||||
|
||||
executable("llvm-rc") {
|
||||
driver_executable("llvm-rc") {
|
||||
deps = [
|
||||
":Opts",
|
||||
":WindresOpts",
|
||||
|
@ -1,5 +1,6 @@
|
||||
import("//llvm/tools/binutils_symlinks.gni")
|
||||
import("//llvm/utils/TableGen/tablegen.gni")
|
||||
import("//llvm/utils/gn/build/driver_executable.gni")
|
||||
import("//llvm/utils/gn/build/symlink_or_copy.gni")
|
||||
|
||||
tablegen("Opts") {
|
||||
@ -27,7 +28,7 @@ group("symlinks") {
|
||||
}
|
||||
}
|
||||
|
||||
executable("llvm-readobj") {
|
||||
driver_executable("llvm-readobj") {
|
||||
deps = [
|
||||
":Opts",
|
||||
"//llvm/lib/BinaryFormat",
|
||||
|
@ -1,5 +1,6 @@
|
||||
import("//llvm/tools/binutils_symlinks.gni")
|
||||
import("//llvm/utils/TableGen/tablegen.gni")
|
||||
import("//llvm/utils/gn/build/driver_executable.gni")
|
||||
import("//llvm/utils/gn/build/symlink_or_copy.gni")
|
||||
|
||||
tablegen("Opts") {
|
||||
@ -23,7 +24,7 @@ group("symlinks") {
|
||||
}
|
||||
}
|
||||
|
||||
executable("llvm-size") {
|
||||
driver_executable("llvm-size") {
|
||||
deps = [
|
||||
":Opts",
|
||||
"//llvm/lib/Object",
|
||||
|
@ -3124,12 +3124,21 @@ gentbl(
|
||||
td_srcs = ["include/llvm/Option/OptParser.td"],
|
||||
)
|
||||
|
||||
expand_template(
|
||||
name = "ifs_main",
|
||||
out = "llvm-ifs-driver.cpp",
|
||||
substitutions = {
|
||||
"@TOOL_NAME@": "llvm_ifs",
|
||||
},
|
||||
template = "cmake/modules/llvm-driver-template.cpp.in",
|
||||
)
|
||||
|
||||
cc_binary(
|
||||
name = "llvm-ifs",
|
||||
srcs = glob([
|
||||
"tools/llvm-ifs/*.cpp",
|
||||
"tools/llvm-ifs/*.h",
|
||||
]),
|
||||
]) + ["llvm-ifs-driver.cpp"],
|
||||
copts = llvm_copts,
|
||||
stamp = 0,
|
||||
deps = [
|
||||
@ -3232,11 +3241,20 @@ gentbl(
|
||||
td_srcs = ["include/llvm/Option/OptParser.td"],
|
||||
)
|
||||
|
||||
expand_template(
|
||||
name = "lipo_main",
|
||||
out = "llvm-lipo-driver.cpp",
|
||||
substitutions = {
|
||||
"@TOOL_NAME@": "llvm_lipo",
|
||||
},
|
||||
template = "cmake/modules/llvm-driver-template.cpp.in",
|
||||
)
|
||||
|
||||
cc_binary(
|
||||
name = "llvm-lipo",
|
||||
srcs = [
|
||||
"tools/llvm-lipo/llvm-lipo.cpp",
|
||||
],
|
||||
] + ["llvm-lipo-driver.cpp"],
|
||||
copts = llvm_copts,
|
||||
stamp = 0,
|
||||
deps = [
|
||||
@ -3391,12 +3409,21 @@ gentbl(
|
||||
td_srcs = ["include/llvm/Option/OptParser.td"],
|
||||
)
|
||||
|
||||
expand_template(
|
||||
name = "mt_main",
|
||||
out = "llvm-mt-driver.cpp",
|
||||
substitutions = {
|
||||
"@TOOL_NAME@": "llvm_mt",
|
||||
},
|
||||
template = "cmake/modules/llvm-driver-template.cpp.in",
|
||||
)
|
||||
|
||||
cc_binary(
|
||||
name = "llvm-mt",
|
||||
srcs = glob([
|
||||
"tools/llvm-mt/*.cpp",
|
||||
"tools/llvm-mt/*.h",
|
||||
]),
|
||||
]) + ["llvm-mt-driver.cpp"],
|
||||
copts = llvm_copts,
|
||||
stamp = 0,
|
||||
deps = [
|
||||
@ -3419,12 +3446,21 @@ gentbl(
|
||||
td_srcs = ["include/llvm/Option/OptParser.td"],
|
||||
)
|
||||
|
||||
expand_template(
|
||||
name = "nm_main",
|
||||
out = "llvm-nm-driver.cpp",
|
||||
substitutions = {
|
||||
"@TOOL_NAME@": "llvm_nm",
|
||||
},
|
||||
template = "cmake/modules/llvm-driver-template.cpp.in",
|
||||
)
|
||||
|
||||
cc_binary(
|
||||
name = "llvm-nm",
|
||||
srcs = glob([
|
||||
"tools/llvm-nm/*.cpp",
|
||||
"tools/llvm-nm/*.h",
|
||||
]),
|
||||
]) + ["llvm-nm-driver.cpp"],
|
||||
copts = llvm_copts,
|
||||
stamp = 0,
|
||||
deps = [
|
||||
@ -3657,12 +3693,21 @@ cc_binary(
|
||||
],
|
||||
)
|
||||
|
||||
expand_template(
|
||||
name = "profdata_main",
|
||||
out = "llvm-profdata-driver.cpp",
|
||||
substitutions = {
|
||||
"@TOOL_NAME@": "llvm_profdata",
|
||||
},
|
||||
template = "cmake/modules/llvm-driver-template.cpp.in",
|
||||
)
|
||||
|
||||
cc_binary(
|
||||
name = "llvm-profdata",
|
||||
srcs = glob([
|
||||
"tools/llvm-profdata/*.cpp",
|
||||
"tools/llvm-profdata/*.h",
|
||||
]),
|
||||
]) + ["llvm-profdata-driver.cpp"],
|
||||
copts = llvm_copts,
|
||||
stamp = 0,
|
||||
deps = [
|
||||
@ -3717,12 +3762,21 @@ cc_library(
|
||||
textual_hdrs = glob(["tools/llvm-rc/*.def"]),
|
||||
)
|
||||
|
||||
expand_template(
|
||||
name = "rc_main",
|
||||
out = "llvm-rc-driver.cpp",
|
||||
substitutions = {
|
||||
"@TOOL_NAME@": "llvm_rc",
|
||||
},
|
||||
template = "cmake/modules/llvm-driver-template.cpp.in",
|
||||
)
|
||||
|
||||
cc_binary(
|
||||
name = "llvm-rc",
|
||||
srcs = glob([
|
||||
"tools/llvm-rc/*.cpp",
|
||||
"tools/llvm-rc/*.h",
|
||||
]),
|
||||
]) + ["llvm-rc-driver.cpp"],
|
||||
copts = llvm_copts,
|
||||
stamp = 0,
|
||||
deps = [
|
||||
@ -3752,12 +3806,21 @@ gentbl(
|
||||
td_srcs = ["include/llvm/Option/OptParser.td"],
|
||||
)
|
||||
|
||||
expand_template(
|
||||
name = "readobj_main",
|
||||
out = "llvm-readobj-driver.cpp",
|
||||
substitutions = {
|
||||
"@TOOL_NAME@": "llvm_readobj",
|
||||
},
|
||||
template = "cmake/modules/llvm-driver-template.cpp.in",
|
||||
)
|
||||
|
||||
cc_binary(
|
||||
name = "llvm-readobj",
|
||||
srcs = glob([
|
||||
"tools/llvm-readobj/*.cpp",
|
||||
"tools/llvm-readobj/*.h",
|
||||
]),
|
||||
]) + ["llvm-readobj-driver.cpp"],
|
||||
copts = llvm_copts,
|
||||
stamp = 0,
|
||||
deps = [
|
||||
@ -3848,12 +3911,21 @@ gentbl(
|
||||
td_srcs = ["include/llvm/Option/OptParser.td"],
|
||||
)
|
||||
|
||||
expand_template(
|
||||
name = "size_main",
|
||||
out = "llvm-size-driver.cpp",
|
||||
substitutions = {
|
||||
"@TOOL_NAME@": "llvm_size",
|
||||
},
|
||||
template = "cmake/modules/llvm-driver-template.cpp.in",
|
||||
)
|
||||
|
||||
cc_binary(
|
||||
name = "llvm-size",
|
||||
srcs = glob([
|
||||
"tools/llvm-size/*.cpp",
|
||||
"tools/llvm-size/*.h",
|
||||
]),
|
||||
]) + ["llvm-size-driver.cpp"],
|
||||
copts = llvm_copts,
|
||||
stamp = 0,
|
||||
deps = [
|
||||
|
Loading…
Reference in New Issue
Block a user