gmp 5.1.1 Solaris 10 & 11 on x86 using Studio 12.3 ABI32 doesn't compile with --disable-assembly

Mark Ashley mark at ibiblio.org
Wed May 15 09:39:52 CEST 2013


Solaris 10 and 11 on x86
Oracle Studio Compiler 12.3
gmake 3.82

If I set the ABI to 32 then the tests/.libs/libtests.a file has different
symbols than if it is compiled with ABI 64.

The recipe I tried:
    setenv CC cc
    setenv CXX CC
    setenv M4 /usr/local/bin/m4
    cd /var/tmp
    rm -rf gmp-5.1.1
    xz -dc /usr/local/src/gnu/gmp-5.1.1.tar.xz | gtar -xvf -
    cd gmp-5.1.1
    ./configure --prefix=/usr/local \
        --disable-assembly
    gmake
    gmake check


setenv ABI 32

libtool: compile:  cc -D_STDC_C99= -DHAVE_CONFIG_H -I. -I.. -I.. -O
-DNO_ASM -c trace.c -o trace.o >/dev/null 2>&1
/bin/bash ../libtool --tag=CC   --mode=link cc -D_STDC_C99=  -O -DNO_ASM
-o libtests.la  memory.lo misc.lo refmpf.lo refmpn.lo refmpq.lo refmpz.lo
spinner.lo trace.lo  ../libgmp.la
libtool: link: ar cq .libs/libtests.a .libs/memory.o .libs/misc.o
.libs/refmpf.o .libs/refmpn.o .libs/refmpq.o .libs/refmpz.o .libs/spinner.o
.libs/trace.o
libtool: link: ranlib .libs/libtests.a
libtool: link: ( cd ".libs" && rm -f "libtests.la" && ln -s "../libtests.la"
"libtests.la" )
cc -D_STDC_C99= -DHAVE_CONFIG_H -I. -I.. -I..    -O -DNO_ASM -c t-bswap.c
"../gmp-impl.h", line 3646: warning:  attribute "mode" is unknown, ignored
"../gmp-impl.h", line 3647: warning:  attribute "mode" is unknown, ignored
"../gmp-impl.h", line 3648: warning:  attribute "mode" is unknown, ignored
"../gmp-impl.h", line 3649: warning:  attribute "mode" is unknown, ignored
"../gmp-impl.h", line 3650: warning:  attribute "mode" is unknown, ignored
/bin/bash ../libtool --tag=CC   --mode=link cc -D_STDC_C99=  -O -DNO_ASM
-o t-bswap t-bswap.o libtests.la ../libgmp.la
libtool: link: cc -D_STDC_C99= -O -DNO_ASM -o .libs/t-bswap t-bswap.o
./.libs/libtests.a /var/tmp/gmp-5.1.1/.libs/libgmp.so ../.libs/libgmp.so
-R/gmp/lib
ld: warning: file ../.libs/libgmp.so: linked to
/var/tmp/gmp-5.1.1/.libs/libgmp.so: attempted multiple inclusion of file
Undefined                       first referenced
 symbol                             in file
x86_fldcw                           ./.libs/libtests.a(misc.o)
x86_fstcw                           ./.libs/libtests.a(misc.o)
ld: fatal: Symbol referencing errors. No output written to .libs/t-bswap
gmake[4]: *** [t-bswap] Error 2
gmake[4]: Leaving directory `/var/tmp/gmp-5.1.1/tests'
gmake[3]: *** [check-am] Error 2
gmake[3]: Leaving directory `/var/tmp/gmp-5.1.1/tests'
gmake[2]: *** [check-recursive] Error 1
gmake[2]: Leaving directory `/var/tmp/gmp-5.1.1/tests'
gmake[1]: *** [check-recursive] Error 1
gmake[1]: Leaving directory `/var/tmp/gmp-5.1.1'
gmake: *** [check] Error 2

host:/var/tmp/gmp-5.1.1/tests/.libs root# nm libtests.a | grep x86
[78]    |         0|       0|FUNC |GLOB |0    |UNDEF  |x86_fldcw
[77]    |         0|       0|FUNC |GLOB |0    |UNDEF  |x86_fstcw

host:/var/tmp/gmp-5.1.1 root# grep ^# config.h > /var/tmp/gmp.config.h.32



setenv ABI 64

libtool: compile:  cc -D_STDC_C99= -DHAVE_CONFIG_H -I. -I.. -I.. -xO3 -m64
-DNO_ASM -c trace.c -o trace.o >/dev/null 2>&1
/bin/bash ../libtool --tag=CC   --mode=link cc -D_STDC_C99=  -xO3 -m64
-DNO_ASM   -o libtests.la  memory.lo misc.lo refmpf.lo refmpn.lo refmpq.lo
refmpz.lo spinner.lo trace.lo  ../libgmp.la
libtool: link: ar cq .libs/libtests.a .libs/memory.o .libs/misc.o
.libs/refmpf.o .libs/refmpn.o .libs/refmpq.o .libs/refmpz.o .libs/spinner.o
.libs/trace.o
libtool: link: ranlib .libs/libtests.a
libtool: link: ( cd ".libs" && rm -f "libtests.la" && ln -s "../libtests.la"
"libtests.la" )
cc -D_STDC_C99= -DHAVE_CONFIG_H -I. -I.. -I..    -xO3 -m64 -DNO_ASM -c
t-bswap.c
"../gmp-impl.h", line 3646: warning:  attribute "mode" is unknown, ignored
"../gmp-impl.h", line 3647: warning:  attribute "mode" is unknown, ignored
"../gmp-impl.h", line 3648: warning:  attribute "mode" is unknown, ignored
"../gmp-impl.h", line 3649: warning:  attribute "mode" is unknown, ignored
"../gmp-impl.h", line 3650: warning:  attribute "mode" is unknown, ignored
/bin/bash ../libtool --tag=CC   --mode=link cc -D_STDC_C99=  -xO3 -m64
-DNO_ASM   -o t-bswap t-bswap.o libtests.la ../libgmp.la
libtool: link: cc -D_STDC_C99= -xO3 -m64 -DNO_ASM -o .libs/t-bswap
t-bswap.o  ./.libs/libtests.a /var/tmp/gmp-5.1.1/.libs/libgmp.so
../.libs/libgmp.so -R/gmp/lib
ld: warning: file ../.libs/libgmp.so: linked to
/var/tmp/gmp-5.1.1/.libs/libgmp.so: attempted multiple inclusion of file
cc -D_STDC_C99= -DHAVE_CONFIG_H -I. -I.. -I..    -xO3 -m64 -DNO_ASM -c
t-constants.c
"../gmp-impl.h", line 3646: warning:  attribute "mode" is unknown, ignored
"../gmp-impl.h", line 3647: warning:  attribute "mode" is unknown, ignored
"../gmp-impl.h", line 3648: warning:  attribute "mode" is unknown, ignored
"../gmp-impl.h", line 3649: warning:  attribute "mode" is unknown, ignored
"../gmp-impl.h", line 3650: warning:  attribute "mode" is unknown, ignored
/bin/bash ../libtool --tag=CC   --mode=link cc -D_STDC_C99=  -xO3 -m64
-DNO_ASM   -o t-constants t-constants.o libtests.la ../libgmp.la
libtool: link: cc -D_STDC_C99= -xO3 -m64 -DNO_ASM -o .libs/t-constants
t-constants.o  ./.libs/libtests.a /var/tmp/gmp-5.1.1/.libs/libgmp.so
../.libs/libgmp.so -R/gmp/lib
ld: warning: file ../.libs/libgmp.so: linked to
/var/tmp/gmp-5.1.1/.libs/libgmp.so: attempted multiple inclusion of file
cc -D_STDC_C99= -DHAVE_CONFIG_H -I. -I.. -I..    -xO3 -m64 -DNO_ASM -c
t-count_zeros.c

host:/var/tmp/gmp-5.1.1/tests/.libs root# nm libtests.a | grep x86
host:/var/tmp/gmp-5.1.1/tests/.libs root#

host:/var/tmp/gmp-5.1.1 root# grep ^# config.h > /var/tmp/gmp.config.h.64

Note the different HAVE_HOST_CPU_FAMILY defines:

host:/var/tmp/gmp-5.1.1 root# diff /var/tmp/gmp.config.h.32
/var/tmp/gmp.config.h.64
25c25
< #define HAVE_HOST_CPU_FAMILY_x86 1
---
> #define HAVE_HOST_CPU_FAMILY_x86_64 1
85c85
< #define SIZEOF_MP_LIMB_T 4
---
> #define SIZEOF_MP_LIMB_T 8
87c87
< #define SIZEOF_UNSIGNED_LONG 4
---
> #define SIZEOF_UNSIGNED_LONG 8
89c89
< #define SIZEOF_VOID_P 4
---
> #define SIZEOF_VOID_P 8


This extra code is added for ABI 32 only compiles:

host:/var/tmp/gmp-5.1.1 root# cat -n tests/misc.c
[...]
   461
   462  /* Set the hardware floating point rounding mode.  Same mode values
as mpfr,
   463     namely 0=nearest, 1=tozero, 2=up, 3=down.  Return 1 if
successful, 0 if
   464     not.  */
   465  int
   466  tests_hardware_setround (int mode)
   467  {
   468  #if HAVE_HOST_CPU_FAMILY_x86
   469    int  rc;
   470    switch (mode) {
   471    case 0: rc = 0; break;  /* nearest */
   472    case 1: rc = 3; break;  /* tozero  */
   473    case 2: rc = 2; break;  /* up      */
   474    case 3: rc = 1; break;  /* down    */
   475    default:
   476      return 0;
   477    }
   478    x86_fldcw ((x86_fstcw () & ~0xC00) | (rc << 10));
   479    return 1;
   480  #endif
   481
   482    return 0;
   483  }
   484
   485  /* Return the hardware floating point rounding mode, or -1 if
unknown. */
   486  int
   487  tests_hardware_getround (void)
   488  {
   489  #if HAVE_HOST_CPU_FAMILY_x86
   490    switch ((x86_fstcw () & ~0xC00) >> 10) {
   491    case 0: return 0; break;  /* nearest */
   492    case 1: return 3; break;  /* down    */
   493    case 2: return 2; break;  /* up      */
   494    case 3: return 1; break;  /* tozero  */
   495    }
   496  #endif
   497
   498    return -1;
   499  }
   500
[...]


But the calls to x86call.asm for the x86_fldcw and x86_fstcw routines
clashes with the -DNO_ASM directive........

Changing the compile recipe to this:

    setenv ABI 32
    setenv CC cc
    setenv CXX CC
    setenv M4 /usr/local/bin/m4
    cd /var/tmp
    rm -rf gmp-5.1.1
    xz -dc /usr/local/src/gnu/gmp-5.1.1.tar.xz | gtar -xvf -
    cd gmp-5.1.1
    ./configure --prefix=/usr/local \
        --disable-assembly
    gmake
    /bin/perl -pe 's#HAVE_HOST_CPU_FAMILY_x86#HAVE_HOST_CPU_FAMILY_x86  &&
! defined (NO_ASM)#' -i tests/misc.c
    gmake check

lets the gmake check finish and pass all tests for ABI32 with
--disable-assembly

The root cause lines (fixed):
host:/var/tmp/gmp-5.1.1 root# grep -n FAMILY tests/misc.c
468:#if HAVE_HOST_CPU_FAMILY_x86  && ! defined (NO_ASM)
489:#if HAVE_HOST_CPU_FAMILY_x86  && ! defined (NO_ASM)

ta,
Mark.


More information about the gmp-bugs mailing list