[PATCH] D66367: [LLD] [COFF] Require an explicit -implib option for creating implibs in mingw mode

Martin Storsjö via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 20 03:16:49 PDT 2019


This revision was automatically updated to reflect the committed changes.
Closed by commit rL369363: [COFF] Require an explicit -implib option for creating implibs in mingw mode (authored by mstorsjo, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D66367?vs=215670&id=216089#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D66367

Files:
  lld/trunk/COFF/Driver.cpp
  lld/trunk/test/COFF/implib-name-mingw.test


Index: lld/trunk/test/COFF/implib-name-mingw.test
===================================================================
--- lld/trunk/test/COFF/implib-name-mingw.test
+++ lld/trunk/test/COFF/implib-name-mingw.test
@@ -0,0 +1,20 @@
+REQUIRES: x86
+RUN: mkdir -p %t-out
+RUN: llvm-mc -triple x86_64-windows-gnu -filetype obj -o %t-out/object.obj %S/Inputs/object.s
+
+Check that linking without an explicit -implib doesn't produce any implib.
+
+First test that linking without -lldmingw does produce an implib, but when
+adding -lldmingw, it no longer is produced. And when it is explicitly named,
+it is created.
+
+RUN: rm -f %t-out/library.lib
+RUN: lld-link -dll -machine:x64 -def:%S/Inputs/named.def -out:%t-out/library.dll %t-out/object.obj -entry:f -subsystem:console
+RUN: test -f %t-out/library.lib
+
+RUN: rm -f %t-out/library.lib
+RUN: lld-link -lldmingw -dll -machine:x64 -def:%S/Inputs/named.def -out:%t-out/library.dll %t-out/object.obj -entry:f -subsystem:console
+RUN: not test -f %t-out/library.lib
+
+RUN: lld-link -lldmingw -dll -machine:x64 -def:%S/Inputs/named.def -out:%t-out/library.dll %t-out/object.obj -entry:f -subsystem:console -implib:%t-out/library.lib
+RUN: test -f %t-out/library.lib
Index: lld/trunk/COFF/Driver.cpp
===================================================================
--- lld/trunk/COFF/Driver.cpp
+++ lld/trunk/COFF/Driver.cpp
@@ -1841,10 +1841,12 @@
   }
 
   // Windows specific -- when we are creating a .dll file, we also
-  // need to create a .lib file.
+  // need to create a .lib file. In MinGW mode, we only do that when the
+  // -implib option is given explicitly, for compatibility with GNU ld.
   if (!config->exports.empty() || config->dll) {
     fixupExports();
-    createImportLibrary(/*asLib=*/false);
+    if (!config->mingw || !config->implib.empty())
+      createImportLibrary(/*asLib=*/false);
     assignExportOrdinals();
   }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D66367.216089.patch
Type: text/x-patch
Size: 1901 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190820/2844e888/attachment.bin>


More information about the llvm-commits mailing list