[lld] r227134 - Fix shared library build

Greg Fitzgerald garious at gmail.com
Mon Jan 26 12:46:47 PST 2015


Author: garious
Date: Mon Jan 26 14:46:47 2015
New Revision: 227134

URL: http://llvm.org/viewvc/llvm-project?rev=227134&view=rev
Log:
Fix shared library build

* Removed cyclic dependency between lldPECOFF and lldDriver
* Added missing dependencies in unit tests

Differential Revision: http://reviews.llvm.org/D7185

Modified:
    lld/trunk/include/lld/Driver/Driver.h
    lld/trunk/include/lld/ReaderWriter/PECOFFLinkingContext.h
    lld/trunk/lib/Driver/WinLinkDriver.cpp
    lld/trunk/lib/ReaderWriter/PECOFF/ReaderCOFF.cpp
    lld/trunk/tools/lld/CMakeLists.txt
    lld/trunk/unittests/DriverTests/CMakeLists.txt

Modified: lld/trunk/include/lld/Driver/Driver.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Driver/Driver.h?rev=227134&r1=227133&r2=227134&view=diff
==============================================================================
--- lld/trunk/include/lld/Driver/Driver.h (original)
+++ lld/trunk/include/lld/Driver/Driver.h Mon Jan 26 14:46:47 2015
@@ -120,6 +120,14 @@ public:
                     bool isDirective = false,
                     std::set<StringRef> *undefinedSymbols = nullptr);
 
+  // Same as parse(), but restricted to the context of directives.
+  static bool parseDirectives(int argc, const char *argv[],
+                    PECOFFLinkingContext &info,
+                    raw_ostream &diagnostics = llvm::errs(),
+                    std::set<StringRef> *undefinedSymbols = nullptr) {
+    return parse(argc, argv, info, diagnostics, true, undefinedSymbols);
+  }
+
 private:
   WinLinkDriver() LLVM_DELETED_FUNCTION;
 };

Modified: lld/trunk/include/lld/ReaderWriter/PECOFFLinkingContext.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/ReaderWriter/PECOFFLinkingContext.h?rev=227134&r1=227133&r2=227134&view=diff
==============================================================================
--- lld/trunk/include/lld/ReaderWriter/PECOFFLinkingContext.h (original)
+++ lld/trunk/include/lld/ReaderWriter/PECOFFLinkingContext.h Mon Jan 26 14:46:47 2015
@@ -47,7 +47,8 @@ public:
         _manifestUAC(true), _manifestLevel("'asInvoker'"),
         _manifestUiAccess("'false'"), _isDll(false), _highEntropyVA(true),
         _requireSEH(false), _noSEH(false), _implib(""), _debug(false),
-        _pdbFilePath(""), _dosStub(llvm::makeArrayRef(DEFAULT_DOS_STUB)) {
+        _pdbFilePath(""), _dosStub(llvm::makeArrayRef(DEFAULT_DOS_STUB)),
+        _parseDirectives(nullptr) {
     setDeadStripping(true);
   }
 
@@ -82,6 +83,9 @@ public:
     bool isPrivate;
   };
 
+  typedef bool (*ParseDirectives)(int, const char **, PECOFFLinkingContext &,
+                                  raw_ostream &, std::set<StringRef> *);
+
   /// \brief Casting support
   static inline bool classof(const LinkingContext *info) { return true; }
 
@@ -326,6 +330,14 @@ public:
 
   std::recursive_mutex &getMutex() { return _mutex; }
 
+  void setParseDirectives(ParseDirectives parseDirectives) {
+    _parseDirectives = parseDirectives;
+  }
+
+  ParseDirectives getParseDirectives() {
+    return _parseDirectives;
+  }
+
 protected:
   /// Method to create a internal file for the entry symbol
   std::unique_ptr<File> createEntrySymbolFile() const override;
@@ -440,6 +452,8 @@ private:
 
   std::set<std::string> _definedSyms;
   std::set<Node *> _seen;
+
+  ParseDirectives _parseDirectives;
 };
 
 } // end namespace lld

Modified: lld/trunk/lib/Driver/WinLinkDriver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/WinLinkDriver.cpp?rev=227134&r1=227133&r2=227134&view=diff
==============================================================================
--- lld/trunk/lib/Driver/WinLinkDriver.cpp (original)
+++ lld/trunk/lib/Driver/WinLinkDriver.cpp Mon Jan 26 14:46:47 2015
@@ -855,6 +855,7 @@ bool WinLinkDriver::linkPECOFF(int argc,
     return true;
 
   PECOFFLinkingContext ctx;
+  ctx.setParseDirectives(parseDirectives);
   ctx.registry().addSupportCOFFObjects(ctx);
   ctx.registry().addSupportCOFFImportLibraries(ctx);
   ctx.registry().addSupportArchives(ctx.logInputFiles());

Modified: lld/trunk/lib/ReaderWriter/PECOFF/ReaderCOFF.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/PECOFF/ReaderCOFF.cpp?rev=227134&r1=227133&r2=227134&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/PECOFF/ReaderCOFF.cpp (original)
+++ lld/trunk/lib/ReaderWriter/PECOFF/ReaderCOFF.cpp Mon Jan 26 14:46:47 2015
@@ -910,9 +910,10 @@ FileCOFF::parseDirectiveSection(StringRe
   const char **argv = &tokens[0];
   std::string errorMessage;
   llvm::raw_string_ostream stream(errorMessage);
-  bool parseFailed = !WinLinkDriver::parse(argc, argv, _ctx, stream,
-                                           /*isDirective*/ true,
-                                           undefinedSymbols);
+  PECOFFLinkingContext::ParseDirectives parseDirectives =
+    _ctx.getParseDirectives();
+  bool parseFailed = !parseDirectives(argc, argv, _ctx, stream,
+                                      undefinedSymbols);
   stream.flush();
   // Print error message if error.
   if (parseFailed) {

Modified: lld/trunk/tools/lld/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/tools/lld/CMakeLists.txt?rev=227134&r1=227133&r2=227134&view=diff
==============================================================================
--- lld/trunk/tools/lld/CMakeLists.txt (original)
+++ lld/trunk/tools/lld/CMakeLists.txt Mon Jan 26 14:46:47 2015
@@ -4,6 +4,7 @@ add_llvm_executable(lld
 
 target_link_libraries(lld
   lldDriver
+  LLVMSupport
   )
 
 install(TARGETS lld

Modified: lld/trunk/unittests/DriverTests/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/unittests/DriverTests/CMakeLists.txt?rev=227134&r1=227133&r2=227134&view=diff
==============================================================================
--- lld/trunk/unittests/DriverTests/CMakeLists.txt (original)
+++ lld/trunk/unittests/DriverTests/CMakeLists.txt Mon Jan 26 14:46:47 2015
@@ -8,4 +8,7 @@ add_lld_unittest(DriverTests
 
 target_link_libraries(DriverTests
   lldDriver
+  lldCore
+  lldPECOFF
+  lldMachO
   )





More information about the llvm-commits mailing list