[PATCH] D62876: [LLD] [MinGW] Support the -u/--undefined option.

Martin Storsjö via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 6 13:05:17 PDT 2019


mstorsjo updated this revision to Diff 203428.
mstorsjo edited the summary of this revision.
mstorsjo added a comment.

Mimic the real -u option behavior properly.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D62876/new/

https://reviews.llvm.org/D62876

Files:
  MinGW/Driver.cpp
  MinGW/Options.td
  test/MinGW/driver.test


Index: test/MinGW/driver.test
===================================================================
--- test/MinGW/driver.test
+++ test/MinGW/driver.test
@@ -157,6 +157,9 @@
 RUN: ld.lld -### foo.o -m i386pe -require-defined _foo --require-defined _bar -require-defined=_baz --require-defined=_foo2 | FileCheck -check-prefix=REQUIRE-DEFINED %s
 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 | FileCheck -check-prefix=UNDEFINED %s
+UNDEFINED: -includeoptional:_foo -includeoptional:_bar -includeoptional:_baz -includeoptional:_foo2
+
 RUN: ld.lld -### -m i386pep foo.o -Llibpath | FileCheck -check-prefix LIBPATH %s
 LIBPATH: -libpath:libpath
 
Index: MinGW/Options.td
===================================================================
--- MinGW/Options.td
+++ MinGW/Options.td
@@ -46,6 +46,10 @@
     HelpText<"Omit all symbol information from the output binary">;
 def strip_debug: F<"strip-debug">,
     HelpText<"Omit all debug information, but keep symbol information">;
+def undefined: S<"u">,
+    HelpText<"Include symbol in the link, if available">;
+def undefined_long: S<"undefined">, Alias<undefined>;
+def undefined_eq: J<"undefined=">, Alias<undefined>;
 def whole_archive: F<"whole-archive">,
     HelpText<"Include all object files for following archives">;
 def v: Flag<["-"], "v">, HelpText<"Display the version number">;
Index: MinGW/Driver.cpp
===================================================================
--- MinGW/Driver.cpp
+++ MinGW/Driver.cpp
@@ -269,6 +269,8 @@
 
   for (auto *A : Args.filtered(OPT_require_defined))
     Add("-include:" + StringRef(A->getValue()));
+  for (auto *A : Args.filtered(OPT_undefined))
+    Add("-includeoptional:" + StringRef(A->getValue()));
 
   std::vector<StringRef> SearchPaths;
   for (auto *A : Args.filtered(OPT_L)) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D62876.203428.patch
Type: text/x-patch
Size: 1910 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190606/592357d5/attachment.bin>


More information about the llvm-commits mailing list