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

Commit 07aa7fd

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 e36f4d4 commit 07aa7fd

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
@@ -881,7 +881,8 @@ void LinkerDriver::link(ArrayRef<const char *> ArgsArr) {
881881
V.push_back("lld-link (LLVM option parsing)");
882882
for (auto *Arg : Args.filtered(OPT_mllvm))
883883
V.push_back(Arg->getValue());
884-
cl::ParseCommandLineOptions(V.size(), V.data());
884+
if (V.size() > 1)
885+
cl::ParseCommandLineOptions(V.size(), V.data());
885886

886887
// Handle /errorlimit early, because error() depends on it.
887888
if (auto *Arg = Args.getLastArg(OPT_errorlimit)) {

wasm/Driver.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,8 @@ void LinkerDriver::link(ArrayRef<const char *> ArgsArr) {
360360
V.push_back("wasm-ld (LLVM option parsing)");
361361
for (auto *Arg : Args.filtered(OPT_mllvm))
362362
V.push_back(Arg->getValue());
363-
cl::ParseCommandLineOptions(V.size(), V.data());
363+
if (V.size() > 1)
364+
cl::ParseCommandLineOptions(V.size(), V.data());
364365

365366
errorHandler().ErrorLimit = args::getInteger(Args, OPT_error_limit, 20);
366367

0 commit comments

Comments
 (0)