Commit c407f7fb authored by Martin Storsjö's avatar Martin Storsjö

contrib: pthreads: Fix building with llvm-mingw

This avoids doing things with dlltool that llvm-dlltool doesn't

I don't see the need of running a second pass with dlltool to
produce an output def file and yet another pass to produce
an import library out of it; just make the linker output the
import library while linking the dll. (If the import library is
to be used by MSVC, there is a point in generating it with dlltool
instead of with ld though. Even then, there's no point in generating
the def file using dlltool though, when it could just be generated by
the linker.)

Remove an inline declaration on a function that can't be inline-only
(static inline).

For non-static inline functions in C, the compiler can choose to
use the inline function itself, or assume that a definition exists
in a different translation unit. In this case, clang seems to
not inline ptw32_cond_check_need_init and creates an undefined
reference to the same function that should be defined in another
translation unit (which doesn't exist).

See for more details
on this.
parent 8743195a
diff -urN pthreads-orig/GNUmakefile pthreads/GNUmakefile
--- pthreads-orig/GNUmakefile 2018-01-05 21:45:34.478551838 +0000
+++ pthreads/GNUmakefile 2018-01-05 21:51:37.918541470 +0000
@@ -523,25 +523,17 @@
- $(CC) $(OPT) -shared -o $(GC_DLL) $(DLL_OBJS) $(LFLAGS)
- $(DLLTOOL) -z pthread.def $(DLL_OBJS)
- $(DLLTOOL) -k --dllname $@ --output-lib $(GC_LIB) --def $(PTHREAD_DEF)
+ $(CC) $(OPT) -shared -o $(GC_DLL) -Wl,--out-implib,$(GC_LIB) $(DLL_OBJS) $(LFLAGS)
- $(CC) $(OPT) -mthreads -shared -o $(GCE_DLL) $(DLL_OBJS) $(LFLAGS)
- $(DLLTOOL) -z pthread.def $(DLL_OBJS)
- $(DLLTOOL) -k --dllname $@ --output-lib $(GCE_LIB) --def $(PTHREAD_DEF)
+ $(CC) $(OPT) -mthreads -shared -o $(GCE_DLL) -Wl,--out-implib,$(GCE_LIB) $(DLL_OBJS) $(LFLAGS)
- $(CC) $(OPT) $(XOPT) -shared -o $(GC_DLL) $(DLL_INLINED_OBJS) $(LFLAGS)
- $(DLLTOOL) -z pthread.def $(DLL_INLINED_OBJS)
- $(DLLTOOL) -k --dllname $(GC_DLL) --output-lib $(GC_LIB) --def $(PTHREAD_DEF)
+ $(CC) $(OPT) $(XOPT) -shared -o $(GC_DLL) -Wl,--out-implib,$(GC_LIB) $(DLL_INLINED_OBJS) $(LFLAGS)
echo touched > $(GC_INLINED_STAMP)
- $(CC) $(OPT) $(XOPT) -mthreads -shared -o $(GCE_DLL) $(DLL_INLINED_OBJS) $(LFLAGS)
- $(DLLTOOL) -z pthread.def $(DLL_INLINED_OBJS)
- $(DLLTOOL) -k --dllname $(GCE_DLL) --output-lib $(GCE_LIB) --def $(PTHREAD_DEF)
+ $(CC) $(OPT) $(XOPT) -mthreads -shared -o $(GCE_DLL) -Wl,--out-implib,$(GCE_LIB) $(DLL_INLINED_OBJS) $(LFLAGS)
echo touched > $(GCE_INLINED_STAMP)
diff -urN pthreads-orig/ptw32_spinlock_check_need_init.c pthreads/ptw32_spinlock_check_need_init.c
--- pthreads-orig/ptw32_spinlock_check_need_init.c 2011-03-10 13:40:17.000000000 +0000
+++ pthreads/ptw32_spinlock_check_need_init.c 2018-01-06 07:22:18.399696662 +0000
@@ -38,7 +38,7 @@
#include "implement.h"
ptw32_spinlock_check_need_init (pthread_spinlock_t * lock)
int result = 0;
......@@ -19,6 +19,8 @@ pthreads: pthreads-w32-$(PTHREADS_W32_VERSION)-release.tar.gz .sum-pthreads
$(APPLY) $(SRC)/pthreads/winrt.patch
$(APPLY) $(SRC)/pthreads/implib.patch
$(APPLY) $(SRC)/pthreads/remove-inline.patch
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment