Skip to content

Commit 88def8e

Browse files
committed
[LDC] LLD: Avoid parsing -mllvm* command-line options if there aren't any
When invoking the integrated LLD from LDC, it somehow uses a different global LLVM command-line parser, 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 c1a0a21 commit 88def8e

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

lld/COFF/Driver.cpp

Lines changed: 2 additions & 1 deletion
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)) {

lld/wasm/Driver.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -691,7 +691,8 @@ void LinkerDriver::link(ArrayRef<const char *> argsArr) {
691691
v.push_back("wasm-ld (LLVM option parsing)");
692692
for (auto *arg : args.filtered(OPT_mllvm))
693693
v.push_back(arg->getValue());
694-
cl::ParseCommandLineOptions(v.size(), v.data());
694+
if (v.size() > 1)
695+
cl::ParseCommandLineOptions(v.size(), v.data());
695696

696697
errorHandler().errorLimit = args::getInteger(args, OPT_error_limit, 20);
697698

0 commit comments

Comments
 (0)