Skip to content

Commit cf4f35b

Browse files
bwerlteresajohnson
authored andcommitted
[ELF] Handle GCC collect2 -plugin-opt= on Windows
Follows up on commit cd5d5ce by additionally ignoring relative paths ending in "lto-wrapper.exe" as can be the case for GCC cross-compiled for Windows. Reviewed By: tejohnson Differential Revision: https://reviews.llvm.org/D138065
1 parent f678217 commit cf4f35b

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

lld/ELF/Driver.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1360,12 +1360,15 @@ static void readConfigs(opt::InputArgList &args) {
13601360
parseClangOption(std::string("-") + arg->getValue(), arg->getSpelling());
13611361

13621362
// GCC collect2 passes -plugin-opt=path/to/lto-wrapper with an absolute or
1363-
// relative path. Just ignore. If not ended with "lto-wrapper", consider it an
1363+
// relative path. Just ignore. If not ended with "lto-wrapper" (or
1364+
// "lto-wrapper.exe" for GCC cross-compiled for Windows), consider it an
13641365
// unsupported LLVMgold.so option and error.
1365-
for (opt::Arg *arg : args.filtered(OPT_plugin_opt_eq))
1366-
if (!StringRef(arg->getValue()).endswith("lto-wrapper"))
1366+
for (opt::Arg *arg : args.filtered(OPT_plugin_opt_eq)) {
1367+
StringRef v(arg->getValue());
1368+
if (!v.endswith("lto-wrapper") && !v.endswith("lto-wrapper.exe"))
13671369
error(arg->getSpelling() + ": unknown plugin option '" + arg->getValue() +
13681370
"'");
1371+
}
13691372

13701373
config->passPlugins = args::getStrings(args, OPT_load_pass_plugins);
13711374

lld/test/ELF/lto-plugin-ignore.s

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88
# RUN: ld.lld %t.o -o /dev/null \
99
# RUN: -plugin path/to/liblto_plugin.so \
1010
# RUN: -plugin-opt=/path/to/lto-wrapper \
11+
# RUN: -plugin-opt=/path/to/lto-wrapper.exe \
1112
# RUN: -plugin-opt=relative/path/to/lto-wrapper \
13+
# RUN: -plugin-opt=relative/path/to/lto-wrapper.exe \
1214
# RUN: -plugin-opt=-fresolution=zed \
1315
# RUN: -plugin-opt=-pass-through=-lgcc \
1416
# RUN: -plugin-opt=-pass-through=-lgcc_eh \

0 commit comments

Comments
 (0)