Difference between revisions of "Compile for the PhatBox"
(Updated crosstool config to produce a compiler that produces programs that don't segfault when linked with full glibc) |
|||
Line 5: | Line 5: | ||
= Cross-Compiler = |
= Cross-Compiler = |
||
+ | Alternatively to a full compilation, a compiler that is almost, if not the same as the one used by phatnoise is available from http://www.opto22.com/products/linux/SNAPOEMIOLinuxREADME.aspx#Installation |
||
+ | |||
Build a cross-compiler for ARM (the processor used in the PhatBox). |
Build a cross-compiler for ARM (the processor used in the PhatBox). |
||
Revision as of 08:48, 14 July 2005
Here are some notes on how to compile C programs to run on the PhatBox. It's from memory, so some of the details may be slightly wrong -- please edit this page if you have any corrections. --bushing
Edit: I recompiled with a combo of gcc and glibc that was listed as supported for ARM on crosstool, the configs I used are listed below. This did NOT segfault on compiled using full glibc rather than diet.
Cross-Compiler
Alternatively to a full compilation, a compiler that is almost, if not the same as the one used by phatnoise is available from http://www.opto22.com/products/linux/SNAPOEMIOLinuxREADME.aspx#Installation
Build a cross-compiler for ARM (the processor used in the PhatBox).
The crosstool utility makes this very easy under Unix-like systems (e.g. Linux).
The configuration files I used were:
arm.dat KERNELCONFIG=`pwd`/arm.config GCC_EXTRA_CONFIG="--with-cpu=arm7tdmi --enable-cxx-flags=-mcpu=arm7tdmi" TARGET=arm-7tdmi-linux-gnu TARGET_CFLAGS="-Os" GLIBC_EXTRA_CONFIG=--enable-omitfp
demo-arm.sh
- !/bin/sh
set -ex TARBALLS_DIR=/mnt/lv0/shared/phat/downloads RESULT_TOP=/opt/crosstool export TARBALLS_DIR RESULT_TOP GCC_LANGUAGES="c,c++" CC="gcc" PARALLELMFLAGS="-j 2" export GCC_LANGUAGES DISTCC CC PARALLELMFLAGS eval `cat arm.dat gcc-3.4.3-glibc-2.3.4.dat` sh all.sh --notest
(As root) create the directory /opt/crosstool and make it writable by you, and finally (as you) run the demo script, e.g.
$ sudo mkdir /opt/crosstool $ sudo chown $USER /opt/crosstool $ sh demo-arm.sh
...and wait for it to compile.
libc
In order to actually compile programs, you also need a libc (c library). Crosstool will build you a glibc, but none of the programs I compiled with it actually worked.
So, I turned to diet libc - a libc optimized for small size. I found that I had to first make a version for i386 (to get the build-i386/diet program), and then I could build a version for arm. IE:
$ make $ make arm
You will then have a program called diet in the bin-i386 directory. Copy this into your path, and then you can build programs for the PhatBox by running
$ diet arm-linux-gcc -o hello hello.c
(this is a GCC wrapper)