Linux Archive

Linux Archive (http://www.linux-archive.org/)
-   Gentoo Embedded (http://www.linux-archive.org/gentoo-embedded/)
-   -   GCC/LLVM-GCC targeting Darwin/OS X/iOS (http://www.linux-archive.org/gentoo-embedded/572730-gcc-llvm-gcc-targeting-darwin-os-x-ios.html)

Andrew Udvare 09-07-2011 06:40 AM

GCC/LLVM-GCC targeting Darwin/OS X/iOS
 
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).

Mike Frysinger 10-13-2011 11:11 PM

GCC/LLVM-GCC targeting Darwin/OS X/iOS
 
On Wednesday 07 September 2011 02:40:05 Andrew Udvare wrote:
> 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.

so you have more ebuilds to add to the tree ? or something else ?

> 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 think i'm going to have to open up crossdev to sucking down from overlays
via layman. there's an open request for better msp430 support, and that
requires hacks to some packages.
-mike

Andrew Udvare 10-14-2011 12:11 AM

GCC/LLVM-GCC targeting Darwin/OS X/iOS
 
I did create some ebuilds of my own because the sys-devel/gcc-apple and sys-devel/binutils-apple are very specifically for use with Gentoo Prefix on OS X. They are just not what I call ready yet because they rely upon EXTRA_ECONF to get the --target triple.

Project is here:*https://github.com/tatsh/xchain
Complete (arm targetting iOS, i686 and x86_64 targeting OS X):- Build Apple's cctools but only with older ld64; equivalent to binutils and 100% not the GNU versions
- Build Apple's GCC but only with precompiled libstdcxx and Libc- Build Apple's LLVM and LLVM-GCC but again with precompiled libs
The main issues are:- How to get the developer libraries from Apple (restricted source, have user get the DMG and put it in /usr/distfiles, extract DMG reliably)
* - If we do this, there's not much point to compiling Libc or libstdcxx since it's included with this- How to build Apple's Libc*http://www.opensource.apple.com/source/Libc/Libc-763.12/*(mainly for testing)
- How to build Apple's libstdcxx*http://opensource.apple.com/source/libstdcxx/libstdcxx-52/*(mainly for testing)- Build latest ld64 from Apple (currently I am using a patched older version); everything in this toolchain at this point must link with ld64 and not what Apple calls 'classic ld'

The patch for Apple's version of binutils (same package as sys-devel/binutils-apple) that I made is quite large and may not be entirely necessary (it patches back in what they used to have, autotools). However Apple developers rely upon OS X's nearly automatic memset'ing which is why somes patches are definitely necessary (or compiling stage will get segfaults).

I am maintaining an overlay*https://github.com/tatsh/tatsh-overlay. What I am planning to do is just add separate ebuilds for each target since only these are supported: i686, x86_64, arm (armv6, armv7 but I don't know how to differentiate these yet; default is armv6), and maybe powerpc and powerpc64.

Andrew
On Thursday, 13 October 2011, Mike Frysinger wrote:
On Wednesday 07 September 2011 02:40:05 Andrew Udvare wrote:


> 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.



so you have more ebuilds to add to the tree ? *or something else ?



> 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 think i'm going to have to open up crossdev to sucking down from overlays

via layman. *there's an open request for better msp430 support, and that

requires hacks to some packages.

-mike


All times are GMT. The time now is 02:22 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.