Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 01bc5ec

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 6009708 commit 01bc5ec

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
@@ -1485,8 +1485,10 @@ void LinkerDriver::linkerMain(ArrayRef<const char *> argsArr) {
14851485
v.push_back(arg->getValue());
14861486
config->mllvmOpts.emplace_back(arg->getValue());
14871487
}
1488-
cl::ResetAllOptionOccurrences();
1489-
cl::ParseCommandLineOptions(v.size(), v.data());
1488+
if (v.size() > 1) {
1489+
cl::ResetAllOptionOccurrences();
1490+
cl::ParseCommandLineOptions(v.size(), v.data());
1491+
}
14901492

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

lld/wasm/Driver.cpp

+4-2
Original file line numberDiff line numberDiff line change
@@ -1125,8 +1125,10 @@ void LinkerDriver::linkerMain(ArrayRef<const char *> argsArr) {
11251125
v.push_back("wasm-ld (LLVM option parsing)");
11261126
for (auto *arg : args.filtered(OPT_mllvm))
11271127
v.push_back(arg->getValue());
1128-
cl::ResetAllOptionOccurrences();
1129-
cl::ParseCommandLineOptions(v.size(), v.data());
1128+
if (v.size() > 1) {
1129+
cl::ResetAllOptionOccurrences();
1130+
cl::ParseCommandLineOptions(v.size(), v.data());
1131+
}
11301132

11311133
readConfigs(args);
11321134
setConfigs();

0 commit comments

Comments
 (0)