[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Guile with win32 cross compiling
From: |
Andy Wingo |
Subject: |
Re: Guile with win32 cross compiling |
Date: |
Tue, 12 Apr 2011 13:14:14 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux) |
Hi Volker,
On Fri 01 Apr 2011 20:50, Volker Grabsch <address@hidden> writes:
> "Portability fixes for win32 cross compiling"
> http://www.mail-archive.com/address@hidden/msg05308.html
Ah yes. Thanks for that link. And thank you for your ongoing patience
:-)
> Gen-scmconfig is a code generator, so it has to be built using
> the native toolchain. However, it is supposed to write take its
> values from the <uniconv.h> of the cross tool chain. Thus, the
> "/usr/include" equivalent of the cross tool chain is added to
> the include path when compiling gen-scmconfig. And here the
> trouble starts, because mixing headers of various toolchains
> is never a good idea. Among others, basic headers like <stdio.h>
> are now taken from the cross toolchain, referring to objects that
> don't even exist in the native toolchain, causing the build to
> fail with all kinds of strange error messages.
Hmmm. Well. We have other code generators in Guile's build system;
notably the configure script (via config.h and other output files).
What do folks think about the attached patch?
Regards,
Andy
>From b03f8337ea62091208680fab901606c9af360a5d Mon Sep 17 00:00:00 2001
From: Andy Wingo <address@hidden>
Date: Tue, 12 Apr 2011 13:12:56 +0200
Subject: [PATCH] check for iconveh values at configure-time
* configure.ac: Check for the iconveh values here, instead of relying on
gen-scmconfig to know them. That doesn't work in general because
gen-scmconfig runs on the build machine, not the target machine.
* libguile/Makefile.am (gen-scmconfig.$(OBJEXT)): Revert rule to the
revision before 533d8212.
* libguile/gen-scmconfig.h.in (SCM_I_GSC_ICONVEH_ERROR):
(SCM_I_GSC_ICONVEH_QUESTION_MARK):
(SCM_I_GSC_ICONVEH_ESCAPE_SEQUENCE):
* libguile/gen-scmconfig.c: Use configure-time substitutions to set
SCM_ICONVEH_ERROR_HANDLER et al.
---
configure.ac | 64 +++++++++++++++++++++++++++++++++++++++++++
libguile/Makefile.am | 12 +++-----
libguile/gen-scmconfig.c | 9 +++---
libguile/gen-scmconfig.h.in | 3 ++
4 files changed, 76 insertions(+), 12 deletions(-)
diff --git a/configure.ac b/configure.ac
index 45438c8..1f68e0f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1188,6 +1188,70 @@ GUILE_STRUCT_UTIMBUF
#--------------------------------------------------------------------
#
+# What values do the iconv error handlers have?
+#
+# The only place that we need iconv in our public interfaces is for
+# the error handlers, which are just ints. So we weaken our
+# dependency by looking up those values at configure-time.
+#--------------------------------------------------------------------
+SCM_I_GSC_ICONVEH_ERROR=0
+SCM_I_GSC_ICONVEH_QUESTION_MARK=1
+SCM_I_GSC_ICONVEH_ESCAPE_SEQUENCE=2
+AC_MSG_CHECKING([for iconveh_error])
+AC_RUN_IFELSE([AC_LANG_SOURCE(
+[AC_INCLUDES_DEFAULT
+#include <uniconv.h>
+int
+main (int argc, char *argv[])
+{
+ if (argc > 1)
+ printf ("%d\n", (int)iconveh_error);
+ return 0;
+}])],
+ [SCM_I_GSC_ICONVEH_ERROR=`./conftest$EXEEXT pretty-please`
+ AC_MSG_RESULT([$SCM_I_GSC_ICONVEH_ERROR])],
+ [AC_MSG_FAILURE([failed to get iconveh_error])],
+ [AC_MSG_WARN([assuming $SCM_I_GSC_ICONVEH_ERROR for
cross-compilation])])
+
+AC_MSG_CHECKING([for iconveh_question_mark])
+AC_RUN_IFELSE([AC_LANG_SOURCE(
+[AC_INCLUDES_DEFAULT
+#include <uniconv.h>
+int
+main (int argc, char *argv[])
+{
+ if (argc > 1)
+ printf ("%d\n", (int)iconveh_question_mark);
+ return 0;
+}])],
+ [SCM_I_GSC_ICONVEH_QUESTION_MARK=`./conftest$EXEEXT
pretty-please`
+ AC_MSG_RESULT([$SCM_I_GSC_ICONVEH_QUESTION_MARK])],
+ [AC_MSG_FAILURE([failed to get iconveh_question_mark])],
+ [AC_MSG_WARN([assuming $SCM_I_GSC_ICONVEH_QUESTION_MARK for
cross-compilation])])
+
+AC_MSG_CHECKING([for iconveh_escape_sequence])
+AC_RUN_IFELSE([AC_LANG_SOURCE(
+[AC_INCLUDES_DEFAULT
+#include <uniconv.h>
+int
+main (int argc, char *argv[])
+{
+ if (argc > 1)
+ printf ("%d\n", (int)iconveh_escape_sequence);
+ return 0;
+}])],
+ [SCM_I_GSC_ICONVEH_ESCAPE_SEQUENCE=`./conftest$EXEEXT
pretty-please`
+ AC_MSG_RESULT([$SCM_I_GSC_ICONVEH_ESCAPE_SEQUENCE])],
+ [AC_MSG_FAILURE([failed to get iconveh_escape_sequence])],
+ [AC_MSG_WARN([assuming $SCM_I_GSC_ICONVEH_ESCAPE_SEQUENCE for
cross-compilation])])
+
+AC_SUBST([SCM_I_GSC_ICONVEH_ERROR])
+AC_SUBST([SCM_I_GSC_ICONVEH_QUESTION_MARK])
+AC_SUBST([SCM_I_GSC_ICONVEH_ESCAPE_SEQUENCE])
+
+
+#--------------------------------------------------------------------
+#
# Which way does the stack grow?
#
# Following code comes from Autoconf 2.61's internal _AC_LIBOBJ_ALLOCA
diff --git a/libguile/Makefile.am b/libguile/Makefile.am
index ac27eb8..ffb4059 100644
--- a/libguile/Makefile.am
+++ b/libguile/Makefile.am
@@ -55,13 +55,11 @@ gen_scmconfig_SOURCES = gen-scmconfig.c
## Override default rule; this should be compiled for BUILD host.
## For some reason, OBJEXT does not include the dot
gen-scmconfig.$(OBJEXT): gen-scmconfig.c
- $(AM_V_GEN) \
- if [ "$(cross_compiling)" = "yes" ]; then \
- $(CC_FOR_BUILD) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
- $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) \
- -c -o $@ $<; \
- else \
- $(COMPILE) -c -o $@ $<; \
+ $(AM_V_GEN) \
+ if [ "$(cross_compiling)" = "yes" ]; then \
+ $(CC_FOR_BUILD) $(DEFS) $(DEFAULT_INCLUDES) $(AM_CPPFLAGS) -c
-o $@ $<; \
+ else \
+ $(COMPILE) -c -o $@ $<; \
fi
## Override default rule; this should run on BUILD host.
diff --git a/libguile/gen-scmconfig.c b/libguile/gen-scmconfig.c
index 5834346..176f25c 100644
--- a/libguile/gen-scmconfig.c
+++ b/libguile/gen-scmconfig.c
@@ -123,7 +123,6 @@
#include <stdio.h>
#include <string.h>
-#include <uniconv.h>
#define pf printf
@@ -397,11 +396,11 @@ main (int argc, char *argv[])
pf ("\n");
pf ("/* Constants from uniconv.h. */\n");
- pf ("#define SCM_ICONVEH_ERROR %d\n", (int) iconveh_error);
- pf ("#define SCM_ICONVEH_QUESTION_MARK %d\n",
- (int) iconveh_question_mark);
+ pf ("#define SCM_ICONVEH_ERROR %d\n", SCM_I_GSC_ICONVEH_ERROR);
+ pf ("#define SCM_ICONVEH_QUESTION_MARK %d\n",
+ SCM_I_GSC_ICONVEH_QUESTION_MARK);
pf ("#define SCM_ICONVEH_ESCAPE_SEQUENCE %d\n",
- (int) iconveh_escape_sequence);
+ SCM_I_GSC_ICONVEH_ESCAPE_SEQUENCE);
printf ("#endif\n");
diff --git a/libguile/gen-scmconfig.h.in b/libguile/gen-scmconfig.h.in
index 125720a..30f43d7 100644
--- a/libguile/gen-scmconfig.h.in
+++ b/libguile/gen-scmconfig.h.in
@@ -31,6 +31,9 @@
#define SCM_I_GSC_NEED_BRACES_ON_PTHREAD_MUTEX_INITIALIZER
@SCM_I_GSC_NEED_BRACES_ON_PTHREAD_MUTEX_INITIALIZER@
#define SCM_I_GSC_HAVE_THREAD_STORAGE_CLASS
@SCM_I_GSC_HAVE_THREAD_STORAGE_CLASS@
#define SCM_I_GSC_HAVE_STRUCT_DIRENT64 @SCM_I_GSC_HAVE_STRUCT_DIRENT64@
+#define SCM_I_GSC_ICONVEH_ERROR @SCM_I_GSC_ICONVEH_ERROR@
+#define SCM_I_GSC_ICONVEH_QUESTION_MARK @SCM_I_GSC_ICONVEH_QUESTION_MARK@
+#define SCM_I_GSC_ICONVEH_ESCAPE_SEQUENCE @SCM_I_GSC_ICONVEH_ESCAPE_SEQUENCE@
/*
Local Variables:
--
1.7.3.4
--
http://wingolog.org/