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.

Mentors: Ian Lance Taylor and Joel Sherrill?

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

Summary The GNU GCC Go port works on RTEMS x86. All the patches have been committed to the respective repositories. Now one can download the sources of both gccgo and RTEMS and build RTEMS GCC Go for x86. The instructions on how to do this are provided here.

New 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)
  • RTEMS_MAKEFILE_PATH is BSP-specific installation folder. It is "INSTALL_DIR/TARGET/BSP".

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.

Building the cross-compiler toolset

First, we have to setup the cross-compiler toolset, which is needed to build RTEMS.

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

Download and patch 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 will be rejected (the one related to missing file lm32.h), and one hunk related to config.gcc needs to be applied manually.

Download and setup gmp and mpfr libraries

The gmp and mpfr libraries are used to help gccgo perform optimisations. Download mpfr-2.4.1.tar.gz from and gmp-4.3.2.tar.gz from These are the version numbers compatible with gccgo at this point in time (17-Jul-2010).

Now put links to these source directories inside the gccgo source directory.

tar zxf mpfr-2.4.1.tar.gz
tar zxf gmp-4.3.2.tar.gz
cd gccgo
ln -s ../mpfr-2.4.1 ./mpfr
ln -s ../gmp-4.3.2 ./gmp
cd ..

Download and setup newlib

The C library used with RTEMS is newlib. It is built alongwith gcc. Download newlib-1.18.0.tar.gz from

After this, we have to apply the RTEMS patch to newlib. The patch can be taken from the RTEMS source code at rtems/contrib/crossrpms/patches or from

Now put a link to the patched newlib inside the gccgo source directory.

tar xzf newlib-1.18.0.tar.gz
patch -p0 < newlib-1.18.0-rtems4.11-20100617.diff
cd gccgo
ln -s ../newlib-1.18.0/newlib ./newlib
cd ..

Build gccgo

Now, after all this, 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. To build multilib just add an --enable-multilib option to configure.

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.

Testing gccgo

The gccgo testsuite can be run using the scripts found in the rtems-testing module in RTEMS source.

Untested testcases

Not all of the tests in the testsuite are used for testing, specifically for RTEMS. This is because of various reasons pertaining to the quirks of RTEMS.

go.test/test/args.go execution
go.test/test/env.go execution

These testcases are untested because RTEMS doesn't handle command line arguments or the environment in the traditional way.

go.test/test/chan/goroutines.go execution
go.test/test/stack.go execution
go.test/test/peano.go execution 

These testcases remain untested due to their high memory requirements, which is unreasonable in the case of embedded applications, and hence, not feasible for RTEMS. The problem with sigchld.go is not high memory requirement, but it uses a feature missing in RTEMS, specifically the syscall wrapper function to invoke any syscall.

Board-specific testcases

Some testcases have a total memory requirement of 16M. Now, this is reasonable for some boards, and not for others. We have decided to allow for these testcases to be passed.

These are

go.test/test/mallocrep.go execution 
go.test/test/mallocrep1.go execution


Last modified on 11/26/10 at 19:36:01 Last modified on 11/26/10 19:36:01