Skip to content

Commit e9e9f10

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 ec28b8f commit e9e9f10

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
@@ -1503,7 +1503,7 @@ void LinkerDriver::linkerMain(ArrayRef<const char *> argsArr) {
15031503
v.push_back(arg->getValue());
15041504
config->mllvmOpts.emplace_back(arg->getValue());
15051505
}
1506-
{
1506+
if (v.size() > 1) {
15071507
llvm::TimeTraceScope timeScope2("Parse cl::opt");
15081508
cl::ResetAllOptionOccurrences();
15091509
cl::ParseCommandLineOptions(v.size(), v.data());

lld/wasm/Driver.cpp

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

13101312
readConfigs(args);
13111313
setConfigs();

0 commit comments

Comments
 (0)