summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lld/COFF/Driver.cpp6
-rw-r--r--lld/test/COFF/implib-name-mingw.test20
2 files changed, 24 insertions, 2 deletions
diff --git a/lld/COFF/Driver.cpp b/lld/COFF/Driver.cpp
index b21846879a4..f8743775dea 100644
--- a/lld/COFF/Driver.cpp
+++ b/lld/COFF/Driver.cpp
@@ -1841,10 +1841,12 @@ void LinkerDriver::link(ArrayRef<const char *> argsArr) {
}
// 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();
}
diff --git a/lld/test/COFF/implib-name-mingw.test b/lld/test/COFF/implib-name-mingw.test
new file mode 100644
index 00000000000..3fb8b363ffe
--- /dev/null
+++ b/lld/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
OpenPOWER on IntegriCloud