Monthly Archives: February 2014

Building gccgo on Solaris 11 x86_64

I wanted to jot down what happened Friday night.  I tried out gccgo on Solaris 11, and it seems to work.  It turns out if you want to use Go (the toolchain) on Solaris, you can use the Go language support that is part of recent versions of gcc.

bash:~/tmp$ cat first.go
package main

import "fmt"

func main() {
fmt.Println("hi")
}
bash:~/tmp$ gccgo first.go
bash:~/tmp$ LD_LIBRARY_PATH=~/opt/gcc-4.8.2/lib ./a.out
hi
bash:~/tmp$

I’ll use bash, the Bourne Again Shell, to allow a kind of short hand in the recipe below. If I made a typo, please let me know in the comments. Here’s a brief key to the bashisms:

bashism meaning example
!$ the last thing (rightmost argument) on the previous command bash$ echo one two three
three
bash$ echo !$
three
bash$
!$:t the basename of the last thing from the previous command bash$ echo one/two/three
one/two/three
bash$ echo !$:t
three
bash$
!$:t:r the extension removed from the basename of the last thing bash$ echo one/two.three
one/two.three
bash$ echo !$:t:r
two
bash$

Here’s the recipe. First it builds and installs two libraries that gcc needs. Then it does the same for gcc itself. The installation goes into ~/opt.

GMP


cd
mkdir -p packages build opt
cd packages
wget https://gmplib.org/download/gmp/gmp-5.1.3.tar.xz
cd ~/build && xzcat ~/packages/!$:t | tar xf -
cd gmp-5.1.3 && mkdir ~/opt/gmp-5.1.3
./configure --prefix=$HOME/opt/gmp-5.1.3 && make install

MPFR


cd ~/packages
wget http://www.mpfr.org/mpfr-current/mpfr-3.1.2.tar.xz
cd ~/build && xzcat ~/packages/!$:t | tar xf - && cd !$:r:r && mkdir ~/opt/!$:r:r
./configure --prefix=$HOME/opt/!$:t --with-gmp=$HOME/opt/gmp-5.1.3 && make install

GCC


cd ~/packages
wget http://www.netgull.com/gcc/releases/gcc-4.8.2/gcc-4.8.2.tar.gz
cd ~/build && tar xf ~/packages/!$:t && mkdir ~/opt/!$:t:r:r && mkdir !$:t:r:r-objdir && cd !$:t:r:r-objdir && echo !$:t:r:r
../!$/configure --prefix=$HOME/opt/!$ --enable-languages=c,c++,go --prefix="$HOME"/opt/gcc-4.8.2 --with-gmp=$HOME/opt/gmp-5.1.3 --with-mpfr=$HOME/opt/mpfr-3.1.2
gmake install

mkdir ~/opt/bin
cd ~/opt/bin
for i in ../gcc-4.8.2/bin/*; do echo ln -s "$i"; done | sh -x

Advertisements