4 This file introduces you to building a cross-toolchain on MacOS-X.
5 Apart from the crosstool-NG configuration options for the specific target,
7 - what pre-requisites to install
9 - how to work around the case-insensitivity of HFS+
11 This file was submitted by:
12 Blair Burtan <info@northernlightstactical.com>
13 The original version was found at:
14 http://homepage.mac.com/macg3/TS7390-OSX-crosstool-instructions.txt
20 Compiling cross compiler for default TS-7390 debian system on Mac OS X
22 Forewarning: It's kind of a pain. Several of OS X's packages aren't good enough
23 so you need to install some GNU stuff. You might have an easier time using a
24 package manager for OS X but I prefer to compile everything from source so I'm
25 going to provide the instructions for that. Also there are a few little catches
26 with how some of the older gcc/glibc stuff compiles on OS X.
28 The version of glibc on the TS-7390 default file system is 2.3.6. So we need to
29 make a compiler with glibc 2.3.6 or older. I guess you can pick whatever version
30 of gcc you want to use. I'll pick 4.1.2, which is what is included with the 7390
31 debian. But you could theoretically do something newer like 4.3.3 (or older,
32 like 4.0.4) if you want, I think. All I know is the following works fine for gcc
33 4.1.2 and glibc 2.3.6.
35 First, you have to install some prerequisites. Go in a temporary folder
36 somewhere and follow these directions.
38 Some of the included OS X utilities aren't cool enough. So we need to download
39 and install some GNU utilities. Luckily they compile with no trouble in
40 Mac OS X! Nice work GNU people!
42 First make sure you've installed the latest version of Xcode so you have gcc
45 Install GNU sed into /usr/local. Note: I believe configure defaults to
46 /usr/local as a prefix, but better safe than sorry.
48 curl -O http://ftp.gnu.org/gnu/sed/sed-4.2.1.tar.bz2
49 tar -xf sed-4.2.1.tar.bz2
51 ./configure --prefix=/usr/local
52 make -j 2 (or 4 or whatever...# of jobs that can run in parallel...
53 on a dual core machine I use 4)
56 Install GNU coreutils:
58 curl -O http://ftp.gnu.org/gnu/coreutils/coreutils-7.4.tar.gz
59 tar -xf coreutils-7.4.tar.gz
61 ./configure --prefix=/usr/local
67 curl -O http://ftp.gnu.org/gnu/libtool/libtool-2.2.6a.tar.gz
68 tar -xf libtool-2.2.6a.tar.gz
70 ./configure --prefix=/usr/local
74 Install GNU awk, needed to fix a weird error in glibc compile:
76 curl -O http://ftp.gnu.org/gnu/gawk/gawk-3.1.7.tar.bz2
77 tar -xf gawk-3.1.7.tar.bz2
79 ./configure --prefix=/usr/local
83 Xcode doesn't come with objcopy/objdump, but you need them. Download GNU
84 binutils 2.19.1 and install just objcopy and objdump. Not sure how exactly to
85 do only them so I compile it all and copy them manually....there may be a
88 curl -O http://ftp.gnu.org/gnu/binutils/binutils-2.19.1.tar.bz2
89 tar -xf binutils-2.19.1.tar.bz2
91 ./configure --prefix=/usr/local
93 sudo cp binutils/obj{dump,copy} /usr/local/bin
96 Done installing prerequisites...now do the fun stuff!
99 1) Create a disk image with Disk Utility (in /Utilities/Disk Utility).
100 Open it and go to File->New->Blank Disk Image.
101 Save As: Call it whatever you want.
102 Volume name: Call it CrosstoolCompile
103 Volume size: Go to custom and choose 2000 MB. This is a temporary image you
104 can delete once you're done compiling if you wish.
105 Volume format: Choose Mac OS Extended (Case-sensitive, journaled).
106 Mac OS X's default file system does not allow you to name two files
107 the same with different cases (abcd and ABCD) but you need this for
108 crosstool. So that's why we're creating a disk image. Leave everything
109 else the default and save it wherever you want.
111 2) Create another disk image where the final toolchain will be installed.
112 Your crosstool needs to go on a disk image for the same reason--needs a
113 case sensitive file system and regular Mac OS X HFS+ is not. So we have to
114 make another one. Follow the steps above but set the volume name to
115 Crosstool and then make the volume size something like 300MB. Just make
116 sure you leave plenty of room for any libraries you want to add to your
117 cross compiler and that kind of stuff. The resulting toolchain will be about
118 110 MB in size. Set the Volume Format to
119 Mac OS Extended (Case-sensitive, journaled).
120 Save this image somewhere handy. You'll be using it forever after this.
123 3) Make sure they're both mounted.
125 4) cd /Volumes/CrosstoolCompile
127 5) Grab crosstool-ng:
128 curl -O http://ymorin.is-a-geek.org/download \
129 /crosstool-ng/crosstool-ng-1.4.2.tar.bz2
130 (OS X doesn't come with wget by default)
133 tar -xf crosstool-ng-1.4.2.tar.bz2
134 cd crosstool-ng-1.4.2
137 export PATH=/usr/local/bin:$PATH
139 Make sure you do it like this.
140 /usr/local/bin has to come in the path BEFORE anything else.
145 8) Configure crosstool
148 At this point you should have a screen up similar to the Linux kernel config.
149 Now set up options. Leave options as default if I haven't mentioned them.
151 Paths and misc options:
152 Enable Use obsolete features
153 Enable Try features marked as EXPERIMENTAL
154 Set prefix directory to:
155 /Volumes/Crosstool/${CT_TARGET}
156 (this tells it to install on the disk image you created)
157 Number of parallel jobs: Multiply the number of cores you have times 2.
158 That's what I generally do. So my dual core can do 4 jobs.
159 Makes compiling the toolchain faster.
162 Target Architecture: ARM
163 Use EABI: Do NOT check this. The default TS Debian filesystem is OABI.
164 If you are doing an EABI one, you can set this to true (but may want
165 to do a different version of gcc/glibc)
166 Architecture level: armv4t
167 armv4t is for the EP9302. other processors you would pick the
168 right architecture here.
169 Floating point: Hardware
171 I believe this is correct even though it's not really using an FPU because
172 the pre-EABI debian distro was compiled with hardfloat instructions so
173 whenever you do a floating point instruction the kernel is actually
174 trapping an illegal instruction error, makes for slow floating point...
175 EABI is so much better.
177 I know hardware is the default, but I just wanted to clarify that you need
178 to choose hardware here. I'm pretty sure anyway.
181 Tuple's vendor string: whatever you want.
182 It'll be arm-yourtuple-linux-gnu when you're finished.
186 Linux kernel version: 2.6.21.7 (best match for TS kernel!)
193 choose C++ below, so you can compile C++!
195 glibc (NOT eglibc for this)
197 Threading implementation to use: linuxthreads
199 (note: nptl is better than linuxthreads, but it looks like nptl didn't support
200 ARM back in glibc 2.3.6?
202 Exit and save config.
204 Now we need to add a patch. Looks like the configure script for glibc does not
205 like some of apple's binutils, so we need to patch it to skip the version tests
206 for as and ld. Stick this patch in crosstool-ng-1.4.2/patches/glibc/2.3.6 to
207 skip the version test for as and ld:
209 http://homepage.mac.com/macg3/300-glibc-2.3.6-configure-patch-OSX.patch
211 (or see below, at the end of this file)
215 Okay, done setting up crosstool...now...
219 Sit back, relax, wait a while. Crosstool-ng will do the rest, automatically
220 downloading tarballs, patching them, installing them. Could take quite a long
221 time. The actual compiling took about 30 minutes on my older MacBook Pro. When
222 you're done you have a cross compiler on your disk image that you named
223 "Crosstool". Look in there and you're all set!
225 So whenever you want to use the cross compiler, you need to mount this disk
226 image. You could also create an actual partition on your computer that is
227 Mac OS X extended case-sensitive if you wish. Then you don't need the disk
230 You can delete the CrosstoolCompile disk image. It was just used temporarily
231 while compiling everything.
233 Note that I'm pretty sure gcc 4.1.2 has a bug in assembly generation that will
234 cause Qt 4.5 to segfault. I'm fairly sure I saw this problem before with 4.1.2.
235 I know for a fact that gcc 4.3.3 has the bug. This bug report:
236 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39429 has the details. I adapted the
237 patch at the bottom to work with gcc 4.3.3. you might be able to apply it to
238 other gcc versions. Not sure. I think 4.0.4 does not have this bug so you might
239 even try compiling 4.0.4 instead of 4.1.2. Lots of options. Hope this helps,
240 I've struggled with this stuff a lot but it's so convenient to have a native
247 Here is the afore-mentioned patch:
250 Mac OS X fails configuring because its included binutils kind of suck.
251 This patch makes the glibc 2.3.6 configure script ignore the
252 installed version of as and ld. It just makes the configure
253 script believe that it's as version 2.13 and ld 2.13.
255 Made on 2009-08-08 by Doug Brown
257 --- glibc-2.3.6/configure.orig 2009-08-08 10:40:10.000000000 -0700
258 +++ glibc-2.3.6/configure 2009-08-08 10:42:49.000000000 -0700
259 @@ -3916,10 +3916,7 @@ else
260 echo $ECHO_N "checking version of $AS... $ECHO_C" >&6
261 ac_prog_version=`$AS -v </dev/null 2>&1 | sed -n 's/^.*GNU assembler.* \([0-9]*\.[0-9.]*\).*$/\1/p'`
262 case $ac_prog_version in
263 - '') ac_prog_version="v. ?.??, bad"; ac_verc_fail=yes;;
265 - ac_prog_version="$ac_prog_version, ok"; ac_verc_fail=no;;
266 - *) ac_prog_version="$ac_prog_version, bad"; ac_verc_fail=yes;;
267 + *) ac_prog_version="2.13, ok"; ac_verc_fail=no;;
270 echo "$as_me:$LINENO: result: $ac_prog_version" >&5
271 @@ -3977,10 +3974,7 @@ else
272 echo $ECHO_N "checking version of $LD... $ECHO_C" >&6
273 ac_prog_version=`$LD --version 2>&1 | sed -n 's/^.*GNU ld.* \([0-9][0-9]*\.[0-9.]*\).*$/\1/p'`
274 case $ac_prog_version in
275 - '') ac_prog_version="v. ?.??, bad"; ac_verc_fail=yes;;
277 - ac_prog_version="$ac_prog_version, ok"; ac_verc_fail=no;;
278 - *) ac_prog_version="$ac_prog_version, bad"; ac_verc_fail=yes;;
279 + *) ac_prog_version="2.13, ok"; ac_verc_fail=no;;
282 echo "$as_me:$LINENO: result: $ac_prog_version" >&5