info@1523: Introduction info@1523: ------------ info@1523: info@1523: This file introduces you to building a cross-toolchain on MacOS-X. info@1523: Apart from the crosstool-NG configuration options for the specific target, info@1523: what is important is: info@1523: - what pre-requisites to install info@1523: - how to install them info@1523: - how to work around the case-insensitivity of HFS+ info@1523: info@1523: This file was submitted by: info@1523: Blair Burtan info@1523: The original version was found at: info@1523: http://homepage.mac.com/macg3/TS7390-OSX-crosstool-instructions.txt info@1523: info@1523: info@1523: Text info@1523: ---- info@1523: info@1523: Compiling cross compiler for default TS-7390 debian system on Mac OS X info@1523: info@1523: Forewarning: It's kind of a pain. Several of OS X's packages aren't good enough info@1523: so you need to install some GNU stuff. You might have an easier time using a info@1523: package manager for OS X but I prefer to compile everything from source so I'm info@1523: going to provide the instructions for that. Also there are a few little catches info@1523: with how some of the older gcc/glibc stuff compiles on OS X. info@1523: info@1523: The version of glibc on the TS-7390 default file system is 2.3.6. So we need to info@1523: make a compiler with glibc 2.3.6 or older. I guess you can pick whatever version info@1523: of gcc you want to use. I'll pick 4.1.2, which is what is included with the 7390 info@1523: debian. But you could theoretically do something newer like 4.3.3 (or older, info@1523: like 4.0.4) if you want, I think. All I know is the following works fine for gcc info@1523: 4.1.2 and glibc 2.3.6. info@1523: info@1523: First, you have to install some prerequisites. Go in a temporary folder info@1523: somewhere and follow these directions. info@1523: info@1523: Some of the included OS X utilities aren't cool enough. So we need to download info@1523: and install some GNU utilities. Luckily they compile with no trouble in info@1523: Mac OS X! Nice work GNU people! info@1523: info@1523: First make sure you've installed the latest version of Xcode so you have gcc info@1523: on your Mac. info@1523: info@1523: Install GNU sed into /usr/local. Note: I believe configure defaults to info@1523: /usr/local as a prefix, but better safe than sorry. info@1523: info@1523: curl -O http://ftp.gnu.org/gnu/sed/sed-4.2.1.tar.bz2 info@1523: tar -xf sed-4.2.1.tar.bz2 info@1523: cd sed-4.2.1 info@1523: ./configure --prefix=/usr/local info@1523: make -j 2 (or 4 or whatever...# of jobs that can run in parallel... info@1523: on a dual core machine I use 4) info@1523: sudo make install info@1523: info@1523: Install GNU coreutils: info@1523: info@1523: curl -O http://ftp.gnu.org/gnu/coreutils/coreutils-7.4.tar.gz info@1523: tar -xf coreutils-7.4.tar.gz info@1523: cd coreutils-7.4 info@1523: ./configure --prefix=/usr/local info@1523: make -j 2 info@1523: sudo make install info@1523: info@1523: Install GNU libtool: info@1523: info@1523: curl -O http://ftp.gnu.org/gnu/libtool/libtool-2.2.6a.tar.gz info@1523: tar -xf libtool-2.2.6a.tar.gz info@1523: cd libtool-2.2.6 info@1523: ./configure --prefix=/usr/local info@1523: make -j 2 info@1523: sudo make install info@1523: info@1523: Install GNU awk, needed to fix a weird error in glibc compile: info@1523: info@1523: curl -O http://ftp.gnu.org/gnu/gawk/gawk-3.1.7.tar.bz2 info@1523: tar -xf gawk-3.1.7.tar.bz2 info@1523: cd gawk-3.1.7 info@1523: ./configure --prefix=/usr/local info@1523: make -j 2 info@1523: sudo make install info@1523: info@1523: Xcode doesn't come with objcopy/objdump, but you need them. Download GNU info@1523: binutils 2.19.1 and install just objcopy and objdump. Not sure how exactly to info@1523: do only them so I compile it all and copy them manually....there may be a info@1523: better way. info@1523: info@1523: curl -O http://ftp.gnu.org/gnu/binutils/binutils-2.19.1.tar.bz2 info@1523: tar -xf binutils-2.19.1.tar.bz2 info@1523: cd binutils-2.19.1 info@1523: ./configure --prefix=/usr/local info@1523: make -j 2 info@1523: sudo cp binutils/obj{dump,copy} /usr/local/bin info@1523: info@1523: info@1523: Done installing prerequisites...now do the fun stuff! info@1523: info@1523: info@1523: 1) Create a disk image with Disk Utility (in /Utilities/Disk Utility). info@1523: Open it and go to File->New->Blank Disk Image. info@1523: Save As: Call it whatever you want. info@1523: Volume name: Call it CrosstoolCompile info@1523: Volume size: Go to custom and choose 2000 MB. This is a temporary image you info@1523: can delete once you're done compiling if you wish. info@1523: Volume format: Choose Mac OS Extended (Case-sensitive, journaled). info@1523: Mac OS X's default file system does not allow you to name two files info@1523: the same with different cases (abcd and ABCD) but you need this for info@1523: crosstool. So that's why we're creating a disk image. Leave everything info@1523: else the default and save it wherever you want. info@1523: info@1523: 2) Create another disk image where the final toolchain will be installed. info@1523: Your crosstool needs to go on a disk image for the same reason--needs a info@1523: case sensitive file system and regular Mac OS X HFS+ is not. So we have to info@1523: make another one. Follow the steps above but set the volume name to info@1523: Crosstool and then make the volume size something like 300MB. Just make info@1523: sure you leave plenty of room for any libraries you want to add to your info@1523: cross compiler and that kind of stuff. The resulting toolchain will be about info@1523: 110 MB in size. Set the Volume Format to info@1523: Mac OS Extended (Case-sensitive, journaled). info@1523: Save this image somewhere handy. You'll be using it forever after this. info@1523: info@1523: info@1523: 3) Make sure they're both mounted. info@1523: info@1523: 4) cd /Volumes/CrosstoolCompile info@1523: info@1523: 5) Grab crosstool-ng: info@1523: curl -O http://ymorin.is-a-geek.org/download \ info@1523: /crosstool-ng/crosstool-ng-1.4.2.tar.bz2 info@1523: (OS X doesn't come with wget by default) info@1523: info@1523: 6) Expand it info@1523: tar -xf crosstool-ng-1.4.2.tar.bz2 info@1523: cd crosstool-ng-1.4.2 info@1523: info@1523: 7) Build it info@1523: export PATH=/usr/local/bin:$PATH info@1523: info@1523: Make sure you do it like this. info@1523: /usr/local/bin has to come in the path BEFORE anything else. info@1523: info@1523: ./configure --local info@1523: make info@1523: info@1523: 8) Configure crosstool info@1523: ./ct-ng menuconfig info@1523: info@1523: At this point you should have a screen up similar to the Linux kernel config. info@1523: Now set up options. Leave options as default if I haven't mentioned them. info@1523: info@1523: Paths and misc options: info@1523: Enable Use obsolete features info@1523: Enable Try features marked as EXPERIMENTAL info@1523: Set prefix directory to: info@1523: /Volumes/Crosstool/${CT_TARGET} info@1523: (this tells it to install on the disk image you created) info@1523: Number of parallel jobs: Multiply the number of cores you have times 2. info@1523: That's what I generally do. So my dual core can do 4 jobs. info@1523: Makes compiling the toolchain faster. info@1523: info@1523: Target options: info@1523: Target Architecture: ARM info@1523: Use EABI: Do NOT check this. The default TS Debian filesystem is OABI. info@1523: If you are doing an EABI one, you can set this to true (but may want info@1523: to do a different version of gcc/glibc) info@1523: Architecture level: armv4t info@1523: armv4t is for the EP9302. other processors you would pick the info@1523: right architecture here. info@1523: Floating point: Hardware info@1523: info@1523: I believe this is correct even though it's not really using an FPU because info@1523: the pre-EABI debian distro was compiled with hardfloat instructions so info@1523: whenever you do a floating point instruction the kernel is actually info@1523: trapping an illegal instruction error, makes for slow floating point... info@1523: EABI is so much better. info@1523: info@1523: I know hardware is the default, but I just wanted to clarify that you need info@1523: to choose hardware here. I'm pretty sure anyway. info@1523: info@1523: Toolchain Options: info@1523: Tuple's vendor string: whatever you want. info@1523: It'll be arm-yourtuple-linux-gnu when you're finished. info@1523: info@1523: Operating System: info@1523: Target OS: linux info@1523: Linux kernel version: 2.6.21.7 (best match for TS kernel!) info@1523: info@1523: binutils: info@1523: version: 2.19.1 info@1523: C compiler: info@1523: gcc info@1523: version: 4.1.2 info@1523: choose C++ below, so you can compile C++! info@1523: C-library: info@1523: glibc (NOT eglibc for this) info@1523: glibc version: 2.3.6 info@1523: Threading implementation to use: linuxthreads info@1523: info@1523: (note: nptl is better than linuxthreads, but it looks like nptl didn't support info@1523: ARM back in glibc 2.3.6? info@1523: info@1523: Exit and save config. info@1523: info@1523: Now we need to add a patch. Looks like the configure script for glibc does not info@1523: like some of apple's binutils, so we need to patch it to skip the version tests info@1523: for as and ld. Stick this patch in crosstool-ng-1.4.2/patches/glibc/2.3.6 to info@1523: skip the version test for as and ld: info@1523: info@1523: http://homepage.mac.com/macg3/300-glibc-2.3.6-configure-patch-OSX.patch info@1523: info@1523: (or see below, at the end of this file) info@1523: info@1523: --------- info@1523: info@1523: Okay, done setting up crosstool...now... info@1523: info@1523: ./ct-ng build info@1523: info@1523: Sit back, relax, wait a while. Crosstool-ng will do the rest, automatically info@1523: downloading tarballs, patching them, installing them. Could take quite a long info@1523: time. The actual compiling took about 30 minutes on my older MacBook Pro. When info@1523: you're done you have a cross compiler on your disk image that you named info@1523: "Crosstool". Look in there and you're all set! info@1523: info@1523: So whenever you want to use the cross compiler, you need to mount this disk info@1523: image. You could also create an actual partition on your computer that is info@1523: Mac OS X extended case-sensitive if you wish. Then you don't need the disk info@1523: image. info@1523: info@1523: You can delete the CrosstoolCompile disk image. It was just used temporarily info@1523: while compiling everything. info@1523: info@1523: Note that I'm pretty sure gcc 4.1.2 has a bug in assembly generation that will info@1523: cause Qt 4.5 to segfault. I'm fairly sure I saw this problem before with 4.1.2. info@1523: I know for a fact that gcc 4.3.3 has the bug. This bug report: info@1523: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39429 has the details. I adapted the info@1523: patch at the bottom to work with gcc 4.3.3. you might be able to apply it to info@1523: other gcc versions. Not sure. I think 4.0.4 does not have this bug so you might info@1523: even try compiling 4.0.4 instead of 4.1.2. Lots of options. Hope this helps, info@1523: I've struggled with this stuff a lot but it's so convenient to have a native info@1523: OS X toolchain! info@1523: info@1523: info@1523: Patch info@1523: ----- info@1523: info@1523: Here is the afore-mentioned patch: info@1523: info@1523: ---8<--- info@1523: Mac OS X fails configuring because its included binutils kind of suck. info@1523: This patch makes the glibc 2.3.6 configure script ignore the info@1523: installed version of as and ld. It just makes the configure info@1523: script believe that it's as version 2.13 and ld 2.13. info@1523: info@1523: Made on 2009-08-08 by Doug Brown info@1523: info@1523: --- glibc-2.3.6/configure.orig 2009-08-08 10:40:10.000000000 -0700 info@1523: +++ glibc-2.3.6/configure 2009-08-08 10:42:49.000000000 -0700 info@1523: @@ -3916,10 +3916,7 @@ else info@1523: echo $ECHO_N "checking version of $AS... $ECHO_C" >&6 info@1523: ac_prog_version=`$AS -v &1 | sed -n 's/^.*GNU assembler.* \([0-9]*\.[0-9.]*\).*$/\1/p'` info@1523: case $ac_prog_version in info@1523: - '') ac_prog_version="v. ?.??, bad"; ac_verc_fail=yes;; info@1523: - 2.1[3-9]*) info@1523: - ac_prog_version="$ac_prog_version, ok"; ac_verc_fail=no;; info@1523: - *) ac_prog_version="$ac_prog_version, bad"; ac_verc_fail=yes;; info@1523: + *) ac_prog_version="2.13, ok"; ac_verc_fail=no;; info@1523: info@1523: esac info@1523: echo "$as_me:$LINENO: result: $ac_prog_version" >&5 info@1523: @@ -3977,10 +3974,7 @@ else info@1523: echo $ECHO_N "checking version of $LD... $ECHO_C" >&6 info@1523: ac_prog_version=`$LD --version 2>&1 | sed -n 's/^.*GNU ld.* \([0-9][0-9]*\.[0-9.]*\).*$/\1/p'` info@1523: case $ac_prog_version in info@1523: - '') ac_prog_version="v. ?.??, bad"; ac_verc_fail=yes;; info@1523: - 2.1[3-9]*) info@1523: - ac_prog_version="$ac_prog_version, ok"; ac_verc_fail=no;; info@1523: - *) ac_prog_version="$ac_prog_version, bad"; ac_verc_fail=yes;; info@1523: + *) ac_prog_version="2.13, ok"; ac_verc_fail=no;; info@1523: info@1523: esac info@1523: echo "$as_me:$LINENO: result: $ac_prog_version" >&5 info@1523: ---8<---