Apple's open-source XNU kernel on Android phones: its own loader and drivers, Metal on the Adreno. Runs from RAM; a reboot gives the phone back to Android.
C
userland/build.sh: on macOS, clone the trees (cp -c) where Linux hard-links them (cp -al, which macOS's cp has not)
shimokufa3a850d9cbf
diff --git a/userland/build.sh b/userland/build.shindex da667a8..84ab50e 100755--- a/userland/build.sh+++ b/userland/build.sh@@ -75,6 +75,8 @@# the kernel's apfs_lib has to read every volume back as the directory it was made of# (../tools/apfs/check-image.sh; the system image takes a few minutes more)set -e+# a copy of a tree that shares its files' data: hard links (Linux), clones of the files (macOS's APFS, whose cp has no -l)+linkcopy() { if [ "$(uname)" = Darwin ]; then cp -cRp "$1" "$2"; else cp -al "$1" "$2"; fi; }cd "$(dirname "$(readlink -f "$0")")"source ../xnu-env.sh@@ -483,7 +485,7 @@ if [ -n "$FLASHBOOT" ] && [ -f $CACHE/dyld_shared_cache_arm64 ]; then# built and thrown away unused. The guard ends with the cache: everything after it goes# into the boot volume, which every recipe carries, flash cryptexes includedif [ "$CRYPTEXES" != flash ]; then- if [ -d $IOS/cryptex ]; then cp -al $IOS/cryptex flashboot.os; else mkdir -p flashboot.os; fi+ if [ -d $IOS/cryptex ]; then linkcopy $IOS/cryptex flashboot.os; else mkdir -p flashboot.os; fiD=flashboot.os/System/Library/Caches/com.apple.dyldmkdir -p $Dfor f in $CACHE/dyld_shared_cache_arm64*; do@@ -518,7 +520,7 @@ if [ -n "$FLASHBOOT" ] && [ -f $CACHE/dyld_shared_cache_arm64 ]; thenfipython3 ../tools/apfs/mkapfs.py -z --plain fw -o flashboot.boot.apfs Boot=flashboot | tail -1[ -z "$CHECK" ] || ../tools/apfs/check-image.sh flashboot.boot.apfs Boot=flashboot- # the third container: Apple's App cryptex as it is (10 MB; fetch.sh), for the boot volume's Cryptexes/App+ # the third container: Apple's App cryptex as it is (10 MB; unpack.sh), for the boot volume's Cryptexes/AppAPP=""[ -f $IOS/cryptex-app.dmg ] && APP=$IOS/cryptex-app.dmgif [ "$CRYPTEXES" = flash ]; then@@ -543,11 +545,11 @@ if [ -f $IOS/system.manifest ] && [ -f $CACHE/dyld_shared_cache_arm64 ] &&# in the image either (so it was once with the audio plug-ins and the system's sounds: iOS found no# speaker and played nothing, though our device was there and the kernel's side worked)if [ -f $IOS/.done-rootfs ] && [ $IOS/select-system.py -nt $IOS/.done-rootfs ]; then- echo "build.sh: sysimage/select-system.py has changed since sysimage/rootfs was extracted: run KEEP=1 sysimage/fetch.sh" >&2+ echo "build.sh: sysimage/select-system.py has changed since sysimage/rootfs was extracted: run KEEP=1 sysimage/unpack.sh" >&2exit 1firm -rf sysroot- cp -al $IOS/rootfs sysroot # hard links: no copies of the 0.5 GB+ linkcopy $IOS/rootfs sysroot # hard links or clones: no copies of the 0.5 GB# launchd must load our choice of jobs, not all 500 that iOS hasrm -rf sysroot/System/Library/LaunchDaemons sysroot/System/Library/NanoLaunchDaemons \sysroot/System/Library/LaunchAngels sysroot/System/Library/xpc/launchd.plist@@ -619,10 +621,10 @@ if [ -f $IOS/system.manifest ] && [ -f $CACHE/dyld_shared_cache_arm64 ] &&# the OS cryptex: on a device a separate volume grafted at /System/Cryptexes/OS. It holds the dyld# shared cache (dyld looks there first) and a few libraries and resources outside the cache.mkdir -p sysroot/System/Cryptexes- if [ -d $IOS/cryptex ]; then cp -al $IOS/cryptex sysroot/System/Cryptexes/OS; fi+ if [ -d $IOS/cryptex ]; then linkcopy $IOS/cryptex sysroot/System/Cryptexes/OS; fi# the App cryptex, the same way: Safari's daemons (eight launchd jobs run them from there), its settings and# the bundles around it, which the root's links reach (System/Library/PreferenceBundles/MobileSafariSettings.bundle...)- if [ -d $IOS/cryptex-app ]; then cp -al $IOS/cryptex-app sysroot/System/Cryptexes/App; fi+ if [ -d $IOS/cryptex-app ]; then linkcopy $IOS/cryptex-app sysroot/System/Cryptexes/App; fiD=sysroot/System/Cryptexes/OS/System/Library/Caches/com.apple.dyldmkdir -p $Dfor f in $CACHE/dyld_shared_cache_arm64*; do