Version 24 (modified by Vinutheraj, on Jul 26, 2010 at 11:12:48 PM) (diff) |
---|
GCCGoRTEMS
Table of Contents
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)
- 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 http://www.rtems.org/ftp/pub/rtems/SOURCES/.
Rather than building from source code, you may be able to use the pre-built versions of the code provided for various architectures at http://www.rtems.org/ftp/pub/rtems. 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 :pserver:anoncvs@www.rtems.com:/usr1/CVS login cvs -z3 -d :pserver:anoncvs@www.rtems.com:/usr1/CVS co -P rtems
For specific releases like RTEMS 4.10, use:
cvs -z3 -d :pserver:anoncvs@www.rtems.com:/usr1/CVS login cvs -z3 -d :pserver:anoncvs@www.rtems.com:/usr1/CVS co -r rtems-4-10-branch -P rtems
Git exports of the various modules in the CVS repository can be found at http://www.rtems.org/ftp/private/git/. The RTEMS module can be cloned like this -
git clone http://www.rtems.org/ftp/private/git/rtems.git
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 ./bootstrap 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 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 \ --enable-rtemsbsp=BSP make 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://gcc.gnu.org/svn/gcc/branches/gccgo.
Basically you do a -
svn co svn://gcc.gnu.org/svn/gcc/branches/gccgo 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 http://www.mpfr.org/mpfr-2.4.1/ and gmp-4.3.2.tar.gz from http://gmplib.org/. 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 ftp://sources.redhat.com/pub/newlib/index.html.
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 http://www.rtems.org/ftp/pub/rtems/SOURCES/.
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 \ CFLAGS_FOR_TARGET="-BRTEMS_MAKEFILE_PATH/lib/ -march=i486" \ --enable-version-specific-runtime-libs --target=i386-rtems4.11 --prefix=INSTALL_DIR \ --enable-languages=c,go make 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.(As of 2010-07-18, the testing patches have not been integrated into RTEMS sources).
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/sigchld.go compilation 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/gc1.go execution go.test/test/mallocrep.go execution go.test/test/mallocrep1.go execution