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

Jonathan Blanchard BlanchardJ at ieee.org
Sun Feb 7 14:44:24 CET 2010


On Sat, Feb 6, 2010 at 9:26 PM, William Bader <williambader at hotmail.com> wrote:
>
> Hi Marc,
>
> Thanks for the reply.
>
>>http://www.google.fr/search?source=ig&hl=fr&rlz=1G1GGLQ_FRFR359&q=ld.so.1%3A+t-bswap%3A+fatal%3A+%2Fusr%2Flocal%2Flib%2Flibgcc_s.so.1%3A+wrong+ELF+class%3A+ELFCLASS32&meta=lr%3D&aq=f&oq=
>
> 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
> "ld.so.1: t-bswap: fatal: /usr/local/lib/libgcc_s.so.1: 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)
> or
> "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 hotmail.com 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 http://www.sunfreeware.com/
> 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,
> William
> williambader at hotmail.com
>
>

Hi,

I do not like doing self promotion but I did write a small guide about
building a multi-lib GCC on Solaris which also contains the
informations about how to correctly set the RPATH of the different
components.

It can be found here :

http://jblopen.com/node/16

I wrote the guide in response the rather large amount of people
seeking help in building gcc on Solaris whether here or on the GCC
mailing list or even coming to the Blastwave irc channel for help.

In a more general context though, this situation is not specific to
GMP or GCC but will affect all software built on Solaris. GMP and MPFR
are certainly not the only piece of code defaulting to different ABI.
As such, the RPATH and bitness issues are just a reality of how the
Solaris platform works. On that respect, I must say that the GMP
configure script is very well behaved on Solaris and is of very good
quality compared to a lot stuff available from the OpenSource world.

I agree though that the Internet maybe needs more "building stuff on
Solaris" guides. As a reference I would however recommend the Solaris
64-bit Developer's Guide which contains most of the needed information
about the different ABI and dynamic linking issues on Solaris. It is
available for download freely :

http://docs.sun.com/app/docs/doc/816-5138

Cheers,

Jonathan Blanchard


More information about the gmp-bugs mailing list