Compilation of Offload C++ code for the Cell BE processor and the Linux OS entirely within a Linux environment is complicated by the fact that the Offload C++ compiler ("offloadcpp") is a Windows executable. This compiler compiles programs to run on the Cell processor by first compiling Offload C++ code into Cell specific C code; the C is then compiled for the Cell processor using a Cell BE GCC tool chain (GCC and associated utilities) on Windows, via Cygwin. The result is that, on Windows, the compiler can generate a Cell Linux executable with embedded SPU sub-programs automatically.
The below process (described by Paul Keir, thanks!) outlines how the Offload C++ compiler can be used to compile for the Cell from within Linux using Wine. The first stage is to compile the Offload C++ code (your original program) into C code targeting the Cell. The second stage is to compile that generated C code on the Cell using the Cell SDK on the PS3 running Linux.
Note that depending on how your Linux PS3 is setup, it is possible to create a script (e.g. via scp and ssh) to push the generated code onto the PS3, and to subsequently invoke the PS3 compilation process on the PS3 automatically.
-------------- Stage 1: Linux/Windows ------------
1. Install Wine on your Linux system.
2. Copy the Codeplay Offload C++ installation directory from Windows to somewhere convenient on your Linux system.
3. On Linux, set the SIEVESDK environment variable to the offload-cell-linux-sdk directory contained within the installation directory.
4. Offload may install a Cygwin-compatible Cell Toolchain. By default it will be installed in C:\cygwin\opt\cell .
Place the entire cell directory tree within the /opt/ directory of your Linux system. The Cygwin-compatible PS3 toolchain is also available here: http://sourceforge.net/projects/cellwindowssdk/
The toolchain.7z file there also contains the /opt/cell/... directory tree.
5. The Offload compiler is now ready to run, though only with the -nomake switch. If you have placed the Offload installation directory at $HOME/apps/codeplay, offloadcpp may be used to compile hello.cpp using the following command:
$ wine $HOME/apps/codeplay/offloadcpp.exe -I$SIEVESDK/include -I/opt/cell/toolchain/include/c++/4.1.1 -I/opt/cell/sysroot/usr/include -I/opt/cell/toolchain/lib/gcc/powerpc-linux/4.1.1/include/c++/powerpc-linux -I/opt/cell/toolchain/lib/gcc/powerpc-linux/4.1.1/include -nomake hello.cpp
An alias may be useful, say "oll":
$ alias oll='wine $HOME/apps/codeplay/offloadcpp.exe -I$SIEVESDK/include -I/opt/cell/toolchain/include/c++/4.1.1 -I/opt/cell/sysroot/usr/include -I/opt/cell/toolchain/lib/gcc/powerpc-linux/4.1.1/include/c++/powerpc-linux -I/opt/cell/toolchain/lib/gcc/powerpc-linux/4.1.1/include'
$ oll -nomake hello.cpp
6. The result will be a directory called "outputc". This directory must now be transferred to the PS3, before issuing the make command, as described in Step 3. below.
-------------- Stage 2: PlayStation 3 ------------
1. Copy the offload-cell-linux-sdk directory to the PS3, and set the SIEVESDK environment variable to that location.
2. Mars should already be installed (mars-1.1.4-1.ppc.rpm), but the development libraries are now also needed, so:
$ wget ftp://ftp.infradead.org/pub/Sony-PS3/mars/1.1.4/mars-devel-1.1.4-1.ppc.rpm
$ rpm -ivh mars-devel-1.1.4-1.ppc.rpm
3. An "outputc" directory, obtained as in step 5. above, contains a makefile. To complete the compilation of hello.cpp:
$ cd outputc
$ make
$ cd ..
$ ./hello