Version 10 (modified by Vinutheraj, on Jul 16, 2010 at 8:51:44 PM) (diff)

/* Building gccgo */


Status: Currently, GCC Go has been ported to RTEMS on x86.

Mentors: Ian Lance Taylor and Joel Sherrill?

Introduction: Go is a new concurrent programming language introduced by a very distinguished group of computer scientists working at Google. There is a new front-end in GCC for the Go language.

Goal: Have a functioning port of GCC Go to RTEMS supporting all the architectures.

General Build Instructions

These instructions assume the following strings in the instructions are replaced with values appropriate for you. These may not work if you use these as environment variables, so do so at your own risk.

  • INSTALL_DIR is the prefix (installation directory) for the toolchain installation
  • TARGET is the target code (tested with TARGET=i386-rtems4.11)
  • BSP is the RTEMS BSP (tested with BSP=pc386)

It is critical that you have a recent enough native GCC in your $PATH before beginning.

Please perform each configure/make/make install trio in a separate empty build directory. In the directions below, the versions for RTEMS 4.11 are used. If you are building RTEMS 4.10, update the commands below with the appropriate older versions. Also set PATH=INSTALL_DIR/bin:$PATH.

The order in which you build is precisely the order followed in this HOWTO. First, the cross-compiler toolset, then RTEMS and finally gccgo.

Source Code and Patches

If you are building from source code, download all of the necessary source code archives, unpackage them, and apply the appropriate patches. More information on this can be found here - Building the GNU Cross Compiler Toolset.

Please use the latest patches available for the tool versions you are using. These should always be in the RTEMS source code at rtems/contrib/crossrpms/patches and at

Rather than building from source code, you may be able to use the pre-built versions of the code provided for various architectures at However, be aware that problems have been identified if the version of the pre-built binutils has an INSTALL_DIR different from the one you are using for the other tools. More information on how to use the pre-built version can be found here - Prebuilt Toolset Executables.

Building RTEMS

First, get the RTEMS source code. For the latest source, use:

cvs -z3 -d login
cvs -z3 -d co -P rtems

For specific releases like RTEMS 4.10, use:

cvs -z3 -d login
cvs -z3 -d co -r rtems-4-10-branch -P rtems

Git exports of the various modules in the CVS repository can be found at The RTEMS module can be cloned like this -

git clone

Then, build RTEMS. Building RTEMS is to be done in two stages, first a multilibed version, then a non-multilibed version

During the tool build the multilibed version is needed to ensure you get the .h files into a place where the "normal" cross builds will see them without adding to the include path.

But you want the BSPs installed so you can actually (later) link executables, so the non-multilibed version.

cd rtems
cd ..
mkdir b-rtems-multi
cd b-rtems-multi
../rtems/configure --enable-multilib --disable-cxx --enable-posix \
  --enable-networking --target=TARGET --prefix=INSTALL_DIR
make install

cd ..
mkdir b-rtems-nomulti
cd b-rtems-nomulti
../rtems/configure --disable-multilib --disable-cxx --enable-posix \
  --enable-networking --target=TARGET --prefix=INSTALL_DIR \
make install

Building gccgo

The gccgo source code is accessible via Subversion. The gcc web site has instructions for getting the gcc source code. The gccgo source code is a branch of the main gcc code repository: svn://

Basically you do a -

svn co svn:// gccgo

Now, we have to patch this gccgo for RTEMS. The patch can be taken from rtems/contrib/crossrpms/patches. Currently (16-Jul-2010), there is no gccgo patch in that folder, but there is a gcc-core-4.5.0-XXX.patch. Apply that to gccgo. One hunk is rejected (the one related to missing file lm32.h), and one hunk related to config.gcc needs to applied manually.

Now, after patching, we are ready to build gccgo for RTEMS. We can choose to build multilib or not. The commands shown here are to build non-multilib. You can choose to build go with c++ too.

mkdir b-gccgo1-i386
cd b-gccgo1-i386
../gccgo/configure --enable-threads=rtems --with-gnu-as --enable-newlib-mb --enable-newlib-iconv \
  --with-gnu-ld --with-newlib --with-system-zlib --disable-nls \
  --enable-version-specific-runtime-libs --target=i386-rtems4.11 --prefix=INSTALL_DIR \
make install

The --march=i486 is because If you are targeting a 32-bit x86, then you will want to build gccgo to default to supporting locked compare and exchange instructions.