[lld] r240045 - COFF: Add /implib option.

Rui Ueyama ruiu at google.com
Thu Jun 18 13:27:10 PDT 2015


Author: ruiu
Date: Thu Jun 18 15:27:09 2015
New Revision: 240045

URL: http://llvm.org/viewvc/llvm-project?rev=240045&view=rev
Log:
COFF: Add /implib option.

Modified:
    lld/trunk/COFF/Config.h
    lld/trunk/COFF/Driver.cpp
    lld/trunk/COFF/DriverUtils.cpp
    lld/trunk/test/COFF/dll.test

Modified: lld/trunk/COFF/Config.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/Config.h?rev=240045&r1=240044&r2=240045&view=diff
==============================================================================
--- lld/trunk/COFF/Config.h (original)
+++ lld/trunk/COFF/Config.h Thu Jun 18 15:27:09 2015
@@ -55,6 +55,7 @@ struct Configuration {
 
   // True if we are creating a DLL.
   bool DLL = false;
+  StringRef Implib;
   std::vector<Export> Exports;
 
   // Options for manifest files.

Modified: lld/trunk/COFF/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/Driver.cpp?rev=240045&r1=240044&r2=240045&view=diff
==============================================================================
--- lld/trunk/COFF/Driver.cpp (original)
+++ lld/trunk/COFF/Driver.cpp Thu Jun 18 15:27:09 2015
@@ -338,6 +338,10 @@ bool LinkerDriver::link(int Argc, const
     if (parseAlternateName(Arg->getValue()))
       return false;
 
+  // Handle /implib
+  if (auto *Arg = Args->getLastArg(OPT_implib))
+    Config->Implib = Arg->getValue();
+
   // Handle /opt
   for (auto *Arg : Args->filtered(OPT_opt)) {
     std::string S = StringRef(Arg->getValue()).lower();

Modified: lld/trunk/COFF/DriverUtils.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/DriverUtils.cpp?rev=240045&r1=240044&r2=240045&view=diff
==============================================================================
--- lld/trunk/COFF/DriverUtils.cpp (original)
+++ lld/trunk/COFF/DriverUtils.cpp Thu Jun 18 15:27:09 2015
@@ -507,14 +507,18 @@ std::error_code writeImportLibrary() {
   std::string Contents = createModuleDefinitionFile();
   std::string Def = writeToTempFile(Contents);
   llvm::FileRemover TempFile(Def);
-  SmallString<128> Out = StringRef(Config->OutputFile);
-  sys::path::replace_extension(Out, ".lib");
 
   Executor E("lib.exe");
   E.add("/nologo");
   E.add("/machine:x64");
   E.add(Twine("/def:") + Def);
-  E.add("/out:" + Out);
+  if (Config->Implib.empty()) {
+    SmallString<128> Out = StringRef(Config->OutputFile);
+    sys::path::replace_extension(Out, ".lib");
+    E.add("/out:" + Out);
+  } else {
+    E.add("/out:" + Config->Implib);
+  }
   return E.run();
 }
 

Modified: lld/trunk/test/COFF/dll.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/COFF/dll.test?rev=240045&r1=240044&r2=240045&view=diff
==============================================================================
--- lld/trunk/test/COFF/dll.test (original)
+++ lld/trunk/test/COFF/dll.test Thu Jun 18 15:27:09 2015
@@ -28,6 +28,10 @@ EXPORT-LTO-NEXT:       3   0x1030  expor
 # RUN: lld -flavor link2 /out:%t2.exe %t2.obj %t.lib
 # RUN: llvm-readobj -coff-imports %t2.exe | FileCheck -check-prefix=IMPORT %s
 
+# RUN: lld -flavor link2 /out:%t.dll /dll %t.obj /implib:%t2.lib /export:exportfn1 /export:exportfn2
+# RUN: lld -flavor link2 /out:%t2.exe %t2.obj %t2.lib
+# RUN: llvm-readobj -coff-imports %t2.exe | FileCheck -check-prefix=IMPORT %s
+
 # RUN: lld -flavor link2 /out:%t2.lto.exe %t2.obj %t.lto.lib
 # RUN: llvm-readobj -coff-imports %t2.lto.exe | FileCheck -check-prefix=IMPORT %s
 





More information about the llvm-commits mailing list