You've already forked linux-packaging-mono
Imported Upstream version 5.18.0.207
Former-commit-id: 3b152f462918d427ce18620a2cbe4f8b79650449
This commit is contained in:
parent
8e12397d70
commit
eb85e2fc17
2
external/llvm/lib/ToolDrivers/CMakeLists.txt
vendored
2
external/llvm/lib/ToolDrivers/CMakeLists.txt
vendored
@ -1,2 +0,0 @@
|
||||
add_subdirectory(llvm-dlltool)
|
||||
add_subdirectory(llvm-lib)
|
24
external/llvm/lib/ToolDrivers/LLVMBuild.txt
vendored
24
external/llvm/lib/ToolDrivers/LLVMBuild.txt
vendored
@ -1,24 +0,0 @@
|
||||
;===- ./lib/ToolDrivers/LLVMBuild.txt --------------------------*- Conf -*--===;
|
||||
;
|
||||
; The LLVM Compiler Infrastructure
|
||||
;
|
||||
; This file is distributed under the University of Illinois Open Source
|
||||
; License. See LICENSE.TXT for details.
|
||||
;
|
||||
;===------------------------------------------------------------------------===;
|
||||
;
|
||||
; 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
|
||||
;
|
||||
;===------------------------------------------------------------------------===;
|
||||
|
||||
[common]
|
||||
subdirectories = llvm-dlltool llvm-lib
|
||||
|
||||
[component_0]
|
||||
type = Group
|
||||
name = ToolDrivers
|
||||
parent = Libraries
|
@ -1,9 +0,0 @@
|
||||
set(LLVM_TARGET_DEFINITIONS Options.td)
|
||||
tablegen(LLVM Options.inc -gen-opt-parser-defs)
|
||||
add_public_tablegen_target(DllOptionsTableGen)
|
||||
|
||||
add_llvm_library(LLVMDlltoolDriver
|
||||
DlltoolDriver.cpp
|
||||
)
|
||||
|
||||
add_dependencies(LLVMDlltoolDriver DllOptionsTableGen)
|
@ -1,179 +0,0 @@
|
||||
//===- DlltoolDriver.cpp - dlltool.exe-compatible driver ------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Defines an interface to a dlltool.exe-compatible driver.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "llvm/ToolDrivers/llvm-dlltool/DlltoolDriver.h"
|
||||
#include "llvm/Object/COFF.h"
|
||||
#include "llvm/Object/COFFImportFile.h"
|
||||
#include "llvm/Object/COFFModuleDefinition.h"
|
||||
#include "llvm/Option/Arg.h"
|
||||
#include "llvm/Option/ArgList.h"
|
||||
#include "llvm/Option/Option.h"
|
||||
#include "llvm/Support/Path.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
using namespace llvm;
|
||||
using namespace llvm::object;
|
||||
using namespace llvm::COFF;
|
||||
|
||||
namespace {
|
||||
|
||||
enum {
|
||||
OPT_INVALID = 0,
|
||||
#define OPTION(_1, _2, ID, _4, _5, _6, _7, _8, _9, _10, _11, _12) OPT_##ID,
|
||||
#include "Options.inc"
|
||||
#undef OPTION
|
||||
};
|
||||
|
||||
#define PREFIX(NAME, VALUE) const char *const NAME[] = VALUE;
|
||||
#include "Options.inc"
|
||||
#undef PREFIX
|
||||
|
||||
static const llvm::opt::OptTable::Info InfoTable[] = {
|
||||
#define OPTION(X1, X2, ID, KIND, GROUP, ALIAS, X7, X8, X9, X10, X11, X12) \
|
||||
{X1, X2, X10, X11, OPT_##ID, llvm::opt::Option::KIND##Class, \
|
||||
X9, X8, OPT_##GROUP, OPT_##ALIAS, X7, X12},
|
||||
#include "Options.inc"
|
||||
#undef OPTION
|
||||
};
|
||||
|
||||
class DllOptTable : public llvm::opt::OptTable {
|
||||
public:
|
||||
DllOptTable() : OptTable(InfoTable, false) {}
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
// Opens a file. Path has to be resolved already.
|
||||
static std::unique_ptr<MemoryBuffer> openFile(const Twine &Path) {
|
||||
ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> MB = MemoryBuffer::getFile(Path);
|
||||
|
||||
if (std::error_code EC = MB.getError()) {
|
||||
llvm::errs() << "cannot open file " << Path << ": " << EC.message() << "\n";
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return std::move(*MB);
|
||||
}
|
||||
|
||||
static MachineTypes getEmulation(StringRef S) {
|
||||
return StringSwitch<MachineTypes>(S)
|
||||
.Case("i386", IMAGE_FILE_MACHINE_I386)
|
||||
.Case("i386:x86-64", IMAGE_FILE_MACHINE_AMD64)
|
||||
.Case("arm", IMAGE_FILE_MACHINE_ARMNT)
|
||||
.Case("arm64", IMAGE_FILE_MACHINE_ARM64)
|
||||
.Default(IMAGE_FILE_MACHINE_UNKNOWN);
|
||||
}
|
||||
|
||||
static std::string getImplibPath(StringRef Path) {
|
||||
SmallString<128> Out = StringRef("lib");
|
||||
Out.append(Path);
|
||||
sys::path::replace_extension(Out, ".a");
|
||||
return Out.str();
|
||||
}
|
||||
|
||||
int llvm::dlltoolDriverMain(llvm::ArrayRef<const char *> ArgsArr) {
|
||||
DllOptTable Table;
|
||||
unsigned MissingIndex;
|
||||
unsigned MissingCount;
|
||||
llvm::opt::InputArgList Args =
|
||||
Table.ParseArgs(ArgsArr.slice(1), MissingIndex, MissingCount);
|
||||
if (MissingCount) {
|
||||
llvm::errs() << Args.getArgString(MissingIndex) << ": missing argument\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Handle when no input or output is specified
|
||||
if (Args.hasArgNoClaim(OPT_INPUT) ||
|
||||
(!Args.hasArgNoClaim(OPT_d) && !Args.hasArgNoClaim(OPT_l))) {
|
||||
Table.PrintHelp(outs(), ArgsArr[0], "dlltool", false);
|
||||
llvm::outs() << "\nTARGETS: i386, i386:x86-64, arm, arm64\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (!Args.hasArgNoClaim(OPT_m) && Args.hasArgNoClaim(OPT_d)) {
|
||||
llvm::errs() << "error: no target machine specified\n"
|
||||
<< "supported targets: i386, i386:x86-64, arm, arm64\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
for (auto *Arg : Args.filtered(OPT_UNKNOWN))
|
||||
llvm::errs() << "ignoring unknown argument: " << Arg->getSpelling() << "\n";
|
||||
|
||||
if (!Args.hasArg(OPT_d)) {
|
||||
llvm::errs() << "no definition file specified\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
std::unique_ptr<MemoryBuffer> MB =
|
||||
openFile(Args.getLastArg(OPT_d)->getValue());
|
||||
if (!MB)
|
||||
return 1;
|
||||
|
||||
if (!MB->getBufferSize()) {
|
||||
llvm::errs() << "definition file empty\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
COFF::MachineTypes Machine = IMAGE_FILE_MACHINE_UNKNOWN;
|
||||
if (auto *Arg = Args.getLastArg(OPT_m))
|
||||
Machine = getEmulation(Arg->getValue());
|
||||
|
||||
if (Machine == IMAGE_FILE_MACHINE_UNKNOWN) {
|
||||
llvm::errs() << "unknown target\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
Expected<COFFModuleDefinition> Def =
|
||||
parseCOFFModuleDefinition(*MB, Machine, true);
|
||||
|
||||
if (!Def) {
|
||||
llvm::errs() << "error parsing definition\n"
|
||||
<< errorToErrorCode(Def.takeError()).message();
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Do this after the parser because parseCOFFModuleDefinition sets OutputFile.
|
||||
if (auto *Arg = Args.getLastArg(OPT_D))
|
||||
Def->OutputFile = Arg->getValue();
|
||||
|
||||
if (Def->OutputFile.empty()) {
|
||||
llvm::errs() << "no output file specified\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
std::string Path = Args.getLastArgValue(OPT_l);
|
||||
if (Path.empty())
|
||||
Path = getImplibPath(Def->OutputFile);
|
||||
|
||||
if (Machine == IMAGE_FILE_MACHINE_I386 && Args.getLastArg(OPT_k)) {
|
||||
for (COFFShortExport& E : Def->Exports) {
|
||||
if (E.isWeak() || (!E.Name.empty() && E.Name[0] == '?'))
|
||||
continue;
|
||||
E.SymbolName = E.Name;
|
||||
// Trim off the trailing decoration. Symbols will always have a
|
||||
// starting prefix here (either _ for cdecl/stdcall, @ for fastcall
|
||||
// or ? for C++ functions). Vectorcall functions won't have any
|
||||
// fixed prefix, but the function base name will still be at least
|
||||
// one char.
|
||||
E.Name = E.Name.substr(0, E.Name.find('@', 1));
|
||||
// By making sure E.SymbolName != E.Name for decorated symbols,
|
||||
// writeImportLibrary writes these symbols with the type
|
||||
// IMPORT_NAME_UNDECORATE.
|
||||
}
|
||||
}
|
||||
|
||||
if (writeImportLibrary(Def->OutputFile, Path, Def->Exports, Machine, true))
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
@ -1,22 +0,0 @@
|
||||
;===- ./lib/ToolDrivers/llvm-dlltool/LLVMBuild.txt -------------*- Conf -*--===;
|
||||
;
|
||||
; The LLVM Compiler Infrastructure
|
||||
;
|
||||
; This file is distributed under the University of Illinois Open Source
|
||||
; License. See LICENSE.TXT for details.
|
||||
;
|
||||
;===------------------------------------------------------------------------===;
|
||||
;
|
||||
; 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 = Library
|
||||
name = DlltoolDriver
|
||||
parent = Libraries
|
||||
required_libraries = Object Option Support
|
@ -1,26 +0,0 @@
|
||||
include "llvm/Option/OptParser.td"
|
||||
|
||||
def m: JoinedOrSeparate<["-"], "m">, HelpText<"Set target machine">;
|
||||
def m_long : JoinedOrSeparate<["--"], "machine">, Alias<m>;
|
||||
|
||||
def l: JoinedOrSeparate<["-"], "l">, HelpText<"Generate an import lib">;
|
||||
def l_long : JoinedOrSeparate<["--"], "output-lib">, Alias<l>;
|
||||
|
||||
def D: JoinedOrSeparate<["-"], "D">, HelpText<"Specify the input DLL Name">;
|
||||
def D_long : JoinedOrSeparate<["--"], "dllname">, Alias<D>;
|
||||
|
||||
def d: JoinedOrSeparate<["-"], "d">, HelpText<"Input .def File">;
|
||||
def d_long : JoinedOrSeparate<["--"], "input-def">, Alias<d>;
|
||||
|
||||
def k: Flag<["-"], "k">, HelpText<"Kill @n Symbol from export">;
|
||||
def k_alias: Flag<["--"], "kill-at">, Alias<k>;
|
||||
|
||||
//==============================================================================
|
||||
// The flags below do nothing. They are defined only for dlltool compatibility.
|
||||
//==============================================================================
|
||||
|
||||
def S: JoinedOrSeparate<["-"], "S">, HelpText<"Assembler">;
|
||||
def S_alias: JoinedOrSeparate<["--"], "as">, Alias<S>;
|
||||
|
||||
def f: JoinedOrSeparate<["-"], "f">, HelpText<"Assembler Flags">;
|
||||
def f_alias: JoinedOrSeparate<["--"], "as-flags">, Alias<f>;
|
@ -1,8 +0,0 @@
|
||||
set(LLVM_TARGET_DEFINITIONS Options.td)
|
||||
tablegen(LLVM Options.inc -gen-opt-parser-defs)
|
||||
add_public_tablegen_target(LibOptionsTableGen)
|
||||
|
||||
add_llvm_library(LLVMLibDriver
|
||||
LibDriver.cpp
|
||||
)
|
||||
add_dependencies(LLVMLibDriver LibOptionsTableGen)
|
@ -1,22 +0,0 @@
|
||||
;===- ./lib/LibDriver/LLVMBuild.txt ----------------------------*- Conf -*--===;
|
||||
;
|
||||
; The LLVM Compiler Infrastructure
|
||||
;
|
||||
; This file is distributed under the University of Illinois Open Source
|
||||
; License. See LICENSE.TXT for details.
|
||||
;
|
||||
;===------------------------------------------------------------------------===;
|
||||
;
|
||||
; 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 = Library
|
||||
name = LibDriver
|
||||
parent = Libraries
|
||||
required_libraries = BinaryFormat Object Option Support
|
171
external/llvm/lib/ToolDrivers/llvm-lib/LibDriver.cpp
vendored
171
external/llvm/lib/ToolDrivers/llvm-lib/LibDriver.cpp
vendored
@ -1,171 +0,0 @@
|
||||
//===- LibDriver.cpp - lib.exe-compatible driver --------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Defines an interface to a lib.exe-compatible driver that also understands
|
||||
// bitcode files. Used by llvm-lib and lld-link /lib.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "llvm/ToolDrivers/llvm-lib/LibDriver.h"
|
||||
#include "llvm/ADT/STLExtras.h"
|
||||
#include "llvm/BinaryFormat/Magic.h"
|
||||
#include "llvm/Object/ArchiveWriter.h"
|
||||
#include "llvm/Option/Arg.h"
|
||||
#include "llvm/Option/ArgList.h"
|
||||
#include "llvm/Option/Option.h"
|
||||
#include "llvm/Support/CommandLine.h"
|
||||
#include "llvm/Support/Path.h"
|
||||
#include "llvm/Support/Process.h"
|
||||
#include "llvm/Support/StringSaver.h"
|
||||
#include "llvm/Support/raw_ostream.h"
|
||||
|
||||
using namespace llvm;
|
||||
|
||||
namespace {
|
||||
|
||||
enum {
|
||||
OPT_INVALID = 0,
|
||||
#define OPTION(_1, _2, ID, _4, _5, _6, _7, _8, _9, _10, _11, _12) OPT_##ID,
|
||||
#include "Options.inc"
|
||||
#undef OPTION
|
||||
};
|
||||
|
||||
#define PREFIX(NAME, VALUE) const char *const NAME[] = VALUE;
|
||||
#include "Options.inc"
|
||||
#undef PREFIX
|
||||
|
||||
static const opt::OptTable::Info InfoTable[] = {
|
||||
#define OPTION(X1, X2, ID, KIND, GROUP, ALIAS, X7, X8, X9, X10, X11, X12) \
|
||||
{X1, X2, X10, X11, OPT_##ID, opt::Option::KIND##Class, \
|
||||
X9, X8, OPT_##GROUP, OPT_##ALIAS, X7, X12},
|
||||
#include "Options.inc"
|
||||
#undef OPTION
|
||||
};
|
||||
|
||||
class LibOptTable : public opt::OptTable {
|
||||
public:
|
||||
LibOptTable() : OptTable(InfoTable, true) {}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
static std::string getOutputPath(opt::InputArgList *Args,
|
||||
const NewArchiveMember &FirstMember) {
|
||||
if (auto *Arg = Args->getLastArg(OPT_out))
|
||||
return Arg->getValue();
|
||||
SmallString<128> Val = StringRef(FirstMember.Buf->getBufferIdentifier());
|
||||
sys::path::replace_extension(Val, ".lib");
|
||||
return Val.str();
|
||||
}
|
||||
|
||||
static std::vector<StringRef> getSearchPaths(opt::InputArgList *Args,
|
||||
StringSaver &Saver) {
|
||||
std::vector<StringRef> Ret;
|
||||
// Add current directory as first item of the search path.
|
||||
Ret.push_back("");
|
||||
|
||||
// Add /libpath flags.
|
||||
for (auto *Arg : Args->filtered(OPT_libpath))
|
||||
Ret.push_back(Arg->getValue());
|
||||
|
||||
// Add $LIB.
|
||||
Optional<std::string> EnvOpt = sys::Process::GetEnv("LIB");
|
||||
if (!EnvOpt.hasValue())
|
||||
return Ret;
|
||||
StringRef Env = Saver.save(*EnvOpt);
|
||||
while (!Env.empty()) {
|
||||
StringRef Path;
|
||||
std::tie(Path, Env) = Env.split(';');
|
||||
Ret.push_back(Path);
|
||||
}
|
||||
return Ret;
|
||||
}
|
||||
|
||||
static std::string findInputFile(StringRef File, ArrayRef<StringRef> Paths) {
|
||||
for (StringRef Dir : Paths) {
|
||||
SmallString<128> Path = Dir;
|
||||
sys::path::append(Path, File);
|
||||
if (sys::fs::exists(Path))
|
||||
return Path.str().str();
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
int llvm::libDriverMain(ArrayRef<const char *> ArgsArr) {
|
||||
BumpPtrAllocator Alloc;
|
||||
StringSaver Saver(Alloc);
|
||||
|
||||
// Parse command line arguments.
|
||||
SmallVector<const char *, 20> NewArgs(ArgsArr.begin(), ArgsArr.end());
|
||||
cl::ExpandResponseFiles(Saver, cl::TokenizeWindowsCommandLine, NewArgs);
|
||||
ArgsArr = NewArgs;
|
||||
|
||||
LibOptTable Table;
|
||||
unsigned MissingIndex;
|
||||
unsigned MissingCount;
|
||||
opt::InputArgList Args =
|
||||
Table.ParseArgs(ArgsArr.slice(1), MissingIndex, MissingCount);
|
||||
if (MissingCount) {
|
||||
llvm::errs() << "missing arg value for \""
|
||||
<< Args.getArgString(MissingIndex) << "\", expected "
|
||||
<< MissingCount
|
||||
<< (MissingCount == 1 ? " argument.\n" : " arguments.\n");
|
||||
return 1;
|
||||
}
|
||||
for (auto *Arg : Args.filtered(OPT_UNKNOWN))
|
||||
llvm::errs() << "ignoring unknown argument: " << Arg->getSpelling() << "\n";
|
||||
|
||||
// If no input files, silently do nothing to match lib.exe.
|
||||
if (!Args.hasArgNoClaim(OPT_INPUT))
|
||||
return 0;
|
||||
|
||||
std::vector<StringRef> SearchPaths = getSearchPaths(&Args, Saver);
|
||||
|
||||
// Create a NewArchiveMember for each input file.
|
||||
std::vector<NewArchiveMember> Members;
|
||||
for (auto *Arg : Args.filtered(OPT_INPUT)) {
|
||||
std::string Path = findInputFile(Arg->getValue(), SearchPaths);
|
||||
if (Path.empty()) {
|
||||
llvm::errs() << Arg->getValue() << ": no such file or directory\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
Expected<NewArchiveMember> MOrErr =
|
||||
NewArchiveMember::getFile(Saver.save(Path), /*Deterministic=*/true);
|
||||
if (!MOrErr) {
|
||||
handleAllErrors(MOrErr.takeError(), [&](const ErrorInfoBase &EIB) {
|
||||
llvm::errs() << Arg->getValue() << ": " << EIB.message() << "\n";
|
||||
});
|
||||
return 1;
|
||||
}
|
||||
|
||||
file_magic Magic = identify_magic(MOrErr->Buf->getBuffer());
|
||||
if (Magic != file_magic::coff_object && Magic != file_magic::bitcode &&
|
||||
Magic != file_magic::windows_resource) {
|
||||
llvm::errs() << Arg->getValue()
|
||||
<< ": not a COFF object, bitcode or resource file\n";
|
||||
return 1;
|
||||
}
|
||||
Members.emplace_back(std::move(*MOrErr));
|
||||
}
|
||||
|
||||
// Create an archive file.
|
||||
std::string OutputPath = getOutputPath(&Args, Members[0]);
|
||||
if (Error E =
|
||||
writeArchive(OutputPath, Members,
|
||||
/*WriteSymtab=*/true, object::Archive::K_GNU,
|
||||
/*Deterministic*/ true, Args.hasArg(OPT_llvmlibthin))) {
|
||||
handleAllErrors(std::move(E), [&](const ErrorInfoBase &EI) {
|
||||
llvm::errs() << OutputPath << ": " << EI.message() << "\n";
|
||||
});
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
@ -1,25 +0,0 @@
|
||||
include "llvm/Option/OptParser.td"
|
||||
|
||||
// lib.exe accepts options starting with either a dash or a slash.
|
||||
|
||||
// Flag that takes no arguments.
|
||||
class F<string name> : Flag<["/", "-", "-?"], name>;
|
||||
|
||||
// Flag that takes one argument after ":".
|
||||
class P<string name, string help> :
|
||||
Joined<["/", "-", "-?"], name#":">, HelpText<help>;
|
||||
|
||||
def libpath: P<"libpath", "Object file search path">;
|
||||
def out : P<"out", "Path to file to write output">;
|
||||
|
||||
def llvmlibthin : F<"llvmlibthin">;
|
||||
|
||||
//==============================================================================
|
||||
// The flags below do nothing. They are defined only for lib.exe compatibility.
|
||||
//==============================================================================
|
||||
|
||||
class QF<string name> : Joined<["/", "-", "-?"], name#":">;
|
||||
|
||||
def ignore : QF<"ignore">;
|
||||
def machine: QF<"machine">;
|
||||
def nologo : F<"nologo">;
|
Reference in New Issue
Block a user