gnucash-on-windows master: Bug 797254 - guile2 fails to build in Windows...

John Ralls jralls at code.gnucash.org
Mon Jun 3 12:35:52 EDT 2019


Updated	 via  https://github.com/Gnucash/gnucash-on-windows/commit/e1ea3478 (commit)
	from  https://github.com/Gnucash/gnucash-on-windows/commit/b4186f16 (commit)



commit e1ea3478e3f24a850f4b1caaf8fa6e1fee42849a
Author: John Ralls <jralls at ceridwen.us>
Date:   Mon Jun 3 09:31:57 2019 -0700

    Bug 797254 - guile2 fails to build in Windows...
    
    time_rz.c:308: undefined reference to `rpl_mktime'
    
    Patch the gnulib part to correctly handle builds where REPLACE_TIMEGM
    is true and REPLACE_MKTIME may or may not be true.
    
    Also switch to building a snapshot from Guile's repo and applying our
    patches via jhbuild instead of using a snapshot of a private repo.

diff --git a/gnucash.modules b/gnucash.modules
index b2d8c0f..0d4e6d1 100644
--- a/gnucash.modules
+++ b/gnucash.modules
@@ -119,8 +119,12 @@
   </autotools>
 
   <autotools id="guile2" autogen-sh="configure" autogenargs="--disable-rpath --enable-networking --enable-nls --enable-posix --enable-regex --with-threads --with-modules --disable-static">
-    <branch repo="sourceforge" module="gnucash/Dependencies/guile-2.2.4.71-28dbc.tar.xz"
-	    version=" 2.2.4.71-28dbc">
+    <branch repo="sourceforge" module="gnucash/Dependencies/guile-2.2.4.68-65d98.tar.xz"
+	    version=" 2.2.4.68-65d98">
+      <patch file="0001-Fix-build-on-MinGW-w64.patch" strip="1"/>
+      <patch file="0002-MinGW-Don-t-break-build-when-including-libguile.h.patch" strip="1"/>
+      <patch file="0003-AC_DEFINE-REPLACE_MKTIME.patch" strip="1"/>
+
     </branch>
     <dependencies>
       <dep package="libunistring"/>
diff --git a/patches/0001-Fix-build-on-MinGW-w64.patch b/patches/0001-Fix-build-on-MinGW-w64.patch
new file mode 100644
index 0000000..b77dd0f
--- /dev/null
+++ b/patches/0001-Fix-build-on-MinGW-w64.patch
@@ -0,0 +1,80 @@
+From 4a78dfc58c82fa87a0d9128c4c9e331cadd20eeb Mon Sep 17 00:00:00 2001
+From: John Ralls <jralls at ceridwen.us>
+Date: Tue, 23 Apr 2019 15:06:48 -0700
+Subject: [PATCH 1/3] Fix build on MinGW-w64
+
+Fixes bug 35405
+
+       * lib/poll.h: MinGW provides struct pollfd in winsock2.h and
+         lib/threads.h includes it so disable declaring it in poll.h and
+         get the declaration from winsock2.h. Otherwise gcc complains that
+         poll() has a different signature between the declaration and
+         definition.
+       * libguile/socket.c: TCP declarations are in winsock.h on Windows.
+       * libguile/timegm.c: MinGW doesn't include mktime so include mktime.c to
+         provide it.
+---
+ lib/poll.in.h     | 5 +++++
+ lib/timegm.c      | 2 ++
+ libguile/socket.c | 6 +++++-
+ 3 files changed, 12 insertions(+), 1 deletion(-)
+
+diff --git a/lib/poll.in.h b/lib/poll.in.h
+index e9b141d8f..3b0a99165 100644
+--- a/lib/poll.in.h
++++ b/lib/poll.in.h
+@@ -40,6 +40,9 @@
+ 
+ 
+ #if !@HAVE_POLL_H@
++# ifdef __MINGW32__
++#  include <winsock2.h>
++# endif
+ 
+ /* fake a poll(2) environment */
+ # define POLLIN      0x0001      /* any readable data available   */
+@@ -55,12 +58,14 @@
+ 
+ # if !GNULIB_defined_poll_types
+ 
++#  ifndef __MINGW32__
+ struct pollfd
+ {
+   int fd;                       /* which file descriptor to poll */
+   short events;                 /* events we are interested in   */
+   short revents;                /* events found on return        */
+ };
++#  endif
+ 
+ typedef unsigned long nfds_t;
+ 
+diff --git a/lib/timegm.c b/lib/timegm.c
+index 168da8ead..35bc67dc1 100644
+--- a/lib/timegm.c
++++ b/lib/timegm.c
+@@ -38,3 +38,5 @@ timegm (struct tm *tmp)
+   tmp->tm_isdst = 0;
+   return __mktime_internal (tmp, __gmtime_r, &gmtime_offset);
+ }
++
++#include "mktime.c"
+diff --git a/libguile/socket.c b/libguile/socket.c
+index 71c17e892..f5371b6c8 100644
+--- a/libguile/socket.c
++++ b/libguile/socket.c
+@@ -40,7 +40,11 @@
+ #include <sys/un.h>
+ #endif
+ #include <netinet/in.h>
+-#include <netinet/tcp.h>
++#ifdef __MINGW32__
++# include <winsock.h>
++#else
++# include <netinet/tcp.h>
++#endif
+ #include <netdb.h>
+ #include <arpa/inet.h>
+ 
+-- 
+2.21.0
+
diff --git a/patches/0002-MinGW-Don-t-break-build-when-including-libguile.h.patch b/patches/0002-MinGW-Don-t-break-build-when-including-libguile.h.patch
new file mode 100644
index 0000000..974028d
--- /dev/null
+++ b/patches/0002-MinGW-Don-t-break-build-when-including-libguile.h.patch
@@ -0,0 +1,28 @@
+From eb6137334bf60be48fdae68cabdb9609cc4bfb21 Mon Sep 17 00:00:00 2001
+From: John Ralls <jralls at ceridwen.us>
+Date: Sun, 26 May 2019 16:35:33 -0700
+Subject: [PATCH 2/3] MinGW: Don't break build when including libguile.h
+
+---
+ libguile/iselect.h | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/libguile/iselect.h b/libguile/iselect.h
+index 945ad14af..c2f42d38b 100644
+--- a/libguile/iselect.h
++++ b/libguile/iselect.h
+@@ -29,7 +29,11 @@
+ /* Needed for FD_SET on some systems.  */
+ #include <sys/types.h>
+ 
++#ifdef __MINGW32__
++#include <winsock2.h>
++#else
+ #include <sys/select.h>
++#endif
+ 
+ SCM_API int scm_std_select (int fds,
+ 			    fd_set *rfds,
+-- 
+2.21.0
+
diff --git a/patches/0003-AC_DEFINE-REPLACE_MKTIME.patch b/patches/0003-AC_DEFINE-REPLACE_MKTIME.patch
new file mode 100644
index 0000000..9cc5763
--- /dev/null
+++ b/patches/0003-AC_DEFINE-REPLACE_MKTIME.patch
@@ -0,0 +1,67 @@
+From 28dbcca3e1e75a709ce780788951e7ca413843b7 Mon Sep 17 00:00:00 2001
+From: John Ralls <jralls at ceridwen.us>
+Date: Mon, 27 May 2019 12:01:29 -0700
+Subject: [PATCH 3/3] AC_DEFINE REPLACE_MKTIME
+
+Using it to control redefinition of mktime() and inclusion of mktime.c
+in  timegm.c.
+
+The former prevents duplicate definitions from mktime.c and the C
+runtime. The latter prevents duplicate definitions when both mktime.c
+and timegm.c are built.
+---
+ lib/mktime.c | 2 ++
+ lib/timegm.c | 2 ++
+ m4/mktime.m4 | 2 ++
+ 3 files changed, 6 insertions(+)
+
+diff --git a/lib/mktime.c b/lib/mktime.c
+index 2efd44a22..588d4d139 100644
+--- a/lib/mktime.c
++++ b/lib/mktime.c
+@@ -462,6 +462,7 @@ __mktime_internal (struct tm *tp,
+ static mktime_offset_t localtime_offset;
+ 
+ /* Convert *TP to a time_t value.  */
++#if REPLACE_MKTIME
+ time_t
+ mktime (struct tm *tp)
+ {
+@@ -476,6 +477,7 @@ mktime (struct tm *tp)
+ 
+   return __mktime_internal (tp, __localtime_r, &localtime_offset);
+ }
++#endif
+ 
+ #ifdef weak_alias
+ weak_alias (mktime, timelocal)
+diff --git a/lib/timegm.c b/lib/timegm.c
+index 35bc67dc1..949f4b7ad 100644
+--- a/lib/timegm.c
++++ b/lib/timegm.c
+@@ -39,4 +39,6 @@ timegm (struct tm *tmp)
+   return __mktime_internal (tmp, __gmtime_r, &gmtime_offset);
+ }
+ 
++#if ! REPLACE_MKTIME
+ #include "mktime.c"
++#endif
+diff --git a/m4/mktime.m4 b/m4/mktime.m4
+index d594ddc58..ec7299f08 100644
+--- a/m4/mktime.m4
++++ b/m4/mktime.m4
+@@ -244,9 +244,11 @@ main ()
+ 
+   if test $gl_cv_func_working_mktime = no; then
+     REPLACE_MKTIME=1
++    AC_DEFINE([REPLACE_MKTIME], [1], [System mktime is defective or missing.])
+   else
+     REPLACE_MKTIME=0
+   fi
++
+ ])
+ 
+ AC_DEFUN([gl_FUNC_MKTIME_INTERNAL], [
+-- 
+2.21.0
+



Summary of changes:
 gnucash.modules                                    |  8 ++-
 patches/0001-Fix-build-on-MinGW-w64.patch          | 80 ++++++++++++++++++++++
 ...n-t-break-build-when-including-libguile.h.patch | 28 ++++++++
 patches/0003-AC_DEFINE-REPLACE_MKTIME.patch        | 67 ++++++++++++++++++
 4 files changed, 181 insertions(+), 2 deletions(-)
 create mode 100644 patches/0001-Fix-build-on-MinGW-w64.patch
 create mode 100644 patches/0002-MinGW-Don-t-break-build-when-including-libguile.h.patch
 create mode 100644 patches/0003-AC_DEFINE-REPLACE_MKTIME.patch



More information about the gnucash-changes mailing list