Building OLPC Tools
From Gnash Project Wiki
Building Tools for the OLPC
This dates from 2007-10-18. GCC 4.3 fully supports -march=geode and -mtune=geode. But as of 2009-02-07, binaries in OLPC OS images are not optimized for geode, see http://dev.laptop.org/ticket/118 , so optimized libraries are still relevant.
Geode support for GCC is a reasonably recent addition. As of Oct 18 2007, it is currently only available if you build GCC from recent subversion sources. Recently Bernardo Innocenti of the OLPC backported the geode specific parts, and produced this This patch for GCC 4.2.1. Without this patch, there is no support for -march=geode, and -mtune=geode for a released version of GCC. This has GCC generate code for the Geode, which has subtle differences between it and a pentium.
When building GLIBC, you need to remove or rename the $prefix/include directory if you build GLIBC and plan to install it on top of an existing installation. When --prefix is set to a directory with an existing GLIBC installation, the wrong thread headers are picked up, and the nptl add on to GLIBC will get caught in a loop, and try to build forever.
This work is based on the Geode Perf tests, written by John M. Zulauf @ AMD to test the performance of hand tuned assembly to improve the performance on the Geode.
The build of GCC that is included in  OLPC builds is configured with these options:
Target: i386-redhat-linux Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-languages=c,c++,objc,obj-c++,java,fortran,ada --enable-java-awt=gtk --disable-dssi --enable-plugin --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-184.108.40.206/jre --enable-libgcj-multifile --enable-java-maintainer-mode --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --with-cpu=generic --host=i386-redhat-linux Thread model: posix gcc version 4.1.2 20070925 (Red Hat 4.1.2-27)
I'm currently using these options with GCC built from up to date subversion sources.
Configured with: /home/rob/projects/gnu/gcc/configure --prefix=/usr/local/olpc --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-languages=c,c++ --disable-dssi
I mostly just dropped all the java, fortran, objc, and ada support, as I don't think those are primary development languages for the OLPC. While you can configure gcc with --with-cpu=geode, I just build a generic pentium compiler, and then use -march=geode at compile time to optimize.
A binary tarball of my latest GCC build, and the one I'm using for building an optimized glibc, can be grabbed from here: gcc-4.3.svn.tar.bz2. This gets installed in /usr/local as /usr/local/olpc.
NOTE: After extracting the tarball to /usr/local/olpc, you will need to: cd /usr/local ; sudo ln -s olpc olpc-test in order to create executables.
The default configuration for glibc for the OLPC is:
../../glibc-20070515T2025/configure --prefix=/usr --enable-add-ons=nptl,rtkaio,c_stubs,libidn --without-cvs --enable-kernel=2.6.9 --with-headers=/usr/src/redhat/BUILD/glibc-20070515T2025/override_headers:/usr/include --enable-bind-now --with-tls --with-__thread --build i686-redhat-linux --host i486-redhat-linux --with-cpu=i386 --disable-profile
I currently use this set of configuration options: ../../glibc-20070515T2025/configure --enable-add-ons=nptl,c_stubs,libidn --without-cvs --enable-bind-now --with-tls --with-__thread --disable-profile --prefix=/usr/local/olpc --with-cpu=geode
I dropped the --build and --host options, as you need an i686 target to support the Geode. So you can change this to --build i686-redhat-linux --host i686-redhat-linux, but if you leave them off configure gets these right by itself. And of course --with-cpu=i386 becomes -with-cpu=geode.
For those on the bleeding edge, here's my builds of glibc with geode specific optimizations for memcpy, memcmp, memset, strcmp, strlen. I'm still working on strcpy, which is having a weird problem in some configurations. I'll have rpms when I finish debugging my changes to the glibc.spec file.
I seem to have beat the rpm building process into shape, although your mileage may vary... These should only be installed on an actual OLPC. These were built with this spec file: glibc.spec
These were both compiled with GCC built out of GCC svn sources from mid Oct 2007, with -march=geode support for all files.