[lld] [LLD][MINGW] Add `--undefined-glob` flag support (PR #109866)
Miguel A. Arroyo via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 24 14:15:42 PDT 2024
https://github.com/mayanez updated https://github.com/llvm/llvm-project/pull/109866
>From 51c3d8e82e6817c8bdbe31dcd0523a521bdb0857 Mon Sep 17 00:00:00 2001
From: Miguel Arroyo <miguel.arroyo at rockstargames.com>
Date: Tue, 24 Sep 2024 09:02:51 -0700
Subject: [PATCH] [LLD][MINGW] Add --undefined-glob flag support
---
lld/MinGW/Driver.cpp | 2 ++
lld/MinGW/Options.td | 2 ++
lld/docs/ReleaseNotes.rst | 1 +
lld/test/MinGW/driver.test | 3 +++
4 files changed, 8 insertions(+)
diff --git a/lld/MinGW/Driver.cpp b/lld/MinGW/Driver.cpp
index c7d7b9cfca386f..553698d4f537fc 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
More information about the llvm-commits
mailing list