From: Cory Fields <[email protected]>

When building a libtool lib, libtool automatically defines "-EXPORT_DLL" for
objects intended to be linked into a shared library.

Applications are then intended to also define "EXPORT_DLL", which has the
effect of importing the functions from the exported dll.

However, this goes bad when a downstream user is itself a libtool lib which is
attempting to statically link in libpthread. libtool sets "EXPORT_DLL" for
itself as expected, so that the downstream lib can export its own symbols.
HOWEVER it also has the effect of trying to _import_ the libpthread symbols,
which doesn't work because libpthread is being linked statically rather than
as a dll.

This commit provides an escape-hatch for downstream libtool libs that need to
statically link in libpthread.

By defining WINPTHREADS_STATIC, the downstream's dll exports will (correctly)
not be affected by pthreads.

Signed-off-by: Cory Fields <[email protected]>
---
 mingw-w64-libraries/winpthreads/include/pthread.h   | 2 +-
 mingw-w64-libraries/winpthreads/include/sched.h     | 2 +-
 mingw-w64-libraries/winpthreads/include/semaphore.h | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/mingw-w64-libraries/winpthreads/include/pthread.h 
b/mingw-w64-libraries/winpthreads/include/pthread.h
index 5aadb1cfa..4b056407e 100644
--- a/mingw-w64-libraries/winpthreads/include/pthread.h
+++ b/mingw-w64-libraries/winpthreads/include/pthread.h
@@ -86,7 +86,7 @@ extern "C" {
 #if defined DLL_EXPORT
 #ifdef IN_WINPTHREAD
 #define WINPTHREAD_API __declspec(dllexport)
-#else
+#elif !defined(WINPTHREAD_STATIC)
 #define WINPTHREAD_API __declspec(dllimport)
 #endif
 #else
diff --git a/mingw-w64-libraries/winpthreads/include/sched.h 
b/mingw-w64-libraries/winpthreads/include/sched.h
index e77bf4cc3..4999d42dc 100644
--- a/mingw-w64-libraries/winpthreads/include/sched.h
+++ b/mingw-w64-libraries/winpthreads/include/sched.h
@@ -52,7 +52,7 @@ extern "C" {
 #if defined DLL_EXPORT && !defined (WINPTHREAD_EXPORT_ALL_DEBUG)
 #ifdef IN_WINPTHREAD
 #define WINPTHREAD_SCHED_API __declspec(dllexport)
-#else
+#elif !defined(WINPTHREAD_STATIC)
 #define WINPTHREAD_SCHED_API __declspec(dllimport)
 #endif
 #else
diff --git a/mingw-w64-libraries/winpthreads/include/semaphore.h 
b/mingw-w64-libraries/winpthreads/include/semaphore.h
index 14cb70371..20f6e1384 100644
--- a/mingw-w64-libraries/winpthreads/include/semaphore.h
+++ b/mingw-w64-libraries/winpthreads/include/semaphore.h
@@ -30,7 +30,7 @@ extern "C" {
 #if defined DLL_EXPORT && !defined (WINPTHREAD_EXPORT_ALL_DEBUG)
 #ifdef IN_WINPTHREAD
 #define WINPTHREAD_SEMA_API __declspec(dllexport)
-#else
+#elif !defined(WINPTHREAD_STATIC)
 #define WINPTHREAD_SEMA_API __declspec(dllimport)
 #endif
 #else
-- 
2.25.1



_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to