- Joined
- Jul 19, 2021
- Messages
- 25
This was posted because apparently someone's trying to figure out the IOPCIFamily issues on MSI 500 series boards and AM5 socket boards and they're having trouble with building XNU.
Here's what I wrote in the Discord server:
Grab the version of Xcode with the correct SDK for the kernel you're building.
Run
Verify that
Go to https://opensource.apple.com/releases/ and pick a macOS version, download all of the following packages from that version of macOS specifically.
(You can also clone the packages from apple-oss-distributions and
But anyway:
Download
It was at this point that I had my first issue:
The path you want is
A wild stupid problem appears! Apparently
You may think "why don't you just find
So i just kept compiling it and compiling it and adding
Here is the result of that lmfao:
To remove the symlink you made earlier:
If you want to use a different build configuration than
Hope this helps.
Here's what I wrote in the Discord server:
Grab the version of Xcode with the correct SDK for the kernel you're building.
Run
xcode-select
on it.Verify that
xcrun -sdk macosx -show-sdk-path
returns the correct path.$ xcode-select --install
to install the Xcode Command Line Tools for that version of Xcode.Go to https://opensource.apple.com/releases/ and pick a macOS version, download all of the following packages from that version of macOS specifically.
(You can also clone the packages from apple-oss-distributions and
checkout
the branch for the release you want.)But anyway:
Download
dtrace
, AvailabilityVersions
, libdispatch
, and xnu
.cd
to dtrace
$ xcodebuild install -sdk macosx -target ctfconvert -target ctfdump -target ctfmerge ARCHS=x86_64 VALID_ARCHS=x86_64 DSTROOT=$PWD/dst
$ export TOOLCHAIN="cd $(xcrun -sdk macosx -show-sdk-platform-path)/../../Toolchains/XcodeDefault.xctoolchain && pwd"
# ditto "$PWD/dst/$TOOLCHAIN" "$TOOLCHAIN"
cd
to AvailabilityVersions
$ make install
# ditto "$PWD/dst/usr/local/libexec" "$(xcrun -sdk macosx -show-sdk-path)/usr/local/libexec"
cd
to xnu
It was at this point that I had my first issue:
scan-build
apparently didn't build+install correctly? So I had to install LLVM (which includes it) and then add the LLVM /bin/ folder to my path variable.The path you want is
/usr/local/opt/llvm/bin
. This will add LLVM Clang to your path, but XNU's build system automatically targets Apple Clang anyway, so it's not an issue.$ brew install llvm
# ln -s /usr/local/bin/python3 /usr/local/bin/python
$ make SDKROOT=macosx ARCH_CONFIGS=X86_64 installhdrs
# ditto "$PWD/BUILD/dst" "$(xcrun -sdk macosx -show-sdk-path)"
cd
to libdispatch
$ xcodebuild install -sdk macosx ARCHS=x86_64 VALID_ARCHS=x86_64 -target libfirehose_kernel PRODUCT_NAME=firehose_kernel DSTROOT=$PWD/dst
# ditto "$PWD/dst/usr/local" "$(xcrun -sdk macosx -show-sdk-path)/usr/local"
cd
back to xnu
A wild stupid problem appears! Apparently
-Werror
is in the clang build options for XNU, but XNU is absolutely riddled with warnings (as you'd expect), so it just errors out.You may think "why don't you just find
-Werror
and remove it?", and that's a great question! The answer is I couldn't find it (sobbing)So i just kept compiling it and compiling it and adding
-Wno-error=whatever
to my clang flags every time an error came up that was actually a warning.Here is the result of that lmfao:
$ make SDKROOT=macosx ARCH_CONFIGS=X86_64 KERNEL_CONFIGS=RELEASE CFLAGS_RELEASEX86_64="-Wno-error=unused-but-set-variable -Wno-error=four-char-constants -Wno-error=suggest-destructor-override -Wno-error=suggest-override -Wno-error=null-pointer-subtraction -Wno-error=void-pointer-to-int-cast -Wno-error=tautological-value-range-compare -Wno-error=unused-but-set-parameter -Wno-error=shorten-64-to-32 -Wno-error=undef-prefix -Wno-error=implicit-int-conversion -Wno-error=pointer-to-int-cast" CXXFLAGS_RELEASEX86_64="-Wno-error=unused-but-set-variable -Wno-error=four-char-constants -Wno-error=suggest-destructor-override -Wno-error=suggest-override -Wno-error=null-pointer-subtraction -Wno-error=void-pointer-to-int-cast -Wno-error=tautological-value-range-compare -Wno-error=unused-but-set-parameter -Wno-error=shorten-64-to-32 -Wno-error=undef-prefix -Wno-error=implicit-int-conversion -Wno-error=pointer-to-int-cast"
To remove the symlink you made earlier:
# rm /usr/local/bin/python
If you want to use a different build configuration than
RELEASE
, youll need to change KERNEL_CONFIGS
, CFLAGS_RELEASEX86_64
, and CXXFLAGS_RELEASEX86_64
to reflect that. In the case of the last two, you'll just need to change the names of the variables, not the actual value.Hope this helps.
Last edited: