https://github.com/tatsh/xchain
I have successfully created multiple compilers (both regular GCC and
LLVM-GCC) targeting the following triples:
arm-apple-darwin* (iOS only)
i686-apple-darwin*
x86_64-apple-darwin*
I have not tried powerpc or powerpc64 yet but I think they will work,
if not then with minimal changes that still keep everything else
working.
Most sources come from http://opensource.apple.com just like the
sys-devel/binutils-apple and sys-devel/gcc-apple packages. The version
of cctools in the project is patched heavily (mainly due to missing
headers, which we can distribute). One source is derived from
iphone-dev's version of odcctools, but only for one part of it (ld64).
It is not the same and needed fixing to compile with GCC 4.5.3. I plan
to fix the up-to-date ld64 regardless.
Their ar and ranlib is VERY sensitive to any optimisation flags and
basically chokes on building GCC if you built with any flags like -O2,
etc.
https://github.com/tatsh/xchain/blob/master/cctools-806/ar/archive.c
https://github.com/tatsh/xchain/blob/master/cctools-806/misc/ranlib.c
lines Any calls to sprintf are in question.
The real caveat is how to get the SDK headers and libs. I haven't
checked but I think everything is under APSL, but I don't know the
legality of creating a custom tarball. I tested everything with the
latest you can get (that's not under NDA), which is Xcode 4.1.1 from
the Mac App Store (it is free). You cannot get this from anywhere
else. You can get Xcode 3.2.6 from Apple's developer site for free,
but that requires login. It cannot be automatically downloaded. Plus I
do not know when it will disappear (I'm betting soon).
So the easiest way IMO is to just install Xcode and scp.
scp -r myname@mymac:/Developer/SDKs/MacOSX10.7.sdk .
scp -r myname@mymac:/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk
.
These are directories and are essentially the sysroot. usr is in them
and should be where any new things like gcc, ar, etc go into.
By default, if x86 or powerpc, everything compiled runs on 10.4u and
up. It is even possible to create fat binaries with lipo (although I
have only tried this with ARM and x86_64). Any x86_64 code requires
10.5 or higher. For iOS, I believe you can specify as low as 1.0 for
iOS minimum but the only sure way to actually ensure it would run is
to use such an SDK.
Obviously the iOS code here is not signed, you would need to do that
on your Mac with the `codesign` utility. You can do half the work on
Linux with the `codesign_allocate` which just makes space for the
signing information. If you have a jailbroken device, all code will
run as is without needing to sign.
Finally, both LLVM GCC and regular GCC will work. The instructions for
this are in the README.
I'd like to reach the point of being able to type (perhaps with
prerequisite work done by me like copying the SDK) `crossdev -t
arm-apple-darwin` and `crossdev -t arm-apple-darwinX` (where X is 9,
10, 11).
I have successfully created multiple compilers (both regular GCC and
LLVM-GCC) targeting the following triples:
arm-apple-darwin* (iOS only)
i686-apple-darwin*
x86_64-apple-darwin*
I have not tried powerpc or powerpc64 yet but I think they will work,
if not then with minimal changes that still keep everything else
working.
Most sources come from http://opensource.apple.com just like the
sys-devel/binutils-apple and sys-devel/gcc-apple packages. The version
of cctools in the project is patched heavily (mainly due to missing
headers, which we can distribute). One source is derived from
iphone-dev's version of odcctools, but only for one part of it (ld64).
It is not the same and needed fixing to compile with GCC 4.5.3. I plan
to fix the up-to-date ld64 regardless.
Their ar and ranlib is VERY sensitive to any optimisation flags and
basically chokes on building GCC if you built with any flags like -O2,
etc.
https://github.com/tatsh/xchain/blob/master/cctools-806/ar/archive.c
https://github.com/tatsh/xchain/blob/master/cctools-806/misc/ranlib.c
lines Any calls to sprintf are in question.
The real caveat is how to get the SDK headers and libs. I haven't
checked but I think everything is under APSL, but I don't know the
legality of creating a custom tarball. I tested everything with the
latest you can get (that's not under NDA), which is Xcode 4.1.1 from
the Mac App Store (it is free). You cannot get this from anywhere
else. You can get Xcode 3.2.6 from Apple's developer site for free,
but that requires login. It cannot be automatically downloaded. Plus I
do not know when it will disappear (I'm betting soon).
So the easiest way IMO is to just install Xcode and scp.
scp -r myname@mymac:/Developer/SDKs/MacOSX10.7.sdk .
scp -r myname@mymac:/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk
.
These are directories and are essentially the sysroot. usr is in them
and should be where any new things like gcc, ar, etc go into.
By default, if x86 or powerpc, everything compiled runs on 10.4u and
up. It is even possible to create fat binaries with lipo (although I
have only tried this with ARM and x86_64). Any x86_64 code requires
10.5 or higher. For iOS, I believe you can specify as low as 1.0 for
iOS minimum but the only sure way to actually ensure it would run is
to use such an SDK.
Obviously the iOS code here is not signed, you would need to do that
on your Mac with the `codesign` utility. You can do half the work on
Linux with the `codesign_allocate` which just makes space for the
signing information. If you have a jailbroken device, all code will
run as is without needing to sign.
Finally, both LLVM GCC and regular GCC will work. The instructions for
this are in the README.
I'd like to reach the point of being able to type (perhaps with
prerequisite work done by me like copying the SDK) `crossdev -t
arm-apple-darwin` and `crossdev -t arm-apple-darwinX` (where X is 9,
10, 11).