aboutsummaryrefslogtreecommitdiff
path: root/contrib/llvm-project/llvm/lib/ToolDrivers/llvm-lib/LibDriver.cpp
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2022-07-04 19:20:19 +0000
committerDimitry Andric <dim@FreeBSD.org>2023-02-08 19:02:26 +0000
commit81ad626541db97eb356e2c1d4a20eb2a26a766ab (patch)
tree311b6a8987c32b1e1dcbab65c54cfac3fdb56175 /contrib/llvm-project/llvm/lib/ToolDrivers/llvm-lib/LibDriver.cpp
parent5fff09660e06a66bed6482da9c70df328e16bbb6 (diff)
parent145449b1e420787bb99721a429341fa6be3adfb6 (diff)
Diffstat (limited to 'contrib/llvm-project/llvm/lib/ToolDrivers/llvm-lib/LibDriver.cpp')
-rw-r--r--contrib/llvm-project/llvm/lib/ToolDrivers/llvm-lib/LibDriver.cpp28
1 files changed, 22 insertions, 6 deletions
diff --git a/contrib/llvm-project/llvm/lib/ToolDrivers/llvm-lib/LibDriver.cpp b/contrib/llvm-project/llvm/lib/ToolDrivers/llvm-lib/LibDriver.cpp
index 8f69282d3443..5f4d0cdf2b57 100644
--- a/contrib/llvm-project/llvm/lib/ToolDrivers/llvm-lib/LibDriver.cpp
+++ b/contrib/llvm-project/llvm/lib/ToolDrivers/llvm-lib/LibDriver.cpp
@@ -77,7 +77,7 @@ static std::vector<StringRef> getSearchPaths(opt::InputArgList *Args,
// Add $LIB.
Optional<std::string> EnvOpt = sys::Process::GetEnv("LIB");
- if (!EnvOpt.hasValue())
+ if (!EnvOpt)
return Ret;
StringRef Env = Saver.save(*EnvOpt);
while (!Env.empty()) {
@@ -229,10 +229,11 @@ static void appendFile(std::vector<NewArchiveMember> &Members,
(Magic == file_magic::coff_object) ? getCOFFFileMachine(MB)
: getBitcodeFileMachine(MB);
if (!MaybeFileMachine) {
- handleAllErrors(MaybeFileMachine.takeError(), [&](const ErrorInfoBase &EIB) {
- llvm::errs() << MB.getBufferIdentifier() << ": " << EIB.message()
- << "\n";
- });
+ handleAllErrors(MaybeFileMachine.takeError(),
+ [&](const ErrorInfoBase &EIB) {
+ llvm::errs() << MB.getBufferIdentifier() << ": "
+ << EIB.message() << "\n";
+ });
exit(1);
}
COFF::MachineTypes FileMachine = *MaybeFileMachine;
@@ -291,10 +292,25 @@ int llvm::libDriverMain(ArrayRef<const char *> ArgsArr) {
return 0;
}
+ // Parse /ignore:
+ llvm::StringSet<> IgnoredWarnings;
+ for (auto *Arg : Args.filtered(OPT_ignore))
+ IgnoredWarnings.insert(Arg->getValue());
+
// If no input files and not told otherwise, silently do nothing to match
// lib.exe
- if (!Args.hasArgNoClaim(OPT_INPUT) && !Args.hasArg(OPT_llvmlibempty))
+ if (!Args.hasArgNoClaim(OPT_INPUT) && !Args.hasArg(OPT_llvmlibempty)) {
+ if (!IgnoredWarnings.contains("emptyoutput")) {
+ llvm::errs() << "warning: no input files, not writing output file\n";
+ llvm::errs() << " pass /llvmlibempty to write empty .lib file,\n";
+ llvm::errs() << " pass /ignore:emptyoutput to suppress warning\n";
+ if (Args.hasFlag(OPT_WX, OPT_WX_no, false)) {
+ llvm::errs() << "treating warning as error due to /WX\n";
+ return 1;
+ }
+ }
return 0;
+ }
if (Args.hasArg(OPT_lst)) {
doList(Args);