From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: nisse@lysator.liu.se (Niels =?UTF-8?Q?M=C3=B6ller?=) Newsgroups: gmane.lisp.guile.bugs Subject: bug#10519: guile and (mini-)gmp Date: Mon, 23 Jul 2012 01:17:51 +0200 Message-ID: References: <874np05fwz.fsf@gnu.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: dough.gmane.org 1342999121 27963 80.91.229.3 (22 Jul 2012 23:18:41 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sun, 22 Jul 2012 23:18:41 +0000 (UTC) Cc: 10519@debbugs.gnu.org, Torbjorn Granlund To: ludo@gnu.org (Ludovic =?UTF-8?Q?Court=C3=A8s?=) Original-X-From: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Mon Jul 23 01:18:40 2012 Return-path: Envelope-to: guile-bugs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1St5Q6-0000o6-2A for guile-bugs@m.gmane.org; Mon, 23 Jul 2012 01:18:38 +0200 Original-Received: from localhost ([::1]:32926 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1St5Q4-00027D-TZ for guile-bugs@m.gmane.org; Sun, 22 Jul 2012 19:18:36 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:44367) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1St5Q1-000278-3H for bug-guile@gnu.org; Sun, 22 Jul 2012 19:18:34 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1St5Pz-0003vV-RF for bug-guile@gnu.org; Sun, 22 Jul 2012 19:18:33 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:48551) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1St5Pz-0003vR-Nj for bug-guile@gnu.org; Sun, 22 Jul 2012 19:18:31 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1St5WI-0006MU-5k for bug-guile@gnu.org; Sun, 22 Jul 2012 19:25:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: nisse@lysator.liu.se (Niels =?UTF-8?Q?M=C3=B6ller?=) Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-guile@gnu.org Resent-Date: Sun, 22 Jul 2012 23:25:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 10519 X-GNU-PR-Package: guile X-GNU-PR-Keywords: Original-Received: via spool by 10519-submit@debbugs.gnu.org id=B10519.134299947024417 (code B ref 10519); Sun, 22 Jul 2012 23:25:02 +0000 Original-Received: (at 10519) by debbugs.gnu.org; 22 Jul 2012 23:24:30 +0000 Original-Received: from localhost ([127.0.0.1]:58097 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1St5Vm-0006Ll-0C for submit@debbugs.gnu.org; Sun, 22 Jul 2012 19:24:30 -0400 Original-Received: from mail.lysator.liu.se ([130.236.254.3]:53890) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1St5Vi-0006Lc-7D for 10519@debbugs.gnu.org; Sun, 22 Jul 2012 19:24:28 -0400 Original-Received: from mail.lysator.liu.se (localhost [127.0.0.1]) by mail.lysator.liu.se (Postfix) with ESMTP id 5AE1640006; Mon, 23 Jul 2012 01:17:54 +0200 (CEST) Original-Received: from stalhein.lysator.liu.se (stalhein.lysator.liu.se [IPv6:2001:6b0:17:f0a0::cc]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.lysator.liu.se (Postfix) with ESMTPS id 0B5AD40005; Mon, 23 Jul 2012 01:17:53 +0200 (CEST) Original-Received: from stalhein.lysator.liu.se (localhost [127.0.0.1]) by stalhein.lysator.liu.se (8.14.4+Sun/8.14.4) with ESMTP id q6MNHrqG015301; Mon, 23 Jul 2012 01:17:53 +0200 (MEST) Original-Received: (from nisse@localhost) by stalhein.lysator.liu.se (8.14.4+Sun/8.14.4/Submit) id q6MNHq3U015300; Mon, 23 Jul 2012 01:17:52 +0200 (MEST) X-Authentication-Warning: stalhein.lysator.liu.se: nisse set sender to nisse@lysator.liu.se using -f In-Reply-To: <874np05fwz.fsf@gnu.org> ("Ludovic =?UTF-8?Q?Court=C3=A8s?="'s message of "Sun, 22 Jul 2012 11:00:28 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (usg-unix-v) X-Virus-Scanned: ClamAV using ClamSMTP X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 140.186.70.43 X-BeenThere: bug-guile@gnu.org List-Id: "Bug reports for GUILE, GNU's Ubiquitous Extension Language" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Original-Sender: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.bugs:6457 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable ludo@gnu.org (Ludovic Court=C3=A8s) writes: > Reviving the discussion, as we=E2=80=99ve been discussing this at the GHM= , and > some people would really like to see it happen. :-) Great! Any summary of the discussion, for those of us who couldn't make it there? > nisse@lysator.liu.se (Niels M=C3=B6ller) skribis: > >> To try that out, I'm working with a slightly patched guile: > > Do you still have the patch around? I'm attaching a patch from I tree I have around, without reading it carefully. I'm not sure this is the latest version I worked with. Maybe it's of some use. >> 1. The header file libguile.h. As far as I understand, this is a public >> header file and it's use of means that the public guile ABI >> depends on gmp. > > The problem is that there=E2=80=99s a public API dealing with mpz_t: Exactly. To me, that seems like a potentially hairy problem to get right. > SCM_API void scm_to_mpz (SCM x, mpz_t rop); > SCM_API SCM scm_from_mpz (mpz_t rop); > > So, when mini-gmp is used, a header should be installed as well, > say under . WDYT? Maybe it would make sense with a level of indirection. User's could include libguile/bignum.h, which would in turn include either mini-gmp.h or the real gmp.h, depending on how guile was configured. Users may also need some way of figuring out if they need to link with -lgmp or not. >> Since mini-gmp is not binary compatible, > > I don=E2=80=99t think there=E2=80=99s a problem, because only mpz_t objec= ts appear in > the API, and they=E2=80=99re pointers. mpz_t is a typedef, which is a single element array of a semi-internal struct. So when you declare mpz_t x; you are really declaring a struct, not a pointer (and then the array type automatically "decays" to a pointer when passed as a function argument). But it's likely that mini-gmp will use the same size of that struct. And even the same layout. I think the main ABI incompatibilities are that 1. symbol names, as seen by the linker, are different. With gmp, mpz_foo is a name mangling #define, and the real name is ___gmpz_foo. mini-gmp doesn't do that. 2. mp_limb_t may be of different size: With mini-gmp, it's always unsigned long, with gmp it's unsigned long long on some platforms (notably 64-bit windows, I think). Hmm, or if you're saying that the use of mpz_t in guile's public API is pointers only, that that might make things a little simpler. But things will still break badly if the user's code is linked with gmp and guile uses mini-gmp, or vice versa. >> 4. mini-gmp has no mp_set_memory_functions. That's added now, with the subtle difference that mini-gmp doesn't pass a valid size for the old_size argument for the free and realloc functions. I don't think guile depends on that feature. Please also note that the most recent version of mini-gmp is now the one included in the main gmp repo. --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=guile-mini-gmp.patch diff --git a/configure.ac b/configure.ac index a32ff4b..089dfbe 100644 --- a/configure.ac +++ b/configure.ac @@ -146,6 +146,10 @@ AC_ARG_ENABLE(regex, [ --disable-regex omit regular expression interfaces],, enable_regex=yes) +AC_ARG_ENABLE(gmp, + [ --disable-gmp omit high performance bignums],, + enable_gmp=yes) + AC_ARG_ENABLE([deprecated], AS_HELP_STRING([--disable-deprecated],[omit deprecated features])) @@ -869,15 +873,20 @@ fi AC_CACHE_SAVE dnl GMP tests +if test "x$enable_gmp" != xno ; then AC_LIB_HAVE_LINKFLAGS([gmp], [], [#include ], [mpz_import (0, 0, 0, 0, 0, 0, 0);]) if test "x$HAVE_LIBGMP" != "xyes"; then - AC_MSG_ERROR([GNU MP 4.1 or greater not found, see README]) + AC_MSG_NOTICE([GNU MP 4.1 or greater not found, see README]) + enable_gmp=no +fi +fi +if test "x$enable_gmp" = xno ; then + AC_LIBOBJ([mini-gmp]) fi - dnl GNU libunistring is checked for by Gnulib's `libunistring' module. if test "x$LTLIBUNISTRING" = "x"; then AC_MSG_ERROR([GNU libunistring is required, please install it.]) @@ -1253,7 +1262,7 @@ main (int argc, char **argv) # Boehm's GC library # #-------------------------------------------------------------------- -PKG_CHECK_MODULES([BDW_GC], [bdw-gc]) +# PKG_CHECK_MODULES([BDW_GC], [bdw-gc]) save_LIBS="$LIBS" LIBS="$BDW_GC_LIBS $LIBS" diff --git a/libguile.h b/libguile.h index 7ac98a5..457dd66 100644 --- a/libguile.h +++ b/libguile.h @@ -22,8 +22,11 @@ /* This needs to be included outside of the extern "C" block. */ +#if HAVE_LIBGMP #include - +#else +#include "libguile/mini-gmp.h" +#endif #ifdef __cplusplus extern "C" { #endif diff --git a/libguile/bytevectors.c b/libguile/bytevectors.c index 811e8d8..240e457 100644 --- a/libguile/bytevectors.c +++ b/libguile/bytevectors.c @@ -24,7 +24,11 @@ #include #include +#if HAVE_LIBGMP #include +#else +#include "mini-gmp.h" +#endif #include "libguile/_scm.h" #include "libguile/extensions.h" diff --git a/libguile/init.c b/libguile/init.c index 35ab856..bb79422 100644 --- a/libguile/init.c +++ b/libguile/init.c @@ -29,7 +29,11 @@ #include #include #include +#if HAVE_LIBGMP #include +#else +#include "mini-gmp.h" +#endif #include "libguile/_scm.h" diff --git a/libguile/numbers.h b/libguile/numbers.h index b7bcfe4..166f222 100644 --- a/libguile/numbers.h +++ b/libguile/numbers.h @@ -22,9 +22,11 @@ */ - +#ifdef HAVE_LIBGMP #include - +#else +#include "mini-gmp.h" +#endif #include "libguile/__scm.h" #include "libguile/print.h" diff --git a/libguile/random.c b/libguile/random.c index 8bc0d87..c216245 100644 --- a/libguile/random.c +++ b/libguile/random.c @@ -25,7 +25,11 @@ #include "libguile/_scm.h" +#if HAVE_LIBGMP #include +#else +#include "mini-gmp.h" +#endif #include #include #include diff --git a/libguile/socket.c b/libguile/socket.c index d085d33..5ec20a2 100644 --- a/libguile/socket.c +++ b/libguile/socket.c @@ -25,7 +25,11 @@ #endif #include +#if HAVE_LIBGMP #include +#else +#include "mini-gmp.h" +#endif #include "libguile/_scm.h" #include "libguile/arrays.h" --=-=-= Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable Regards, /Niels --=20 Niels M=F6ller. PGP-encrypted email is preferred. Keyid C0B98E26. Internet email is subject to wholesale government surveillance. --=-=-=--