Skip to content

Commit 276022b

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 8dfdcc7 commit 276022b

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
@@ -1424,8 +1424,10 @@ void LinkerDriver::linkerMain(ArrayRef<const char *> argsArr) {
14241424
v.push_back("lld-link (LLVM option parsing)");
14251425
for (auto *arg : args.filtered(OPT_mllvm))
14261426
v.push_back(arg->getValue());
1427-
cl::ResetAllOptionOccurrences();
1428-
cl::ParseCommandLineOptions(v.size(), v.data());
1427+
if (v.size() > 1) {
1428+
cl::ResetAllOptionOccurrences();
1429+
cl::ParseCommandLineOptions(v.size(), v.data());
1430+
}
14291431

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

lld/wasm/Driver.cpp

+4-2
Original file line numberDiff line numberDiff line change
@@ -880,8 +880,10 @@ void LinkerDriver::linkerMain(ArrayRef<const char *> argsArr) {
880880
v.push_back("wasm-ld (LLVM option parsing)");
881881
for (auto *arg : args.filtered(OPT_mllvm))
882882
v.push_back(arg->getValue());
883-
cl::ResetAllOptionOccurrences();
884-
cl::ParseCommandLineOptions(v.size(), v.data());
883+
if (v.size() > 1) {
884+
cl::ResetAllOptionOccurrences();
885+
cl::ParseCommandLineOptions(v.size(), v.data());
886+
}
885887

886888
readConfigs(args);
887889

0 commit comments

Comments
 (0)