[vlc-commits] contrib: pthreads: fix OpenProcess called in mingw-w64 but missing when linking

Steve Lhomme git at videolan.org
Tue Jun 16 15:54:01 CEST 2020


vlc/vlc-3.0 | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Tue Jun 16 15:13:52 2020 +0200| [df81e4f412b87f3705d32e01755852f1d98fbce4] | committer: Steve Lhomme

contrib: pthreads: fix OpenProcess called in mingw-w64 but missing when linking

We should not be calling this code but zvbi fails with this error:

 lld-link: error: undefined symbol: _OpenProcess
>>> referenced by libpthreadGC2.a(pthread.o):(_sched_setscheduler)
>>> referenced by libpthreadGC2.a(pthread.o):(_sched_getscheduler)
1 warning generated.
clang-8: error: linker command failed with exit code 1 (use -v to see invocation)
make[4]: *** [Makefile:18055: libzvbi_plugin.la] Error 1

This is on registry.videolan.org/vlc-debian-llvm-mingw:20181128171234 it doesn't happen
anymore on newer images.

> http://git.videolan.org/gitweb.cgi/vlc/vlc-3.0.git/?a=commit;h=df81e4f412b87f3705d32e01755852f1d98fbce4
---

 contrib/src/pthreads/pthreads-fix-old-mingw.patch | 42 +++++++++++++++++++++++
 contrib/src/pthreads/rules.mak                    |  1 +
 2 files changed, 43 insertions(+)

diff --git a/contrib/src/pthreads/pthreads-fix-old-mingw.patch b/contrib/src/pthreads/pthreads-fix-old-mingw.patch
new file mode 100644
index 0000000000..cf67354a10
--- /dev/null
+++ b/contrib/src/pthreads/pthreads-fix-old-mingw.patch
@@ -0,0 +1,42 @@
+--- pthreads/sched_getscheduler.c.uwpmingw7	2020-06-16 15:09:45.975803600 +0200
++++ pthreads/sched_getscheduler.c	2020-06-16 15:09:54.479850300 +0200
+@@ -52,6 +52,7 @@ sched_getscheduler (pid_t pid)
+
+       if (pid != selfPid)
+ 	{
++#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) || !defined(__MINGW64_VERSION_MAJOR) || __MINGW64_VERSION_MAJOR > 7
+ 	  HANDLE h =
+ 	    OpenProcess (PROCESS_QUERY_INFORMATION, PTW32_FALSE, (DWORD) pid);
+
+@@ -64,6 +65,10 @@ sched_getscheduler (pid_t pid)
+ 	    }
+ 	  else
+ 	    CloseHandle(h);
++#else
++	  errno = EPERM;
++	  return -1;
++#endif
+ 	}
+     }
+
+--- pthreads/sched_setscheduler.c.uwpmingw7	2020-06-16 15:09:43.567989900 +0200
++++ pthreads/sched_setscheduler.c	2020-06-16 15:09:59.727891200 +0200
+@@ -54,6 +54,7 @@ sched_setscheduler (pid_t pid, int polic
+
+       if (pid != selfPid)
+ 	{
++#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) || !defined(__MINGW64_VERSION_MAJOR) || __MINGW64_VERSION_MAJOR > 7
+ 	  HANDLE h =
+ 	    OpenProcess (PROCESS_SET_INFORMATION, PTW32_FALSE, (DWORD) pid);
+
+@@ -66,6 +67,10 @@ sched_setscheduler (pid_t pid, int polic
+ 	    }
+ 	  else
+ 	    CloseHandle(h);
++#else
++	  errno = EPERM;
++	  return -1;
++#endif
+ 	}
+     }
+
diff --git a/contrib/src/pthreads/rules.mak b/contrib/src/pthreads/rules.mak
index a87a924049..723c874fed 100644
--- a/contrib/src/pthreads/rules.mak
+++ b/contrib/src/pthreads/rules.mak
@@ -25,6 +25,7 @@ endif
 	$(APPLY) $(SRC)/pthreads/arm64.patch
 	$(APPLY) $(SRC)/pthreads/pthreads-fix-mode_t.patch
 	$(APPLY) $(SRC)/pthreads/pthread-fix-inline.patch
+	$(APPLY) $(SRC)/pthreads/pthreads-fix-old-mingw.patch
 	$(MOVE)
 
 PTHREADS_W32_CONF := LFLAGS="$(LDFLAGS)" PTW32_FLAGS="$(CFLAGS)"



More information about the vlc-commits mailing list