From d972a8646edc79e7f4e373c51dc2fb77233989f2 Mon Sep 17 00:00:00 2001 From: jstebbins Date: Sun, 18 Jan 2015 17:25:51 +0000 Subject: [PATCH] Work around fedora mingw pthread library requirement Fedora mingw seems to require it's own pthread library which causes build conflicts with our pthread lib. So this patch distinguishes whether libpthread or libpthreadGC2 is already installed on the system and uses the appropriate system lib when found. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@6766 b64f7644-9d1e-0410-96f1-a4d463321fa5 --- libhb/module.defs | 9 +++++++-- libhb/ports.c | 4 ++++ make/configure.py | 5 ++++- make/include/main.defs | 2 ++ test/module.defs | 7 ++++++- 5 files changed, 23 insertions(+), 4 deletions(-) diff --git a/libhb/module.defs b/libhb/module.defs index a6eb72fe9..473a058ca 100644 --- a/libhb/module.defs +++ b/libhb/module.defs @@ -53,7 +53,10 @@ else ifeq ($(BUILD.system),darwin) else ifeq ($(BUILD.system),linux) LIBHB.GCC.D += SYS_LINUX _LARGEFILE_SOURCE _FILE_OFFSET_BITS=64 else ifeq ($(BUILD.system),mingw) - LIBHB.GCC.D += SYS_MINGW PTW32_STATIC_LIB + LIBHB.GCC.D += SYS_MINGW +ifeq ($(HAS.pthreadGC2),1) + LIBHB.GCC.D += PTW32_STATIC_LIB +endif LIBHB.GCC.args.extra.dylib++ += -Wl,--enable-auto-import -static else ifeq ($(BUILD.system),solaris) LIBHB.GCC.D += SYS_SunOS _LARGEFILE_SOURCE _FILE_OFFSET_BITS=64 _POSIX_C_SOURCE=200112L __EXTENSIONS__ @@ -140,7 +143,9 @@ else LIBHB.GCC.l += fribidi endif -ifneq ($(HAS.pthread),1) +ifeq ($(HAS.pthread),1) + LIBHB.GCC.l += pthread +else ifneq ($(HAS.pthreadGC2),1) LIBHB.dll.libs += $(CONTRIB.build/)lib/libpthreadGC2.a else LIBHB.GCC.l += pthreadGC2 diff --git a/libhb/ports.c b/libhb/ports.c index bb7c235a2..d519f593c 100644 --- a/libhb/ports.c +++ b/libhb/ports.c @@ -697,7 +697,11 @@ static uint64_t hb_thread_to_integer( const hb_thread_t* t ) #if defined( SYS_CYGWIN ) return (uint64_t)t->thread; #elif defined( _WIN32 ) || defined( __MINGW32__ ) + #if defined(PTW32_STATIC_LIB) return (uint64_t)(ptrdiff_t)t->thread.p; + #else + return (uint64_t)t->thread; + #endif #elif defined( SYS_DARWIN ) return (unsigned long)t->thread; #else diff --git a/make/configure.py b/make/configure.py index 1bac0874f..e1e8e4d66 100644 --- a/make/configure.py +++ b/make/configure.py @@ -1541,7 +1541,8 @@ int main () return 0; } """ - pthread = LDProbe( 'static pthread', '%s -static' % Tools.gcc.pathname, '-lpthreadGC2', pthread_test ) + pthreadGC2 = LDProbe( 'static pthread', '%s -static' % Tools.gcc.pathname, '-lpthreadGC2', pthread_test ) + pthread = LDProbe( 'static pthread', '%s -static' % Tools.gcc.pathname, '-lpthread', pthread_test ) pthread.run() bz2_test = """ @@ -1733,6 +1734,8 @@ int main() doc.add( 'HAS.dlfcn', 1 ) if not pthread.fail: doc.add( 'HAS.pthread', 1 ) + if not pthreadGC2.fail: + doc.add( 'HAS.pthreadGC2', 1 ) if not bz2.fail: doc.add( 'HAS.bz2', 1 ) if not libz.fail: diff --git a/make/include/main.defs b/make/include/main.defs index 4aa659c6e..56db40c4d 100644 --- a/make/include/main.defs +++ b/make/include/main.defs @@ -69,9 +69,11 @@ MODULES += contrib/libbluray ifneq (,$(filter $(BUILD.system),mingw)) ifneq ($(HAS.pthread),1) +ifneq ($(HAS.pthreadGC2),1) MODULES += contrib/pthreadw32 endif endif +endif ifeq (1,$(FEATURE.qsv)) MODULES += contrib/libmfx diff --git a/test/module.defs b/test/module.defs index 6f9904852..1f794e93a 100644 --- a/test/module.defs +++ b/test/module.defs @@ -60,7 +60,12 @@ endif ifeq (1,$(FEATURE.hwd)) TEST.GCC.D += USE_HWD endif - TEST.GCC.l += pthreadGC2 iconv ws2_32 regex +ifeq (1,$(HAS.pthread)) + TEST.GCC.l += pthread +else + TEST.GCC.l += pthreadGC2 +endif + TEST.GCC.l += iconv ws2_32 regex TEST.GCC.D += PTW32_STATIC_LIB TEST.GCC.args.extra.exe++ += -static endif # (1-mingw,$(BUILD.cross)-$(BUILD.system)) -- 2.40.0