Commit 1d156f09 authored by Steve Lhomme's avatar Steve Lhomme

contrib: replace pthreads-w32 with winpthreads

parent ce9261d9
......@@ -24,13 +24,9 @@ ifdef HAVE_WINSTORE
endif
$(MOVE)
AOM_CFLAGS := $(CFLAGS)
AOM_CXXFLAGS := $(CXXFLAGS)
DEPS_aom =
ifdef HAVE_WINSTORE
DEPS_aom += pthreads $(DEPS_pthreads)
AOM_CFLAGS += -DPTW32_STATIC_LIB
AOM_CXXFLAGS += -DPTW32_STATIC_LIB
endif
AOM_LDFLAGS := $(LDFLAGS)
......@@ -68,7 +64,7 @@ endif
# libaom doesn't allow in-tree builds
.aom: aom toolchain.cmake
cd $< && mkdir -p aom_build
cd $</aom_build && LDFLAGS="$(AOM_LDFLAGS)" CFLAGS="$(AOM_CFLAGS)" CXXFLAGS="$(AOM_CXXFLAGS)" $(HOSTVARS) $(CMAKE) ../ $(AOM_CONF)
cd $</aom_build && LDFLAGS="$(AOM_LDFLAGS)" $(HOSTVARS) $(CMAKE) ../ $(AOM_CONF)
cd $< && $(MAKE) -C aom_build
cd $</aom_build && ../../../../contrib/src/pkg-static.sh aom.pc
cd $</aom_build && $(MAKE) install
......
......@@ -9,13 +9,9 @@ ifeq ($(call need_pkg,"mysofa"),)
PKGS_FOUND += mysofa
endif
MYSOFA_CFLAGS := $(CFLAGS)
MYSOFA_CXXFLAGS := $(CXXFLAGS)
DEPS_mysofa += zlib $(DEPS_zlib)
ifdef HAVE_WINSTORE
DEPS_mysofa += pthreads $(DEPS_pthreads)
MYSOFA_CFLAGS += -DPTW32_STATIC_LIB
MYSOFA_CXXFLAGS += -DPTW32_STATIC_LIB
endif
$(TARBALLS)/libmysofa-$(MYSOFA_VERSION).tar.gz:
......@@ -29,7 +25,7 @@ mysofa: libmysofa-$(MYSOFA_VERSION).tar.gz .sum-mysofa
.mysofa: mysofa toolchain.cmake
-cd $< && rm CMakeCache.txt
cd $< && $(HOSTVARS) CFLAGS="$(MYSOFA_CFLAGS)" CXXFLAGS="$(MYSOFA_CXXFLAGS)" $(CMAKE) -DBUILD_TESTS=OFF -DBUILD_SHARED_LIBS=OFF
cd $< && $(HOSTVARS) $(CMAKE) -DBUILD_TESTS=OFF -DBUILD_SHARED_LIBS=OFF
cd $< && $(MAKE) install
touch $@
......@@ -3,12 +3,8 @@
OPENJPEG_VERSION := 2.3.0
OPENJPEG_URL := https://github.com/uclouvain/openjpeg/archive/v$(OPENJPEG_VERSION).tar.gz
OPENJPEG_CFLAGS := $(CFLAGS)
OPENJPEG_CXXFLAGS := $(CXXFLAGS)
ifdef HAVE_WINSTORE
DEPS_openjpeg += pthreads $(DEPS_pthreads)
OPENJPEG_CFLAGS += -DPTW32_STATIC_LIB
OPENJPEG_CXXFLAGS += -DPTW32_STATIC_LIB
endif
$(TARBALLS)/openjpeg-v$(OPENJPEG_VERSION).tar.gz:
......@@ -30,7 +26,7 @@ endif
$(MOVE)
.openjpeg: openjpeg toolchain.cmake
cd $< && $(HOSTVARS) CFLAGS="$(OPENJPEG_CFLAGS)" CXXFLAGS="$(OPENJPEG_CXXFLAGS)" $(CMAKE) \
cd $< && $(HOSTVARS) $(CMAKE) \
-DBUILD_SHARED_LIBS:bool=OFF -DBUILD_PKGCONFIG_FILES=ON \
-DBUILD_CODEC:bool=OFF \
.
......
......@@ -27,13 +27,9 @@ $(TARBALLS)/protobuf-$(PROTOBUF_VERSION)-cpp.tar.gz:
.sum-protobuf: protobuf-$(PROTOBUF_VERSION)-cpp.tar.gz
PROTOBUF_CFLAGS := $(CFLAGS)
PROTOBUF_CXXFLAGS := $(CXXFLAGS)
DEPS_protobuf = zlib $(DEPS_zlib)
ifdef HAVE_WINSTORE
DEPS_protobuf += pthreads $(DEPS_pthreads)
PROTOBUF_CFLAGS += -DPTW32_STATIC_LIB
PROTOBUF_CXXFLAGS += -DPTW32_STATIC_LIB
endif
protobuf: protobuf-$(PROTOBUF_VERSION)-cpp.tar.gz .sum-protobuf
......@@ -45,6 +41,6 @@ protobuf: protobuf-$(PROTOBUF_VERSION)-cpp.tar.gz .sum-protobuf
.protobuf: protobuf
$(RECONF)
cd $< && CFLAGS="$(PROTOBUF_CFLAGS)" CXXFLAGS="$(PROTOBUF_CXXFLAGS)" $(HOSTVARS) ./configure $(HOSTCONF) --with-protoc="$(PROTOC)"
cd $< && $(HOSTVARS) ./configure $(HOSTCONF) --with-protoc="$(PROTOC)"
cd $< && $(MAKE) && $(MAKE) install
touch $@
9c06e85310766834370c3dceb83faafd397da18a32411ca7645c8eb6b9495fea54ca2872f4a3e8d83cb5fdc5dea7f3f0464be5bb9af3222a6534574a184bd551 pthreads-w32-2-9-1-release.tar.gz
85bc0244cd30ef38262792d61502a012348b8220ef249352b68ddfa40663ca1cae5f81bed70caa9579469fad6ad16a95f02387c280effeda7ce8287b549f3fc9 mingw-w64-v5.0.3.tar.bz2
diff -urN pthreads-orig/context.h pthreads/context.h
--- pthreads-orig/context.h 2011-03-04 01:37:20.000000000 +0200
+++ pthreads/context.h 2018-03-18 13:50:07.362676429 +0200
@@ -67,6 +67,10 @@
#define PTW32_PROGCTR(Context) ((Context).Pc)
#endif
+#if defined(_ARM64_) || defined(__aarch64__)
+#define PTW32_PROGCTR(Context) ((Context).Pc)
+#endif
+
#if !defined(PTW32_PROGCTR)
#error Module contains CPU-specific code; modify and recompile.
#endif
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 @@
$(GC_DLL) $(GCD_DLL): $(DLL_OBJS)
- $(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)
$(GCE_DLL): $(DLL_OBJS)
- $(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)
$(GC_INLINED_STAMP) $(GCD_INLINED_STAMP): $(DLL_INLINED_OBJS)
- $(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)
$(GCE_INLINED_STAMP) $(GCED_INLINED_STAMP): $(DLL_INLINED_OBJS)
- $(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)
$(GC_STATIC_STAMP) $(GCD_STATIC_STAMP): $(DLL_INLINED_OBJS)
--- pthreads/semaphore.h 2018-05-16 22:10:12.938777300 +0200
+++ pthreads/semaphore.h.mode_t 2018-05-16 22:08:58.453800700 +0200
@@ -98,8 +98,10 @@
# if defined(__MINGW64__)
# define HAVE_STRUCT_TIMESPEC
# define HAVE_MODE_T
+# include <sys/types.h>
# elif defined(_UWIN) || defined(__MINGW32__)
# define HAVE_MODE_T
+# include <sys/types.h>
# endif
#endif
--- pthreads/pthread.h 2018-05-16 09:51:14.092544900 +0200
+++ pthreads/pthread.h.warning 2018-05-16 09:50:54.762826300 +0200
@@ -105,6 +105,7 @@
#define PTW32_LEVEL_MAX 3
#if ( defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 200112 ) || !defined(PTW32_LEVEL)
+#undef PTW32_LEVEL
#define PTW32_LEVEL PTW32_LEVEL_MAX
/* Include everything */
#endif
--- pthreads/sched.h 2018-05-16 09:55:09.844370300 +0200
+++ pthreads/sched.h.warning 2018-05-16 09:54:53.024845400 +0200
@@ -61,6 +61,7 @@
#define PTW32_SCHED_LEVEL_MAX 3
#if ( defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 200112 ) || !defined(PTW32_SCHED_LEVEL)
+#undef PTW32_SCHED_LEVEL
#define PTW32_SCHED_LEVEL PTW32_SCHED_LEVEL_MAX
/* Include everything */
#endif
# POSIX threads
# winpthreads
WINPTHREADS_VERSION := 5.0.3
WINPTHREADS_URL := https://sourceforge.net/projects/mingw-w64/files/mingw-w64/mingw-w64-release/mingw-w64-v$(WINPTHREADS_VERSION).tar.bz2/download
ifdef HAVE_WIN32
PKGS += pthreads
endif
ifndef HAVE_WINSTORE
PKGS_FOUND += pthreads
endif
PTHREADS_W32_VERSION := 2-9-1
PTHREADS_W32_URL := ftp://sources.redhat.com/pub/pthreads-win32/pthreads-w32-$(PTHREADS_W32_VERSION)-release.tar.gz
$(TARBALLS)/mingw-w64-v$(WINPTHREADS_VERSION).tar.bz2:
$(call download_pkg,$(WINPTHREADS_URL),winpthreads)
$(TARBALLS)/pthreads-w32-$(PTHREADS_W32_VERSION)-release.tar.gz:
$(call download_pkg,$(PTHREADS_W32_URL),pthreads)
.sum-pthreads: mingw-w64-v$(WINPTHREADS_VERSION).tar.bz2
.sum-pthreads: pthreads-w32-$(PTHREADS_W32_VERSION)-release.tar.gz
ifdef HAVE_WIN32
pthreads: pthreads-w32-$(PTHREADS_W32_VERSION)-release.tar.gz .sum-pthreads
pthreads: mingw-w64-v$(WINPTHREADS_VERSION).tar.bz2 .sum-pthreads
$(UNPACK)
sed -e 's/^CROSS.*=/CROSS ?=/' -i.orig $(UNPACK_DIR)/GNUmakefile
ifdef HAVE_WINSTORE
$(APPLY) $(SRC)/pthreads/winrt.patch
endif
$(APPLY) $(SRC)/pthreads/implib.patch
$(APPLY) $(SRC)/pthreads/x86-inline-asm.patch
$(APPLY) $(SRC)/pthreads/arm64.patch
$(APPLY) $(SRC)/pthreads/pthreads-fix-warning.patch
$(APPLY) $(SRC)/pthreads/pthreads-fix-mode_t.patch
$(MOVE)
ifdef HAVE_CROSS_COMPILE
PTHREADS_W32_CONF := CROSS="$(HOST)-"
endif
.pthreads: pthreads
cd $< && $(HOSTVARS) $(PTHREADS_W32_CONF) $(MAKE) GC-static
mkdir -p -- "$(PREFIX)/include"
cd $< && cp -v pthread.h sched.h semaphore.h "$(PREFIX)/include/"
mkdir -p -- "$(PREFIX)/lib"
cp -v $</*.a "$(PREFIX)/lib/"
$(REQUIRE_GPL)
cd $</mingw-w64-libraries/winpthreads && $(HOSTVARS) ./configure $(HOSTCONF)
cd $< && $(MAKE) -C mingw-w64-libraries -C winpthreads install
touch $@
endif
--- pthreads/ptw32_getprocessors.c.orig 2016-05-11 20:50:47.774849703 +0200
+++ pthreads/ptw32_getprocessors.c 2016-05-11 20:50:56.054865989 +0200
@@ -55,6 +55,11 @@
int
ptw32_getprocessors (int *count)
{
+ SYSTEM_INFO systemInfo;
+ GetNativeSystemInfo(&systemInfo);
+ return systemInfo.dwNumberOfProcessors;
+#if 0
+
DWORD_PTR vProcessCPUs;
DWORD_PTR vSystemCPUs;
int result = 0;
@@ -88,4 +93,5 @@
#endif
return (result);
+#endif
}
--- pthreads/pthread_win32_attach_detach_np.c.orig 2016-05-11 21:08:47.988487073 +0200
+++ pthreads/pthread_win32_attach_detach_np.c 2016-05-11 21:09:06.804511207 +0200
@@ -70,6 +70,7 @@
*
* This should take care of any security issues.
*/
+#if 0
#if defined(__GNUC__) || _MSC_VER < 1400
if(GetSystemDirectory(QuserExDLLPathBuf, sizeof(QuserExDLLPathBuf)))
{
@@ -97,6 +98,7 @@
GetProcAddress (ptw32_h_quserex, (LPCSTR) "QueueUserAPCEx");
#endif
}
+#endif
if (NULL == ptw32_register_cancelation)
{
--- pthreads/pthread_cancel.c.orig 2016-05-11 22:43:53.653343096 +0200
+++ pthreads/pthread_cancel.c 2016-05-11 22:54:22.110220490 +0200
@@ -62,6 +62,7 @@
DWORD
ptw32_RegisterCancelation (PAPCFUNC unused1, HANDLE threadH, DWORD unused2)
{
+#if 0
CONTEXT context;
context.ContextFlags = CONTEXT_CONTROL;
@@ -69,6 +70,7 @@
PTW32_PROGCTR (context) = (DWORD_PTR) ptw32_cancel_self;
SetThreadContext (threadH, &context);
return 0;
+#endif
}
int
diff -u pthreads-orig/implement.h pthreads/implement.h
--- pthreads-orig/implement.h 2012-03-18 07:11:43.000000000 +0200
+++ pthreads/implement.h 2018-01-10 14:53:53.596756881 +0200
@@ -746,7 +746,7 @@
*
* The above aren't available in Mingw32 as of gcc 4.5.2 so define our own.
*/
-#if defined(__GNUC__)
+#if defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))
# if defined(_WIN64)
# define PTW32_INTERLOCKED_COMPARE_EXCHANGE_64(location, value, comparand) \
({ \
......@@ -16,8 +16,6 @@ SRT_CXXFLAGS := $(CXXFLAGS)
DEPS_srt = gnutls $(DEPS_gnutls)
ifdef HAVE_WINSTORE
DEPS_srt += pthreads $(DEPS_pthreads)
SRT_CFLAGS += -DPTW32_STATIC_LIB
SRT_CXXFLAGS += -DPTW32_STATIC_LIB
endif
ifdef HAVE_DARWIN_OS
......
--- upnp/configure.ac.pthread-w32 2018-05-17 11:51:47.115502500 +0200
+++ upnp/configure.ac 2018-05-17 12:49:30.371786100 +0200
@@ -667,6 +667,7 @@ ACX_PTHREAD(
#
# Update environment variables for pthreads
#
+PTHREAD_LIBS="-lpthreadGC2"
CC="$PTHREAD_CC"
CFLAGS="$PTHREAD_CFLAGS $CFLAGS"
LIBS="$PTHREAD_LIBS $LIBS"
@@ -676,7 +677,7 @@ PC_CFLAGS="$PTHREAD_CFLAGS"
# WIN32 specific
if test "$ac_cv_win32" = "yes"; then
WIN32_LIBS="-liphlpapi -lws2_32"
-PC_CFLAGS="$PC_CFLAGS -DUPNP_STATIC_LIB"
+PC_CFLAGS="$PC_CFLAGS -DUPNP_STATIC_LIB -DPTW32_STATIC_LIB"
fi
AC_SUBST(PC_CFLAGS)
AC_SUBST(WIN32_LIBS)
......@@ -15,8 +15,6 @@ UPNP_CFLAGS := $(CFLAGS) -DUPNP_STATIC_LIB
UPNP_CXXFLAGS := $(CXXFLAGS) -DUPNP_STATIC_LIB
ifdef HAVE_WINSTORE
DEPS_upnp += pthreads $(DEPS_pthreads)
UPNP_CFLAGS += -DPTW32_STATIC_LIB
UPNP_CXXFLAGS += -DPTW32_STATIC_LIB
endif
ifdef HAVE_WINSTORE
CONFIGURE_ARGS=--disable-ipv6 --enable-unspecified_server
......@@ -38,7 +36,6 @@ ifdef HAVE_WIN32
$(APPLY) $(SRC)/upnp/libupnp-pthread-w32-checks.patch
ifdef HAVE_WINSTORE
$(APPLY) $(SRC)/upnp/no-getifinfo.patch
$(APPLY) $(SRC)/upnp/libupnp-pthread-w32-force.patch
endif
endif
$(APPLY) $(SRC)/upnp/libpthread.patch
......
......@@ -30,12 +30,8 @@ endif
DEPS_vpx =
VPX_CFLAGS := $(CFLAGS)
VPX_CXXFLAGS := $(CXXFLAGS)
ifdef HAVE_WINSTORE
DEPS_vpx += pthreads $(DEPS_pthreads)
VPX_CFLAGS += -DPTW32_STATIC_LIB
VPX_CXXFLAGS += -DPTW32_STATIC_LIB
endif
ifdef HAVE_CROSS_COMPILE
......@@ -169,7 +165,7 @@ VPX_CONF += --enable-debug --disable-optimizations
endif
.vpx: libvpx
cd $< && LDFLAGS="$(VPX_LDFLAGS)" CROSS=$(VPX_CROSS) CFLAGS="$(VPX_CFLAGS)" CXXFLAGS="$(VPX_CXXFLAGS)" ./configure --target=$(VPX_TARGET) \
cd $< && LDFLAGS="$(VPX_LDFLAGS)" CROSS=$(VPX_CROSS) ./configure --target=$(VPX_TARGET) \
$(VPX_CONF) --prefix=$(PREFIX)
cd $< && $(MAKE)
cd $< && ../../../contrib/src/pkg-static.sh vpx.pc
......
......@@ -42,8 +42,6 @@ ZVBICONF := \
ifdef HAVE_WINSTORE
DEPS_upnp += pthreads $(DEPS_pthreads)
ZVBI_CFLAGS += -DPTW32_STATIC_LIB
ZVBI_CXXFLAGS += -DPTW32_STATIC_LIB
endif
ifdef HAVE_MACOSX
ZVBI_CFLAGS += -fnested-functions
......
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