gmp problem under darwin powerpc

Denis Excoffier Cygwin at Denis-Excoffier.org
Thu Jul 19 14:03:28 CEST 2012


Hello,

We have a problem in mpc under darwin/powerpc. It seems related to
gmp (5.0.5). Look at this:

% cat e.c
#include <stdio.h>
#include "gmp.h"

int
main()
{
  mpz_t a;
  int ret;
  mpz_init (a);
  mpz_set_str (a, "13017918183496977133775209079164003070786863049686786465873731362497345253379866083852810820103005813030391929785402872601518953148250859762321945896609724349178326747526622443454716367524", 10);
  gmp_printf ("a=%Zd\n", a);
  ret = mpz_perfect_square_p (a);
  printf ("ret=%d\n", ret);
  mpz_clear (a);
}
% ./config.guess
powerpc-apple-darwin9.8.0
% gcc --version | head -1
gcc (GCC) 4.7.1
% gcc -O0 -g -o e.o -I.../gmp/include -c e.c
% gcc -O0 -g -o e e.o -L.../gmp/lib -lgmp
% ./e
a=13017918183496977133775209079164003070786863049686786465873731362497345253379866083852810820103005813030391929785402872601518953148250859762321945896609724349178326747526622443454716367524
Segmentation fault
% gdb ./e
...
(gdb) run
...
Reading symbols for shared libraries +++. done
a=13017918183496977133775209079164003070786863049686786465873731362497345253379866083852810820103005813030391929785402872601518953148250859762321945896609724349178326747526622443454716367524

Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_INVALID_ADDRESS at address: 0x00200000
0x000793c0 in __gmpn_mod_34lsub1 ()
(gdb) where
#0  0x000793c0 in __gmpn_mod_34lsub1 ()
#1  0x00080da4 in __gmpn_perfect_square_p ()
#2  0x00001e84 in main () at e.c:12
(gdb) 


I compiled gmp-5.0.5 with default options (ie no specific CFLAGS from
myself), which brings -O2 and -force_cpusubtype_ALL, and all tests
passed.
If i compile using "setenv CFLAGS -O0" (csh syntax), compilation fails
with 92 messages like (this one is the first one):

tmp-mod_34lsub1.s:166:vxor vector instruction is optional for the PowerPC (not allowed without -force_cpusubtype_ALL option)
(with vxor replaced sometimes with lvx, vsldoi, vadduwm etc.)

If i compile using -O0 -force_cpusubtype_ALL, compilation is OK.

My GCC is 4.7.1 bootstrapped 3 stages, with 1st stage under Xcode 3.1.4,
with sources of gmp-5.0.5, mpfr-3.1.1 and mpc-1.0.0rc1 included within
the build tree (i mean: if you feel suspicious towards the compiler...).

I would suggest that you add the e.c above (thanks to Paul Zimmermann)
to your testsuite.

Regards,

Denis Excoffier.


More information about the gmp-bugs mailing list