Skip to content

Commit abcd034

Browse files
bwerltru
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 (cherry picked from commit cf4f35b)
1 parent e6e61e9 commit abcd034

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
@@ -1330,12 +1330,15 @@ static void readConfigs(opt::InputArgList &args) {
13301330
parseClangOption(std::string("-") + arg->getValue(), arg->getSpelling());
13311331

13321332
// GCC collect2 passes -plugin-opt=path/to/lto-wrapper with an absolute or
1333-
// relative path. Just ignore. If not ended with "lto-wrapper", consider it an
1333+
// relative path. Just ignore. If not ended with "lto-wrapper" (or
1334+
// "lto-wrapper.exe" for GCC cross-compiled for Windows), consider it an
13341335
// unsupported LLVMgold.so option and error.
1335-
for (opt::Arg *arg : args.filtered(OPT_plugin_opt_eq))
1336-
if (!StringRef(arg->getValue()).endswith("lto-wrapper"))
1336+
for (opt::Arg *arg : args.filtered(OPT_plugin_opt_eq)) {
1337+
StringRef v(arg->getValue());
1338+
if (!v.endswith("lto-wrapper") && !v.endswith("lto-wrapper.exe"))
13371339
error(arg->getSpelling() + ": unknown plugin option '" + arg->getValue() +
13381340
"'");
1341+
}
13391342

13401343
config->passPlugins = args::getStrings(args, OPT_load_pass_plugins);
13411344

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)