Skip to content

Commit 69b8ba6

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 7cbf1a2 commit 69b8ba6

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

lld/COFF/Driver.cpp

+4-2
Original file line numberDiff line numberDiff line change
@@ -1436,8 +1436,10 @@ void LinkerDriver::linkerMain(ArrayRef<const char *> argsArr) {
14361436
v.push_back(arg->getValue());
14371437
config->mllvmOpts.emplace_back(arg->getValue());
14381438
}
1439-
cl::ResetAllOptionOccurrences();
1440-
cl::ParseCommandLineOptions(v.size(), v.data());
1439+
if (v.size() > 1) {
1440+
cl::ResetAllOptionOccurrences();
1441+
cl::ParseCommandLineOptions(v.size(), v.data());
1442+
}
14411443

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

lld/wasm/Driver.cpp

+4-2
Original file line numberDiff line numberDiff line change
@@ -1065,8 +1065,10 @@ void LinkerDriver::linkerMain(ArrayRef<const char *> argsArr) {
10651065
v.push_back("wasm-ld (LLVM option parsing)");
10661066
for (auto *arg : args.filtered(OPT_mllvm))
10671067
v.push_back(arg->getValue());
1068-
cl::ResetAllOptionOccurrences();
1069-
cl::ParseCommandLineOptions(v.size(), v.data());
1068+
if (v.size() > 1) {
1069+
cl::ResetAllOptionOccurrences();
1070+
cl::ParseCommandLineOptions(v.size(), v.data());
1071+
}
10701072

10711073
readConfigs(args);
10721074
setConfigs();

0 commit comments

Comments
 (0)