• Building the Sierra Kernel

  • Development and testing of modified XNU Kernels for AMD CPUs on OS X

Please remember to read and follow the rules here.


Please Donate if you've found the website useful. Thanks.

Development and testing of modified XNU Kernels for AMD CPUs on OS X
 #14095  by Shaneee
 Tue Feb 07, 2017 11:30 pm
If you feel like building your own kernel for Sierra or wish to help out with it here is how to build it.

First of all you are going to need Xcode installed. It's in the App Store. Then download the Sierra XNU Preparation from the GitHub link below.. Open up Terminal and drag the build.sh file onto the Terminal window and press Enter. It'll ask for the password to perform the Sudo function.

Once it's done the System will have the required dependencies to build the XNU.

Now you can download the latest Sierra source. As of now it's 10.12.4. Here's the link,
Code: Select all
https://opensource.apple.com/tarballs/xnu/xnu-3789.51.2.tar.gz

Put it somewhere for example the desktop and unzip it. Then in Terminal run,
Code: Select all
cd Desktop/xnu-3789.51.2

Now you can apply my patches which are also attached at the bottom of this post. Still in Terminal in the XNU folder run this command. After the < Drag the diff onto the Terminal Window and press enter.
Code: Select all
patch -p1 < 

This will apply the patches onto the source. You are now free to tinker with the source code. Once ready to build run this in Terminal,
Code: Select all
sudo make SDKROOT=macosx ARCH_CONFIGS=X86_64 KERNEL_CONFIGS=RELEASE

If it completes successfully the built kernel will be in BUILD/obj/RELEASE_X86_64/

GitHub Link:
Code: Select all
https://github.com/Shaneee92/Sierra_XNU_Prep
Changelog:
  • Script added to GitHub.
  • dtrace updated.
  • AvailablityVersions updated.
  • Libdispatch updated.
  • Diff updated.
You do not have the required permissions to view the files attached to this post.
Last edited by Shaneee on Wed Mar 29, 2017 3:39 pm, edited 1 time in total.
 #14218  by Ackados
 Thu Feb 09, 2017 12:37 am
From what I'm told, you need X Code, or at least Mac OS X. I'm going to see if I can getting on working on Windows too.
 #14272  by Shaneee
 Thu Feb 09, 2017 8:22 pm
As far as I'm aware running from OS X is required. Xcode and the dependencies are a requirement.
 #14307  by Ackados
 Fri Feb 10, 2017 2:10 am
Could be correct. I did try installing Cygwin on Windows and it didn't work, and I think you do need OS X. Maybe on Linux.
 #14773  by BlazeThunderkush
 Wed Feb 15, 2017 7:34 pm
Ackados wrote:Could be correct. I did try installing Cygwin on Windows and it didn't work, and I think you do need OS X. Maybe on Linux.
I'm afraid it requires an OSX Environment and Xcode for Apple's Clang. Plus i have no idea if there are cross compilers for xnu executables. More info: i found this helper tool which works very well
Code: Select all
https://github.com/ddeville/xnu-make
, you can switch SDK's (ive been able to build vanilla-xnu kernel using older sdk's) in case of problems installing binaries usingf Shaneee's script should fix that. Also i'm working on doing a proper merge of xnu kernel with full commits tree
Code: Select all
https://github.com/ddeville/xnu
. I recommend this tools, because everything goes to /usr/local instead of system wide, because i dont want to risk breaking the system :) I broke bash and c library once and had to do refresh install :)

I need to modify your script so it won't install deps system-wide, or better, make a package installing deps and deps deps using either
Code: Select all
https://brew.sh/
or use
Code: Select all
https://wiki.gentoo.org/wiki/Project:Prefix
because im familar with portage. Also, i need to study this linux patch
Code: Select all
https://github.com/graysky2/kernel_gcc_patch/blob/master/enable_additional_cpu_optimizations_for_gcc_v4.9%2B_kernel_v3.15%2B.patch
Also i reccomend this tool
Code: Select all
http://meldmerge.org/
and this arm port
Code: Select all
https://github.com/darwin-on-arm/xnu
This weekend im gonna meld a x86 tree an arm tree and hackintosh tree of version 10.9 to have lowest common denominator
We're dealing with a POSIX kernel that follows design and programming patterns, so i gues freebsd kernel should be analyzed to see where is the easiest to port modules and amd opcode. We may even need to patch clang for that :D
edit: forum bug on chrome @ yosemite :)
Last edited by Shaneee on Sun Feb 26, 2017 5:20 pm, edited 4 times in total. Reason: Links coded.
Ackados liked this
 #14778  by Shaneee
 Wed Feb 15, 2017 7:47 pm
The builder script won't break your system. I tested it on multiple installs to be sure. I have the xnu on github just haven't got round to adding all the commits.
BlazeThunderkush liked this
 #14850  by BlazeThunderkush
 Thu Feb 16, 2017 7:12 pm
Shaneee wrote:The builder script won't break your system. I tested it on multiple installs to be sure. I have the xnu on github just haven't got round to adding all the commits.
I'm sorry if you got me wrong, your script is fine, i broke the c runtime on my own :) it's just i'm terribly picky when it comes to "make instal" style installation, on every server i'm guarding there's no single file in the system tree that's not managed by package manager, and everything done with "make" goes either to /usr/local or /opt
Cheers, this weekend it's gonna be me and xnu. Death by xnu xnu :)
Shaneee liked this
 #15363  by DarOSX
 Thu Feb 23, 2017 2:30 am
@Shanee How did you get passed the firehose error? I ran the xnu script but I still get that error?
 #15364  by DarOSX
 Thu Feb 23, 2017 2:46 am
NVM.... I figured it out for some reason your script moves to fast and didn't copy things to the SDK for firehose
Shaneee liked this
 #17209  by Shaneee
 Wed Mar 29, 2017 3:40 pm
Post updated :geek: