Skip to content
This repository was archived by the owner on Dec 20, 2019. It is now read-only.

Commit d165b07

Browse files
committed
Avoid parsing -mllvm* command-line options if there aren't any
LLD somehow uses a different global LLVM command-line parser than LDC, one with no registered options, so parsing is guaranteed to fail, even if there are no args. [It's only needed for LTO codegen options anyway.]
1 parent 59baa6d commit d165b07

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

COFF/Driver.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -1086,7 +1086,8 @@ void LinkerDriver::link(ArrayRef<const char *> argsArr) {
10861086
v.push_back("lld-link (LLVM option parsing)");
10871087
for (auto *arg : args.filtered(OPT_mllvm))
10881088
v.push_back(arg->getValue());
1089-
cl::ParseCommandLineOptions(v.size(), v.data());
1089+
if (v.size() > 1)
1090+
cl::ParseCommandLineOptions(v.size(), v.data());
10901091

10911092
// Handle /errorlimit early, because error() depends on it.
10921093
if (auto *arg = args.getLastArg(OPT_errorlimit)) {

wasm/Driver.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -687,7 +687,8 @@ void LinkerDriver::link(ArrayRef<const char *> argsArr) {
687687
v.push_back("wasm-ld (LLVM option parsing)");
688688
for (auto *arg : args.filtered(OPT_mllvm))
689689
v.push_back(arg->getValue());
690-
cl::ParseCommandLineOptions(v.size(), v.data());
690+
if (v.size() > 1)
691+
cl::ParseCommandLineOptions(v.size(), v.data());
691692

692693
errorHandler().errorLimit = args::getInteger(args, OPT_error_limit, 20);
693694

0 commit comments

Comments
 (0)