I know there may not be much demand for this these days, but I find myself in a job working with Solaris daily and I needed to have access to go.
After many hours of searching the internet and many failed attempts I was finally able to compile gccgo for Solaris 11.3 (11.3.13.4). I'm posting this here because most things you find on this topic will be discussing Solaris 10 or older versions of Solaris, I had to tweek and modify to get things working, so I hope this helps someone else.
1) Start by installing necessary packages from rep
# pkg install gmp
# pkg install mpc
# pkg install mpfr here...
2) Setup some directories
mkdir -p $HOME/src/gccgo
cd $HOME/src/gccgo
3) Get the gccgo source (I've used version 6 of golang here)
4) create a new script (this is where the magic happens) I cannot take all the credit for this. This whole thing was inspired by
THIS post from this group, but once again it was a few years old and needed updating. vi build-gcc.sh
#!/bin/sh
dir=$HOME/src/gccgo
srcdir=$dir/gccgo-src
objdir=$dir/gccgo-obj
prefix=$dir/gccgo
jobs=8
export PATH=/usr/gcc/4.8/bin:/usr/sfw/bin:/usr/gnu/bin:/usr/bin
export LD_OPTIONS='-R$ORIGIN/../lib/ -R/usr/gnu/lib -R/usr/sfw/lib'
languages="--enable-languages=go,"
version="--with-pkgversion=gccgo-249045"
options="--with-as=/usr/sfw/bin/gas --with-gnu-as --with-ld=/usr/bin/ld --without-gnu-ld --with-gmp-include=/usr/include/gmp --with-gmp-lib=/usr/lib --with-mpfr-include=/usr/include/mpfr --with-mpfr-lib=/usr/lib --with-mpfr=/usr/include --with-mpc=/usr/include --disable-nls --disable-libquadmath --disable-libssp --disable-lto --disable-libgomp --with-build-time-tools=/usr/sfw"
multilib="--enable-multilib"
shared="--enable-shared"
static="--enable-static"
if [ ! -d $objdir ]; then
mkdir $objdir
fi
cd $objdir
$srcdir/configure --prefix=$prefix "$languages" $options $shared $static $multilib "$version" && gmake -j$jobs
4) set perms and run script
chmod +x build-gcc.sh
./build-gcc.sh
5) Sit back and watch the fun!
Once the compile has finished you will have a statically linked binary that you can put where ever you like. WINNING!
bancroft@box:~/src/gccgo/gccgo-obj/gcc$ uname -a
SunOS box 5.11 11.3 sun4v sparc SUNW,Sun-Fire-T200 Solaris
bancroft@box:~/src/gccgo/gccgo-obj/gcc$ ./gccgo --version
gccgo (gccgo-249045) 6.3.1 20170703
Copyright (C) 2016 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Let me know how you get on......