Welcome to PureDarwin Developers!
Registration for New Users can be done via GitHub/Google/OpenID/Live/Yahoo accounts!

Building XNU 16.7(xnu-3789.70.16)

Discussion of x86_64 Kernel Development
InSaneDarwin
Site Admin
Posts: 2
Joined: Tue Oct 03, 2017 11:50 pm

Building XNU 16.7(xnu-3789.70.16)

Postby InSaneDarwin » Thu Oct 12, 2017 2:26 am

Here's a guide for Building XNU 16.7 from start to finish

Requirements macOS 10.12.6 and Xcode 8.3.3

**These must be done in order or it will not build**

Open terminal.app // copy each command in as you go.

* Creating workspace
*************************************

Code: Select all

# mkdir -p ~/Desktop/xnu_build
# cd ~/Desktop/xnu_build
* Curling needed Sources
************************************

Code: Select all

# curl -O https://opensource.apple.com/tarballs/dtrace/dtrace-209.50.12.tar.gz && 
curl -O https://opensource.apple.com/tarballs/AvailabilityVersions/AvailabilityVersions-26.50.4.tar.gz && 
curl -O https://opensource.apple.com/tarballs/xnu/xnu-3789.70.16.tar.gz && 
curl -O https://opensource.apple.com/tarballs/libdispatch/libdispatch-703.50.37.tar.gz && 
curl -O https://opensource.apple.com/tarballs/libplatform/libplatform-126.50.8.tar.gz
* Extracting and Removing Tar.gz files
************************************

Code: Select all

# for file in *.tar.gz; do tar -zxf $file; done && rm -f *.tar.gz
* Building Dtrace's CTF"s Bianries
************************************

Code: Select all

# cd dtrace-209.50.12
# 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/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain   
* Installing Availability
************************************

Code: Select all

# cd ../AvailabilityVersions-26.50.4/ 
# mkdir -p dst 
# make install SRCROOT=$PWD DSTROOT=$PWD/dst
# sudo ditto $PWD/dst/usr/local `xcrun -sdk macosx -show-sdk-path`/usr/local
* Installing Headers to build libfirehose_kernel.a for XNU
************************************

Code: Select all

# cd ../xnu-3789.70.16/
# mkdir -p BUILD.hdrs/obj BUILD.hdrs/sym BUILD.hdrs/dst
# make installhdrs SDKROOT=macosx ARCH_CONFIGS=X86_64 SRCROOT=$PWD OBJROOT=$PWD/BUILD.hdrs/obj SYMROOT=$PWD/BUILD.hdrs/sym DSTROOT=$PWD/BUILD.hdrs/dst
# sudo xcodebuild installhdrs -project libsyscall/Libsyscall.xcodeproj -sdk macosx ARCHS='x86_64 i386' SRCROOT=$PWD/libsyscall OBJROOT=$PWD/BUILD.hdrs/obj SYMROOT=$PWD/BUILD.hdrs/sym DSTROOT=$PWD/BUILD.hdrs/dst   
# sudo ditto BUILD.hdrs/dst `xcrun -sdk macosx -show-sdk-path`  

* Copying libplatform source needed for libfirehose_kernel.a
************************************

Code: Select all

# cd ../libplatform-126.50.8
# sudo ditto $PWD/include `xcrun -sdk macosx -show-sdk-path`/usr/local/include   
* Building libfirehose_kernel.a
************************************

Code: Select all

# cd ../libdispatch-703.50.37
# mkdir -p BUILD.hdrs/obj BUILD.hdrs/sym BUILD.hdrs/dst
# sudo xcodebuild install -project libdispatch.xcodeproj -target libfirehose_kernel -sdk macosx ARCHS='x86_64 i386' SRCROOT=$PWD OBJROOT=$PWD/obj SYMROOT=$PWD/sym DSTROOT=$PWD/dst
# sudo ditto $PWD/dst/usr/local `xcrun -sdk macosx -show-sdk-path`/usr/local
* Building XNU
**********************************

Code: Select all

# cd ../xnu-3789.70.16/
# make SDKROOT=macosx ARCH_CONFIGS=X86_64 KERNEL_CONFIGS=RELEASE

bart
Posts: 4
Joined: Wed Oct 04, 2017 1:26 am

Re: Building XNU 16.7(xnu-3789.70.16)

Postby bart » Thu Oct 12, 2017 10:43 am

Thanks for this build guide @InSaneDarwin,

i think with this guide we help a lot of ppl who searching a kernel build Guide for 16.7 XNU Kernel.

Cheers

User avatar
OmeletHopper
Posts: 1
Joined: Tue Jun 05, 2018 8:19 am

Re: Building XNU 16.7(xnu-3789.70.16)

Postby OmeletHopper » Tue Jun 05, 2018 8:22 am

After building the kernel, how can we build a bootable image of darwin?


Who is online

Users browsing this forum: No registered users and 0 guests