GNU bug report logs - #22406
Cannot compile for Windows x64 due to LLP64 model

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: guile; Reported by: Peter TB Brett <peter@HIDDEN>; Keywords: patch; merged with #19019; dated Tue, 19 Jan 2016 13:51:01 UTC; Maintainer for guile is bug-guile@HIDDEN.
Added tag(s) patch. Request was from Taylan Kammer <taylan.kammer@HIDDEN> to control <at> debbugs.gnu.org. Full text available.
Merged 19019 22406. Request was from Andy Wingo <wingo@HIDDEN> to control <at> debbugs.gnu.org. Full text available.

Message received at 22406 <at> debbugs.gnu.org:


Received: (at 22406) by debbugs.gnu.org; 20 Jun 2016 20:01:33 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Jun 20 16:01:33 2016
Received: from localhost ([127.0.0.1]:48041 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1bF5O0-0001pS-UG
	for submit <at> debbugs.gnu.org; Mon, 20 Jun 2016 16:01:33 -0400
Received: from world.peace.net ([50.252.239.5]:36956)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <mhw@HIDDEN>) id 1bF5Nz-0001pG-Ir
 for 22406 <at> debbugs.gnu.org; Mon, 20 Jun 2016 16:01:31 -0400
Received: from c-73-253-48-168.hsd1.ma.comcast.net ([73.253.48.168] helo=jojen)
 by world.peace.net with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.84_2) (envelope-from <mhw@HIDDEN>)
 id 1bF5Nt-0000OQ-AE; Mon, 20 Jun 2016 16:01:25 -0400
From: Mark H Weaver <mhw@HIDDEN>
To: Peter TB Brett <peter@HIDDEN>
Subject: Re: bug#22406: Cannot compile for Windows x64 due to LLP64 model
References: <569E3F19.9000502@HIDDEN>
Date: Mon, 20 Jun 2016 16:01:13 -0400
In-Reply-To: <569E3F19.9000502@HIDDEN> (Peter TB Brett's message of
 "Tue, 19 Jan 2016 13:50:17 +0000")
Message-ID: <87a8iftyt2.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.95 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 22406
Cc: 22406 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: 0.0 (/)

Peter TB Brett <peter@HIDDEN> writes:

> It is not currently possible to compile Guile 2.0.11 for Windows x64
> (in particular 64-bit Windows running on the x86-64 arch).
>
> Most operating systems' C libraries for x86-64 use an "LP64" model,
> where sizeof(long int) == sizeof(void *) == 8.
>
> However, for backwards-compatibility reasons, Windows uses an "LLP64"
> model, where sizeof(long long int) == sizeof(void *) == 8 and
> sizeof(long int) == 4.

I pushed commit b0a702d7733e02cb68ea2331bd632e25a3127c75 to stable-2.0
which should, I hope, fix the specific issues raised in this bug report.
However, there are likely to be other places in guile where similar
assumptions are made.  If you'd like to test current 'stable-2.0' on
LLP64, we can proceed.

    Thanks!
      Mark




Information forwarded to bug-guile@HIDDEN:
bug#22406; Package guile. Full text available.

Message received at 22406 <at> debbugs.gnu.org:


Received: (at 22406) by debbugs.gnu.org; 26 Jan 2016 17:38:19 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Jan 26 12:38:19 2016
Received: from localhost ([127.0.0.1]:37875 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1aO7ZL-0004Ax-2y
	for submit <at> debbugs.gnu.org; Tue, 26 Jan 2016 12:38:19 -0500
Received: from world.peace.net ([50.252.239.5]:51304 ident=hope1)
 by debbugs.gnu.org with esmtp (Exim 4.84)
 (envelope-from <mhw@HIDDEN>) id 1aO7ZI-0004Ao-QB
 for 22406 <at> debbugs.gnu.org; Tue, 26 Jan 2016 12:38:17 -0500
Received: from [10.1.10.78] (helo=jojen)
 by world.peace.net with esmtpsa (TLS1.0:RSA_AES_128_CBC_SHA1:16)
 (Exim 4.72) (envelope-from <mhw@HIDDEN>)
 id 1aO7Z7-00019a-HC; Tue, 26 Jan 2016 12:38:05 -0500
From: Mark H Weaver <mhw@HIDDEN>
To: Peter TB Brett <peter@HIDDEN>
Subject: Re: bug#22406: Cannot compile for Windows x64 due to LLP64 model
References: <569E3F19.9000502@HIDDEN> <87y4bcnxbq.fsf@HIDDEN>
Date: Tue, 26 Jan 2016 12:38:04 -0500
In-Reply-To: <87y4bcnxbq.fsf@HIDDEN> (Mark H. Weaver's message of "Tue, 26
 Jan 2016 11:02:17 -0500")
Message-ID: <87twm0nsw3.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux)
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="=-=-="
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 22406
Cc: 22406 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: 0.0 (/)

--=-=-=
Content-Type: text/plain

Mark H Weaver <mhw@HIDDEN> writes:

> Peter TB Brett <peter@HIDDEN> writes:
>
>> It is not currently possible to compile Guile 2.0.11 for Windows x64
>> (in particular 64-bit Windows running on the x86-64 arch).
>>
>> Most operating systems' C libraries for x86-64 use an "LP64" model,
>> where sizeof(long int) == sizeof(void *) == 8.
>>
>> However, for backwards-compatibility reasons, Windows uses an "LLP64"
>> model, where sizeof(long long int) == sizeof(void *) == 8 and
>> sizeof(long int) == 4.
>>
>> Guile 2.0.11 can't cope with this; the libguile build fails due to
>> this code:
>
> I've attached a patch that attempts to address this issue by using
> 'long' as the scm_t_inum type.  So, fixnums will be limited to 30 bits
> on LLP64 systems.  We can't easily avoid this while using GMP's mpz API,
> since the mpz_*_si functions except longs and there are no analogous
> functions that accept larger C integer types.
>
> Can you test this patch and report back?

Disregard my first patch, as it missed a few important changes.
Please try this one instead.

     Thanks,
       Mark



--=-=-=
Content-Type: text/x-patch
Content-Disposition: inline; filename=0001-PRELIMINARY-fixes-for-LLP64.patch
Content-Description: PRELIMINARY fixes for LLP64 v2

From 333ec4fd35c5625cd090e216a77842a5e1ca9941 Mon Sep 17 00:00:00 2001
From: Mark H Weaver <mhw@HIDDEN>
Date: Tue, 26 Jan 2016 03:42:18 -0500
Subject: [PATCH] PRELIMINARY fixes for LLP64.

---
 libguile/numbers.c     | 12 ++++--------
 libguile/numbers.h     | 37 ++++++++++++++++++-------------------
 libguile/vm-i-scheme.c | 28 ++++++++++++++--------------
 3 files changed, 36 insertions(+), 41 deletions(-)

diff --git a/libguile/numbers.c b/libguile/numbers.c
index 1e3fc30..205548d 100644
--- a/libguile/numbers.c
+++ b/libguile/numbers.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1995-2015 Free Software Foundation, Inc.
+/* Copyright (C) 1995-2016 Free Software Foundation, Inc.
  *
  * Portions Copyright 1990, 1991, 1992, 1993 by AT&T Bell Laboratories
  * and Bellcore.  See scm_divide.
@@ -87,7 +87,9 @@
 /* FIXME: We assume that FLT_RADIX is 2 */
 verify (FLT_RADIX == 2);
 
-typedef scm_t_signed_bits scm_t_inum;
+/* Make sure that scm_t_inum fits within a SCM value.  */
+verify (sizeof (scm_t_inum) <= sizeof (scm_t_bits));
+
 #define scm_from_inum(x) (scm_from_signed_integer (x))
 
 /* Test an inum to see if it can be converted to a double without loss
@@ -272,13 +274,7 @@ scm_i_inum2big (scm_t_inum x)
 {
   /* Return a newly created bignum initialized to X. */
   SCM z = make_bignum ();
-#if SIZEOF_VOID_P == SIZEOF_LONG
   mpz_init_set_si (SCM_I_BIG_MPZ (z), x);
-#else
-  /* Note that in this case, you'll also have to check all mpz_*_ui and
-     mpz_*_si invocations in Guile. */
-#error creation of mpz not implemented for this inum size
-#endif
   return z;
 }
 
diff --git a/libguile/numbers.h b/libguile/numbers.h
index b929b7a..9f7dd3c 100644
--- a/libguile/numbers.h
+++ b/libguile/numbers.h
@@ -3,8 +3,8 @@
 #ifndef SCM_NUMBERS_H
 #define SCM_NUMBERS_H
 
-/* Copyright (C) 1995,1996,1998,2000,2001,2002,2003,2004,2005, 2006,
- *   2008, 2009, 2010, 2011, 2013, 2014 Free Software Foundation, Inc.
+/* Copyright (C) 1995, 1996, 1998, 2000-2006, 2008-2011, 2013, 2014,
+ *   2016 Free Software Foundation, Inc.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public License
@@ -38,16 +38,15 @@ typedef scm_t_int32 scm_t_wchar;
 
 /* Immediate Numbers, also known as fixnums
  *
- * Inums are exact integer data that fits within an SCM word.  */
-
-/* SCM_T_SIGNED_MAX is                 (- (expt 2 n) 1),
- * SCM_MOST_POSITIVE_FIXNUM should be  (- (expt 2 (- n 2)) 1)
- * which is the same as                (/ (- (expt 2 n) 4) 4)
- */
-
+ * Inums are exact integers that fit within an SCM word
+ * (along with two tagging bits).
+ *
+ * In the current implementation, Inums must also fit within a long
+ * because that's what GMP's mpz_*_si functions accept.  */
+typedef long scm_t_inum;
 #define SCM_I_FIXNUM_BIT         (SCM_LONG_BIT - 2)
-#define SCM_MOST_POSITIVE_FIXNUM ((SCM_T_SIGNED_BITS_MAX-3)/4)
-#define SCM_MOST_NEGATIVE_FIXNUM (-SCM_MOST_POSITIVE_FIXNUM-1)
+#define SCM_MOST_NEGATIVE_FIXNUM (-1L << (SCM_I_FIXNUM_BIT - 1))
+#define SCM_MOST_POSITIVE_FIXNUM (- (SCM_MOST_NEGATIVE_FIXNUM + 1))
 
 /* SCM_SRS (X, Y) is signed right shift, defined as floor (X / 2^Y),
    where Y must be non-negative and less than the width in bits of X.
@@ -58,9 +57,9 @@ typedef scm_t_int32 scm_t_wchar;
 #if (-1 >> 2 == -1) && (-4 >> 2 == -1) && (-5 >> 2 == -2) && (-8 >> 2 == -2)
 # define SCM_SRS(x, y)  ((x) >> (y))
 #else
-# define SCM_SRS(x, y)                                   \
-  ((x) < 0                                               \
-   ? -1 - (scm_t_signed_bits) (~(scm_t_bits)(x) >> (y))  \
+# define SCM_SRS(x, y)                          \
+  ((x) < 0                                      \
+   ? -1 - (long) (~(unsigned long)(x) >> (y))   \
    : ((x) >> (y)))
 #endif
 
@@ -74,12 +73,12 @@ typedef scm_t_int32 scm_t_wchar;
 
    NOTE: X must not perform side effects.  */
 #ifdef __GNUC__
-# define SCM_I_INUM(x)  (SCM_SRS ((scm_t_signed_bits) SCM_UNPACK (x), 2))
+# define SCM_I_INUM(x)  (SCM_SRS ((scm_t_inum) SCM_UNPACK (x), 2))
 #else
-# define SCM_I_INUM(x)                                \
-  (SCM_UNPACK (x) > LONG_MAX                          \
-   ? -1 - (scm_t_signed_bits) (~SCM_UNPACK (x) >> 2)  \
-   : (scm_t_signed_bits) (SCM_UNPACK (x) >> 2))
+# define SCM_I_INUM(x)                          \
+  (SCM_UNPACK (x) > SCM_T_SIGNED_BITS_MAX       \
+   ? -1 - (scm_t_inum) (~SCM_UNPACK (x) >> 2)   \
+   : (scm_t_inum) (SCM_UNPACK (x) >> 2))
 #endif
 
 #define SCM_I_INUMP(x)	(2 & SCM_UNPACK (x))
diff --git a/libguile/vm-i-scheme.c b/libguile/vm-i-scheme.c
index 162efab..452a459 100644
--- a/libguile/vm-i-scheme.c
+++ b/libguile/vm-i-scheme.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2001, 2009-2014 Free Software Foundation, Inc.
+/* Copyright (C) 2001, 2009-2014, 2016 Free Software Foundation, Inc.
  * 
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public License
@@ -236,9 +236,9 @@ VM_DEFINE_FUNCTION (149, ge, "ge?", 2)
 #if SCM_GNUC_PREREQ (4, 5) && (defined __x86_64__ || defined __i386__)
 
 # undef _CX
-# if SIZEOF_VOID_P == 8
+# if SCM_I_FIXNUM_BIT == 62
 #  define _CX "rcx"
-# elif SIZEOF_VOID_P == 4
+# elif SCM_I_FIXNUM_BIT == 30
 #  define _CX "ecx"
 # else
 #  error unsupported word size
@@ -291,7 +291,7 @@ VM_DEFINE_FUNCTION (149, ge, "ge?", 2)
 
 # define ASM_MUL(x, y)							\
     {									\
-      scm_t_signed_bits xx = SCM_I_INUM (x);				\
+      scm_t_inum xx = SCM_I_INUM (x);					\
       asm volatile goto ("mov %1, %%"_CX"; "				\
 			 "test %[tag], %%cl;   je %l[slow_mul]; "	\
 			 "sub %[tag], %%"_CX"; "			\
@@ -360,7 +360,7 @@ VM_DEFINE_FUNCTION (149, ge, "ge?", 2)
 #  define ASM_MUL(x, y)							\
     if (SCM_LIKELY (SCM_I_INUMP (x) && SCM_I_INUMP (y)))		\
       {									\
-	scm_t_signed_bits rlo, rhi;					\
+	scm_t_inum rlo, rhi;						\
 	asm ("smull %0, %1, %2, %3\n"					\
 	     : "=&r" (rlo), "=&r" (rhi)					\
 	     : "r" (SCM_UNPACK (x) - scm_tc2_int),			\
@@ -496,7 +496,7 @@ VM_DEFINE_FUNCTION (159, ash, "ash", 2)
       else
         /* Left shift. See comments in scm_ash. */
         {
-          scm_t_signed_bits nn, bits_to_shift;
+          scm_t_inum nn, bits_to_shift;
 
           nn = SCM_I_INUM (x);
           bits_to_shift = SCM_I_INUM (y);
@@ -552,7 +552,7 @@ VM_DEFINE_FUNCTION (162, logxor, "logxor", 2)
 
 VM_DEFINE_FUNCTION (163, vector_ref, "vector-ref", 2)
 {
-  scm_t_signed_bits i = 0;
+  scm_t_inum i = 0;
   ARGS2 (vect, idx);
   if (SCM_LIKELY (SCM_I_IS_NONWEAK_VECTOR (vect)
                   && SCM_I_INUMP (idx)
@@ -568,7 +568,7 @@ VM_DEFINE_FUNCTION (163, vector_ref, "vector-ref", 2)
 
 VM_DEFINE_INSTRUCTION (164, vector_set, "vector-set", 0, 3, 0)
 {
-  scm_t_signed_bits i = 0;
+  scm_t_inum i = 0;
   SCM vect, idx, val;
   POP3 (val, idx, vect);
   if (SCM_LIKELY (SCM_I_IS_NONWEAK_VECTOR (vect)
@@ -792,7 +792,7 @@ BV_REF_WITH_ENDIANNESS (f64, ieee_double)
 
 #define BV_FIXABLE_INT_REF(stem, fn_stem, type, size)			\
 {									\
-  scm_t_signed_bits i;							\
+  scm_t_inum i;								\
   const scm_t_ ## type *int_ptr;					\
   ARGS2 (bv, idx);							\
 									\
@@ -814,7 +814,7 @@ BV_REF_WITH_ENDIANNESS (f64, ieee_double)
 
 #define BV_INT_REF(stem, type, size)					\
 {									\
-  scm_t_signed_bits i;							\
+  scm_t_inum i;								\
   const scm_t_ ## type *int_ptr;					\
   ARGS2 (bv, idx);							\
 									\
@@ -845,7 +845,7 @@ BV_REF_WITH_ENDIANNESS (f64, ieee_double)
 
 #define BV_FLOAT_REF(stem, fn_stem, type, size)				\
 {									\
-  scm_t_signed_bits i;							\
+  scm_t_inum i;								\
   const type *float_ptr;						\
   ARGS2 (bv, idx);							\
 									\
@@ -933,7 +933,7 @@ BV_SET_WITH_ENDIANNESS (f64, ieee_double)
 
 #define BV_FIXABLE_INT_SET(stem, fn_stem, type, min, max, size)		\
 {									\
-  scm_t_signed_bits i, j = 0;						\
+  scm_t_inum i, j = 0;							\
   SCM bv, idx, val;							\
   scm_t_ ## type *int_ptr;						\
 									\
@@ -960,7 +960,7 @@ BV_SET_WITH_ENDIANNESS (f64, ieee_double)
 
 #define BV_INT_SET(stem, type, size)					\
 {									\
-  scm_t_signed_bits i = 0;						\
+  scm_t_inum i = 0;							\
   SCM bv, idx, val;							\
   scm_t_ ## type *int_ptr;						\
 									\
@@ -984,7 +984,7 @@ BV_SET_WITH_ENDIANNESS (f64, ieee_double)
 
 #define BV_FLOAT_SET(stem, fn_stem, type, size)                         \
 {                                                                       \
-  scm_t_signed_bits i = 0;                                              \
+  scm_t_inum i = 0;                                                     \
   SCM bv, idx, val;                                                     \
   type *float_ptr;                                                      \
                                                                         \
-- 
2.6.3


--=-=-=--




Information forwarded to bug-guile@HIDDEN:
bug#22406; Package guile. Full text available.

Message received at 22406 <at> debbugs.gnu.org:


Received: (at 22406) by debbugs.gnu.org; 26 Jan 2016 16:02:36 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Jan 26 11:02:36 2016
Received: from localhost ([127.0.0.1]:37815 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1aO64g-0001pI-LQ
	for submit <at> debbugs.gnu.org; Tue, 26 Jan 2016 11:02:36 -0500
Received: from world.peace.net ([50.252.239.5]:50983 ident=hope2)
 by debbugs.gnu.org with esmtp (Exim 4.84)
 (envelope-from <mhw@HIDDEN>) id 1aO64b-0001p7-6J
 for 22406 <at> debbugs.gnu.org; Tue, 26 Jan 2016 11:02:32 -0500
Received: from [10.1.10.78] (helo=jojen)
 by world.peace.net with esmtpsa (TLS1.0:RSA_AES_128_CBC_SHA1:16)
 (Exim 4.72) (envelope-from <mhw@HIDDEN>)
 id 1aO64Q-0000dw-Qx; Tue, 26 Jan 2016 11:02:18 -0500
From: Mark H Weaver <mhw@HIDDEN>
To: Peter TB Brett <peter@HIDDEN>
Subject: Re: bug#22406: Cannot compile for Windows x64 due to LLP64 model
References: <569E3F19.9000502@HIDDEN>
Date: Tue, 26 Jan 2016 11:02:17 -0500
In-Reply-To: <569E3F19.9000502@HIDDEN> (Peter TB Brett's message of
 "Tue, 19 Jan 2016 13:50:17 +0000")
Message-ID: <87y4bcnxbq.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux)
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="=-=-="
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 22406
Cc: 22406 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: 0.0 (/)

--=-=-=
Content-Type: text/plain

Hi Peter,

Peter TB Brett <peter@HIDDEN> writes:

> It is not currently possible to compile Guile 2.0.11 for Windows x64
> (in particular 64-bit Windows running on the x86-64 arch).
>
> Most operating systems' C libraries for x86-64 use an "LP64" model,
> where sizeof(long int) == sizeof(void *) == 8.
>
> However, for backwards-compatibility reasons, Windows uses an "LLP64"
> model, where sizeof(long long int) == sizeof(void *) == 8 and
> sizeof(long int) == 4.
>
> Guile 2.0.11 can't cope with this; the libguile build fails due to
> this code:

I've attached a patch that attempts to address this issue by using
'long' as the scm_t_inum type.  So, fixnums will be limited to 30 bits
on LLP64 systems.  We can't easily avoid this while using GMP's mpz API,
since the mpz_*_si functions except longs and there are no analogous
functions that accept larger C integer types.

Can you test this patch and report back?

     Thanks,
       Mark


--=-=-=
Content-Type: text/x-patch
Content-Disposition: inline; filename=0001-PRELIMINARY-fixes-for-LLP64.patch
Content-Description: PRELIMINARY fixes for LLP64 v1

From 4a923816c9814b07556fdcc53b74b3e1ca2a0f41 Mon Sep 17 00:00:00 2001
From: Mark H Weaver <mhw@HIDDEN>
Date: Tue, 26 Jan 2016 03:42:18 -0500
Subject: [PATCH] PRELIMINARY fixes for LLP64.

---
 libguile/numbers.c     | 19 ++++++++++---------
 libguile/numbers.h     | 29 ++++++++++++++---------------
 libguile/vm-i-scheme.c |  2 +-
 3 files changed, 25 insertions(+), 25 deletions(-)

diff --git a/libguile/numbers.c b/libguile/numbers.c
index 1e3fc30..7d32c20 100644
--- a/libguile/numbers.c
+++ b/libguile/numbers.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1995-2015 Free Software Foundation, Inc.
+/* Copyright (C) 1995-2016 Free Software Foundation, Inc.
  *
  * Portions Copyright 1990, 1991, 1992, 1993 by AT&T Bell Laboratories
  * and Bellcore.  See scm_divide.
@@ -87,7 +87,14 @@
 /* FIXME: We assume that FLT_RADIX is 2 */
 verify (FLT_RADIX == 2);
 
-typedef scm_t_signed_bits scm_t_inum;
+/* We assume that a long fits within a SCM value.  */
+verify (SCM_SIZEOF_LONG <= SIZEOF_SCM_T_BITS);
+
+/* We use 'long' as the type for Inums, because that's the type accepted
+   by GMP's mpz_*_si functions.  Above, we checked that a long fits
+   within an SCM.  */
+typedef long scm_t_inum;
+
 #define scm_from_inum(x) (scm_from_signed_integer (x))
 
 /* Test an inum to see if it can be converted to a double without loss
@@ -272,13 +279,7 @@ scm_i_inum2big (scm_t_inum x)
 {
   /* Return a newly created bignum initialized to X. */
   SCM z = make_bignum ();
-#if SIZEOF_VOID_P == SIZEOF_LONG
   mpz_init_set_si (SCM_I_BIG_MPZ (z), x);
-#else
-  /* Note that in this case, you'll also have to check all mpz_*_ui and
-     mpz_*_si invocations in Guile. */
-#error creation of mpz not implemented for this inum size
-#endif
   return z;
 }
 
@@ -4966,7 +4967,7 @@ left_shift_exact_integer (SCM n, long count)
       if (nn == 0)
         return n;
       else if (count < SCM_I_FIXNUM_BIT-1 &&
-               ((scm_t_bits) (SCM_SRS (nn, (SCM_I_FIXNUM_BIT-1 - count)) + 1)
+               ((unsigned long) (SCM_SRS (nn, (SCM_I_FIXNUM_BIT-1 - count)) + 1)
                 <= 1))
         return SCM_I_MAKINUM (nn < 0 ? -(-nn << count) : (nn << count));
       else
diff --git a/libguile/numbers.h b/libguile/numbers.h
index b929b7a..d5e4f2b 100644
--- a/libguile/numbers.h
+++ b/libguile/numbers.h
@@ -3,8 +3,8 @@
 #ifndef SCM_NUMBERS_H
 #define SCM_NUMBERS_H
 
-/* Copyright (C) 1995,1996,1998,2000,2001,2002,2003,2004,2005, 2006,
- *   2008, 2009, 2010, 2011, 2013, 2014 Free Software Foundation, Inc.
+/* Copyright (C) 1995, 1996, 1998, 2000-2006, 2008-2011, 2013, 2014,
+ *   2016 Free Software Foundation, Inc.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public License
@@ -38,16 +38,15 @@ typedef scm_t_int32 scm_t_wchar;
 
 /* Immediate Numbers, also known as fixnums
  *
- * Inums are exact integer data that fits within an SCM word.  */
-
-/* SCM_T_SIGNED_MAX is                 (- (expt 2 n) 1),
- * SCM_MOST_POSITIVE_FIXNUM should be  (- (expt 2 (- n 2)) 1)
- * which is the same as                (/ (- (expt 2 n) 4) 4)
- */
-
+ * Inums are exact integers that fit within an SCM word
+ * (along with two tagging bits).
+ *
+ * In the current implementation, Inums must also fit within a long
+ * because that's what GMP's mpz_*_si functions accept.  We assume that
+ * a long fits in a SCM value (this is checked in numbers.c).  */
 #define SCM_I_FIXNUM_BIT         (SCM_LONG_BIT - 2)
-#define SCM_MOST_POSITIVE_FIXNUM ((SCM_T_SIGNED_BITS_MAX-3)/4)
-#define SCM_MOST_NEGATIVE_FIXNUM (-SCM_MOST_POSITIVE_FIXNUM-1)
+#define SCM_MOST_NEGATIVE_FIXNUM (-1L << (SCM_I_FIXNUM_BIT - 1))
+#define SCM_MOST_POSITIVE_FIXNUM (- (SCM_MOST_NEGATIVE_FIXNUM + 1))
 
 /* SCM_SRS (X, Y) is signed right shift, defined as floor (X / 2^Y),
    where Y must be non-negative and less than the width in bits of X.
@@ -60,7 +59,7 @@ typedef scm_t_int32 scm_t_wchar;
 #else
 # define SCM_SRS(x, y)                                   \
   ((x) < 0                                               \
-   ? -1 - (scm_t_signed_bits) (~(scm_t_bits)(x) >> (y))  \
+   ? -1 - (long) (~(unsigned long)(x) >> (y))            \
    : ((x) >> (y)))
 #endif
 
@@ -74,12 +73,12 @@ typedef scm_t_int32 scm_t_wchar;
 
    NOTE: X must not perform side effects.  */
 #ifdef __GNUC__
-# define SCM_I_INUM(x)  (SCM_SRS ((scm_t_signed_bits) SCM_UNPACK (x), 2))
+# define SCM_I_INUM(x)  (SCM_SRS ((long) SCM_UNPACK (x), 2))
 #else
 # define SCM_I_INUM(x)                                \
   (SCM_UNPACK (x) > LONG_MAX                          \
-   ? -1 - (scm_t_signed_bits) (~SCM_UNPACK (x) >> 2)  \
-   : (scm_t_signed_bits) (SCM_UNPACK (x) >> 2))
+   ? -1 - (long) (~SCM_UNPACK (x) >> 2)               \
+   : (long) (SCM_UNPACK (x) >> 2))
 #endif
 
 #define SCM_I_INUMP(x)	(2 & SCM_UNPACK (x))
diff --git a/libguile/vm-i-scheme.c b/libguile/vm-i-scheme.c
index 162efab..249b835 100644
--- a/libguile/vm-i-scheme.c
+++ b/libguile/vm-i-scheme.c
@@ -360,7 +360,7 @@ VM_DEFINE_FUNCTION (149, ge, "ge?", 2)
 #  define ASM_MUL(x, y)							\
     if (SCM_LIKELY (SCM_I_INUMP (x) && SCM_I_INUMP (y)))		\
       {									\
-	scm_t_signed_bits rlo, rhi;					\
+	long rlo, rhi;							\
 	asm ("smull %0, %1, %2, %3\n"					\
 	     : "=&r" (rlo), "=&r" (rhi)					\
 	     : "r" (SCM_UNPACK (x) - scm_tc2_int),			\
-- 
2.6.3


--=-=-=--




Information forwarded to bug-guile@HIDDEN:
bug#22406; Package guile. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 19 Jan 2016 13:50:42 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Jan 19 08:50:42 2016
Received: from localhost ([127.0.0.1]:53522 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1aLWgE-0008OE-3s
	for submit <at> debbugs.gnu.org; Tue, 19 Jan 2016 08:50:42 -0500
Received: from eggs.gnu.org ([208.118.235.92]:59594)
 by debbugs.gnu.org with esmtp (Exim 4.84)
 (envelope-from <peter@HIDDEN>) id 1aLWgB-0008Nu-J3
 for submit <at> debbugs.gnu.org; Tue, 19 Jan 2016 08:50:40 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <peter@HIDDEN>) id 1aLWg2-00085M-Gr
 for submit <at> debbugs.gnu.org; Tue, 19 Jan 2016 08:50:34 -0500
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=-0.0 required=5.0 tests=BAYES_40 autolearn=disabled
 version=3.3.2
Received: from lists.gnu.org ([2001:4830:134:3::11]:35938)
 by eggs.gnu.org with esmtp (Exim 4.71)
 (envelope-from <peter@HIDDEN>) id 1aLWg2-00085I-Ea
 for submit <at> debbugs.gnu.org; Tue, 19 Jan 2016 08:50:30 -0500
Received: from eggs.gnu.org ([2001:4830:134:3::10]:50496)
 by lists.gnu.org with esmtp (Exim 4.71)
 (envelope-from <peter@HIDDEN>) id 1aLWg1-0003YY-Aq
 for bug-guile@HIDDEN; Tue, 19 Jan 2016 08:50:30 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <peter@HIDDEN>) id 1aLWfy-0007zB-0p
 for bug-guile@HIDDEN; Tue, 19 Jan 2016 08:50:29 -0500
Received: from mail.net2air.co ([195.167.180.164]:58706)
 by eggs.gnu.org with esmtp (Exim 4.71)
 (envelope-from <peter@HIDDEN>) id 1aLWfx-0007vx-S4
 for bug-guile@HIDDEN; Tue, 19 Jan 2016 08:50:25 -0500
Received: from Peters-iMac.lan (82-68-142-126.dsl.in-addr.zen.co.uk
 [82.68.142.126])
 by mail.net2air.co (Postfix) with ESMTPSA id C882FF1888
 for <bug-guile@HIDDEN>; Tue, 19 Jan 2016 13:50:17 +0000 (GMT)
To: bug-guile@HIDDEN
From: Peter TB Brett <peter@HIDDEN>
Subject: Cannot compile for Windows x64 due to LLP64 model
Message-ID: <569E3F19.9000502@HIDDEN>
Date: Tue, 19 Jan 2016 13:50:17 +0000
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:38.0)
 Gecko/20100101 Thunderbird/38.5.1
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x
X-Received-From: 2001:4830:134:3::11
X-Spam-Score: -4.0 (----)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -4.0 (----)

It is not currently possible to compile Guile 2.0.11 for Windows x64 (in 
particular 64-bit Windows running on the x86-64 arch).

Most operating systems' C libraries for x86-64 use an "LP64" model, 
where sizeof(long int) == sizeof(void *) == 8.

However, for backwards-compatibility reasons, Windows uses an "LLP64" 
model, where sizeof(long long int) == sizeof(void *) == 8 and 
sizeof(long int) == 4.

Guile 2.0.11 can't cope with this; the libguile build fails due to this 
code:

 > static SCM
 > scm_i_inum2big (scm_t_inum x)
 > {
 >   /* Return a newly created bignum initialized to X. */
 >   SCM z = make_bignum ();
 > #if SIZEOF_VOID_P == SIZEOF_LONG
 >   mpz_init_set_si (SCM_I_BIG_MPZ (z), x);
 > #else
 >   /* Note that in this case, you'll also have to check all mpz_*_ui and
 >      mpz_*_si invocations in Guile. */
 > #error creation of mpz not implemented for this inum size
 > #endif
 >   return z;
 > }

http://git.savannah.gnu.org/cgit/guile.git/tree/libguile/numbers.c?id=v2.0.11#n272

Some work appears to be required before using 64-bit Guile on Windows 
x64 is possible.


-- 
Dr Peter Brett <peter@HIDDEN>




Acknowledgement sent to Peter TB Brett <peter@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-guile@HIDDEN. Full text available.
Report forwarded to bug-guile@HIDDEN:
bug#22406; Package guile. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Mon, 17 May 2021 21:15:02 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.