Wednesday, December 26, 2007

Compile xnu on Leopard

After Lepard shipped, the darwin source code for leopard, version 9.0.0, is also out. The source code includes the kernel source, xnu. I tried its compilation, but I always failed without darwinbuild. The error message was as followed:

C++ IOUserClient.cpo
C++ AppleNMI.cpo
C++ AppleMacIO.cpo
C++ IOPMrootDomain.cpo
LD iokit
ld_classic: ./WKdmDecompress.o section's (__HIB,__debug_frame) has debug attribute (S_ATTR_DEBUG) which does not match previously loaded object's sections for this segment
ld_classic: ./IOHibernateRestoreKernel.o section's (__HIB,__debug_frame) has debug attribute (S_ATTR_DEBUG) which does not match previously loaded object's sections for this segment
collect2: ld returned 1 exit status
make[6]: *** [iokit.o] Error 1
make[5]: *** [build_all] Error 2
make[4]: *** [do_all] Error 2
make[3]: *** [build_all] Error 2
make[2]: *** [build_all] Error 2
make[1]: *** [build_all] Error 2
make: *** [all] Error 2

As a result, this is caused because some outdated commands are used for the compilation, such as seg_hack and kextsymtool. If you installed these command with kernel-tools-8J2135.root.tar.gz distributed at MacOS Forge, you would see the above message.

To install the new commands to be able to compile leopard xnu, you should complie cctools by yourself or install its binaries from http://src.macosforge.org/Roots/9A581/cctools.root.tar.gz.


Here is more detail to build the tools:

  1. Bulidng darwinbuild (you can skip this step if you have already it)


  2. $ cd ${somewhere}
    $ svn co http://svn.macosforge.org/repositorydarwinbuild/trunk darwinbuild
    $ make
    $ sudo make install

  3. Build necessary tools with darwinbuild

    $ cd ${another place}
    $ mkdir 9C31
    $ sudo darwinbuild -init 9C31
    $ sudo darwinbuild cctools