Skip to content

Commit 62a0fb6

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 b708aea commit 62a0fb6

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

lld/COFF/Driver.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1536,7 +1536,7 @@ void LinkerDriver::linkerMain(ArrayRef<const char *> argsArr) {
15361536
v.push_back(arg->getValue());
15371537
config->mllvmOpts.emplace_back(arg->getValue());
15381538
}
1539-
{
1539+
if (v.size() > 1) {
15401540
llvm::TimeTraceScope timeScope2("Parse cl::opt");
15411541
cl::ResetAllOptionOccurrences();
15421542
cl::ParseCommandLineOptions(v.size(), v.data());

lld/wasm/Driver.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1307,8 +1307,10 @@ void LinkerDriver::linkerMain(ArrayRef<const char *> argsArr) {
13071307
v.push_back("wasm-ld (LLVM option parsing)");
13081308
for (auto *arg : args.filtered(OPT_mllvm))
13091309
v.push_back(arg->getValue());
1310-
cl::ResetAllOptionOccurrences();
1311-
cl::ParseCommandLineOptions(v.size(), v.data());
1310+
if (v.size() > 1) {
1311+
cl::ResetAllOptionOccurrences();
1312+
cl::ParseCommandLineOptions(v.size(), v.data());
1313+
}
13121314

13131315
readConfigs(args);
13141316
setConfigs();

0 commit comments

Comments
 (0)