Jax RCFB Sun Solaris Tip: Building 64-bit GCC 3.x



Disclaimer: No warranty or guarantee applies to this tip. This tip and all Jax RCFB Sun Solaris Tips are garnered solely from the author's own experience and the experience of his acquaintances.

Note: For best results, please read the entire document before proceeding.

2001-10-02 -- updated for GCC 3.0.1
2004-10-10 -- updated for GCC 3.4.2



Jürgen Keil jk@tools.de of Tools GmbH +49 (228) 9858011 posted the following to USENET as 64-bit gcc 3.0 build  instructions for  Sparc Solaris. I would add a couple of points to Mr. Keil's most excellent instructions:


Build instruction to bootstrap a 64-bit gcc compiler on SPARC Solaris
=====================================================================
 

Get the 'gcc 3.0' source release from

        http://gcc.gnu.org/
        http://gcc.gnu.org/gcc-3.0/gcc-3.0.html
 

Prerequisites:

- gcc 2.95.[23] is installed and working
- gnu assember / gnu linker not required
  (I've use solaris as and ld found in /usr/ccs/bin )
 
 

Step 1:
=======

Compile and install an ordinary 32-bit gcc compiler.  The 32-bit
version of gcc on sparc solaris is a 'primary evaluation platform', so
there should be no major problem building the 32-bit version.  I've
choosen to install the gcc 3.0 compiler into a separate directory tree
(/usr/local/gcc-3.0); by including or removing the
/usr/local/gcc-3.0/bin directory in my $PATH environment variable, I
can switch between different versions of the GCC compiler.

    bunzip2 < gcc-3.0.tar.bz2 | tar xf -
    mkdir gcc-3.0-sparc-32bit-obj
    cd gcc-3.0-sparc-32bit-obj
    ../gcc-3.0/configure --prefix=/usr/local/gcc-3.0 --enable-languages=c
    make
    make install
 

Step 2:
=======

Prepend the bin directory for the compiler installed in step 1 to
$PATH, create a fresh object directory hierarchy for the 64-bit
compiler, then configure and compile the 64-bit compiler.  Again I
choose a separate directory for the installed 64-bit gcc development
compiler, /usr/local/gcc-3.0-v9 in this example:
 

    set path=(/usr/local/gcc-3.0/bin $path)
    cd ..
    mkdir gcc-3.0-sparc-64bit-obj
    cd gcc-3.0-sparc-64bit-obj
    ../gcc-3.0/configure --prefix=/usr/local/gcc-3.0-v9 --enable-languages=c sparcv9-sun-solaris2
    make
    make install
 

Step 3:
=======

OPTIONAL: The compiler binaries installed in the previous step are
still using 32-bit code (but they are able to produce 64-bit binaries
now).  You may want to recompile the 64-bit compiler into real 64-bit
binaries.

Prepend /usr/local/gcc-3.0-v9/bin to $PATH, create a fresh (empty)
object directory for the 64-bit objects, then configure and compile
the 64-bit compiler.

    set path=(/usr/local/gcc-3.0-v9/bin $path)
    cd ..
    rm -rf gcc-3.0-sparc-64bit-obj
    mkdir gcc-3.0-sparc-64bit-obj
    cd gcc-3.0-sparc-64bit-obj
    ../gcc-3.0/configure --prefix=/usr/local/gcc-3.0-v9 --enable-languages=c sparcv9-sun-solaris2
    make
    make install



Chris Parker writes as follows:

Thanks for posting the 'how-to' on building a 64-bit compiler on Solaris8.

I recently got an e4500 ( sweet little box ) and decided to test some apps
running in native 64-bit mode vs. 32-bit mode.

Needless to say, GCC is not easy to trick into compiling 64-bit code.

In my case I was compiling mySQL 3.23 latest version and GCC-3.0.1

I do have some additional tips that make your page more useful:

   o  --languages=c,c++   ( this will build c and c++ compilers )

   o  LD_LIBRARY_PATH needs to be set properly for g++/c++ to properly
      find libstc++ if not installed into /usr/local/lib ( which happens
      if you redefine --prefix. )

Other than that, it worked as advertised:

      gcc:            ELF 64-bit MSB executable SPARCV9 Version 1,
dynamically
      linked, not stripped
 

Once again, many thanks!

Cheers,
-Chris Parker
--
    \\\|||///  \  Chris Parker    -    Manager, Development Engineering
    \ ~   ~ /   \       WX *is* Wireless!    \   cparker@starnetusa.net
    | @   @ |    \   http://www.starnetwx.net \      (847) 963-0116
oOo---(_)---oOo--\------------------------------------------------------
                   \ Without C we would have 'obol', 'basi', and 'pasal'


2001-10-02 -- updated for GCC 3.0.1

Here I'd like to note that

2004-10-10 -- updated for GCC 3.4.2

I've been building GCC 3.x.x from GCC 3.x.x for a while now. When starting from a GCC 3.x.x there's not the 32 -> 64 problem you've had before. You just configure something like:
$ cd gcc-3.4.2-build
$ ../gcc-3.4.2/configure --prefix=/usr/local/gcc-3.4.2 --enable-languages=c,c++ sparcv9-sun-solaris2.9

Note the new wrinkle (by GCC 3.4.x at least, possibly earlier, I didn't build every intermediate release) ... you must specify the Solaris version, so now it is
sparcv9-sun-solaris2.9
which you are targeting, not merely plain
sparcv9-sun-solaris2

- Jack Woehr