Skip Menu |

This queue is for tickets about the Math-GMPz CPAN distribution.

Report information
The Basics
Id: 46604
Status: resolved
Priority: 0/
Queue: Math-GMPz

People
Owner: Nobody in particular
Requestors: jonathan [...] leto.net
Cc:
AdminCc:

Bug Information
Severity: Critical
Broken in: 0.27
Fixed in: (no value)



Subject: Math::GMPz 0.27 uses __GMP_CC and __GMP_CFLAGS which require recent versions of GMP
These flags were added to GMP on 2008-07-23, the relevant part of the GMP Changelog: 2008-07-23 Torbjorn Granlund <tege@gmplib.org> * gmp-h.in (__GMP_CC): New define, undocumented for now. (__GMP_CFLAGS): Likewise. I think this corresponds to version 4.2.3, since I have 4.2.2 and it I do not have such defines in my gmp.h : cp GMPz.pm blib/lib/Math/GMPz.pm /usr/bin/perl5.10 /opt/local/lib/perl5/5.10.0/ExtUtils/xsubpp -typemap /opt/local/lib/perl5/5.10.0/ExtUtils/typemap -typemap typemap GMPz.xs > GMPz.xsc && mv GMPz.xsc GMPz.c cc -c -I/opt/local/include -I/opt/local/include -fno-common -DPERL_DARWIN -no-cpp-precomp -fno-strict-aliasing -pipe -I/usr/local/include -I/opt/local/include -O3 -DVERSION=\"0.27\" -DXS_VERSION=\"0.27\" "-I/opt/local/lib/perl5/5.10.0/darwin-2level/CORE" -DNEWPERL GMPz.c GMPz.xs: In function ‘Rmpz_get_d_2exp’: GMPz.xs:365: warning: pointer targets in passing argument 1 of ‘__gmpz_get_d_2exp’ differ in signedness GMPz.xs: In function ‘___GMP_CC’: GMPz.xs:3905: error: ‘__GMP_CC’ undeclared (first use in this function) GMPz.xs:3905: error: (Each undeclared identifier is reported only once GMPz.xs:3905: error: for each function it appears in.) GMPz.xs: In function ‘___GMP_CFLAGS’: GMPz.xs:3910: error: ‘__GMP_CFLAGS’ undeclared (first use in this function) make: *** [GMPz.o] Error 1 Are the flags still undocumented in GMP? That kind of determines where to go from here.
On Tue Jun 02 04:20:04 2009, LETO wrote: Show quoted text
> * gmp-h.in (__GMP_CC): New define, undocumented for now. > (__GMP_CFLAGS): Likewise. > > I think this corresponds to version 4.2.3, since I have 4.2.2 and it I > do not have such defines in my gmp.h :
Yes - first defined in 4.2.3, and still not documented. I included them because it could be very handy to know what these defines are (without having to rely on the user to correctly dig them up himself - a tricky task if there are multiple versions of the gmp library kicking around). Show quoted text
> Are the flags still undocumented in GMP? That kind of determines where > to go from here.
I just fired off a post to the GMP mailing list to see what was planned - Torbjorn Granlund is of the opinion that those defines should be documented (and that it's an oversight they weren't documented right from the start). Vincent Lefevre suggested that the Math::GMPz build should not fail if the defines are unavailable - perl should simply return undef for them. I think he's right, and that's the way I'd like to implement it (and should have implemented it in 0.27). Does that seem reasonable to you ? Try these alterations to ___GMP_CC() and ___GMP_CFLAGS()in GMPz.xs: ############################# SV * ___GMP_CC() { +#ifdef __GMP_CC char * ret = __GMP_CC; return newSVpv(ret, 0); +#else + return &PL_sv_undef; +#endif } SV * ___GMP_CFLAGS() { +#ifdef __GMP_CFLAGS char * ret = __GMP_CFLAGS; return newSVpv(ret, 0); +#else + return &PL_sv_undef; +#endif } ############################# Then apply the attached patch to t/aa_basic.t and see how it all fares. Cheers, Rob
--- aa_basic.t Thu May 14 02:15:14 2009 +++ aa_basic.t_new Tue Jun 2 23:30:11 2009 @@ -2,12 +2,12 @@ use strict; use Math::GMPz qw(__GNU_MP_VERSION __GNU_MP_VERSION_MINOR __GNU_MP_VERSION_PATCHLEVEL); -print "1..7\n"; +print "1..9\n"; warn "\n# Using Math::GMPz version ", $Math::GMPz::VERSION, "\n"; warn "# Using gmp library version ", Math::GMPz::gmp_v(), "\n"; -warn "# CC is ", Math::GMPz::__GMP_CC, "\n"; -warn "# CFLAGS are ", Math::GMPz::__GMP_CFLAGS, "\n"; +warn "# CC is ", Math::GMPz::__GMP_CC, "\n" if defined Math::GMPz::__GMP_CC; +warn "# CFLAGS are ", Math::GMPz::__GMP_CFLAGS, "\n" if defined Math::GMPz::__GMP_CFLAGS; if($Math::GMPz::VERSION eq '0.27') {print "ok 1\n"} else {print "not ok 1 $Math::GMPz::VERSION\n"} @@ -38,4 +38,16 @@ else { warn "$@\n"; print "not ok 7\n" +} + +my $version_num = version_num(__GNU_MP_VERSION, __GNU_MP_VERSION_MINOR, __GNU_MP_VERSION_PATCHLEVEL); + +print $version_num < 262659 ? !defined(Math::GMPz::__GMP_CC) ? "ok 8\n" : "not ok 8\n" + : defined(Math::GMPz::__GMP_CC) ? "ok 8\n" : "not ok 8\n"; + +print $version_num < 262659 ? !defined(Math::GMPz::__GMP_CFLAGS) ? "ok 9\n" : "not ok 9\n" + : defined(Math::GMPz::__GMP_CFLAGS) ? "ok 9\n" : "not ok 9\n"; + +sub version_num { + return ($_[0] << 16) | ($_[1] << 8) | $_[2]; }
Fixed with release of Math-GMPz-0.28.