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

Commit 28fc253

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 d60a035 commit 28fc253

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
@@ -923,7 +923,8 @@ void LinkerDriver::link(ArrayRef<const char *> ArgsArr) {
923923
V.push_back("lld-link (LLVM option parsing)");
924924
for (auto *Arg : Args.filtered(OPT_mllvm))
925925
V.push_back(Arg->getValue());
926-
cl::ParseCommandLineOptions(V.size(), V.data());
926+
if (V.size() > 1)
927+
cl::ParseCommandLineOptions(V.size(), V.data());
927928

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

wasm/Driver.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,8 @@ void LinkerDriver::link(ArrayRef<const char *> ArgsArr) {
522522
V.push_back("wasm-ld (LLVM option parsing)");
523523
for (auto *Arg : Args.filtered(OPT_mllvm))
524524
V.push_back(Arg->getValue());
525-
cl::ParseCommandLineOptions(V.size(), V.data());
525+
if (V.size() > 1)
526+
cl::ParseCommandLineOptions(V.size(), V.data());
526527

527528
errorHandler().ErrorLimit = args::getInteger(Args, OPT_error_limit, 20);
528529

0 commit comments

Comments
 (0)