ABI defaults

Niels Möller nisse at lysator.liu.se
Wed Nov 17 10:08:22 CET 2010


By default, gmp's configure selects what it considers to be the best
available ABI, and it can be overridden manually with ABI=32 or ABI=64.

Can I pass any flag to configure to tell it that I want whatever ABI is
the compiler's default, so that after make install,

  gcc foo.c -lgmp

will just work (assuming the same gcc was used for compiling gmp)? I'd
prefer not to have to write my own shell scripts to figure out things
like

  1. which compiler to use (using the same rules as configure)

  2. identify that compiler's default ABI

before invoking configure. That seems booth complex and fragile, and
better left for configure to do.

The system where I have observed problems: sparc-solaris systems with
gcc, where ./configure && make && make install in gmp builds 64-bit
objects, while gcc by default produces 32-bit objects. I get errors like

  configure:10269: result: yes
  configure:10283: checking for __gmpz_getlimbn in -lgmp
  configure:10318: gcc -o conftest -g -O2  -I/export/xenofarm/xenofarm/client/lsh/mothra.roxen.com/buildtmp/dist/pfx/include -I/usr/local/include  -L/export/xenofarm/xenofarm/client/lsh/mothra.roxen.com/buildtmp/dist/pfx/lib -L/usr/local/lib conftest.c -lgmp   >&5
  ld: warning: file /export/xenofarm/xenofarm/client/lsh/mothra.roxen.com/buildtmp/dist/pfx/lib/libgmp.a(getlimbn.o): wrong ELF class: ELFCLASS64
  Undefined			first referenced
   symbol				    in file
  __gmpz_getlimbn                     /var/tmp//ccImphhS.o
  ld: fatal: Symbol referencing errors. No output written to conftest
  collect2: ld returned 1 exit status
  configure:10325: $? = 1

This is when running nettle's configure script; just before this,
gmp-5.0.1 was built and installed with
--prefix=/export/xenofarm/xenofarm/client/lsh/mothra.roxen.com/buildtmp/dist/pfx
--disable-shared. (configure for lsh tests the same thing).

In Nettle I have similar ABI detection needs as GMP, but I approach it
somewhat differently. I always let the compiler choose ABI (so to
configure the ABI, the user would need to pass something like
CFLAGS=-m64 or CC="gcc -m64"). Then I detect the ABI used by looking for
preprocessor symbols like __x86_64__, __sparcv9 and __arch64__, and use
this to select the correct assembler files. And finallly, I also tweak
the libdir default depending on the detected ABI.

Regards,
/Niels

PS. I'm not subscribed to this list, so please cc me on replies.

-- 
Niels Möller. PGP-encrypted email is preferred. Keyid C0B98E26.
Internet email is subject to wholesale government surveillance.



More information about the gmp-discuss mailing list