[MinGW] Hook up the --require-defined option to -include:
authorMartin Storsjo <martin@martin.st>
Mon, 10 Sep 2018 17:41:40 +0000 (17:41 +0000)
committerMartin Storsjo <martin@martin.st>
Mon, 10 Sep 2018 17:41:40 +0000 (17:41 +0000)
Differential Revision: https://reviews.llvm.org/D51840

llvm-svn: 341846

lld/MinGW/Driver.cpp
lld/MinGW/Options.td
lld/test/MinGW/driver.test

index 27a5550..dc9b046 100644 (file)
@@ -212,6 +212,9 @@ bool mingw::link(ArrayRef<const char *> ArgsArr, raw_ostream &Diag) {
   else
     Add("-alternatename:__image_base__=__ImageBase");
 
+  for (auto *A : Args.filtered(OPT_require_defined))
+    Add("-include:" + StringRef(A->getValue()));
+
   std::vector<StringRef> SearchPaths;
   for (auto *A : Args.filtered(OPT_L))
     SearchPaths.push_back(A->getValue());
index ad699f7..948faa6 100644 (file)
@@ -40,6 +40,9 @@ def strip_debug: F<"strip-debug">,
 def whole_archive: F<"whole-archive">,
     HelpText<"Include all object files for following archives">;
 def verbose: F<"verbose">, HelpText<"Verbose mode">;
+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>;
 
 // LLD specific options
 def _HASH_HASH_HASH : Flag<["-"], "###">,
index 35d3ccf..58c589c 100644 (file)
@@ -145,3 +145,6 @@ RUN: ld.lld -### foo.o -m i386pep --Map bar.map | FileCheck -check-prefix=MAP %s
 RUN: ld.lld -### foo.o -m i386pep -Map=bar.map | FileCheck -check-prefix=MAP %s
 RUN: ld.lld -### foo.o -m i386pep --Map=bar.map | FileCheck -check-prefix=MAP %s
 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
+REQUIRE-DEFINED: -include:_foo -include:_bar -include:_baz -include:_foo2