Difference between revisions of "CrossCompilingOsX"

From Inkscape Wiki
Jump to: navigation, search
m (formatting)
Line 8: Line 8:
  
 
The following should be done on the ''host'' system first. Download the Xcode DMG, and use dmg2img to convert it to an IMG. Mount the IMG, and put the .pkg files into the chroot somewhere. I'm using /mnt/apple.
 
The following should be done on the ''host'' system first. Download the Xcode DMG, and use dmg2img to convert it to an IMG. Mount the IMG, and put the .pkg files into the chroot somewhere. I'm using /mnt/apple.
 +
 +
 +
== Making the chroot ==
  
 
I used Ubuntu 14.04 "Trusty Tahr" for doing the initial chroot. The process was as follows:
 
I used Ubuntu 14.04 "Trusty Tahr" for doing the initial chroot. The process was as follows:
Line 56: Line 59:
 
This may take a while.
 
This may take a while.
  
Next, we're going to build clang, llvm, and libc++ that target OS X.
+
 
 +
== Building clang ==
 +
 
 
'''NOTE:''' There is a [http://llvm.org/bugs/show_bug.cgi?id=19945 bug] with building cross-compilers for OS X.
 
'''NOTE:''' There is a [http://llvm.org/bugs/show_bug.cgi?id=19945 bug] with building cross-compilers for OS X.
 
  cd /usr/src
 
  cd /usr/src
Line 69: Line 74:
 
  make install
 
  make install
  
 +
== Getting Headers ==
 
To tease the headers out of the Xcode so that we can compile anything, we need to install the xar archiver, which is not packaged in Trusty.
 
To tease the headers out of the Xcode so that we can compile anything, we need to install the xar archiver, which is not packaged in Trusty.
 
  wget https://xar.googlecode.com/files/xar-1.5.2.tar.gz
 
  wget https://xar.googlecode.com/files/xar-1.5.2.tar.gz
Line 98: Line 104:
  
 
Next step: APSL headers for OSX, from Xcode, and then add libc++ compile instructions
 
Next step: APSL headers for OSX, from Xcode, and then add libc++ compile instructions
+
 
 +
 
 +
== Installing dyld ==
 +
 
 +
 
  
 
More coming...
 
More coming...

Revision as of 20:30, 5 June 2014

This is being worked on, please maintain your patience. I have successfully done this before but I don't remember what I did, so I will have to recreate a lot of stuff.

You need:

  • a mind so deadset on cross-compiling you won't stop to think
  • the Xcode .dmg for your target OS X version
  • root access to your build system
  • a good processor and a lot of RAM

The following should be done on the host system first. Download the Xcode DMG, and use dmg2img to convert it to an IMG. Mount the IMG, and put the .pkg files into the chroot somewhere. I'm using /mnt/apple.


Making the chroot

I used Ubuntu 14.04 "Trusty Tahr" for doing the initial chroot. The process was as follows:

apt-get install dchroot debootstrap

Then edit /etc/schroot/schroot.conf with your favourite text editor, and add this at the end:

[trusty]
description=Ubuntu Trusty
location=/var/chroot
priority=3
users=your_username
groups=sbuild
root-groups=root

Install a base system:

sudo debootstrap --variant=buildd --arch amd64 trusty /var/chroot/ mirror.url.com/ubuntu/

where mirror.url.com/ubuntu/ can be any of these mirrors.

Now copy your resolv.conf for internet access (required):

sudo cp /etc/resolv.conf /var/chroot/etc/resolv.conf

Bind your procfs into the chroot for gnustep:

sudo mount -o bind /proc /var/chroot/proc

Finally, chroot into your target:

sudo chroot /var/chroot

You should now have a working chroot, free for you to destroy as you see fit. (from https://help.ubuntu.com/community/BasicChroot)

To avoid pointless warnings about missing locales, do this:

apt-get install language-pack-en

Install some packages to start off with:

apt-get install sudo nano vim bzr subversion groff man-db

Edit your /etc/apt/sources.list to include the universe source and update:

deb mirror.url.com/ubuntu/ trusty main
deb-src mirror.url.com/ubuntu/ trusty main

deb mirror.url.com/ubuntu/ trusty universe
deb-src mirror.url.com/ubuntu/ trusty universe

Now install gnustep:

apt-get install gnustep gnustep-devel

This may take a while.


Building clang

NOTE: There is a bug with building cross-compilers for OS X.

cd /usr/src
svn co http://llvm.org/svn/llvm-project/llvm/trunk llvm
cd llvm/tools
svn co http://llvm.org/svn/llvm-project/cfe/trunk clang
cd ..; mkdir build; cd build
../configure --prefix=/usr/clang_3_4 --enable-optimized --enable-targets=x86_64,x86 \
   --disable-compiler-version-checks --host=x86_64-unknown-linux-gnu --build=x86_64-unknown-linux-gnu \
   --target=x86_64-apple-darwin11.4.2
make -j4
make install

Getting Headers

To tease the headers out of the Xcode so that we can compile anything, we need to install the xar archiver, which is not packaged in Trusty.

wget https://xar.googlecode.com/files/xar-1.5.2.tar.gz
tar -xvf xar-1.5.2.tar.gz
apt-get install libxml2-dev libssl-dev libbz2-dev
cd xar-1.5.2; ./configure
make; make install

Now go to the location of your PKG files. Each one needs to be extracted, and then the payload needs to be extracted too.

cd /mnt/apple
mkdir DeveloperToolsCLI
cd DeveloperToolsCLI
xar -xvf ../DeveloperToolsCLI.pkg

Extract the payload (gzip doesn't really like unnamed files)

mv ./Payload ./Payload.gz
gunzip ./Payload.gz

The resulting file is a compressed CPIO archive. Extract that too:

mkdir Contents; cd Contents
cpio -idv < ../Payload

Okay, finally. Now we can figure out what's going where.

./System and ./Library are fine. We can just copy those over:

cp -R ./System /System
cp -R ./Library /Library

But ./usr is tricky — we might end up overwriting some sort of important file if we try just blatantly overwriting our /usr. So, what do we do? Scan the include paths for clang, and see what we can get away with, of course.


Next step: APSL headers for OSX, from Xcode, and then add libc++ compile instructions


Installing dyld

More coming...