summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrett Werling <bwerl.dev@gmail.com>2022-11-16 08:16:11 -0800
committerTobias Hieta <tobias@hieta.se>2022-11-29 10:26:09 +0100
commitabcd0341d8465d55d7293dfc7142fef5055047fa (patch)
tree3a02fdb70c2e079d2d628bc40540f02652da6df4
parente6e61e9b2ef7c0fa3fe2cd7c612e00ecf57a9dd8 (diff)
downloadllvm-abcd0341d8465d55d7293dfc7142fef5055047fa.tar.gz
[ELF] Handle GCC collect2 -plugin-opt= on Windows
Follows up on commit cd5d5ce235081005173566c99c592550021de058 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 cf4f35b78871aecc21e663067c57e60595bd7197)
-rw-r--r--lld/ELF/Driver.cpp9
-rw-r--r--lld/test/ELF/lto-plugin-ignore.s2
2 files changed, 8 insertions, 3 deletions
diff --git a/lld/ELF/Driver.cpp b/lld/ELF/Driver.cpp
index 296fb4220012..58d863776430 100644
--- a/lld/ELF/Driver.cpp
+++ b/lld/ELF/Driver.cpp
@@ -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);
diff --git a/lld/test/ELF/lto-plugin-ignore.s b/lld/test/ELF/lto-plugin-ignore.s
index 2935bad149de..dd39139b6243 100644
--- a/lld/test/ELF/lto-plugin-ignore.s
+++ b/lld/test/ELF/lto-plugin-ignore.s
@@ -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 \