unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
* cross building 1.9.14 for mingw
@ 2011-01-29 19:41 Jan Nieuwenhuizen
  2011-01-29 21:34 ` Ludovic Courtès
                   ` (2 more replies)
  0 siblings, 3 replies; 25+ messages in thread
From: Jan Nieuwenhuizen @ 2011-01-29 19:41 UTC (permalink / raw)
  To: guile-devel

[-- Attachment #1: Type: text/plain, Size: 2534 bytes --]

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=. --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --libtool --macro-prefix=gl --no-vc-files alignof alloca-opt announce-gen autobuild byteswap canonicalize-lgpl duplocale environ extensions flock fpieee full-read full-write func gendocs getaddrinfo git-version-gen gitlog-to-changelog gnu-web-doc-update gnupload havelib iconv_open-utf inet_ntop inet_pton isinf isnan lib-symbol-versions lib-symbol-visibility libunistring locale maintainer-makefile nproc putenv stat-time stdlib strcase strftime striconveh string sys_stat verify version-etc-fsf vsnprintf warnings     accept bind close connect getpeername getsockname getsockopt listen malloc malloca recv recv recvfrom send sendto setsockopt shutdown socket sockets

and used the attached patches.  Without this update you get things
like

    .libs/socket.o:socket.c:(.text+0xc72): undefined reference to `_accept_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 

    $ autoreconf
    Usage: build-aux/git-version-gen $srcdir/.tarball-version
    configure.ac:39: error: AC_INIT should be called with package and version 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 with exit status: 1

esp. because the README talks about ./autogen.sh which does not exist.


Greetings,
Jan.

-- 
Jan Nieuwenhuizen <janneke@gnu.org> | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar®  http://AvatarAcademy.nl  

[-- Attachment #2: 0001-Add-dynamic-relocation-support-default-off.patch --]
[-- Type: text/x-patch, Size: 4967 bytes --]

From ed1507425da819363cc6592ee033076838c82051 Mon Sep 17 00:00:00 2001
From: Jan Nieuwenhuizen <janneke@gnu.org>
Date: Sat, 29 Jan 2011 17:31:17 +0100
Subject: [PATCH 1/4] Add dynamic relocation support, default off.

2005-06-08  Jan Nieuwenhuizen  <janneke@gnu.org>

	* configure.in: Add --enable-relocation option.  Default off.

libguile/ ChangeLog

2005-06-09  Jan Nieuwenhuizen  <janneke@gnu.org>

	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 @@
 
 \f
 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


[-- Attachment #3: 0002-Use-AC_CHECK_LIB-rather-than-AC_LIB_HAVE_LINKFLAGS.-.patch --]
[-- Type: text/x-patch, Size: 2059 bytes --]

From 4aeb4bb48423d87001b598030afed0a2dc03e747 Mon Sep 17 00:00:00 2001
From: Jan Nieuwenhuizen <janneke@gnu.org>
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 <ltdl.h>],
-  [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 <gmp.h>],
-  [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


[-- Attachment #4: 0003-When-cross-building-run-GUILE_FOR_BUILD-instead-of-j.patch --]
[-- Type: text/x-patch, Size: 767 bytes --]

From 90631baf616303e1a8983b3b1eca101f5c5ac0ac Mon Sep 17 00:00:00 2001
From: Jan Nieuwenhuizen <janneke@gnu.org>
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


[-- Attachment #5: 0004-Mingw-compile-fixes.patch --]
[-- Type: text/x-patch, Size: 2895 bytes --]

From a597cd2edd0ebe3341e435ad08af4450b43beb31 Mon Sep 17 00:00:00 2001
From: Jan Nieuwenhuizen <janneke@gnu.org>
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)
 \f
 /* 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 */
 
 \f
 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.  */
 
 \f
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 <unistd.h>
 #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 <netdb.h>
 #endif
 
 #ifdef HAVE_STDINT_H
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 25+ messages in thread

end of thread, other threads:[~2011-03-20  8:56 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-01-29 19:41 cross building 1.9.14 for mingw Jan Nieuwenhuizen
2011-01-29 21:34 ` Ludovic Courtès
2011-01-31 20:16   ` Jan Nieuwenhuizen
2011-01-31 20:44     ` Ludovic Courtès
2011-02-15 10:20   ` Jan Nieuwenhuizen
2011-02-22  8:34     ` Andy Wingo
2011-02-24  9:39       ` Jan Nieuwenhuizen
2011-02-24 10:37         ` Ludovic Courtès
2011-03-04 11:11         ` problems solved by AC_LIB_HAVE_LINKFLAGS [was: cross building 1.9.14 for mingw] Andy Wingo
2011-03-20  8:08           ` Jan Nieuwenhuizen
2011-03-20  8:21             ` Ralf Wildenhues
2011-03-20  8:34               ` Jan Nieuwenhuizen
2011-03-20  8:56                 ` Ralf Wildenhues
2011-01-29 21:39 ` Relocatable installation Ludovic Courtès
2011-01-31 20:26   ` Jan Nieuwenhuizen
2011-01-31 20:50     ` Andy Wingo
2011-01-31 20:55       ` Jan Nieuwenhuizen
2011-01-31 21:30         ` Andy Wingo
2011-01-31 21:49           ` Jan Nieuwenhuizen
2011-01-31 21:00     ` Ludovic Courtès
2011-01-31 21:18       ` Jan Nieuwenhuizen
2011-01-31 22:09         ` Ludovic Courtès
2011-01-31 22:26           ` Jan Nieuwenhuizen
2011-02-14 12:29 ` cross building 1.9.14 for mingw Ludovic Courtès
2011-02-15 10:02   ` Jan Nieuwenhuizen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).