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

Martin Storsjö via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 4 13:25:40 PDT 2019


mstorsjo created this revision.
mstorsjo added reviewers: rnk, ruiu, pcc.
Herald added a project: LLVM.

This is implemented by the lld-link option -include:, just like --require-defined. Contrary to --require-defined, the -u/--undefined option allows the symbol to remain undefined in the end, which this implementation doesn't honor.

This should fix PR42121.


Repository:
  rLLD LLVM Linker

https://reviews.llvm.org/D62876

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


Index: test/MinGW/driver.test
===================================================================
--- test/MinGW/driver.test
+++ test/MinGW/driver.test
@@ -155,6 +155,7 @@
 MAP: -lldmap:bar.map
 
 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
+RUN: ld.lld -### foo.o -m i386pe -u _foo --undefined _bar -undefined=_baz --undefined=_foo2 | FileCheck -check-prefix=REQUIRE-DEFINED %s
 REQUIRE-DEFINED: -include:_foo -include:_bar -include:_baz -include:_foo2
 
 RUN: ld.lld -### -m i386pep foo.o -Llibpath | FileCheck -check-prefix LIBPATH %s
Index: MinGW/Options.td
===================================================================
--- MinGW/Options.td
+++ MinGW/Options.td
@@ -54,6 +54,11 @@
 def require_defined: S<"require-defined">,
     HelpText<"Force symbol to be added to symbol table as an undefined one">;
 def require_defined_eq: J<"require-defined=">, Alias<require_defined>;
+// Strictly taken, the -u option allows for the symbol to remain undefined,
+// which this currently doesn't.
+def undefined: S<"u">, Alias<require_defined>;
+def undefined_long: S<"undefined">, Alias<require_defined>;
+def undefined_eq: J<"undefined=">, Alias<require_defined>;
 
 // LLD specific options
 def _HASH_HASH_HASH : Flag<["-"], "###">,


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D62876.203008.patch
Type: text/x-patch
Size: 1361 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190604/f1454db1/attachment.bin>


More information about the llvm-commits mailing list