NOTICE - These instructions are not complete See HowTo.CompileCrossToolOnOSX for ones that do work. This page documents my tests/problems with the individual tools. I intend to continue testing the individual tools and documenting any problems/progress here.
I'm trying to set up the cross compile toolchain on the mac. I'm doing this the long manual way. As far as I know this should work for a linux box as well.
Once I get the entire thing working I'll condense it into a script. For now I'm going to list detailed instructions. (FWIW I have done extensive development with gcc/AVR, but never for the ARM. I'll be following the same steps which may be wrong for the ARM. So if I'm doing something wrong please help out.)
Since this is a work in progress and this is my documentation, please coordinate any edits with me at seadevil@gmail.com. Once I get (and understand) a working toolchain I'll remove this request.
- make sure you have a new enough gcc (3.1 failed for me)
- gcc --version
> gcc (GCC) 3.1 20020420 (prerelease)
- Visit the apple developer connection (http://developer.apple.com free registration required.) download "Xcode Tools v1.5" from the free downloads section.
- gcc --version
> gcc (GCC) 3.3 20030304 (Apple Computer, Inc. build 1666)
- choose an install directory
- PREFIX=~/local/nslu2
- export PREFIX
- choose the target
- TARGET=arm-linux
- export TARGET
- set up sysroot as per crosstool docs
- SYSROOT=${PREFIX}/${TARGET}
- BUILD=powerpc-apple-darwin7.5.0
- GCC_DIR=gcc-3.3.5
- BUILD=${BUILD-`$GCC_DIR/config.guess`}
- download/build binutils
- download http://ftp.gnu.org/gnu/binutils/binutils-2.15.tar.gz
- tar zxf binutils-2.15.tar.gz
- mkdir -p arm-linux-binutils ; cd arm-linux-binutils
- ../binutils-2.15/configure --prefix=$PREFIX --target=$TARGET --enable-languages=c,c++ -enable-targets="arm-elf,arm-coff,arm-aout,arm-pe,arm-linux" --disable-nls --with-sysroot=${SYSROOT}
- make
- make install
- set up the path to use the new binutils
- PATH=$PATH:$PREFIX/bin
- export PATH
- download/build bootstrap gcc
- download gcc-3.3.5.tar.bz2 from http://gcc.gnu.org/gcc-3.4/
- bunzip2 -c gcc-3.3.5.tar.bz2 | tar xf -
- mkdir -p arm-linux-gcc ; cd arm-linux-gcc
- ../gcc-3.3.5/configure --prefix=$PREFIX --target=$TARGET --enable-languages=c --without-headers --disable-shared --with-newlib --disable-threads --disable-nls
- make all-gcc
- make install-gcc
- Install a new vesrion of sed (required for glibc) (mac osx will hang with out this, "sed --version" doesn't work on the default install)
- get sed from http://ftp.gnu.org/pub/gnu/sed/sed-4.1.2.tar.gz
- tar xzf sed-4.1.2.tar.gz
- cd sed-4.1.2
- ./configure --prefix=$PREFIX
- make
- make install
- rearange path so it finds the new sed first:
- PATH=$PREFIX/bin:$PATH
- download/install gnu gettext
- I used: gettext-0.14.tar.gz (from http://www.gnu.org/software/gettext/)
- tar xzf gettext-0.14.tar.gz
- cd gettext-0.14
- ./configure --prefix=$PREFIX --disable-csharp
- make
- make install
- install "expr" from the gnu sh-utils package
- download from http://ftp.gnu.org/pub/gnu/sh-utils/
- tar xzf sh-utils-2.0.tar.gz
- cd sh-utils-2.0
- ./configure --prefix=$PREFIX --host=powerpc
- make
- cp src/expr $PREFIX/bin
- set up the "kernal includes" (so glibc will know how to fopen, puts etc)
- (I looked at http://www.arm.linux.org.uk/developer/ but decided to use the cd thatcame with the nslu2. It has file "snapgear-3.0.0.tar.gz)
- KERNEL=~/Desktop/projects/nslu2/cd/snapgear/linux-2.4.x
- pushd $KERNEL/..
- make menuconfig
--> change to linux 2.4.x
--> change to glibc
--> exit/save
- make dep
- popd
- mkdir -p $PREFIX/$TARGET/include
- #ln -s $KERNEL/include/asm-arm $PREFIX/$TARGET/include/asm
- #ln -s $KERNEL/include/linux $PREFIX/$TARGET/include/linux
- cp -r $KERNEL/include/linux $PREFIX/$TARGET/include
- cp -r $KERNEL/include/asm-arm $PREFIX/$TARGET/include/asm
- build glibc (not newlib like mentioned above)
- tar xzf glibc-2.3.3.tar.gz
- bunzip2 -c glibc-linuxthreads-2.3.3.tar.bz2 | tar xf -
- mv linuxthreads linuxthreads_db glibc-2.3.3
- mkdir -p arm_libc && cd arm_libc
- (1st try) ../glibc-2.3.3/configure --prefix=$PREFIX --target=$TARGET
looks like I need --build=$TARGET --host
or --build --host=$TARGET
- (2nd try) CC=arm-linux-gcc ../glibc-2.3.3/configure --prefix=$PREFIX --build=arm-linux --host=arm-linux --disable-nls --with-headers=$PREFIX/$TARGET/include --disable-debug --disable-profile --disable-sanity-checks
- (3rd try) CC=arm-linux-gcc ../glibc-2.3.3/configure --prefix=$PREFIX --build=arm-linux --host=arm-linux --disable-nls --with-headers=$PREFIX/$TARGET/include --enable-add-ons=linuxthreads
- make
*** errlist.c count 126 vs Versions sys_errlist@GLIBC_2.0 count 123
make[2]: *** [/Users/randymelton/Desktop/projects/nslu2/build_tools/arm_libc/stdio-common/errlist-compat.c] Error 1
make[1]: *** [stdio-common/subdir_lib] Error 2
- touch stdio-common/errlist-compat.c
- make (framestate problem)
- touch ../glibc-2.3.3/sysdeps/arm/framestate.c
- make
problems and solutions
- gcc build fails gcc: Internal error: Segmentation fault (program /usr/libexec/gcc/darwin/ppc/cpp-precomp)
(I pgraded the mac gcc from developer.apple.com)
old: gcc --version = gcc (GCC) 3.1 20020420 (prerelease)
new: gcc --version = gcc (GCC) 3.3 20030304 (Apple Computer, Inc. build 1666)
- gcc build fails configure: WARNING: float.h: present but cannot be compiled
(You need to build the bootstrap gcc, you don't have c libs yet...)
- gettext C# compiler not found, try installing pnet, then reconfigure
( configure with --disable-csharp)
- glibc configure hangs determining sed version
put a newer version of sed in the path
-or- (untested)
change glibc configure script to something like "echo 'print "sed does not support --version"' | sed...'
- running "make dep" in in the kernal includes gives:
expr: syntax error
KERNELRELEASE "2.4.22-uc0" exceeds 64 characters
(I've rad that bsd expr command has problems, so I need to compile sh-utils
but only install 'expr' because uname is broken on mac os x)
- glibc - *** errlist.c count 126 vs Versions sys_errlist@GLIBC_2.0 count 123
touch stdio-common/errlist-compat.c (before building, apparently this is a known bug?)
- glibc - ../sysdeps/generic/framestate.c:44: error: `fallback_frame_state_for' undeclared (first use in this function)
(seems there is some sjlj issue? see http://lists.debian.org/debian-glibc/2003/07/msg00030.html)
so I'm trying "touch ../glibc-2.3.3/sysdeps/arm/framestate.c"
- glibc - undefined reference to `__open
(still investigating, done for tonight...)
- glibc - Error: can't resolve `_GLOBAL_OFFSET_TABLE_'
(use TARGET_CFLAGS="-O1" as per http://www.spinics.net/lists/arm/msg08066.html)
- glibc - error: compiler support for __thread is required
(delete glibc-2.3.3/nptl see: http://sources.redhat.com/ml/crossgcc/2004-08/msg00138.html)
- glibc - cc1: error: unrecognized command line option "-std1"
(still tracking this down http://www.google.com/search?hl=en&lr=&q=cc1++unrecognized+option+%22-std1%22&btnG=Search )
binutils - I've discovered that glibc requires a working readelf (I beleive native to powerpc)
and the one in gnu binutils will not compile...
I'm trying the darwin copy (from cvs)
mkdir -p darwin ; cd darwin
cvs -d:pserver:anonymous@anoncvs.opendarwin.org:/Volumes/src/cvs/od login
(enter blank password)
cvs -d:pserver:anonymous@anoncvs.opendarwin.org:/Volumes/src/cvs/od co src/binutils
cd src/binutils
cd src
./configure --prefix=~/local/mac --enable-languages=c,c++ --disable-nls
make
(fails)
cd binutils
make readelf
(fails)
cd ../intl
make libintl.a
cd ../electric-fence
make libefence.a
cd ../binutils
make readelf
cp readelf ~/local/nslu2/bin
references
crosstool on mac (see CompileCrossToolOnOSX)
(download/install wget http://www.gnu.org/software/wget/wget.html#downloading)
(download/install 'install' from fileutils http://ftp.gnu.org/pub/gnu/fileutils)
If anybody has any suggestions or comments on this wiki page I can be reached at seadevil@gmail.com