From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Sylvain Beucler Newsgroups: gmane.lisp.guile.bugs Subject: Re: Cross-compiling with mingw Date: Wed, 28 May 2008 23:00:05 +0200 Message-ID: <20080528210005.GA19203@perso.beuc.net> References: <20080526204344.GA14261@perso.beuc.net> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1212008422 26853 80.91.229.12 (28 May 2008 21:00:22 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 28 May 2008 21:00:22 +0000 (UTC) To: bug-guile@gnu.org Original-X-From: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Wed May 28 23:01:02 2008 Return-path: Envelope-to: guile-bugs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1K1SlZ-0008D7-OE for guile-bugs@m.gmane.org; Wed, 28 May 2008 23:01:02 +0200 Original-Received: from localhost ([127.0.0.1]:44356 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1K1Sko-0003n5-F4 for guile-bugs@m.gmane.org; Wed, 28 May 2008 17:00:14 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1K1Skl-0003mx-5n for bug-guile@gnu.org; Wed, 28 May 2008 17:00:11 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1K1Skj-0003mg-MJ for bug-guile@gnu.org; Wed, 28 May 2008 17:00:10 -0400 Original-Received: from [199.232.76.173] (port=52054 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1K1Skj-0003mV-Bc for bug-guile@gnu.org; Wed, 28 May 2008 17:00:09 -0400 Original-Received: from smtp3-g19.free.fr ([212.27.42.29]:39176) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1K1Ski-0000sU-Rv for bug-guile@gnu.org; Wed, 28 May 2008 17:00:09 -0400 Original-Received: from smtp3-g19.free.fr (localhost.localdomain [127.0.0.1]) by smtp3-g19.free.fr (Postfix) with ESMTP id D3D5B17B5B3 for ; Wed, 28 May 2008 23:00:06 +0200 (CEST) Original-Received: from localhost.localdomain (unknown [82.238.35.175]) by smtp3-g19.free.fr (Postfix) with ESMTP id 846B517B5BB for ; Wed, 28 May 2008 23:00:06 +0200 (CEST) Original-Received: from me by localhost.localdomain with local (Exim 4.69) (envelope-from ) id 1K1Skf-00075j-U9 for bug-guile@gnu.org; Wed, 28 May 2008 23:00:05 +0200 Content-Disposition: inline In-Reply-To: <20080526204344.GA14261@perso.beuc.net> X-Operating-System: GNU/Linux User-Agent: Mutt/1.5.17+20080114 (2008-01-14) X-detected-kernel: by monty-python.gnu.org: Linux 2.6 (newer, 3) X-BeenThere: bug-guile@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Bug reports for GUILE, GNU's Ubiquitous Extension Language" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Errors-To: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.bugs:3880 Archived-At: On Mon, May 26, 2008 at 10:43:44PM +0200, Sylvain Beucler wrote: > Hi, >=20 > I'm tring to cross-compile Guile from GNU/Linux with mingw (so I can > statically build guile in a .exe without having to use that other OS). >=20 > I cross-compiled gmp and libltdl (dependencies). > Now I have a few troubles with guile: >=20 >=20 > Act I) Configuration >=20 > $ CPPFLAGS=3D"-I/usr/local/cross-tools/i386-mingw32msvc/include" \ > LDFLAGS=3D"-L/usr/local/cross-tools/i386-mingw32msvc/lib" \ > ./configure --host=3Di586-mingw32msvc --build=3Di686-pc-linux-gnu > [...] > checking for restartable system calls... configure: error: cannot run t= est program while cross compiling >=20 > The problem apparently lies in configure.in, macro AC_SYS_RESTARTABLE_S= YSCALLS >=20 > Note that the autoconf documentation deprecates this macro: > "These days portable programs [...] should not rely on > `HAVE_RESTARTABLE_SYSCALLS', since nowadays whether a system call is > restartable is a dynamic issue, not a configuration-time issue." >=20 > I commented it out for a start. >=20 >=20 > Act II) Compilation >=20 > $ make > [...] > DLL_EXPORT -DPIC -o .libs/libguile_la-stime.o > cc1: warnings being treated as errors > stime.c:85: warning: =E2=80=98tzname=E2=80=99 redeclared without dllimp= ort attribute: previous dllimport ignored >=20 > I found 2 references to this issue: > - http://cygwin.com/ml/cygwin/2008-01/msg00491.html > =3D> removed tzname > - http://www.nabble.com/getdate-on-mingw:-tzname-problems-td14855896.ht= ml > =3D> use HAVE_DECL_TZNAME instead >=20 > I used the 2nd option: > # if !HAVE_DECL_TZNAME /* For SGI. */ > extern char *tzname[]; /* RS6000 and others reject char **tzname. */ > #endif > #if defined (__MINGW32__) > # define tzname _tzname > #endif >=20 >=20 > Act III) Linking >=20 > i586-mingw32msvc-gcc -I/usr/local/cross-tools/i386-mingw32msvc/include = -g -O2 -Wall -Wmissing-prototypes -Werror .libs/guile.exeS.o -I/usr/local= /cross-tools/i386-mingw32msvc/include -o guile.exe guile-guile.o -Wl,--ex= port-dynamic -L/usr/local/cross-tools/i386-mingw32msvc/lib ./.libs/libgu= ile.a /usr/local/cross-tools/i386-mingw32msvc/lib/libgmp.a -lws2_32 /usr/= local/cross-tools/i386-mingw32msvc/lib/libltdl.dll.a -L/usr/local/cross= -tools/i386-mingw32msvc/lib -L/usr/local/cross-tools/i386-mingw32msvc/lib > guile-guile.o: In function `main': > /usr/src/guile-1.8.5/libguile/guile.c:74: undefined reference to `__imp= __scm_boot_guile' > guile-guile.o: In function `inner_main': > /usr/src/guile-1.8.5/libguile/guile.c:55: undefined reference to `__imp= __gdb_options' > /usr/src/guile-1.8.5/libguile/guile.c:55: undefined reference to `__imp= __gdb_language' > /usr/src/guile-1.8.5/libguile/guile.c:55: undefined reference to `__imp= __gdb_result' > /usr/src/guile-1.8.5/libguile/guile.c:55: undefined reference to `__imp= __gdb_output' > /usr/src/guile-1.8.5/libguile/guile.c:55: undefined reference to `__imp= __gdb_output_length' > /usr/src/guile-1.8.5/libguile/guile.c:55: undefined reference to `__imp= __gdb_maybe_valid_type_p' > /usr/src/guile-1.8.5/libguile/guile.c:55: undefined reference to `__imp= __gdb_read' > /usr/src/guile-1.8.5/libguile/guile.c:55: undefined reference to `__imp= __gdb_eval' > /usr/src/guile-1.8.5/libguile/guile.c:55: undefined reference to `__imp= __gdb_print' > /usr/src/guile-1.8.5/libguile/guile.c:55: undefined reference to `__imp= __gdb_binding' > /usr/src/guile-1.8.5/libguile/guile.c:59: undefined reference to `__imp= __scm_shell' > collect2: ld returned 1 exit status > rm -f .libs/guile.exeS.o > make[3]: *** [guile.exe] Erreur 1 >=20 > Duh! > I'm out of ideas. Help? :) This one is apparently due to guile.c: #ifdef __MINGW32__ # define SCM_IMPORT 1 #endif When the error occured, the build system was apparently using libguile.la statically. In this case, __declspec (dllimport) need not be used, and so SCM_IMPORT need not be defined, so the linker won't use the '__imp__' symbols. ( The goat book uses a slightly more complex technique to detect the use of DLL imports: http://sources.redhat.com/autobook/autobook/autobook_255.html # ---------------------------------------------------------------------- # Win32 objects need to tell the header whether they will be linking # with a dll or static archive in order that everything is imported # to the object in the same way that it was exported from the # archive (extern for static, __declspec(dllimport) for dlls) # ---------------------------------------------------------------------- LIBHELLO_DLL_IMPORT=3D case "$host" in *-*-cygwin* | *-*-mingw* ) if test X"$enable_shared" =3D Xyes; then AC_TRY_LINK_FUNC([libhello_is_dll], [LIBHELLO_DLL_IMPORT=3D-DLIBHELLO_DLL_IMPORT]) fi ;; esac AC_SUBST(LIBHELLO_DLL_IMPORT) and then: #ifdef _WIN32 # ifdef DLL_EXPORT # define HELLO_SCOPE __declspec(dllexport) # else # ifdef LIBHELLO_DLL_IMPORT # define HELLO_SCOPE extern __declspec(dllimport) # endif # endif #endif #ifndef HELLO_SCOPE # define HELLO_SCOPE extern #endif ) With the ./configure line I mentioned, I then ran in to problems linking with gmp. GMP can't be built statically and as a DLL at once ("gmp.h is different for each", it says), so it was only built statically in my environment, and thus guile didn't link. So I added "--disable-shared" to ./configure, added an '#undefine SCM_IMPORT' in guile.c, and it eventually (cross-)compiled entirely. Now, how to properly fix it? :) --=20 Sylvain