Go to the documentation of this file.
38 #define OPTION(_1, _2, ID, _4, _5, _6, _7, _8, _9, _10, _11, _12) OPT_##ID,
39 #include "Options.inc"
43 #define PREFIX(NAME, VALUE) const char *const NAME[] = VALUE;
44 #include "Options.inc"
48 #define OPTION(X1, X2, ID, KIND, GROUP, ALIAS, X7, X8, X9, X10, X11, X12) \
49 {X1, X2, X10, X11, OPT_##ID, opt::Option::KIND##Class, \
50 X9, X8, OPT_##GROUP, OPT_##ALIAS, X7, X12},
51 #include "Options.inc"
57 LibOptTable() : OptTable(InfoTable,
true) {}
65 return std::string(Val.
str());
70 std::vector<StringRef>
Ret;
75 for (
auto *
Arg :
Args->filtered(OPT_libpath))
76 Ret.push_back(
Arg->getValue());
83 while (!Env.
empty()) {
85 std::tie(Path, Env) = Env.
split(
';');
96 return std::string(Path);
112 std::unique_ptr<MemoryBuffer>
B;
113 for (
auto *
Arg :
Args.filtered(OPT_INPUT)) {
116 Arg->getValue(),
false,
false);
146 return Obj.takeError();
176 "unknown arch in target triple: " + *TripleStr);
180 static void appendFile(std::vector<NewArchiveMember> &Members,
189 <<
": not a COFF object, bitcode, archive, import library or "
207 llvm::errs() << MB.getBufferIdentifier() <<
": " << EIB.message()
213 appendFile(Members, LibMachine, LibMachineSource, *ChildMB);
231 if (!MaybeFileMachine) {
234 llvm::errs() << MB.getBufferIdentifier() <<
": "
235 << EIB.message() <<
"\n";
247 LibMachine = FileMachine;
251 }
else if (LibMachine != FileMachine) {
254 <<
" conflicts with library machine type "
255 <<
machineToStr(LibMachine) << LibMachineSource <<
'\n';
261 Members.emplace_back(MB);
274 unsigned MissingIndex;
275 unsigned MissingCount;
277 Table.ParseArgs(ArgsArr.
slice(1), MissingIndex, MissingCount);
280 <<
Args.getArgString(MissingIndex) <<
"\", expected "
282 << (MissingCount == 1 ?
" argument.\n" :
" arguments.\n");
285 for (
auto *
Arg :
Args.filtered(OPT_UNKNOWN))
290 if (
Args.hasArg(OPT_help)) {
291 Table.printHelp(
outs(),
"llvm-lib [options] file...",
"LLVM Lib");
297 for (
auto *
Arg :
Args.filtered(OPT_ignore))
302 if (!
Args.hasArgNoClaim(OPT_INPUT) && !
Args.hasArg(OPT_llvmlibempty)) {
303 if (!IgnoredWarnings.
contains(
"emptyoutput")) {
304 llvm::errs() <<
"warning: no input files, not writing output file\n";
305 llvm::errs() <<
" pass /llvmlibempty to write empty .lib file,\n";
306 llvm::errs() <<
" pass /ignore:emptyoutput to suppress warning\n";
307 if (
Args.hasFlag(OPT_WX, OPT_WX_no,
false)) {
308 llvm::errs() <<
"treating warning as error due to /WX\n";
315 if (
Args.hasArg(OPT_lst)) {
323 std::string LibMachineSource;
324 if (
auto *
Arg =
Args.getLastArg(OPT_machine)) {
327 llvm::errs() <<
"unknown /machine: arg " <<
Arg->getValue() <<
'\n';
331 std::string(
" (from '/machine:") +
Arg->getValue() +
"' flag)";
334 std::vector<std::unique_ptr<MemoryBuffer>> MBs;
336 std::vector<NewArchiveMember> Members;
339 for (
auto *
Arg :
Args.filtered(OPT_INPUT)) {
343 llvm::errs() <<
Arg->getValue() <<
": no such file or directory\n";
354 if (!Seen.
insert(Path).second)
364 appendFile(Members, LibMachine, LibMachineSource, MBRef);
371 std::string OutputPath;
372 if (
auto *
Arg =
Args.getLastArg(OPT_out)) {
373 OutputPath =
Arg->getValue();
374 }
else if (!Members.empty()) {
377 llvm::errs() <<
"no output path given, and cannot infer with no inputs\n";
388 Member.MemberName = Saver.
save(*PathOrErr);
395 true,
Args.hasArg(OPT_llvmlibthin))) {
Provide access to the Option info table.
This is an optimization pass for GlobalISel generic memory operations.
StringRef machineToStr(COFF::MachineTypes MT)
file_magic - An "enum class" enumeration of file types based on magic (the first N bytes of the file)...
iterator_range< child_iterator > children(Error &Err, bool SkipInternal=true) const
COFF::MachineTypes getMachineType(StringRef S)
std::unique_ptr< MemoryBuffer > Buf
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
static ErrorSuccess success()
Create a success value.
static void doList(opt::InputArgList &Args)
@ IMAGE_FILE_MACHINE_AMD64
@ IMAGE_FILE_MACHINE_UNKNOWN
Triple - Helper class for working with autoconf configuration names.
@ IMAGE_FILE_MACHINE_ARMNT
static Expected< COFF::MachineTypes > getBitcodeFileMachine(MemoryBufferRef MB)
raw_fd_ostream & errs()
This returns a reference to a raw_ostream for standard error.
std::pair< typename Base::iterator, bool > insert(StringRef key)
Tagged union holding either a T or a Error.
static std::vector< StringRef > getSearchPaths(opt::InputArgList *Args, StringSaver &Saver)
void append(SmallVectorImpl< char > &path, const Twine &a, const Twine &b="", const Twine &c="", const Twine &d="")
Append to path.
amdgpu Simplify well known AMD library false FunctionCallee Value * Arg
static ErrorOr< std::unique_ptr< MemoryBuffer > > getFile(const Twine &Filename, bool IsText=false, bool RequiresNullTerminator=true, bool IsVolatile=false)
Open the specified file as a MemoryBuffer, returning a new MemoryBuffer if successful,...
@ IMAGE_FILE_MACHINE_I386
raw_fd_ostream & outs()
This returns a reference to a raw_fd_ostream for standard output.
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
LLVM_NODISCARD std::pair< StringRef, StringRef > split(char Separator) const
Split into two substrings around the first occurrence of a separator character.
(vector float) vec_cmpeq(*A, *B) C
Error errorCodeToError(std::error_code EC)
Helper for converting an std::error_code to a Error.
Error writeArchive(StringRef ArcName, ArrayRef< NewArchiveMember > NewMembers, bool WriteSymtab, object::Archive::Kind Kind, bool Deterministic, bool Thin, std::unique_ptr< MemoryBuffer > OldArchiveBuf=nullptr)
std::error_code getError() const
bool contains(StringRef key) const
Check if the set contains the given key.
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
void TokenizeWindowsCommandLine(StringRef Source, StringSaver &Saver, SmallVectorImpl< const char * > &NewArgv, bool MarkEOLs=false)
Tokenizes a string of Windows command line arguments, which may contain quotes and escaped quotes.
ArchType getArch() const
Get the parsed architecture type of this triple.
ArrayRef< T > slice(size_t N, size_t M) const
slice(n, m) - Chop off the first N elements of the array, and keep M elements in the array.
Base class for error info classes.
static std::string findInputFile(StringRef File, ArrayRef< StringRef > Paths)
virtual std::string message() const
Return the error message as a string.
static void fatalOpenError(llvm::Error E, Twine File)
@ coff_import_library
COFF import library.
bool exists(const basic_file_status &status)
Does file exist?
constexpr LLVM_NODISCARD bool empty() const
empty - Check if the string is empty.
void replace_extension(SmallVectorImpl< char > &path, const Twine &extension, Style style=Style::native)
Replace the file extension of path with extension.
Allocate memory in an ever growing pool, as if by bump-pointer.
compiles ldr LCPI1_0 ldr ldr mov lsr tst moveq r1 ldr LCPI1_1 and r0 bx lr It would be better to do something like to fold the shift into the conditional move
@ coff_object
COFF object file.
static Expected< std::unique_ptr< COFFObjectFile > > create(MemoryBufferRef Object)
bool ExpandResponseFiles(StringSaver &Saver, TokenizerCallback Tokenizer, SmallVectorImpl< const char * > &Argv, bool MarkEOLs, bool RelativeNames, bool ExpandBasePath, llvm::Optional< llvm::StringRef > CurrentDir, llvm::vfs::FileSystem &FS)
Expand response files on a command line recursively using the given StringSaver and tokenization stra...
static Optional< std::string > GetEnv(StringRef name)
int libDriverMain(ArrayRef< const char * > ARgs)
StringRef getBuffer() const
static std::string getDefaultOutputPath(const NewArchiveMember &FirstMember)
Saves strings in the provided stable storage and returns a StringRef with a stable character pointer.
Expected< std::string > computeArchiveRelativePath(StringRef From, StringRef To)
StringSet - A wrapper for StringMap that provides set-like functionality.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
static void appendFile(std::vector< NewArchiveMember > &Members, COFF::MachineTypes &LibMachine, std::string &LibMachineSource, MemoryBufferRef MB)
StringRef - Represent a constant reference to a string, i.e.
static const char Magic[]
Expected< std::string > getBitcodeTargetTriple(MemoryBufferRef Buffer)
Read the header of the specified bitcode buffer and extract just the triple information.
reference get()
Returns a reference to the stored T value.
@ IMAGE_FILE_MACHINE_ARM64
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Error createStringError(std::error_code EC, char const *Fmt, const Ts &... Vals)
Create formatted StringError object.
std::error_code inconvertibleErrorCode()
The value returned by this function can be returned from convertToErrorCode for Error values where no...
Lightweight error class with error context and mandatory checking.
@ archive
ar style archive file
StringRef str() const
Explicit conversion to StringRef.
Error takeError()
Take ownership of the stored error.
static Expected< COFF::MachineTypes > getCOFFFileMachine(MemoryBufferRef MB)
COFF::MachineTypes Machine
declare void exit(i32) noreturn nounwind This compiles into
Represents either an error or a value T.
std::string to_string(const T &Value)
StringRef save(const char *S)
StringRef getBufferIdentifier() const
Entry for a single option instance in the option data table.
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
file_magic identify_magic(StringRef magic)
Identify the type of a binary file based on how magical it is.
@ windows_resource
Windows compiled resource file (.res)
bool is_relative(const Twine &path, Style style=Style::native)
Is path relative?
void handleAllErrors(Error E, HandlerTs &&... Handlers)
Behaves the same as handleErrors, except that by contract all errors must be handled by the given han...