Subject: bug#22959: Emacs on Windows depends on libwinpthreads

From: Fabrice Popineau <[email-masked]>
Date: Mon, 18 Apr 2016 15:41:59 +0200

2016-04-18 15:06 GMT+02:00 Phillip Lord <[email-masked]>:

> Eli Zaretskii <[email-masked]> writes:
>
> >> From: Fabrice Popineau <[email-masked]>
> >> Date: Sat, 16 Apr 2016 23:48:35 +0200
> >>
> >> At this point, when I build emacs for w64 using msys2,
> >> emacs.exe depends on libwinpthread for only one symbol
> >> which is clock_gettime().
> >> This is called from lib/gettime.c:gettime().
> >
> > This is not supposed to happen.  I don't see this on my system.
> >
> > There's some factor at work here that I cannot figure out: the
> > configure-time test for clock_gettime doesn't try to look for that
> > function in the pthreads library, it only tries the "normal" link
> > without any extra libraries, and if that fails, tries 2 extra
> > libraries: librt and libposix4, none of which I'd expect to see on
> > MS-Windows in a MinGW installation.
>
>
> I did get the same thing at one point.
>
>
> > It could be something peculiar to MinGW64/MSYS2 build.  Are you sure
> > libwinpthread dependency is not a requirement of the MinGW64 GCC port?
>
> This was the cause of the problem for me.
>
>
Add this:

diff --git a/nt/mingw-cfg.site b/nt/mingw-cfg.site
index 05034fe..0063c2b 100644
--- a/nt/mingw-cfg.site
+++ b/nt/mingw-cfg.site
@@ -40,6 +40,12 @@ gl_cv_sys_struct_timespec_in_pthread_h=no
 # Or at all...
 ac_cv_header_pthread_h=no

+# We don't want to check for these functions
+# because they are implemented in libwinpthread.
+ac_cv_search_clock_gettime="none required"
+ac_cv_func_clock_gettime=no
+ac_cv_func_clock_settime=no
+
 # ACL functions are implemented in w32.c
 ac_cv_search_acl_get_file="none required"
 ac_cv_func_acl_get_file=yes

And the dependency towards libwinpthread is gone for MinGW64.

Fabrice