Tuesday, March 11, 2008

Building GCC 4.2.1 On Solaris

Alex and I are currently trying to implement a 64bit version of Firebird 2.x for Solaris 10, and we are running into a number of problems. However they shouldn't be insurmountable. Every port has its problems one way or another, but this one is proving to be particularly annoying....

The default version of gcc shipped with Solaris 10 is 3.4.3 and is found in /usr/sfw/bin
The current available version of gcc (released is) 4.3
So the version Sun makes available dates from 2005...
One assumes that Sun has no interest in letting Solaris users use more modern versions of gcc and would rather we use their own compiler.
Hmm so much for Sun and open source...

But to properly compile on Solaris 10 with 64bit see notes from gcc.gnu.org

"
i?86-*-solaris2.10
Use this for Solaris 10 or later on x86 and x86-64 systems. This configuration is supported by GCC 4.0 and later versions only.

It is recommended that you configure GCC to use the GNU assembler in /usr/sfw/bin/gas but the Sun linker, using the options --with-gnu-as --with-as=/usr/sfw/bin/gas --without-gnu-ld --with-ld=/usr/ccs/bin/ld"

So gcc 4.0 is the lowest version you can use for cross-compiling 32bit and 64bit applications on Solaris 10...

So we have to build our own gcc to do the firebird compilation, here's how you do it....
1. Download a copy of the gcc source (e.g. gcc-4.1.2.tar.gz) from gcc.gnu.org
2. Install gnu tar, solaris tar has problems extracting the source from the gcc tar file.
3. You will probably need to install libintl too (you can get a pre-built version of this froim www.sunfreeware.com)
4. gunzip gcc-4.1.2.tar.gz
5. /usr/local/bin/tar -xvf gcc-4.1.2.tar
6. cd gcc-4.1.2
7. mkdir objdir
8. cd objdir
9. ../configure --with-gnu-as --with-as=/usr/sfw/bin/gas --without-gnu-ld --with-ld=/usr/ccs/bin/ld --enable-shared --enable-languages=c,c++
10. gmake
11. as root - make install

Your new version of gcc will be installed in /usr/local/bin

5 comments:

jamesd_wi said...

now if you can just make 3rd party plugins that only come in 32bit version work in the 64bit browser, it might be worth your effort.

to me its just a lot of time wasted as I never few files larger than 2GB dispite my attempts to keep tabs open needlessly and firefox's poor memory managment I haven't got it to use more than 1GB of ram, so here again there is no reason for a 64bit browser.

Paul Beach said...

Firefox? This is about Firebird. This is a relational database not a browser.

Jonathan King said...

thanks for your overview. it was a real help, and i don't think i could have gotten it done otherwise. my only suggestion is that you might change "make" to "gmake" in your instructions. sun make fails to compile gcc, but gnu make seems to be chugging right along...

Pourhaus said...

Thanks for the overview, but I am not sure you covered everything. I wrote a blog on how I did it, including getting RPATH right (so that there is no need to set LD_LIBRARY_PATH).

Regards,
Tim

CS said...

Thanks Paul!