gccgo on Solaris (I got it to work)

683 views
Skip to first unread message

Stephen Bancroft

unread,
Jul 5, 2017, 11:09:23 AM7/5/17
to golang-nuts
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)

             svn co svn://gcc.gnu.org/svn/gcc/branches/gcc-6-branch gccgo-src


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......

fmg...@gmail.com

unread,
Jun 29, 2018, 4:18:29 PM6/29/18
to golang-nuts
I needed to make some modifications, 
After that it was possible to compile Go in Solaris 5.13

build.sh

#!/bin/sh

#
# GccGo Setup
#

# Deps
# pkg install gcc-c-48 ;
# pkg install gmp ;
# pkg install mpc ;
# pkg install mpfr ;
# pkg developer/versioning/subversion ;

# Get Source ;
# mkdir -p /dados_hdd/setup/gccgo-6 ;
# chmod 0777 /dados_hdd/setup/gccgo-6 ;
# cd /dados_hdd/setup/gccgo-6 ;

# Config Directory
dir=/dados_hdd/setup/gccgo-6
srcdir=$dir/gccgo-src
objdir=$dir/gccgo-obj
prefix=/opt/gccgo-6

# Create Directory
mkdir -p $objdir
mkdir -p $prefix

# Exports
export PATH=/usr/gcc/4.8/bin:/usr/gnu/bin:/usr/sfw/bin:/usr/bin:
export LD_OPTIONS='-R/usr/gnu/lib -R/usr/sfw/lib'

# Make
cd $objdir
$srcdir/configure \
    --prefix=$prefix \
    --enable-languages=go \
    --with-as=/usr/gnu/bin/as --with-gnu-as \
    --with-ld=/usr/bin/ld --without-gnu-ld \
    --with-gmp-include=/usr/include/gmp --with-gmp-lib=/usr/lib \
    --with-mpfr=/usr/include --with-mpfr-include=/usr/include/mpfr --with-mpfr-lib=/usr/lib \
    --with-mpc=/usr/include \
    --with-build-time-tools=/usr/gnu
    --enable-multilib \
    --enable-shared \
    --enable-static \
    --disable-nls \
    --disable-libquadmath \
    --disable-libssp \
    --disable-lto \
    --disable-libgomp
gmake -j8
gmake install


Checking...

root@XXX:/opt# uname -a
SunOS XXX 5.11 11.3 sun4v sparc sun4v
root@ XXX:/opt# /opt/gccgo-6/bin/gccgo --version
gccgo (GCC) 6.4.1 20180629
Copyright (C) 2017 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.

root@ XXX:/opt#

Reply all
Reply to author
Forward
0 new messages