Repository navigation
Build macOS with the Command Line Tools instead of full Xcode - #83
Conversation
RT64 now embeds its MSL shader source on macOS and plume compiles it at runtime, so the build no longer needs Xcode's offline Metal toolchain. iOS keeps precompiled metallibs. N64Recomp emits a null statement before instruction hooks so Apple clang 16 (the newest for macOS 14) accepts a declaring hook after a branch label under C17. Setup installs only missing Homebrew tools, avoiding source builds of tools already present. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
| + # macOS embeds the MSL source; plume compiles it at runtime, so the | ||
| + # build needs no Xcode Metal toolchain. | ||
| + set(_dkr_msl_blob ${OUTNAME}.metal) |
There was a problem hiding this comment.
RasterShader calls createShader with these blobs for every new combiner/other-mode combo (src/render/rt64_raster_shader.cpp:166-167), so I think every specialized raster shader now recompiles the whole ubershader MSL, not just once at setup. The 2.66 s number only covers setup. We should watch for pop-in during gameplay on a cold cache.
Maybe keep the metallib when xcrun -sdk macosx -f metal resolves at configure time and only embed source when it doesn't? The plume patch already handles both, and CI/release builds keep the old load path and build-time shader errors.
| # Install only what is missing: on macOS releases Homebrew no longer | ||
| # bottles, reinstalling a present tool (python) means a failing source build. |
There was a problem hiding this comment.
brew install on an already-installed formula is a no-op with HOMEBREW_NO_INSTALL_UPGRADE=1, so the failing case is really brew python missing while some other 3.11+ is on PATH. A fresh macOS 14 box with only the CLT python (3.9) still hits brew install python here. Maybe reword the comment so it doesn't read like it fixes that?
|
WOW! I'm stoked this made the cut! Just caught up on all this. The revisions are great, definitely cracks in the ground on my end. The following PR was insightful as well. Definitely will look deeper across the codebase and see what else I can do. No joke this is the first video game I ever played growing up, so I'm jazzed about this recomp project 🙌🏻 Thanks for letting me contribute! |
What
This removes the multi-GB full Xcode requirement for building DKR-R on macOS. As a developer I avoid
Xcode like the plague, but Apple's Command Line Tools are genuinely useful and save me a lot of local
storage. With this change, the Command Line Tools (
xcode-select --install) are all a macOS build needs.Benefits
Homebrew already requires them, so most Mac developers have them and building DKR-R needs no
extra Apple download.
sudo xcode-select --switch,no
sudo xcodebuild -license accept, no first-launch run.xcodebuild -downloadComponent MetalToolchain.xcrun metalandmetallibsteps at build time.build tools from source that are already present (see Python below).
machine's actual GPU.
How
patches/rt64/0021): on macOS, RT64 embeds the MSL source that spirv-cross alreadyproduces, instead of compiling it with
xcrun metalandmetallib.patches/plume/0003): a shader blob starting with theMTLBmagic loads as aprecompiled library as before; anything else is compiled at runtime with
MTLDevice newLibraryWithSource.plume already compiles its own clear and resolve shaders this way.
patches/n64recomp/0003): instruction hooks are emitted after a null statement(
; <hook>). Apple clang 16 rejects a declaration directly after a branch label under-std=c17;Clang 18+ accepts it. The hooks are deliberately not wrapped in braces: several hooks declare
locals (
dkr_free_max,dkr_model_count_before, ...) that later hooks in the same function read.The policy JSON is untouched, so
DKR_PATCH_POLICY_SHA256and the netplay identity don't change.scripts/macos-host-tools.sh): requires only the macOS SDK from the Command Line Tools,and installs only missing Homebrew tools. Python counts as missing when it is older than 3.11
(
tomllib). Previouslybrew install pythonpulled Python 3.15, which has no bottle on macOS 14and fails to build from source with Apple clang 16.
Pattern checklist
runtime-recomp/,modding/orscripts/(no newpatches/<name>/)*.patchfiles registered inpatches/manifest.json(rt64/0021,plume/0003,n64recomp/0003)guest-hooks/hooks.toml; symbols only viasymbols/*.toml(no hooks or symbols added)netplay/legacy_identity.hppupdated if simulation, wire or owned-service behaviour changed (not needed: generated code is semantically identical)python scripts/check.py --suite allpasses locally (updated the host-tools stub inbuild_tooling_tests.py)Verification
python3 scripts/check.py --suite all: passes.python3 scripts/apply_dependency_patches.py --check: all 15 dependencies validate../Setup-macOS.shthen./Build-macOS.shin a fresh shell with no Xcode installed: the buildcompletes and 166 of 168 CTest tests pass.
DKRFriendServiceandDKRProfileBridgefail with or without this change. The callbacks they needare installed only by
patches/online-directory/native/online_directory.cpp, which no CMake target builds.first frame was presented. The runtime stopped cleanly.
Risk
the M1). macOS caches them after that; setup took 58 ms on the second launch.
The MSL is generated by spirv-cross, and the boot test above showed no errors.
macos-15-intelCIjob will exercise it. The CI runners have full Xcode installed, so CI does not prove the no-Xcode
path; the local M1 build above does.
🤖 Assited with Claude Code, reviewed by @actuallyitsnathaniel