view · edit · print · history

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.

  1. make sure you have a new enough gcc (3.1 failed for me)
    1. gcc --version
      > gcc (GCC) 3.1 20020420 (prerelease)
    2. Visit the apple developer connection (http://developer.apple.com free registration required.) download "Xcode Tools v1.5" from the free downloads section.
    3. gcc --version
      > gcc (GCC) 3.3 20030304 (Apple Computer, Inc. build 1666)
  2. choose an install directory
    1. PREFIX=~/local/nslu2
    2. export PREFIX
  3. choose the target
    1. TARGET=arm-linux
    2. export TARGET
  4. set up sysroot as per crosstool docs
    2. BUILD=powerpc-apple-darwin7.5.0
    3. GCC_DIR=gcc-3.3.5
    4. BUILD=${BUILD-`$GCC_DIR/config.guess`}
  5. download/build binutils
    1. download http://ftp.gnu.org/gnu/binutils/binutils-2.15.tar.gz
    2. tar zxf binutils-2.15.tar.gz
    3. mkdir -p arm-linux-binutils ; cd arm-linux-binutils
    4. ../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}
    5. make
    6. make install
  6. set up the path to use the new binutils
    1. PATH=$PATH:$PREFIX/bin
    2. export PATH
  7. download/build bootstrap gcc
    1. download gcc-3.3.5.tar.bz2 from http://gcc.gnu.org/gcc-3.4/
    2. bunzip2 -c gcc-3.3.5.tar.bz2 | tar xf -
    3. mkdir -p arm-linux-gcc ; cd arm-linux-gcc
    4. ../gcc-3.3.5/configure --prefix=$PREFIX --target=$TARGET --enable-languages=c --without-headers --disable-shared --with-newlib --disable-threads --disable-nls
    5. make all-gcc
    6. make install-gcc
  8. 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)
    1. get sed from http://ftp.gnu.org/pub/gnu/sed/sed-4.1.2.tar.gz
    2. tar xzf sed-4.1.2.tar.gz
    3. cd sed-4.1.2
    4. ./configure --prefix=$PREFIX
    5. make
    6. make install
  9. rearange path so it finds the new sed first:
    1. PATH=$PREFIX/bin:$PATH
  10. download/install gnu gettext
    1. I used: gettext-0.14.tar.gz (from http://www.gnu.org/software/gettext/)
    2. tar xzf gettext-0.14.tar.gz
    3. cd gettext-0.14
    4. ./configure --prefix=$PREFIX --disable-csharp
    5. make
    6. make install
  11. install "expr" from the gnu sh-utils package
    1. download from http://ftp.gnu.org/pub/gnu/sh-utils/
    2. tar xzf sh-utils-2.0.tar.gz
    3. cd sh-utils-2.0
    4. ./configure --prefix=$PREFIX --host=powerpc
    5. make
    6. cp src/expr $PREFIX/bin
  12. set up the "kernal includes" (so glibc will know how to fopen, puts etc)
    1. (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)
    2. KERNEL=~/Desktop/projects/nslu2/cd/snapgear/linux-2.4.x
    3. pushd $KERNEL/..
    4. make menuconfig
      --> change to linux 2.4.x
      --> change to glibc
      --> exit/save
    5. make dep
    6. popd
    7. mkdir -p $PREFIX/$TARGET/include
    8. #ln -s $KERNEL/include/asm-arm $PREFIX/$TARGET/include/asm
    9. #ln -s $KERNEL/include/linux $PREFIX/$TARGET/include/linux
    10. cp -r $KERNEL/include/linux $PREFIX/$TARGET/include
    11. cp -r $KERNEL/include/asm-arm $PREFIX/$TARGET/include/asm
  13. build glibc (not newlib like mentioned above)
    1. tar xzf glibc-2.3.3.tar.gz
    2. bunzip2 -c glibc-linuxthreads-2.3.3.tar.bz2 | tar xf -
    3. mv linuxthreads linuxthreads_db glibc-2.3.3
    4. mkdir -p arm_libc && cd arm_libc
    5. (1st try) ../glibc-2.3.3/configure --prefix=$PREFIX --target=$TARGET
      looks like I need --build=$TARGET --host
      or --build --host=$TARGET
    6. (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
    7. (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
    8. 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
    9. touch stdio-common/errlist-compat.c
    10. make (framestate problem)
    11. touch ../glibc-2.3.3/sysdeps/arm/framestate.c
    12. 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
 cd binutils
 make readelf
 cd ../intl
 make libintl.a
 cd ../electric-fence
 make libefence.a
 cd ../binutils
 make readelf
 cp readelf ~/local/nslu2/bin


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

view · edit · print · history · Last edited by baicj.
Based on work by mhornsby, seadevil, and tman.
Originally by seadevil.
Page last modified on September 22, 2007, at 02:45 PM