Files
Anees Iqbal 91211ecb57 ✅ Check the guest's kext sets against a release's KC
Neither make -C guest test nor prebuilt-check links a kext against a kernel,
and set-check needs OpenCore's TestKextInject and covers only the x86-64 set.
So the guest's mouse (21632b275) shipped imports that x86-64 11 and 12 and
arm64 14 and 15 lack, and the merge boots, x86-64 26.7.2 and arm64 26 only,
did not see it.

guest/tools/kc-imports.py takes a guest's kernel collection and a set. It
reads the KC raw, or as an arm64 guest's IMG4, whose LZFSE payload it decodes
with compression_tool. It then fails on each name a kext imports that neither
the collection nor an earlier kext of the set defines, which is the rule
Ambrosia's linker refuses by. An x86-64 kext imports its undefined external
symbols; an arm64e kext imports the names its chained fixups bind, so an
import that Graft binds at run time is not counted. make -C guest kc-check
KC=... KC64=... runs it on guest/prebuilt and guest/prebuilt-arm64e.

It runs on a Mac after a set rebuild, against the oldest release of each set
(x86-64 11.7.11's Boot KC, arm64 14.6.1's kernelcache) and the newest. The
collections are copied out of the guests and kept local: nothing taken from
them is committed. docs/development.md, Testing, says where each one lives.

Against development's sets it named the six IOHIDDevice methods on x86-64
11.7.11 and 12.7.6, and didTerminate alone on x86-64 13.7.8 to 15.8.2 and
arm64 14.6.1 and 15.6.1. Against the fixed sets every import resolves on
x86-64 11.7.11 to 26.7.2 and arm64 14.6.1 to 27.0.1 (m3-max-35732).
2026-11-16 02:44:27 -08:00

115 lines
5.1 KiB
Makefile

# The guest side of the reims-graphics device (QEMU's reims-graphics-pci) for
# x86-64 macOS 11 to 26 guests, and the kext set their OpenCore image injects
# for it, and the arm64e set for the arm64 macOS 14 and later guests Ambrosia
# boots (prebuilt-arm64e/, which Ambrosia's config bundle places):
# Graft (graft/, vendored from Graft's repository with its record),
# ReimsGraphics (kext/), injected dormant for Graft to bind against the
# System kernel collection's libraries, and RgfxGate (rgfxgate/), a Graft
# client that carries the Metal bundle (bundle/). Builds on a Mac with Xcode
# alone: no KDK and nothing fetched.
#
# make set [OUT=build/set]
# build each part in build/set-work/ and write OUT: the set's bundles
# and set.toml, their Kernel > Add entries in order (tools/prebuilt.py)
# make prebuilt
# the set built afresh into prebuilt/, which the repository carries
# for hosts that cannot build it, and prebuilt/sources.toml, the
# record of the sources it was built from; commit prebuilt/ with the
# change to those sources
# make set-arm64e [OUT64=build/set-arm64e]
# the arm64e set: Graft's arm64e build, and ReimsGraphics and RgfxGate
# for arm64e, with the Metal bundle for arm64e and arm64 inside RgfxGate
# make prebuilt-arm64e
# that set built afresh into prebuilt-arm64e/ with its own sources.toml
# make prebuilt-check
# fail unless prebuilt/ and prebuilt-arm64e/ are each what their
# sources.toml records, the tree's sources are the ones they were built
# from, graft/ is the copy its source.toml records, and no kext leaves
# one of our own symbols undefined that no kext before it defines (which
# staging a set checks too); hashes and symbol tables only, on any host
# make set-check KEXTINJECT=<OpenCorePkg's TestKextInject binary>
# BOOT_KC=<the guest's x86_64 BootKernelExtensions.kc> [SET=prebuilt]
# link SET into BOOT_KC with OpenCore's linker, in user space, in
# Kernel > Add order; check every kext injects and every name
# resolves, and that ReimsGraphics stays bindable by Graft
# (tools/oc-link-set.sh)
# make kc-check KC=<an x86-64 guest's BootKernelExtensions.kc>
# KC64=<an arm64 guest's kernelcache> [SET=prebuilt] [SET64=prebuilt-arm64e]
# check that a release's kernel collection defines every name the set
# it boots imports (tools/kc-imports.py): SET against KC, SET64 against
# KC64, each where it is given. After `make prebuilt` and `make
# prebuilt-arm64e`, run it against the oldest release of each set
# (x86-64 11.7.11, arm64 14.6.1) and the newest: the SDK's headers are
# the newest release's, and an import an older release lacks keeps the
# set off it (Ambrosia refuses the boot). The collections are the
# guests' own, copied out of a guest, kept local and never committed
# (docs/development.md, Testing)
# make test the parts' own tests: kext/, rgfxgate/ and bundle/
# make clean remove build/
#
# Everything but prebuilt/ lands in build/ or the parts' own build/, never
# committed. To take a new Graft, replace graft/ with Graft's
# tools/vendor.py and rebuild prebuilt/.
OUT ?= build/set
OUT64 ?= build/set-arm64e
SET ?= prebuilt
SET64 ?= prebuilt-arm64e
WORK = $(abspath build/set-work)
WORK64 = $(abspath build/set-work-arm64e)
BUNDLE = $(WORK)/bundle/package/reims-graphics.bundle
BUNDLE64 = $(WORK64)/bundle/package/reims-graphics.bundle
KEXTINJECT ?=
BOOT_KC ?=
KC ?=
KC64 ?=
# The parts' Makefiles get only the variables given them below, not this
# command line's (OUT would set theirs).
MAKEOVERRIDES =
.PHONY: set prebuilt set-arm64e prebuilt-arm64e prebuilt-check set-check kc-check test clean
set:
$(MAKE) -C kext BUILD=$(WORK)/kext
$(MAKE) -C bundle BUILD=$(WORK)/bundle package
$(MAKE) -C rgfxgate BUILD=$(WORK)/rgfxgate BUNDLE_DIR=$(BUNDLE)
ditto graft/Graft.kext $(WORK)/Graft.kext
python3 -I -B tools/prebuilt.py stage $(OUT) $(WORK)
prebuilt:
rm -rf $(WORK)
$(MAKE) set OUT=prebuilt
python3 -I -B tools/prebuilt.py record prebuilt
set-arm64e:
$(MAKE) -C kext ARCH_NAME=arm64e BUILD=$(WORK64)/kext
$(MAKE) -C bundle ARCH=arm64e PACKAGE_ARCHS="arm64e arm64" BUILD=$(WORK64)/bundle package
$(MAKE) -C rgfxgate ARCH_NAME=arm64e BUILD=$(WORK64)/rgfxgate BUNDLE_DIR=$(BUNDLE64)
ditto graft/Graft-arm64e.kext $(WORK64)/Graft-arm64e.kext
python3 -I -B tools/prebuilt.py stage-arm64e $(OUT64) $(WORK64)
prebuilt-arm64e:
rm -rf $(WORK64)
$(MAKE) set-arm64e OUT64=prebuilt-arm64e
python3 -I -B tools/prebuilt.py record prebuilt-arm64e
prebuilt-check:
python3 -I -B tools/prebuilt.py check
python3 -I -B tools/prebuilt.py check prebuilt-arm64e
set-check:
bash tools/oc-link-set.sh "$(KEXTINJECT)" "$(BOOT_KC)" $(SET) build/set-check
kc-check:
@[ -n "$(KC)$(KC64)" ] || { echo "kc-check: give KC (an x86-64 guest's Boot KC), KC64 (an arm64 guest's kernelcache) or both" >&2; exit 2; }
$(if $(KC),python3 -I -B tools/kc-imports.py "$(KC)" $(SET))
$(if $(KC64),python3 -I -B tools/kc-imports.py "$(KC64)" $(SET64))
test:
$(MAKE) -C kext test
$(MAKE) -C rgfxgate test
$(MAKE) -C bundle test
clean:
rm -rf build