The patch below allows a complete MinGW build of branch_release-1-8; I haven't tried actually running the built .exe and .dlls yet.
Comments appreciated as usual! Neil
>From ed7189a28292cd9ba8fcb5d18d2dcd817061935a Mon Sep 17 00:00:00 2001 From: Neil Jerram <n...@ossau.uklinux.net> Date: Sat, 27 Jun 2009 00:33:06 +0100 Subject: [PATCH] MinGW build fixes - Need to use GUILE_FOR_BUILD for autogeneration steps during the build. - MinGW can't export/import struct variables from/to a DLL, so wrap the ones needed by inline.h in exported/imported pointer variables. - The dummy scm_init_* and scm_c_init_* functions in the empty libraries for SRFIs 4, 13 and 14 clash with declarations with the same names in libguile.h that are marked (in the MinGW build) with __declspec (dllimport). These libraries are empty because their content was moved into libguile some time ago, and I think these functions are needed only so that the libraries appear to contain something. They used also to be needed for the (load-extension ...) forms in the corresponding .scm modules, but those forms were not needed anymore, and so were removed, when everything moved into libguile. * doc/ref/Makefile.am (autoconf-macros.texi): Use GUILE_FOR_BUILD to generate this. * libguile/gc-freelist.c (scm_i_master_freelist_ptr, scm_i_master_freelist2_ptr): New API variables. * libguile/gc.h (scm_i_freelist_ptr, scm_i_freelist2_ptr, scm_i_master_freelist_ptr, scm_i_master_freelist2_ptr): New global variable declarations. * libguile/inline.h (scm_cell): Use scm_i_freelist_ptr and scm_i_master_freelist_ptr instead of scm_i_freelist and scm_i_master_freelist. (scm_double_cell): Use scm_i_freelist2_ptr and scm_i_master_freelist2_ptr instead of scm_i_freelist2 and scm_i_master_freelist2. * libguile/threads.c (scm_i_freelist_ptr, scm_i_freelist2_ptr): New global variables. * srfi/srfi-13.c (scm_init_srfi_13_no_clash_with_libguile): Renamed from scm_init_srfi_13. (scm_init_srfi_13_14_no_clash_with_libguile): Same. * srfi/srfi-14.c (scm_init_srfi_14_no_clash_with_libguile): Same. (scm_c_init_srfi_14_no_clash_with_libguile): Same. * srfi/srfi-4.c (scm_init_srfi_4_no_clash_with_libguile): Same. * srfi/srfi-60.c (SCM_MIN): Define here instead of including private-gc.h. --- doc/ref/Makefile.am | 2 +- libguile/gc-freelist.c | 2 ++ libguile/gc.h | 4 ++++ libguile/inline.h | 8 ++++---- libguile/threads.c | 2 ++ srfi/srfi-13.c | 7 +++++-- srfi/srfi-14.c | 7 +++++-- srfi/srfi-4.c | 4 +++- srfi/srfi-60.c | 2 +- 9 files changed, 27 insertions(+), 11 deletions(-) diff --git a/doc/ref/Makefile.am b/doc/ref/Makefile.am index b60f2ff..46958b6 100644 --- a/doc/ref/Makefile.am +++ b/doc/ref/Makefile.am @@ -86,7 +86,7 @@ include $(top_srcdir)/am/pre-inst-guile autoconf.texi: autoconf-macros.texi autoconf-macros.texi: $(top_srcdir)/guile-config/guile.m4 - $(preinstguiletool)/snarf-guile-m4-docs $(top_srcdir)/guile-config/guile.m4 \ + GUILE="$(GUILE_FOR_BUILD)" $(top_srcdir)/scripts/snarf-guile-m4-docs $(top_srcdir)/guile-config/guile.m4 \ > $(srcdir)/$@ MAINTAINERCLEANFILES = autoconf-macros.texi diff --git a/libguile/gc-freelist.c b/libguile/gc-freelist.c index c8824df..4b38992 100644 --- a/libguile/gc-freelist.c +++ b/libguile/gc-freelist.c @@ -29,6 +29,8 @@ scm_t_cell_type_statistics scm_i_master_freelist; scm_t_cell_type_statistics scm_i_master_freelist2; +scm_t_cell_type_statistics *scm_i_master_freelist_ptr = &scm_i_master_freelist; +scm_t_cell_type_statistics *scm_i_master_freelist2_ptr = &scm_i_master_freelist2; diff --git a/libguile/gc.h b/libguile/gc.h index 3cedeb4..3b60689 100644 --- a/libguile/gc.h +++ b/libguile/gc.h @@ -273,9 +273,13 @@ SCM_API size_t scm_max_segment_size; #define SCM_SET_FREELIST_LOC(key,ptr) scm_i_pthread_setspecific ((key), (ptr)) #define SCM_FREELIST_LOC(key) ((SCM *) scm_i_pthread_getspecific (key)) SCM_API scm_i_pthread_key_t scm_i_freelist; +SCM_API scm_i_pthread_key_t *scm_i_freelist_ptr; SCM_API scm_i_pthread_key_t scm_i_freelist2; +SCM_API scm_i_pthread_key_t *scm_i_freelist2_ptr; SCM_API struct scm_t_cell_type_statistics scm_i_master_freelist; +SCM_API struct scm_t_cell_type_statistics *scm_i_master_freelist_ptr; SCM_API struct scm_t_cell_type_statistics scm_i_master_freelist2; +SCM_API struct scm_t_cell_type_statistics *scm_i_master_freelist2_ptr; SCM_API unsigned long scm_gc_cells_swept; diff --git a/libguile/inline.h b/libguile/inline.h index eae1e22..de2a50a 100644 --- a/libguile/inline.h +++ b/libguile/inline.h @@ -109,10 +109,10 @@ SCM scm_cell (scm_t_bits car, scm_t_bits cdr) { SCM z; - SCM *freelist = SCM_FREELIST_LOC (scm_i_freelist); + SCM *freelist = SCM_FREELIST_LOC (*scm_i_freelist_ptr); if (scm_is_null (*freelist)) - z = scm_gc_for_newcell (&scm_i_master_freelist, freelist); + z = scm_gc_for_newcell (scm_i_master_freelist_ptr, freelist); else { z = *freelist; @@ -180,10 +180,10 @@ scm_double_cell (scm_t_bits car, scm_t_bits cbr, scm_t_bits ccr, scm_t_bits cdr) { SCM z; - SCM *freelist = SCM_FREELIST_LOC (scm_i_freelist2); + SCM *freelist = SCM_FREELIST_LOC (*scm_i_freelist2_ptr); if (scm_is_null (*freelist)) - z = scm_gc_for_newcell (&scm_i_master_freelist2, freelist); + z = scm_gc_for_newcell (scm_i_master_freelist2_ptr, freelist); else { z = *freelist; diff --git a/libguile/threads.c b/libguile/threads.c index 3d6df11..ff8771d 100644 --- a/libguile/threads.c +++ b/libguile/threads.c @@ -1680,6 +1680,8 @@ scm_dynwind_critical_section (SCM mutex) /*** Initialization */ scm_i_pthread_key_t scm_i_freelist, scm_i_freelist2; +scm_i_pthread_key_t *scm_i_freelist_ptr = &scm_i_freelist; +scm_i_pthread_key_t *scm_i_freelist2_ptr = &scm_i_freelist2; scm_i_pthread_mutex_t scm_i_misc_mutex; #if SCM_USE_PTHREAD_THREADS diff --git a/srfi/srfi-13.c b/srfi/srfi-13.c index dd5ce9b..8655885 100644 --- a/srfi/srfi-13.c +++ b/srfi/srfi-13.c @@ -29,12 +29,15 @@ #include <srfi/srfi-13.h> +void scm_init_srfi_13_no_clash_with_libguile (void); +void scm_init_srfi_13_14_no_clash_with_libguile (void); + void -scm_init_srfi_13 (void) +scm_init_srfi_13_no_clash_with_libguile (void) { } void -scm_init_srfi_13_14 (void) +scm_init_srfi_13_14_no_clash_with_libguile (void) { } diff --git a/srfi/srfi-14.c b/srfi/srfi-14.c index 1a7297b..76cea87 100644 --- a/srfi/srfi-14.c +++ b/srfi/srfi-14.c @@ -23,12 +23,15 @@ #include <srfi/srfi-14.h> +void scm_init_srfi_14_no_clash_with_libguile (void); +void scm_c_init_srfi_14_no_clash_with_libguile (void); + void -scm_init_srfi_14 (void) +scm_init_srfi_14_no_clash_with_libguile (void) { } void -scm_c_init_srfi_14 (void) +scm_c_init_srfi_14_no_clash_with_libguile (void) { } diff --git a/srfi/srfi-4.c b/srfi/srfi-4.c index f40c6b3..f2e29e2 100644 --- a/srfi/srfi-4.c +++ b/srfi/srfi-4.c @@ -28,8 +28,10 @@ #include <srfi/srfi-4.h> +void scm_init_srfi_4_no_clash_with_libguile (void); + void -scm_init_srfi_4 (void) +scm_init_srfi_4_no_clash_with_libguile (void) { } diff --git a/srfi/srfi-60.c b/srfi/srfi-60.c index e173369..a91cb50 100644 --- a/srfi/srfi-60.c +++ b/srfi/srfi-60.c @@ -22,9 +22,9 @@ #endif #include <libguile.h> -#include <libguile/private-gc.h> /* for SCM_MIN */ #include <srfi/srfi-60.h> +#define SCM_MIN(A, B) ((A) < (B) ? (A) : (B)) SCM_DEFINE (scm_srfi60_log2_binary_factors, "log2-binary-factors", 1, 0, 0, (SCM n), -- 1.5.6.5