[lld] r369363 - [COFF] Require an explicit -implib option for creating implibs in mingw mode

Martin Storsjo via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 20 03:14:55 PDT 2019


Author: mstorsjo
Date: Tue Aug 20 03:14:54 2019
New Revision: 369363

URL: http://llvm.org/viewvc/llvm-project?rev=369363&view=rev
Log:
[COFF] Require an explicit -implib option for creating implibs in mingw mode

GNU ld doesn't produce implibs unless explicitly requested.

Differential Revision: https://reviews.llvm.org/D66367

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

Modified: lld/trunk/COFF/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/Driver.cpp?rev=369363&r1=369362&r2=369363&view=diff
==============================================================================
--- lld/trunk/COFF/Driver.cpp (original)
+++ lld/trunk/COFF/Driver.cpp Tue Aug 20 03:14:54 2019
@@ -1841,10 +1841,12 @@ void LinkerDriver::link(ArrayRef<const c
   }
 
   // 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();
   }
 

Added: lld/trunk/test/COFF/implib-name-mingw.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/COFF/implib-name-mingw.test?rev=369363&view=auto
==============================================================================
--- lld/trunk/test/COFF/implib-name-mingw.test (added)
+++ lld/trunk/test/COFF/implib-name-mingw.test Tue Aug 20 03:14:54 2019
@@ -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




More information about the llvm-commits mailing list