[lld] 99cd4cb - [LLD][MINGW] Add `--undefined-glob` flag support (#109866)

via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 25 01:29:43 PDT 2024


Author: Miguel A. Arroyo
Date: 2024-09-25T11:29:40+03:00
New Revision: 99cd4cb1231a7209725722e477c2d829a18fb252

URL: https://github.com/llvm/llvm-project/commit/99cd4cb1231a7209725722e477c2d829a18fb252
DIFF: https://github.com/llvm/llvm-project/commit/99cd4cb1231a7209725722e477c2d829a18fb252.diff

LOG: [LLD][MINGW] Add `--undefined-glob` flag support (#109866)

Added: 
    

Modified: 
    lld/MinGW/Driver.cpp
    lld/MinGW/Options.td
    lld/docs/ReleaseNotes.rst
    lld/test/MinGW/driver.test

Removed: 
    


################################################################################
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