Wednesday, October 23, 2013

Building xnu for OS X 10.9 Mavericks

The OS X kernel source (xnu) has been released for OS X 10.9 Mavericks: here

Building xnu requires Xcode and some additional open-source (but not pre-installed) dependencies. You can build xnu manually by doing:


  1. Install OS X Mavericks and Xcode 5.0.1, make sure the Xcode license has been agreed-to with "sudo xcodebuild -license"
  2. Download the source for the dtrace and AvailabilityVersions projects, which are required dependencies, as well as xnu itself
    $ curl -O http://opensource.apple.com/tarballs/dtrace/dtrace-118.tar.gz
    $ curl -O http://opensource.apple.com/tarballs/AvailabilityVersions/AvailabilityVersions-6.tar.gz
    $ curl -O http://opensource.apple.com/tarballs/xnu/xnu-2422.1.72.tar.gz
  3. Build and install CTF tools from dtrace
    $ tar zxf dtrace-118.tar.gz
    $ cd dtrace-118
    $ mkdir -p obj sym dst
    $ xcodebuild install -target ctfconvert -target ctfdump -target ctfmerge ARCHS="x86_64" SRCROOT=$PWD OBJROOT=$PWD/obj SYMROOT=$PWD/sym DSTROOT=$PWD/dst
    ...
    $ sudo ditto $PWD/dst/usr/local /usr/local
    Password:
    $ cd ..
    
  4. Install AvailabilityVersions
    $ tar zxf AvailabilityVersions-6.tar.gz
    $ cd AvailabilityVersions-6
    $ mkdir -p dst
    $ make install SRCROOT=$PWD DSTROOT=$PWD/dst
    $ sudo ditto $PWD/dst/usr/local `xcrun -sdk / -show-sdk-path`/usr/local
    $ cd ..
    
  5. Build xnu
    $ tar zxf xnu-2422.1.72.tar.gz
    $ cd xnu-2422.1.72
    $ make ARCH_CONFIGS=X86_64 KERNEL_CONFIGS=RELEASE