[lld] [LLD][MINGW] Add `--undefined-glob` flag support (PR #109866)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 24 14:11:01 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-lld
Author: Miguel A. Arroyo (mayanez)
<details>
<summary>Changes</summary>
## Description
* Implements Mingw support for `--undefined-glob` as discussed here: https://github.com/llvm/llvm-project/pull/109721#pullrequestreview-2324899660
---
Full diff: https://github.com/llvm/llvm-project/pull/109866.diff
4 Files Affected:
- (modified) lld/MinGW/Driver.cpp (+2)
- (modified) lld/MinGW/Options.td (+2)
- (modified) lld/docs/ReleaseNotes.rst (+1)
- (modified) lld/test/MinGW/driver.test (+3)
``````````diff
diff --git a/lld/MinGW/Driver.cpp b/lld/MinGW/Driver.cpp
index c7d7b9cfca386f..ec16cf374efe77 100644
--- a/lld/MinGW/Driver.cpp
+++ b/lld/MinGW/Driver.cpp
@@ -514,6 +514,8 @@ bool link(ArrayRef<const char *> argsArr, llvm::raw_ostream &stdoutOS,
for (auto *a : args.filtered(OPT_require_defined))
add("-include:" + StringRef(a->getValue()));
+ for (auto *a: args.filtered(OPT_undefined_glob))
+ add("-includeglob:" + StringRef(a->getValue()));
for (auto *a : args.filtered(OPT_undefined))
add("-includeoptional:" + StringRef(a->getValue()));
for (auto *a : args.filtered(OPT_delayload))
diff --git a/lld/MinGW/Options.td b/lld/MinGW/Options.td
index 7bd5fb80749da2..ff7e21fa808f39 100644
--- a/lld/MinGW/Options.td
+++ b/lld/MinGW/Options.td
@@ -139,6 +139,8 @@ defm threads
defm tsaware: B_disable<"tsaware",
"Set the 'Terminal Server aware' flag", "Don't set the 'Terminal Server aware' flag">;
defm undefined: Eq<"undefined", "Include symbol in the link, if available">;
+defm undefined_glob: EEq<"undefined-glob", "Force undefined symbol during linking">,
+ MetaVarName<"<pattern>">;
defm whole_archive: B<"whole-archive",
"Include all object files for following archives",
"No longer include all object files for following archives">;
diff --git a/lld/docs/ReleaseNotes.rst b/lld/docs/ReleaseNotes.rst
index 6e043773f00379..da93da9196af70 100644
--- a/lld/docs/ReleaseNotes.rst
+++ b/lld/docs/ReleaseNotes.rst
@@ -45,6 +45,7 @@ COFF Improvements
MinGW Improvements
------------------
+* ``--undefined-glob`` is now supported by translating into the ``/includeglob`` flag.
MachO Improvements
------------------
diff --git a/lld/test/MinGW/driver.test b/lld/test/MinGW/driver.test
index 0dab66b613c774..2831d155fef128 100644
--- a/lld/test/MinGW/driver.test
+++ b/lld/test/MinGW/driver.test
@@ -249,6 +249,9 @@ REQUIRE-DEFINED: -include:_foo -include:_bar -include:_baz -include:_foo2
RUN: ld.lld -### foo.o -m i386pe -u _foo --undefined _bar -undefined=_baz --undefined=_foo2 -u_foo3 2>&1 | FileCheck -check-prefix=UNDEFINED %s
UNDEFINED: -includeoptional:_foo -includeoptional:_bar -includeoptional:_baz -includeoptional:_foo2 -includeoptional:_foo3
+RUN: ld.lld -### foo.o -m i386pe --undefined-glob="_foo*" 2>&1 | FileCheck -check-prefix=UNDEFINED-GLOB %s
+UNDEFINED-GLOB: -includeglob:_foo*
+
RUN: ld.lld -### -m i386pep foo.o -Llibpath 2>&1 | FileCheck -check-prefix LIBPATH %s
LIBPATH: -libpath:libpath
``````````
</details>
https://github.com/llvm/llvm-project/pull/109866
More information about the llvm-commits
mailing list