gmp, gcc and Solaris 10 (Was: RE: your mail)

William Bader williambader at
Sun Feb 7 02:26:24 CET 2010

Hi Marc,

Thanks for the reply.


That query returns 10 hits, mostly people with the same problem asking for help.  Two of them had replies saying either that LD_LIBRARY_PATH was wrong or that the C compiler was bad.  None of them mentions setting ABI=32.  I suspect that most of the people are in my situation of building gmp only for the purpose of building gcc, and once they figure out that they need /usr/local/lib/sparcv9 on LD_LIBRARY_PATH to build a 64 bit gmp, they will get stuck when gcc defaults to a 32 bit build and the gcc configure or make fails.

I did a similar query on the link error before posting to the list.

I'm sure that it would be possible to find a google query that would show the solution, but it is a lot harder to write the query if you don't already know the answer.  That is why I suggested placing the information somewhere more visible than postings in the mailing list.  It will only save you work when the next person has the same question.

I will even offer that if anyone reading this has the error
" t-bswap: fatal: /usr/local/lib/ wrong ELF class: ELFCLASS32"
building gmp or mpfr or has issues with gmp or mpfr when building gcc, like
"ld: warning: file ../build-sparc-sun-solaris2.10/libiberty/libiberty.a(hashtab.o): wrong ELF class: ELFCLASS64" (from trying to force a 64 bit gcc build with CFLAGS=-m64)
"init2.c:37:  assertion failed: ((64 - 0)+0) == (((64 - 0)+0)/8) * 8 && sizeof(mp_limb_t) == (((64 - 0)+0)/8)" (I think from using a 32 bit gcc compiled with a 64 bit header)
they can write to me at williambader at and I will explain how I ran export ABI=32, built gmp, built mpfr with --with-gmp=/usr/local and send my script for building gcc.

>It doesn't happen when you use a version of gcc currently provided by Sun.

I am using gcc-3.4.6 for SPARC/Solaris 10 from
I have as and ld from Sun in /usr/ccs/bin/, but I do not have Sun cc.

>it defaults to 64 where others default to 32, so more people hit the problem (most of them don't actually want a 64 bit version).

I usually build 32 bit applications, so I didn't realize that "wrong ELF class" meant that I had tried to mix 32 and 64 bit objects.

Why is it necessary to have a default?
Could gmp and mpfr build both 32 and 64 bit libraries?

Back in MSDOS days 25 years ago, I had tiny, small, medium, large, and huge memory-model versions of some libraries.
The header files had #ifdefs based on settings passed by the compiler, and each instance of the library had its own special prefix or directory.

>And the easiest when you are only trying to build gcc is to let gcc build gmp and mpfr for you, as documented in gcc.

I would have tried that next.  gcc-4.4.3/INSTALL/prerequisites.html mentions it as a second option if gmp is not installed on your search path: "Alternatively, if a GMP source distribution is found in a subdirectory of your GCC sources named gmp, it will be built together with GCC."

I didn't try that first because 1) my Sun is slow (the gcc-core "make bootstrap" takes over 10 hours) and I didn't want to build or debug anything extra inside the gcc build and 2) I haven't needed to do that since a long time ago when I built cross-compilers and I had to include gas, binutils, gdb, etc. inside the gcc source tree.

I don't have time to reply again, but I hope that this will get into the mailing list archive so someone else who has the same problem might find it instead of posting.

Warm regards,
williambader at

Hotmail: Powerful Free email with security by Microsoft.

More information about the gmp-bugs mailing list