Building xnu requires Xcode and some additional open-source (but not pre-installed) dependencies. You can build xnu manually by doing:
- Install OS X Mavericks and Xcode 5.0.1, make sure the Xcode license has been agreed-to with "sudo xcodebuild -license"
- 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
- 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 ..
- 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 ..
- Build xnu
$ tar zxf xnu-2422.1.72.tar.gz $ cd xnu-2422.1.72 $ make ARCH_CONFIGS=X86_64 KERNEL_CONFIGS=RELEASE
18 comments:
Thank you very much for your guide! It helped a lot!
I'm building on 10.9.2 with the latest Xcode (5.1.1). I get several errors when building xnu:
1.
In
http://www.opensource.apple.com/source/xnu/xnu-2422.1.72/osfmk/kern/extmod_statistics.h
it complains about a mismatch of the define: testing "_KERN_EXTMOD_STATISTICS_H_" but defining "_KERN_EXTMODE_STATISTICS_H_".
2.
Getting this message on several files:
"ERROR: ctfconvert: file does not contain dwarf type data (try compiling with -g)"
3.
Lots of errors around "vlan" functions, such as:
"/Development/Darwin/xnu/bsd/net/if_vlan.c:267:1: error: unused function 'vlan_parent_flags_clear_supports_vlan_mtu'
[-Werror,-Wunused-function]"
Any idea what's going wrong?
(Yes, I am building "xnu-2422.1.72", I just renamed the dir to "xnu", but that can hardly be the cause of these errors).
BTW. I am using:
$ cc --version
Apple LLVM version 5.1 (clang-503.0.40) (based on LLVM 3.4svn)
Target: x86_64-apple-darwin13.1.0
Thread model: posix
Have you tried building xnu with Xcode 5.1 on 10.9.2? Does it work for you? If not, I might just try to install Xcode 5.0.1 in a VM and see if that helps.
Turns out it's a problem with Xcode 5.1.1 - I have installed a clean 10.9.2 with Xcode 5.0.2 - that one built the kernel fine, even though I got the "ctfconvert" errors there as well.
Then I installed Xcode 5.1.1 and did another make - that one then failed again.
So, for anyone trying to build xnu Darwin 13.1.0 - get the older Xcode 5.0.2 from Apple's "Additional Tools" Downloads page (https://developer.apple.com/downloads/).
I was able to compile this with Xcode 5.1, after removing the occurrences of -Werror from makedefs/MakeInc.def
Greetings,
Great tutorial! I've been building xnu this way for quite a while. I built and installed the kernel just fine, however, what I noticed is that, this kernel is not being loaded by the kernelcache file. I tested this by comparing the boot time between the stock kernel and this kernel in verbose mode. The stock kernel boots in approximately 6-8 seconds. This kernel however, takes 30-40 seconds to boot. I'm presuming that the kernel built from your guide is not a `prelinked' kernel.
The system is definitely not loading the kernelcache file when I boot with the kernel created from your guide.
I'm somewhat new to building prelinked mach_kernels. Do you have any ideas on how to go about doing anything like this, or; i.e., is there some other way to get this kernel to use the already existing kernelcache file that the stock kernel uses? Or, is that a bad idea?
The primary reason that I'm wanting to do this is because I want to rectify the extremely slow boot with this self-compiled kernel. I've tried rebuilding the caches, etc... and that does nothing, as far as affecting the speed up.
Any suggestions would be greatly appreciated.
Thanks.
Thank you very much! This works with Yosemite (10.10) running XCode 6.1 as well. The only difference is the package version numbers you build.
dtrace-147
AvailabilityVersions-9
xnu-2782.1.97
Oh, and the command to compile xnu for Yosemite is slightly different as well:
make TARGET_CONFIGS="release x86_64 default" SDKROOT=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk
I would love to know if I could build all the versions mentioned here with One OS and current Xcode !
Or at least all the downward versions of xnu from what I've for OS version.
In my case, it is 10.9.5, Xcode 6.1.1 - so what version(s) could I possibly build with this ?
Thanks
Prokash
Why iMac Macbook production before Maverick Osx no internet recovery
this an answer
Hello, do you know if modern xnu (included in OSX) is compiled with clang or with gcc? thanks!
Good and very useful article. Thanks a lot!
MgmD | MgmD
The MgmD is an innovative 통영 출장샵 and exciting social platform and 천안 출장샵 betting app. The 수원 출장안마 MgmD is 제천 출장샵 an innovative and 경주 출장마사지 exciting social platform and betting app. Rating: 4.4 · 3,254 reviews
Post a Comment