Skip to content

Commit

Permalink
[ELF] Handle GCC collect2 -plugin-opt= on Windows
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
bwerl authored and tru committed Nov 29, 2022
1 parent e6e61e9 commit abcd034
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
9 changes: 6 additions & 3 deletions lld/ELF/Driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1330,12 +1330,15 @@ static void readConfigs(opt::InputArgList &args) {
parseClangOption(std::string("-") + arg->getValue(), arg->getSpelling());

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

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

Expand Down
2 changes: 2 additions & 0 deletions lld/test/ELF/lto-plugin-ignore.s
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
# RUN: ld.lld %t.o -o /dev/null \
# RUN: -plugin path/to/liblto_plugin.so \
# RUN: -plugin-opt=/path/to/lto-wrapper \
# RUN: -plugin-opt=/path/to/lto-wrapper.exe \
# RUN: -plugin-opt=relative/path/to/lto-wrapper \
# RUN: -plugin-opt=relative/path/to/lto-wrapper.exe \
# RUN: -plugin-opt=-fresolution=zed \
# RUN: -plugin-opt=-pass-through=-lgcc \
# RUN: -plugin-opt=-pass-through=-lgcc_eh \
Expand Down

0 comments on commit abcd034

Please sign in to comment.