Thursday, September 22, 2011

Building the Go gcc Compiler on Ubuntu 11.04

I recently built the Go gcc compiler on Ubunutu 11.04 and the initial build took a couple of days with a lot of incredible help from Ian Lance Taylor of the Go development team via the golang-nuts group. It appears that Debian has changed a lot of things since the instructions on were written last year.

After figuring out everything on my laptop, I installed Ubuntu 11.04 fresh on another system. There were a couple of hiccups, like I had not installed flex and once I had I did not realize that it needed a fresh directory or the build would fail in a new and different way.

The steps below should allow you to build the compiler. I would love to see someone duplicate the results.


sudo apt-get install bison gawk gcc libc6-dev libc6-dev-i386 make binutils-dev texinfo flex libmpc-dev cvs subversion

cd /usr/lib64
sudo ln -s /usr/lib/x86_64-linux-gnu/
sudo ln -s /usr/lib/x86_64-linux-gnu/
sudo ln -s /usr/lib/x86_64-linux-gnu/
sudo ln -s /usr/lib/x86_64-linux-gnu/
sudo ln -s /usr/local/lib64/

Not A Prerequisite But Helpful

sudo apt-get install apt-file

If you receive an error that the process cannot find a file, this will allow you to determine in which package it resides.

Build binutils

Note that the enable-gold switch is different from what is on

cd ~
cvs -z 9 -d login
[password is "anoncvs"]
cvs -z 9 -d co binutils
mkdir binutils-objdir
cd binutils-objdir
../src/configure --enable-gold=default --prefix=/opt/gold
sudo make install

Build gccgo

cd ~
svn checkout svn:// gccgo
mkdir objdir
cd objdir
../gccgo/configure --enable-languages=c,c++,go --with-ld=/opt/gold/bin/ld
make install

Runtime Env

gccgo -version

There will be a lot of information, but you only need these two elements.
Target: x86_64-unknown-linux-gnu
gcc version 4.7.0 20110520 (experimental) (GCC)

where MACHINE is the string after Target
and VERSION is the number after version


1 comment:

  1. In order to get the build to work I had to do two things:

    A)include "--diable-bootstrap" as part of the gccgo configure step.
    B) "sudo make install" as part of the last step.

    One last thing, I had to reboot as I couldn't remember the commmand to get the linker to find new .so files in order to link the simple hello world example.