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

Commit 977c965

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 ffbe162 commit 977c965

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
@@ -746,7 +746,8 @@ void LinkerDriver::link(ArrayRef<const char *> ArgsArr) {
746746
V.push_back("lld-link (LLVM option parsing)");
747747
for (auto *Arg : Args.filtered(OPT_mllvm))
748748
V.push_back(Arg->getValue());
749-
cl::ParseCommandLineOptions(V.size(), V.data());
749+
if (V.size() > 1)
750+
cl::ParseCommandLineOptions(V.size(), V.data());
750751

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

ELF/Driver.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,8 @@ static void initLLVM(opt::InputArgList &Args) {
259259
V.push_back("lld (LLVM option parsing)");
260260
for (auto *Arg : Args.filtered(OPT_mllvm))
261261
V.push_back(Arg->getValue());
262-
cl::ParseCommandLineOptions(V.size(), V.data());
262+
if (V.size() > 1)
263+
cl::ParseCommandLineOptions(V.size(), V.data());
263264
}
264265

265266
// Some command line options or some combinations of them are not allowed.

0 commit comments

Comments
 (0)