Gentoo Archives: gentoo-embedded

From: Andrew Udvare <audvare@×××××.com>
To: gentoo-embedded@l.g.o
Subject: [gentoo-embedded] GCC/LLVM-GCC targeting Darwin/OS X/iOS
Date: Wed, 07 Sep 2011 06:40:29
Message-Id: CAJfjkGoobruToEEEh8bizQPu493WRA3naMOTc-FvuxOaQw+suw@mail.gmail.com
1 https://github.com/tatsh/xchain
2
3 I have successfully created multiple compilers (both regular GCC and
4 LLVM-GCC) targeting the following triples:
5 arm-apple-darwin* (iOS only)
6 i686-apple-darwin*
7 x86_64-apple-darwin*
8
9 I have not tried powerpc or powerpc64 yet but I think they will work,
10 if not then with minimal changes that still keep everything else
11 working.
12
13 Most sources come from http://opensource.apple.com just like the
14 sys-devel/binutils-apple and sys-devel/gcc-apple packages. The version
15 of cctools in the project is patched heavily (mainly due to missing
16 headers, which we can distribute). One source is derived from
17 iphone-dev's version of odcctools, but only for one part of it (ld64).
18 It is not the same and needed fixing to compile with GCC 4.5.3. I plan
19 to fix the up-to-date ld64 regardless.
20
21 Their ar and ranlib is VERY sensitive to any optimisation flags and
22 basically chokes on building GCC if you built with any flags like -O2,
23 etc.
24 https://github.com/tatsh/xchain/blob/master/cctools-806/ar/archive.c
25 https://github.com/tatsh/xchain/blob/master/cctools-806/misc/ranlib.c
26 lines Any calls to sprintf are in question.
27
28 The real caveat is how to get the SDK headers and libs. I haven't
29 checked but I think everything is under APSL, but I don't know the
30 legality of creating a custom tarball. I tested everything with the
31 latest you can get (that's not under NDA), which is Xcode 4.1.1 from
32 the Mac App Store (it is free). You cannot get this from anywhere
33 else. You can get Xcode 3.2.6 from Apple's developer site for free,
34 but that requires login. It cannot be automatically downloaded. Plus I
35 do not know when it will disappear (I'm betting soon).
36
37 So the easiest way IMO is to just install Xcode and scp.
38 scp -r myname@mymac:/Developer/SDKs/MacOSX10.7.sdk .
39 scp -r myname@mymac:/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk
40 .
41
42 These are directories and are essentially the sysroot. usr is in them
43 and should be where any new things like gcc, ar, etc go into.
44
45 By default, if x86 or powerpc, everything compiled runs on 10.4u and
46 up. It is even possible to create fat binaries with lipo (although I
47 have only tried this with ARM and x86_64). Any x86_64 code requires
48 10.5 or higher. For iOS, I believe you can specify as low as 1.0 for
49 iOS minimum but the only sure way to actually ensure it would run is
50 to use such an SDK.
51
52 Obviously the iOS code here is not signed, you would need to do that
53 on your Mac with the `codesign` utility. You can do half the work on
54 Linux with the `codesign_allocate` which just makes space for the
55 signing information. If you have a jailbroken device, all code will
56 run as is without needing to sign.
57
58 Finally, both LLVM GCC and regular GCC will work. The instructions for
59 this are in the README.
60
61 I'd like to reach the point of being able to type (perhaps with
62 prerequisite work done by me like copying the SDK) `crossdev -t
63 arm-apple-darwin` and `crossdev -t arm-apple-darwinX` (where X is 9,
64 10, 11).

Replies

Subject Author
Re: [gentoo-embedded] GCC/LLVM-GCC targeting Darwin/OS X/iOS Mike Frysinger <vapier@g.o>