From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.lisp.guile.bugs Subject: bug#10474: Building guile 2.x under mingw + msys Date: Thu, 02 Feb 2012 19:34:49 +0200 Message-ID: <83ehudp29y.fsf@gnu.org> References: <87pqerdxq4.fsf@pobox.com> <83ehuy698u.fsf@gnu.org> <8362ga5h7h.fsf@gnu.org> <87r4ywpnv0.fsf@gnu.org> <83r4yw49u6.fsf@gnu.org> <87y5smnj86.fsf@pobox.com> Reply-To: Eli Zaretskii NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: QUOTED-PRINTABLE X-Trace: dough.gmane.org 1328204266 18878 80.91.229.3 (2 Feb 2012 17:37:46 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 2 Feb 2012 17:37:46 +0000 (UTC) Cc: ludo@gnu.org, 10474@debbugs.gnu.org, commander.sirow@googlemail.com To: Andy Wingo Original-X-From: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Thu Feb 02 18:37:44 2012 Return-path: Envelope-to: guile-bugs@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Rt0bQ-0005xH-6a for guile-bugs@m.gmane.org; Thu, 02 Feb 2012 18:37:44 +0100 Original-Received: from localhost ([::1]:53574 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rt0bP-0002aH-3m for guile-bugs@m.gmane.org; Thu, 02 Feb 2012 12:37:43 -0500 Original-Received: from eggs.gnu.org ([140.186.70.92]:38458) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rt0bL-0002ZY-L2 for bug-guile@gnu.org; Thu, 02 Feb 2012 12:37:41 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Rt0bG-0005UU-Oe for bug-guile@gnu.org; Thu, 02 Feb 2012 12:37:39 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:47487) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rt0bG-0005UP-Io for bug-guile@gnu.org; Thu, 02 Feb 2012 12:37:34 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1Rt0bi-00028m-96 for bug-guile@gnu.org; Thu, 02 Feb 2012 12:38:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-guile@gnu.org Resent-Date: Thu, 02 Feb 2012 17:38:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 10474 X-GNU-PR-Package: guile X-GNU-PR-Keywords: Original-Received: via spool by 10474-submit@debbugs.gnu.org id=B10474.13282042448087 (code B ref 10474); Thu, 02 Feb 2012 17:38:02 +0000 Original-Received: (at 10474) by debbugs.gnu.org; 2 Feb 2012 17:37:24 +0000 Original-Received: from localhost ([127.0.0.1]:51109 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Rt0b5-00026N-FC for submit@debbugs.gnu.org; Thu, 02 Feb 2012 12:37:24 -0500 Original-Received: from mtaout22.012.net.il ([80.179.55.172]:56677) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Rt0b2-000268-Kq for 10474@debbugs.gnu.org; Thu, 02 Feb 2012 12:37:22 -0500 Original-Received: from conversion-daemon.a-mtaout22.012.net.il by a-mtaout22.012.net.il (HyperSendmail v2007.08) id <0LYS005000URRI00@a-mtaout22.012.net.il> for 10474@debbugs.gnu.org; Thu, 02 Feb 2012 19:36:46 +0200 (IST) Original-Received: from HOME-C4E4A596F7 ([77.124.37.111]) by a-mtaout22.012.net.il (HyperSendmail v2007.08) with ESMTPA id <0LYS004590X9HBD0@a-mtaout22.012.net.il>; Thu, 02 Feb 2012 19:36:46 +0200 (IST) In-reply-to: <87y5smnj86.fsf@pobox.com> X-012-Sender: halo1@inter.net.il X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 140.186.70.43 X-BeenThere: bug-guile@gnu.org List-Id: "Bug reports for GUILE, GNU's Ubiquitous Extension Language" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Original-Sender: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.bugs:6165 Archived-At: > From: Andy Wingo > Cc: ludo@gnu.org (Ludovic Court=C3=A8s), 10474@debbugs.gnu.org, > commander.sirow@googlemail.com > Date: Thu, 02 Feb 2012 01:59:21 +0100 >=20 > I will assume that the canonicalize_file_name issues will get resol= ved > eventually in gnulib, once your assignment completes. I will go > through the rest of the issues. As promised, the diffs that I suggest to install to take care of the problems I bumped into are at the end of this message. For your convenience, I grouped the changes into several related groups, in case you'd like to make them separate commits. Each group is preceded by a short description (a candidate for a commit log message) and ChangeLog entries for the changes. In addition to the diffs, there are a few other changes for which I don't show my changes, because they were ad-hoc and not very clean. Instead, I describe what I think should be the "right" solutions for them: . lib/canonicalize-lgpl.c -- does not support Windows absolute file names. Will be fixed in gnulib. . libguile/dynl.c -- lacks setenv. Gnulib's setenv should be used. . libguile/expand.c -- Defines CONST and VOID. Should define SCM_CONST and SCM_VOID (or some other, less ubiquitous, symbols) instead. . libguile/fports.c -- Doesn't implement fport_input_waiting when neither poll nor select nor FIONREAD are available, without which interactive guile won't start. Should use the gnulib select module. . libguile/socket.c -- Lacks implementation of `times' for MS-Windows, without which guile.exe aborts during startup. Should use the gnulib times module. . module/ice-9/boot-9.scm -- absolute-path? does not support Windows file names with drive letters. Windows absolute file names match the regex "\([a-zA-Z]:\)?[\\/]". I don't know Scheme well enough to write this in a clean way, sorry... Here are the diffs: =09Fix startup of guile.exe on MS-Windows. =09* module/system/base/compile.scm (call-with-output-file/atomic): =09Call close-port before deleting the temporary file name, otherwise =09deletion fails on MS-Windows (cannot delete a file that is still =09open). =09* libguile/load.c (scm_init_load_path) [__MINGW32__]: Convert =09backslashes to forward slashes in values of GUILE_LOAD_PATH and =09GUILE_LOAD_COMPILED_PATH. --- module/system/base/compile.scm~0=092011-10-08 01:49:48.000000000 = +0200 +++ module/system/base/compile.scm=092012-01-19 16:49:26.528084600 +0= 200 @@ -61,6 +61,7 @@ (close-port tmp) (rename-file template filename)) (lambda args +=09 (close-port tmp) (delete-file template))))))) =20 (define (ensure-language x) --- libguile/load.c~0=092011-10-08 01:49:48.000000000 +0200 +++ libguile/load.c=092012-01-17 16:47:19.325381400 +0200 @@ -310,10 +309,36 @@ scm_init_load_path () } =20 env =3D getenv ("GUILE_LOAD_PATH"); +#ifdef __MINGW32__ + if (env) + { + char *p =3D env; + + while (*p) +=09{ +=09 if (*p =3D=3D '\\') +=09 *p =3D '/'; +=09 p++; +=09} + } +#endif if (env) path =3D scm_parse_path (scm_from_locale_string (env), path); =20 env =3D getenv ("GUILE_LOAD_COMPILED_PATH"); +#ifdef __MINGW32__ + if (env) + { + char *p =3D env; + + while (*p) +=09{ +=09 if (*p =3D=3D '\\') +=09 *p =3D '/'; +=09 p++; +=09} + } +#endif if (env) cpath =3D scm_parse_path (scm_from_locale_string (env), cpath); =20 =09Avoid compiler warnings on MS-Windows. =09* libguile/print.c (display_string_using_iconv): Cast 2nd arg of =09`iconv' to `const char **', to avoid compiler warnings. =09* libguile/ports.c (get_iconv_codepoint): Cast 2nd arg of `iconv' =09to `const char **', to avoid compiler warnings. =09* libguile/deprecation.c (vsnprintf) [__MINGW32__]: Don't redefine =09if already defined. Avoids compiler warnings. =09* libguile/filesys.c (mkdir) [__MINGW32__]: Don't redefine if =09GNULIB_defined_rpl_mkdir is defined, meaning that the gnulib =09replacement is being used. =09(fchmod) [__MINGW32__]: Define to zero, to avoid gratuitous failur= es =09of many file operations on MS-Windows. --- libguile/print.c~0=092011-10-08 01:49:48.000000000 +0200 +++ libguile/print.c=092012-01-15 15:10:51.450848400 +0200 @@ -899,7 +899,7 @@ display_string_using_iconv (const void * output =3D encoded_output; output_left =3D sizeof (encoded_output); =20 - done =3D iconv (pt->output_cd, &input, &input_left, + done =3D iconv (pt->output_cd, (const char **)&input, &input_l= eft, =09=09 &output, &output_left); =20 output_len =3D sizeof (encoded_output) - output_left; --- libguile/ports.c~0=092011-10-08 01:49:48.000000000 +0200 +++ libguile/ports.c=092012-01-15 15:11:11.856706600 +0200 @@ -1305,7 +1305,7 @@ get_iconv_codepoint (SCM port, scm_t_wch input_left =3D bytes_consumed + 1; output_left =3D sizeof (utf8_buf); =20 - done =3D iconv (pt->input_cd, &input, &input_left, + done =3D iconv (pt->input_cd, (const char **)&input, &input_le= ft, =09=09 &output, &output_left); if (done =3D=3D (size_t) -1) =09{ --- libguile/deprecation.c~0=092011-07-07 02:49:59.000000000 +0300 +++ libguile/deprecation.c=092012-01-15 14:48:55.966092400 +0200 @@ -36,7 +36,7 @@ =20 =20 /* Windows defines. */ -#ifdef __MINGW32__ +#if defined (__MINGW32__) && !defined (vsnprintf) #define vsnprintf _vsnprintf #endif =20 --- libguile/filesys.c~0=092011-10-08 01:49:48.000000000 +0200 +++ libguile/filesys.c=092012-01-18 08:29:49.629722000 +0200 @@ -116,11 +116,24 @@ =20 /* Some more definitions for the native Windows port. */ #ifdef __MINGW32__ -# define mkdir(path, mode) mkdir (path) +/* When configured to use the gnulib replacement, don't redefine + mkdir, as it is already redirected to the replacement, see + lib/sys/stat.h. */ +# if !GNULIB_defined_rpl_mkdir +# define mkdir(path, mode) mkdir (path) +# endif # define fsync(fd) _commit (fd) -# define fchmod(fd, mode) (-1) +# define fchmod(fd, mode) (0) #endif /* __MINGW32__ */ =20 +#ifndef O_BINARY +# ifdef _O_BINARY +# define O_BINARY _O_BINARY +# else +# define O_BINARY 0 +# endif +#endif + /* dirfd() returns the file descriptor underlying a "DIR*" directory= stream. Found on MacOS X for instance. The following definition is for S= olaris 10, it's probably not right elsewhere, but that's ok, it shouldn'= t be =20 =09Read and write *.go files and copy files in binary mode on =09MS-Windows. =09* libguile/objcodes.c (O_BINARY): Define on all platforms. =09(make_objcode_from_file): Zero out errno before calling full_read, =09to make sure the value after the call reflects errors inside =09full_read. =09(scm_load_objcode): Open objcode files in binary mode, so that =09*.go files are read verbatim on MS-Windows. =09* libguile/mkstemp.c (O_BINARY): Define for all platforms. =09(mkstemp): Open the temporary file in binary mode, so that =09compiled *.go files are written verbatim on MS-Windows. =09* libguile/filesys.c (O_BINARY): Define for all platforms. =09(scm_copy_file): Use O_BINARY in the call to open_or_open64. --- libguile/objcodes.c~0=092011-10-08 01:49:48.000000000 +0200 +++ libguile/objcodes.c=092012-01-18 08:47:46.857202700 +0200 @@ -39,6 +39,14 @@ #include "programs.h" #include "objcodes.h" =20 +#ifndef O_BINARY +# ifdef _O_BINARY +# define O_BINARY _O_BINARY +# else +# define O_BINARY 0 +# endif +#endif + /* SCM_OBJCODE_COOKIE, defined in _scm.h, is a magic value prepended to objcode on disk but not in memory. =20 @@ -169,9 +177,10 @@ make_objcode_from_file (int fd) { SCM bv =3D scm_c_make_bytevector (st.st_size - sizeof cookie); =20 + errno =3D 0; if (full_read (fd, cookie, sizeof cookie) !=3D sizeof cookie - || full_read (fd, SCM_BYTEVECTOR_CONTENTS (bv), - SCM_BYTEVECTOR_LENGTH (bv)) !=3D SCM_BYTEVECTO= R_LENGTH (bv)) +=09|| full_read (fd, SCM_BYTEVECTOR_CONTENTS (bv), +=09=09 SCM_BYTEVECTOR_LENGTH (bv)) !=3D SCM_BYTEVECTOR_LENGTH (= bv)) { int errno_save =3D errno; (void) close (fd); @@ -295,7 +304,7 @@ SCM_DEFINE (scm_load_objcode, "load-objc SCM_VALIDATE_STRING (1, file); =20 c_file =3D scm_to_locale_string (file); - fd =3D open (c_file, O_RDONLY | O_CLOEXEC); + fd =3D open (c_file, O_RDONLY | O_BINARY | O_CLOEXEC); free (c_file); if (fd < 0) SCM_SYSERROR; =20 --- libguile/mkstemp.c~0=092010-12-08 11:07:02.000000000 +0200 +++ libguile/mkstemp.c=092012-01-18 08:46:36.123280400 +0200 @@ -43,6 +43,14 @@ #include #endif =20 +#ifndef O_BINARY +# ifdef _O_BINARY +# define O_BINARY _O_BINARY +# else +# define O_BINARY 0 +# endif +#endif + #ifndef TMP_MAX #define TMP_MAX 16384 #endif @@ -112,7 +120,7 @@ mkstemp (template) v /=3D 62; XXXXXX[5] =3D letters[v % 62]; =20 - fd =3D open (template, O_RDWR|O_CREAT|O_EXCL, 0600); + fd =3D open (template, O_RDWR|O_BINARY|O_CREAT|O_EXCL, 0600); if (fd >=3D 0) =09/* The file does not exist. */ =09return fd; --- libguile/filesys.c~0=092011-10-08 01:49:48.000000000 +0200 +++ libguile/filesys.c=092012-01-18 08:29:49.629722000 +0200 @@ -1118,7 +1131,7 @@ SCM_DEFINE (scm_copy_file, "copy-file",=20 c_newfile =3D scm_to_locale_string (newfile); scm_dynwind_free (c_newfile); =20 - oldfd =3D open_or_open64 (c_oldfile, O_RDONLY); + oldfd =3D open_or_open64 (c_oldfile, O_RDONLY | O_BINARY); if (oldfd =3D=3D -1) SCM_SYSERROR; =20 @@ -1131,7 +1144,7 @@ SCM_DEFINE (scm_copy_file, "copy-file",=20 goto err_close_oldfd; =20 /* use POSIX flags instead of 07777?. */ - newfd =3D open_or_open64 (c_newfile, O_WRONLY | O_CREAT | O_TRUNC, + newfd =3D open_or_open64 (c_newfile, O_WRONLY | O_BINARY | O_CREAT= | O_TRUNC, oldstat.st_mode & 07777); if (newfd =3D=3D -1) { =09Fix compilation warnings and errors on MS-Windows when =09compiling network-related code due to missing macros and =09prototypes. =09* libguile/net_db.c [HAVE_WINSOCK2_H]: Add !GNULIB_TEST_SOCKET to =09the condition, to include sys/socket.h and netdb.h when gnulib's =09socket module is being used. Fixes compiler warnings and errors =09on MS-Windows. =09* libguile/socket.c: Likewise. --- libguile/net_db.c~0=092011-07-07 02:49:59.000000000 +0300 +++ libguile/net_db.c=092012-01-15 16:22:56.366898100 +0200 @@ -49,8 +49,11 @@ =20 #include =20 -#ifdef HAVE_WINSOCK2_H +#if HAVE_WINSOCK2_H && !GNULIB_TEST_SOCKET #include +# if HAVE_WS2TCPIP_H +# include +# endif #else #include #include --- libguile/socket.c~0=092011-10-08 01:49:48.000000000 +0200 +++ libguile/socket.c=092012-01-15 16:40:46.891296700 +0200 @@ -58,7 +58,7 @@ #include #endif #include -#ifdef HAVE_WINSOCK2_H +#if HAVE_WINSOCK2_H && !GNULIB_TEST_SOCKET #include #else #include