From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Jan Nieuwenhuizen Newsgroups: gmane.lisp.guile.devel Subject: cross building 1.9.14 for mingw Date: Sat, 29 Jan 2011 20:41:21 +0100 Organization: www.AvatarAcademy.nl Message-ID: <1296330082.8111.371.camel@vuurvlieg> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-UsBy14h1D11TNWdzEWf8" X-Trace: dough.gmane.org 1296330130 8801 80.91.229.12 (29 Jan 2011 19:42:10 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sat, 29 Jan 2011 19:42:10 +0000 (UTC) To: guile-devel@gnu.org Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Sat Jan 29 20:42:04 2011 Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1PjGgK-00086Q-9d for guile-devel@m.gmane.org; Sat, 29 Jan 2011 20:42:02 +0100 Original-Received: from localhost ([127.0.0.1]:39124 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PjGgI-0001kK-Qk for guile-devel@m.gmane.org; Sat, 29 Jan 2011 14:41:58 -0500 Original-Received: from [140.186.70.92] (port=44942 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PjGg7-0001i9-Uj for guile-devel@gnu.org; Sat, 29 Jan 2011 14:41:56 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PjGfm-0005RQ-JA for guile-devel@gnu.org; Sat, 29 Jan 2011 14:41:47 -0500 Original-Received: from smtp-vbr19.xs4all.nl ([194.109.24.39]:4990) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PjGfm-0005Pe-87 for guile-devel@gnu.org; Sat, 29 Jan 2011 14:41:26 -0500 Original-Received: from [192.168.1.112] (peder.onsbrabantnet.nl [88.159.206.46] (may be forged)) (authenticated bits=0) by smtp-vbr19.xs4all.nl (8.13.8/8.13.8) with ESMTP id p0TJfNSU018929; Sat, 29 Jan 2011 20:41:23 +0100 (CET) (envelope-from janneke-list@xs4all.nl) X-Mailer: Evolution 2.30.3 X-Virus-Scanned: by XS4ALL Virus Scanner X-detected-operating-system: by eggs.gnu.org: FreeBSD 4.6-4.9 X-Received-From: 194.109.24.39 X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.devel:11407 Archived-At: --=-UsBy14h1D11TNWdzEWf8 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-MIME-Autoconverted: from 8bit to quoted-printable by smtp-vbr19.xs4all.nl id p0TJfNSU018929 Hi, To get guile-1.9.14 cross built for mingw, I re-updated gnulib to include socket-related modules (starting with accept here) gnulib-tool --import --dir=3D. --lib=3Dlibgnu --source-base=3Dlib --m= 4-base=3Dm4 --doc-base=3Ddoc --tests-base=3Dtests --aux-dir=3Dbuild-aux -= -libtool --macro-prefix=3Dgl --no-vc-files alignof alloca-opt announce-ge= n autobuild byteswap canonicalize-lgpl duplocale environ extensions flock= fpieee full-read full-write func gendocs getaddrinfo git-version-gen git= log-to-changelog gnu-web-doc-update gnupload havelib iconv_open-utf inet_= ntop inet_pton isinf isnan lib-symbol-versions lib-symbol-visibility libu= nistring locale maintainer-makefile nproc putenv stat-time stdlib strcase= strftime striconveh string sys_stat verify version-etc-fsf vsnprintf war= nings accept bind close connect getpeername getsockname getsockopt li= sten malloc malloca recv recv recvfrom send sendto setsockopt shutdown so= cket sockets and used the attached patches. Without this update you get things like .libs/socket.o:socket.c:(.text+0xc72): undefined reference to `_accep= t_used_without_requesting_gnulib_module_accept' when building for mingw. The full cross build recipe is in GUB git://github.com/janneke/gub.git in the guile-1.9 branch https://github.com/janneke/gub/blob/guile-1.9/gub/specs/guile.py Of course, when cross building someone should verify that build and host have the same endianess and word size. This means that for cross building on an x86_64 box, we'd probably need to build a 32-bits guile too. Another small gripe, this handy thing in configure.ac m4_esyscmd([build-aux/git-version-gen\ .tarball-version\ 's/^release_\([0-9][0-9]*\)-\([0-9][0-9]*\)-\([0-9][0-9]*\)/v\1.\= 2\.\3/g']), makes it tricky to patch configure.ac when working from a tarball release, I got=20 $ autoreconf Usage: build-aux/git-version-gen $srcdir/.tarball-version configure.ac:39: error: AC_INIT should be called with package and ver= sion arguments /home/janneke/vc/gub/target/tools/root/usr/share/aclocal-1.10/init.m4= :26: AM_INIT_AUTOMAKE is expanded from... configure.ac:39: the top level autom4te: /home/janneke/vc/gub/target/tools/root/usr/bin/m4 failed wi= th exit status: 1 esp. because the README talks about ./autogen.sh which does not exist. Greetings, Jan. --=20 Jan Nieuwenhuizen | GNU LilyPond http://lilypond.org Freelance IT http://JoyofSource.com | Avatar=C2=AE http://AvatarAcademy.= nl =20 --=-UsBy14h1D11TNWdzEWf8 Content-Disposition: attachment; filename="0001-Add-dynamic-relocation-support-default-off.patch" Content-Type: text/x-patch; name="0001-Add-dynamic-relocation-support-default-off.patch"; charset="UTF-8" Content-Transfer-Encoding: 7bit >From ed1507425da819363cc6592ee033076838c82051 Mon Sep 17 00:00:00 2001 From: Jan Nieuwenhuizen Date: Sat, 29 Jan 2011 17:31:17 +0100 Subject: [PATCH 1/4] Add dynamic relocation support, default off. 2005-06-08 Jan Nieuwenhuizen * configure.in: Add --enable-relocation option. Default off. libguile/ ChangeLog 2005-06-09 Jan Nieuwenhuizen Experimental relocation patch. * load.c (scm_init_argv0_relocation)[ARGV0_RELOCATION]: New function. (scm_init_load_path)[ARGV0_RELOCATION]: Use it. * load.c (scm_c_argv0_relocation)[ARGV0_RELOCATION]: * guile.c (main)[ARGV0_RELOCATION]: Use it to append from executable location derived scm library directory. [__MINGW32__|__CYGWIN__]: Append directory of executable to PATH. --- configure.ac | 12 +++++++++++ libguile/guile.c | 3 ++ libguile/load.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ libguile/load.h | 4 +++ 4 files changed, 77 insertions(+), 0 deletions(-) diff --git a/configure.ac b/configure.ac index 5c70aa8..5fa6cf4 100644 --- a/configure.ac +++ b/configure.ac @@ -1452,6 +1452,18 @@ GUILE_THREAD_LOCAL_STORAGE fi # with_threads=pthreads +## Dynamic relocation, based on argv[0]. +reloc_p=no +AC_ARG_ENABLE(relocation, + [ --enable-relocation compile with dynamic relocation. Default: off], + [reloc_p=$enableval]) + +if test "$reloc_p" = "yes"; then + AC_DEFINE([ARGV0_RELOCATION], [1], [Dynamic relocation]) + AC_DEFINE_UNQUOTED([PATH_SEPARATOR], "$PATH_SEPARATOR", [Path separator]) + AC_DEFINE_UNQUOTED([GUILE_EFFECTIVE_VERSION], "$GUILE_EFFECTIVE_VERSION", [GUILE_EFFECTIVE_VERSION]) +fi # $reloc_b + ## Cross building if test "$cross_compiling" = "yes"; then AC_MSG_CHECKING(cc for build) diff --git a/libguile/guile.c b/libguile/guile.c index 6da547b..896adc4 100644 --- a/libguile/guile.c +++ b/libguile/guile.c @@ -67,6 +67,9 @@ inner_main (void *closure SCM_UNUSED, int argc, char **argv) int main (int argc, char **argv) { +#if ARGV0_RELOCATION + scm_c_argv0_relocation (argv[0]); +#endif /* ARGV0_RELOCATION */ scm_boot_guile (argc, argv, inner_main, 0); return 0; /* never reached */ } diff --git a/libguile/load.c b/libguile/load.c index cbf9dc0..c887810 100644 --- a/libguile/load.c +++ b/libguile/load.c @@ -234,6 +234,59 @@ SCM_DEFINE (scm_parse_path, "parse-path", 1, 1, 0, } #undef FUNC_NAME +#if ARGV0_RELOCATION +#include "filesys.h" +#if defined (__CYGWIN__) || defined (__MINGW32__) +#include "posix.h" +#endif + +char const *global_argv0 = 0; + +void +scm_c_argv0_relocation (char const *argv0) +{ + global_argv0 = argv0; +} + +SCM +scm_init_argv0_relocation (char const* argv0) +{ + SCM bindir = scm_dirname (scm_from_locale_string (argv0)); + SCM prefix = scm_dirname (bindir); + SCM datadir = scm_string_append (scm_list_2 (prefix, + scm_from_locale_string ("/share/guile/" GUILE_EFFECTIVE_VERSION))); + SCM libdir = scm_string_append (scm_list_2 (prefix, + scm_from_locale_string ("/lib"))); + +#if 0 /* def SYSV */ + { + SCM path; + char *env = getenv ("LD_LIBRARY_PATH"); + if (env) + path = scm_string_append (scm_list_3 (scm_from_locale_string (env), + scm_from_locale_string (PATH_SEPARATOR), + datadir)); + else + path = libdir; + scm_putenv (scm_string_append (scm_list_2 (scm_from_locale_string ("LD_LIBRARY_PATH="), path))); + } +#elif defined (__CYGWIN__) || defined (__MINGW32__) + { + SCM path; + char *env = getenv ("PATH"); + if (env) + path = scm_string_append (scm_list_3 (scm_from_locale_string (env), + scm_from_locale_string (PATH_SEPARATOR), + bindir)); + else + path = bindir; + scm_putenv (scm_string_append (scm_list_2 (scm_from_locale_string ("PATH="), path))); + } +#endif /* __CYGWIN__ || __MINGW32__ */ + + return scm_list_1 (datadir); +} +#endif /* ARGV0_RELOCATION */ /* Initialize the global variable %load-path, given the value of the SCM_SITE_DIR and SCM_LIBRARY_DIR preprocessor symbols and the @@ -304,6 +357,11 @@ scm_init_load_path () if (env) cpath = scm_parse_path (scm_from_locale_string (env), cpath); +#if ARGV0_RELOCATION + if (global_argv0) + path = scm_append (scm_list_2 (path, scm_init_argv0_relocation (global_argv0))); +#endif /* __CYGWIN__ || __MINGW32__ */ + *scm_loc_load_path = path; *scm_loc_load_compiled_path = cpath; } diff --git a/libguile/load.h b/libguile/load.h index d1afefb..d0f7543 100644 --- a/libguile/load.h +++ b/libguile/load.h @@ -27,6 +27,10 @@ SCM_API SCM scm_parse_path (SCM path, SCM tail); +#if ARGV0_RELOCATION +SCM_API void scm_c_argv0_relocation (char const *argv0); +SCM_API SCM scm_init_argv0_relocation (char const* argv0); +#endif SCM_API SCM scm_primitive_load (SCM filename); SCM_API SCM scm_c_primitive_load (const char *filename); SCM_API SCM scm_sys_package_data_dir (void); -- 1.7.1 --=-UsBy14h1D11TNWdzEWf8 Content-Disposition: attachment; filename*0=0002-Use-AC_CHECK_LIB-rather-than-AC_LIB_HAVE_LINKFLAGS.-.pat; filename*1=ch Content-Type: text/x-patch; name="0002-Use-AC_CHECK_LIB-rather-than-AC_LIB_HAVE_LINKFLAGS.-.patch"; charset="UTF-8" Content-Transfer-Encoding: 7bit >From 4aeb4bb48423d87001b598030afed0a2dc03e747 Mon Sep 17 00:00:00 2001 From: Jan Nieuwenhuizen Date: Sat, 29 Jan 2011 19:42:46 +0100 Subject: [PATCH 2/4] Use AC_CHECK_LIB rather than AC_LIB_HAVE_LINKFLAGS. Fixes cross configuring. AC_LIB_HAVE_LINKFLAGS blondly looks in $prefix etc. for libraries. Not only is that unnecessary, it also breaks cross building. Here's what config.log says: configure:33053: i686-mingw32-gcc -mms-bitfields -std=gnu99 -o conftest.exe -O2 -DHAVE_CONFIG_H=1 -I/home/janneke/vc/gub/target/mingw/build/guile-1.9.14 -I/home/janneke/vc/gub/target/mingw/root/usr/include -L/home/janneke/vc/gub/target/mingw/root/usr/lib -L/home/janneke/vc/gub/target/mingw/root/usr/bin -L/home/janneke/vc/gub/target/mingw/root/usr/lib/w32api conftest.c /usr/lib/libltdl.a /usr/lib/libdl.a >&5 /tmp/cc5v8vq5.o:conftest.c:(.text+0x1e): undefined reference to `_lt_dlopenext' note that using -lltdl -ldl instead of /usr/lib/libltdl.a /usr/lib/libdl.la works fine. --- configure.ac | 11 ++--------- 1 files changed, 2 insertions(+), 9 deletions(-) diff --git a/configure.ac b/configure.ac index 5fa6cf4..0684e6b 100644 --- a/configure.ac +++ b/configure.ac @@ -76,11 +76,7 @@ AC_LIBTOOL_DLOPEN AC_PROG_LIBTOOL dnl Check for libltdl. -AC_LIB_HAVE_LINKFLAGS([ltdl], [], [#include ], - [lt_dlopenext ("foo");]) -if test "x$HAVE_LIBLTDL" != "xyes"; then - AC_MSG_ERROR([GNU libltdl (Libtool) not found, see README.]) -fi +AC_CHECK_LIB(ltdl, lt_dlopenext, [HAVE_LIBLTDL=yes AC_SUBST(HAVE_LIBLTDL) LTLIBLTDL="-lltdl" AC_SUBST(LTLIBLTDL)]) AC_CHECK_PROG(have_makeinfo, makeinfo, yes, no) AM_CONDITIONAL(HAVE_MAKEINFO, test "$have_makeinfo" = yes) @@ -854,10 +850,7 @@ fi dnl GMP tests -AC_LIB_HAVE_LINKFLAGS([gmp], - [], - [#include ], - [mpz_import (0, 0, 0, 0, 0, 0, 0);]) +AC_CHECK_LIB(gmp, main, [HAVE_LIBGMP=yes AC_SUBST(HAVE_LIBGMP) LTLIBGMP="-lgmp" AC_SUBST(LTLIBGMP)]) if test "x$HAVE_LIBGMP" != "xyes"; then AC_MSG_ERROR([GNU MP 4.1 or greater not found, see README]) -- 1.7.1 --=-UsBy14h1D11TNWdzEWf8 Content-Disposition: attachment; filename*0=0003-When-cross-building-run-GUILE_FOR_BUILD-instead-of-j.pat; filename*1=ch Content-Type: text/x-patch; name="0003-When-cross-building-run-GUILE_FOR_BUILD-instead-of-j.patch"; charset="UTF-8" Content-Transfer-Encoding: 7bit >From 90631baf616303e1a8983b3b1eca101f5c5ac0ac Mon Sep 17 00:00:00 2001 From: Jan Nieuwenhuizen Date: Sat, 29 Jan 2011 19:51:37 +0100 Subject: [PATCH 3/4] When cross building, run GUILE_FOR_BUILD instead of just-built guile. --- meta/guile.in | 6 +++++- 1 files changed, 5 insertions(+), 1 deletions(-) diff --git a/meta/guile.in b/meta/guile.in index d1ae0d4..5125827 100644 --- a/meta/guile.in +++ b/meta/guile.in @@ -45,7 +45,11 @@ XDG_CACHE_HOME=${top_builddir}/cache export XDG_CACHE_HOME # do it -exec ${top_builddir}/meta/uninstalled-env $GUILE "$@" +if test "@cross_compiling@" = "no"; then + exec ${top_builddir}/meta/uninstalled-env $GUILE "$@" +else + exec @GUILE_FOR_BUILD@ "$@" +fi # never reached exit 1 -- 1.7.1 --=-UsBy14h1D11TNWdzEWf8 Content-Disposition: attachment; filename="0004-Mingw-compile-fixes.patch" Content-Type: text/x-patch; name="0004-Mingw-compile-fixes.patch"; charset="UTF-8" Content-Transfer-Encoding: 7bit >From a597cd2edd0ebe3341e435ad08af4450b43beb31 Mon Sep 17 00:00:00 2001 From: Jan Nieuwenhuizen Date: Sat, 29 Jan 2011 19:52:39 +0100 Subject: [PATCH 4/4] Mingw compile fixes. --- libguile/bdw-gc.h | 2 ++ libguile/deprecated.c | 4 ++-- libguile/filesys.c | 2 +- libguile/net_db.c | 3 +++ libguile/ports.h | 1 + libguile/socket.c | 1 + 6 files changed, 10 insertions(+), 3 deletions(-) diff --git a/libguile/bdw-gc.h b/libguile/bdw-gc.h index 3adf99e..09e0662 100644 --- a/libguile/bdw-gc.h +++ b/libguile/bdw-gc.h @@ -30,7 +30,9 @@ allocation. */ # define GC_THREADS 1 +#ifndef __MINGW32__ # define GC_REDIRECT_TO_LOCAL 1 +#endif /* __MINGW32__ */ #endif diff --git a/libguile/deprecated.c b/libguile/deprecated.c index e11d353..12a61f6 100644 --- a/libguile/deprecated.c +++ b/libguile/deprecated.c @@ -1639,7 +1639,7 @@ scm_i_fluidp (SCM x) /* Networking. */ -#ifdef HAVE_NETWORKING +#ifdef HAVE_IPV6 SCM_DEFINE (scm_inet_aton, "inet-aton", 1, 0, 0, (SCM address), @@ -1674,7 +1674,7 @@ SCM_DEFINE (scm_inet_ntoa, "inet-ntoa", 1, 0, 0, } #undef FUNC_NAME -#endif /* HAVE_NETWORKING */ +#endif /* HAVE_IPV6 */ void diff --git a/libguile/filesys.c b/libguile/filesys.c index 68d90d9..d6251a0 100644 --- a/libguile/filesys.c +++ b/libguile/filesys.c @@ -523,7 +523,7 @@ static int fstat_Win32 (int fdes, struct stat *buf) /* Is this a socket ? */ if (getsockopt (fdes, SOL_SOCKET, SO_ERROR, (void *) &error, &optlen) >= 0) { - buf->st_mode = _S_IFSOCK | _S_IREAD | _S_IWRITE | _S_IEXEC; + buf->st_mode = _S_IREAD | _S_IWRITE | _S_IEXEC; buf->st_nlink = 1; buf->st_atime = buf->st_ctime = buf->st_mtime = time (NULL); return 0; diff --git a/libguile/net_db.c b/libguile/net_db.c index 14722d5..a017921 100644 --- a/libguile/net_db.c +++ b/libguile/net_db.c @@ -456,6 +456,7 @@ SCM_DEFINE (scm_setserv, "setserv", 0, 1, 0, SCM_SYMBOL (sym_getaddrinfo_error, "getaddrinfo-error"); +#ifndef __MINGW32__ /* Make sure the `AI_*' flags can be stored as INUMs. */ verify (SCM_I_INUM (SCM_I_MAKINUM (AI_ALL)) == AI_ALL); @@ -745,6 +746,8 @@ SCM_DEFINE (scm_gai_strerror, "gai-strerror", 1, 0, 0, } #undef FUNC_NAME +#endif /* __MINGW32__ */ + /* TODO: Add a getnameinfo(3) wrapper. */ diff --git a/libguile/ports.h b/libguile/ports.h index 36289ef..7408b9b 100644 --- a/libguile/ports.h +++ b/libguile/ports.h @@ -26,6 +26,7 @@ #include "libguile/__scm.h" +#include #include "libguile/print.h" #include "libguile/struct.h" #include "libguile/threads.h" diff --git a/libguile/socket.c b/libguile/socket.c index 9b1618f..301854e 100644 --- a/libguile/socket.c +++ b/libguile/socket.c @@ -40,6 +40,7 @@ #ifdef __MINGW32__ #include "win32-socket.h" +#include #endif #ifdef HAVE_STDINT_H -- 1.7.1 --=-UsBy14h1D11TNWdzEWf8--