Cross Compiling References

These are the general instructions for cross compiling code to run on the DCM embedded linux platform. The DCM uses a powerpc-603 micro processor and code must be correctly compiled for that processor on the build machine.

Currently novatest01 is setup with an appropriate x86_64 -> powerpc-603 cross compiler. There are two different types of cross compilers, the general purpose gcc and the kernel code gcc. These have different version numbers and have been specifically built to work with our DCMs.

To setup the cross compilers on the build system (novatest01) use the UPS facility with appropriate qualifiers:

setup nova_crosscompiler v4_1_0-2.3.6 -q powerpc-603


setup nova_crosscompiler v4_1_0-2.3.6 -q powerpc-603:full

In the first invocation, the prefixed versions of the compiler will be made available to you. The entire gcc build chain is available in this mode. Each utility's name is simply prefixed by the destination architecture that is designed to build for.

powerpc-603-linux-gnu-gcc (the standard GNU c compiler)
powerpc-603-linux-gnu-as (the standard GNU assembler)
powerpc-603-linux-gnu-ld (the standard GNU linker/loader)

Programs can be built to run on the in this mode by simply using the correct compiler on your code:

powerpc-603-linux-gnu-g++ hello_world.cpp -o Hello_World

While the normal (un-prefixed version) remains the native compiler for the system (i.e. g++ hello_world.cpp will produce an executable for novatest01 still, not for the dcm)

Many standard packages use the GNU-Autotools build system and are easy to compile for all the different platforms using this method.

If you are using an Autotools package (i.e. it has a configure script and generates an Automake file) then to cross compile you will typically only need to do the following:

Make a "build" directory (i.e. a directory other than the one where your source code is)
cd build_directory
../source_directory/configure --host=powerpc-603-linux-gnu --build=`config.guess` --prefix=/install_directory
make install

Note: when cross compiling using Autotools you won't be able to run the "make test" or "make check" steps of the build since the executables you are creating only work on the DCMs. Just skip these steps and hope that things work (and test them on the DCMs at some point)


50% of the time (if you're lucky) this procedure will work. However, many packages either do not use the Autotools build system, or are incorrectly configured. In these cases the simple solution is to simply replace the entire GNU tool chain with the cross-build version.

In this case setup the UPS package with the "full" qualification.

| setup nova_crosscompiler -q powerpc-603:full

When you run this setup, it will give you both the prefixed versions of the GNU tools, as replace the unprefixed ones with the cross compiler versions. What this means is if you execute:

| gcc hello_world.c

The output will only run on one of the DCM systems.

This is useful for "fooling" a package into compiling for the DCM. When operating in this mode, you will have to be careful to make sure that the libraries that are getting picked (external libs) are for the correct architecture (i.e. if you aren't careful the compiler will try to link against what it finds in /user/lib)