mirror of
https://github.com/seedds/nxnative.git
synced 2026-11-23 11:39:42 -10:00
Metal stop message says to select the tested Xcode before downloading its toolchain (GitHub issue #717)
Each Xcode downloads and uses its own Metal toolchain, whatever the macOS version, so with Xcode 27.2 selected -downloadComponent fetched 32023.922 again. The message now names the selected Xcode and says to install 27.1 beside it, select it, then download its toolchain; README links Apple's download page instead of the App Store. The lock stays at the one tested compiler.
This commit is contained in:
1 parent
e513bfeb24
commit
195986fa99
7 files changed
+49
-8
No files matched your search
@@ -17,7 +17,9 @@ Community projects build on nxnative with Mac apps that turn your games into app
|
||||
|
||||
### Build from the command line
|
||||
|
||||
You need a Mac with macOS 26.6 or later, [Xcode](https://apps.apple.com/app/xcode/id497799835) 27.1, [Homebrew](https://brew.sh) and Python 3.12 or newer (an arm64 one, not an Intel Homebrew's). An iPhone build also needs Xcode's iOS platform (Xcode → Settings → Components).
|
||||
You need a Mac with macOS 26.6 or later, [Xcode](https://developer.apple.com/download/all/?q=Xcode%2027.1) 27.1, [Homebrew](https://brew.sh) and Python 3.12 or newer (an arm64 one, not an Intel Homebrew's). An iPhone build also needs Xcode's iOS platform (Xcode → Settings → Components).
|
||||
|
||||
The shaders are built with Xcode 27.1's Metal compiler, so take 27.1 from Apple's download page, not the App Store's newer Xcode. With a newer Xcode installed too, rename 27.1 to `Xcode-27.1.app` and select it before step 1: `sudo xcode-select -s /Applications/Xcode-27.1.app`.
|
||||
|
||||
**1. Install the tools** (only once), in Terminal:
|
||||
|
||||
|
||||
@@ -10,7 +10,9 @@ import os, re, sys, runpy, subprocess
|
||||
HERE = os.path.dirname(os.path.abspath(__file__)); sys.path.insert(0, HERE); import dmsh_chain, tool_lock
|
||||
OWN = re.compile(r'(metal_macosx|metal_iphoneos): lock (.*) / actual (?!missing$)(.*)') # a missing compiler still stops the build
|
||||
ALLOW = 'DM_ALLOW_OTHER_METAL'
|
||||
XCODE = 'Xcode 27.1 (macOS 26.6 or later)' # the Xcode whose Metal compiler dmsh_chain.lock records; README.md names it too
|
||||
XCODE_VERSION = '27.1' # the Xcode whose Metal compiler dmsh_chain.lock records; README.md names it too
|
||||
XCODE = f'Xcode {XCODE_VERSION} (macOS 26.6 or later)'
|
||||
XCODE_APP = f'/Applications/Xcode-{XCODE_VERSION}.app' # the name the message suggests for it beside a newer Xcode.app
|
||||
strict = tool_lock.check_tools
|
||||
|
||||
def allowed(): return os.environ.get(ALLOW) == '1'
|
||||
@@ -19,12 +21,22 @@ def metal_version(sdk): # as tool_lock.tools_now records it: the first line of
|
||||
r = subprocess.run(['xcrun', '-sdk', sdk, 'metal', '--version'], capture_output=True, text=True)
|
||||
return (r.stdout.splitlines() or ['missing'])[0]
|
||||
|
||||
def selected_xcode(): # ' (selected: Xcode 27.2 in /Applications/Xcode.app/Contents/Developer)', '' when it cannot be read; both tools follow DEVELOPER_DIR as xcrun does
|
||||
try:
|
||||
dev = subprocess.run(['xcode-select', '-p'], capture_output=True, text=True).stdout.strip()
|
||||
ver = (subprocess.run(['xcodebuild', '-version'], capture_output=True, text=True).stdout.splitlines() or [''])[0]
|
||||
except OSError: return ''
|
||||
return f' (selected: {ver or "no Xcode"} in {dev})' if dev else ''
|
||||
|
||||
def other_metal_message(metal):
|
||||
"""The stop message for the Metal compilers that differ from the lock: [(lock key, tested, actual)]"""
|
||||
"""The stop message for the Metal compilers that differ from the lock: [(lock key, tested, actual)]. Each Xcode downloads and uses its own Metal toolchain (a system asset),
|
||||
whatever the macOS version, so with a newer Xcode selected -downloadComponent fetches that Xcode's compiler again: the tested Xcode must be selected first (GitHub issue #717)"""
|
||||
return ('[RED] this Mac\'s Metal compiler is not the one the shaders were tested with (dm/gfx/tools/dmsh_chain.lock): ' +
|
||||
'; '.join(f'{k} {now} (tested: {want})' for k, want, now in metal) +
|
||||
f'. Untested compilers are unsupported (GitHub issue #242). Install {XCODE} and its Metal toolchain '
|
||||
f'(xcodebuild -downloadComponent MetalToolchain), or set {ALLOW}=1 (the NSP script\'s --allow-other-metal) to build with this one anyway')
|
||||
f'. Untested compilers are unsupported (GitHub issue #242). The Metal compiler is the selected Xcode\'s{selected_xcode()}: install {XCODE} '
|
||||
f'from https://developer.apple.com/download/all/ (beside a newer Xcode, as {XCODE_APP}), select it (sudo xcode-select -s {XCODE_APP}, '
|
||||
f'or DEVELOPER_DIR={XCODE_APP}/Contents/Developer for one build), then download its Metal toolchain (xcodebuild -downloadComponent MetalToolchain), '
|
||||
f'or set {ALLOW}=1 (the NSP script\'s --allow-other-metal) to build with this one anyway')
|
||||
|
||||
def other_metal():
|
||||
"""The Metal compilers (macOS, iOS) that differ from the lock and are present: [(lock key, tested, actual)]; a missing one is dmsh_build.py's to report"""
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
"""CI builds with the toolchain the project supports: the Xcode that .github/workflows/tests.yml names in DEVELOPER_DIR is the one README tells players to install and the NSP
|
||||
script names beside dmsh_chain.lock, and every macOS job runs on the GitHub image of that Xcode (xcode-<major>). The build check compares the image's Metal compiler with the
|
||||
lock itself (own_compilers.py --check-metal); this test keeps the names in step, so raising the toolchain is one change in all of them. No Xcode or network needed."""
|
||||
lock itself (own_compilers.py --check-metal); this test keeps the names in step (own_compilers.py's stop message too), so raising the toolchain is one change in all of them. No Xcode or network needed."""
|
||||
from pathlib import Path
|
||||
import re
|
||||
import unittest
|
||||
@@ -22,8 +22,14 @@ class Toolchain(unittest.TestCase):
|
||||
self.assertEqual(sorted({r for r in runners if r.startswith(('macos-', 'xcode-'))}), [image], f'tests.yml: every macOS job runs on {image} (Xcode {self.xcode})')
|
||||
|
||||
def test_readme_names_the_same_xcode(self):
|
||||
named = re.findall(r'\[Xcode\]\([^)]*\) (\d+\.\d+)', (REPO / 'README.md').read_text())
|
||||
readme = (REPO / 'README.md').read_text()
|
||||
named = re.findall(r'\[Xcode\]\([^)]*\) (\d+\.\d+)', readme)
|
||||
self.assertEqual(set(named), {self.xcode}, f'README.md: the Xcode to install is not CI\'s {self.xcode}')
|
||||
self.assertEqual(set(re.findall(r'Xcode[ -](\d+\.\d+)', readme)), {self.xcode}, f'README.md: an Xcode it names (the side-by-side one too) is not CI\'s {self.xcode}')
|
||||
|
||||
def test_metal_stop_names_the_same_xcode(self): # own_compilers.py's stop message: the Xcode to install and select (GitHub issue #717)
|
||||
named = re.findall(r"XCODE_VERSION = '(\d+\.\d+)'", (REPO / 'dm/gfx/tools/own_compilers.py').read_text())
|
||||
self.assertEqual(named, [self.xcode], f'dm/gfx/tools/own_compilers.py: XCODE_VERSION is not CI\'s {self.xcode}')
|
||||
|
||||
def test_nsp_script_names_the_same_xcode(self):
|
||||
named = re.findall(r'Xcode (\d+\.\d+)', (REPO / 'scripts/build_ipa_from_nsp.py').read_text())
|
||||
|
||||
@@ -45,6 +45,18 @@ class CheckTools(unittest.TestCase):
|
||||
self.assertTrue(msg.startswith('[RED] '), msg)
|
||||
for want in (key, OTHER, LOCKED[key], 'Xcode 27.1', 'macOS 26.6', 'xcodebuild -downloadComponent MetalToolchain', 'DM_ALLOW_OTHER_METAL=1', '#242'): self.assertIn(want, msg)
|
||||
|
||||
def test_other_metal_says_to_select_the_tested_xcode(self): # a newer Xcode selected downloads its own toolchain again (GitHub issue #717)
|
||||
sel = ' (selected: Xcode 27.2 in /Applications/Xcode.app/Contents/Developer)'
|
||||
with mock.patch.object(own_compilers, 'selected_xcode', lambda: sel):
|
||||
msg = own_compilers.other_metal_message([('metal_macosx', LOCKED['metal_macosx'], OTHER)])
|
||||
app = own_compilers.XCODE_APP
|
||||
for want in (sel, 'https://developer.apple.com/download/all/', f'sudo xcode-select -s {app}', f'DEVELOPER_DIR={app}/Contents/Developer'): self.assertIn(want, msg)
|
||||
self.assertLess(msg.index('xcode-select -s'), msg.index('-downloadComponent'), 'select the tested Xcode before downloading its toolchain')
|
||||
|
||||
def test_selected_xcode_without_xcode(self): # no xcode-select or xcodebuild: the message goes without the selected Xcode
|
||||
with mock.patch.object(own_compilers.subprocess, 'run', side_effect=FileNotFoundError):
|
||||
self.assertEqual(own_compilers.selected_xcode(), '')
|
||||
|
||||
def test_other_metal_allowed(self):
|
||||
bad, out = self.check([mismatch('metal_macosx', OTHER), mismatch('metal_iphoneos', OTHER)], allow=True)
|
||||
self.assertEqual(bad, [])
|
||||
|
||||
@@ -558,6 +558,7 @@ One line per symptom in the [subsystem references](../reference/): what you see
|
||||
- GLSLC outputs fail the reader's check and are dropped (44 of DARK SOULS: REMASTERED's `main`'s 72 outputs and most of its archives' pixel shaders). → [GLSLC outputs read through their section headers](../reference/shaders.md#glslc-outputs-read-through-their-section-headers)
|
||||
- `shader_split.py` finds no stage for vertex shaders and stops at the first captured output (`no GLSLC output`). Translated, every post pass and the window draw one texel's colour (a black screen with sound); every varying at (0, 0, 0, 1). → [VertexA and VertexB parts merged into one vertex shader](../reference/shaders.md#vertexa-and-vertexb-parts-merged-into-one-vertex-shader)
|
||||
- a shader build accepts tools that differ from `dmsh_chain.lock`; after an override build, returning to the tested Metal compiler can still restore the override's libraries. → [Tested tools and compiler-specific shader caches](../reference/shaders.md#tested-tools-and-compiler-specific-shader-caches)
|
||||
- after an Xcode update the build stops with `[RED] this Mac's Metal compiler is not the one the shaders were tested with (dm/gfx/tools/dmsh_chain.lock): metal_macosx Apple metal version 32023.922 …`; `xcodebuild -downloadComponent MetalToolchain`, as the message said, downloads the same untested compiler again. → [Metal compiler of a newer Xcode](../reference/shaders.md#metal-compiler-of-a-newer-xcode)
|
||||
- SPIRV-Cross can't parse the SPIR-V (`nullptr` exception). → [SPIRV-Cross parse failures](../reference/shaders.md#spirv-cross-parse-failures)
|
||||
- `Fragment input(s) user(locnN) mismatching vertex shader output type(s) or not written by vertex shader` and the draw is skipped; the host reports `[RED] failed to create render pipeline (vertex … fragment …)`. Offline packing fails with `pso_offline: metal-tt failed` for the same reason. → [Pixel shader inputs the vertex shader does not write](../reference/shaders.md#pixel-shader-inputs-the-vertex-shader-does-not-write)
|
||||
- outdoors dim and nothing casts a sun shadow (every shadow-map lookup fails). → [Unwritten components of a written output start as (0, 0, 0, 1)](../reference/shaders.md#unwritten-components-of-a-written-output-start-as-0-0-0-1)
|
||||
|
||||
+1
-1
@@ -212,7 +212,7 @@ What the script does:
|
||||
So does an OpenGL game with no GLSL source in its RomFS or `main` (Balatro: LÖVE puts its shaders together at run time, in Lua): `DM_GL_CAPTURE` at `<id>_build/extract/<version>/gl_capture` until every file in the profile's `gl_capture.tsv` is there (Balatro: 35, made before its first frame). Without the profile's tables (a provisional profile) a capture stops once nothing has been added for 20 s.
|
||||
The Vulkan and GL captures also run on a Mac whose GPU has no Metal 4, such as a virtual Mac (GitHub's `macos-26` runner). Those two layers draw on classic Metal queues of their own, so there the NVN layer starts only its classic part and drops every present, which a headless capture does not need (`nvn_mtl.m` `mtl_device_classic`; `DM_TEST_NO_METAL4=1` does the same on any Mac). The GLSLC capture boots an NVN game, which needs Metal 4.
|
||||
5. It splits out the shaders from the game and every extracted DLC RomFS and checks them against the profile's tables (a Vulkan profile: it translates the RomFS's SPIR-V and the capture with `vk_shaders.py` instead; an OpenGL one: the GLSL sources and the capture with `gl_shaders.py`). Optional DLC that changes only the NVN shader union gets new tables in an external profile after the non-DLC shaders and facts have matched; registered module builds and fixes stay in use.
|
||||
6. It builds the iOS shader libraries with the in-repo SPIRV-Cross (`dm/gfx/tools/spirv_cross_bin`) and the Metal compiler in `dmsh_chain.lock` (Xcode 27.1). Another Metal compiler stops an NVN game's build before its shader steps. Issue #242 reported corruption with an untested compiler; its role remains unconfirmed. `--allow-other-metal` (`ALLOW_OTHER_METAL = True` in Spyder; `DM_ALLOW_OTHER_METAL=1` for `own_compilers.py`) permits it and reports the actual version. If a registered profile's `dmsh_chain.h` does not hold the version the source tree gives (a chain change left it behind), the script writes it again before any host is built, so it shows as changed in the checkout (`dmsh_build.py` would stop otherwise). Then the script makes the profile's `c1_full.tsv` and `cb_extent.tsv` from this build's Mac outputs when they are missing or name another chain. These two tables are not committed and git ignores them; `build_ipa.sh` stops without a current `c1_full.tsv`. Each line in the output names the file.
|
||||
6. It builds the iOS shader libraries with the in-repo SPIRV-Cross (`dm/gfx/tools/spirv_cross_bin`) and the Metal compiler in `dmsh_chain.lock` (Xcode 27.1). Another Metal compiler stops an NVN game's build before its shader steps; the compiler is the selected Xcode's, so a Mac with a newer Xcode installs 27.1 beside it and selects it ([Metal compiler of a newer Xcode](reference/shaders.md#metal-compiler-of-a-newer-xcode)). Issue #242 reported corruption with an untested compiler; its role remains unconfirmed. `--allow-other-metal` (`ALLOW_OTHER_METAL = True` in Spyder; `DM_ALLOW_OTHER_METAL=1` for `own_compilers.py`) permits it and reports the actual version. If a registered profile's `dmsh_chain.h` does not hold the version the source tree gives (a chain change left it behind), the script writes it again before any host is built, so it shows as changed in the checkout (`dmsh_build.py` would stop otherwise). Then the script makes the profile's `c1_full.tsv` and `cb_extent.tsv` from this build's Mac outputs when they are missing or name another chain. These two tables are not committed and git ignores them; `build_ipa.sh` stops without a current `c1_full.tsv`. Each line in the output names the file.
|
||||
It then compares the build with the game's previous one, the newest other `b-*/` in `<id>_build/shader/cache/` (the one the last chain change left: a build that succeeds removes the older chain folders and their keys, so each game keeps one) (`dm/gfx/tools/shader_regressions.py`, which reads the two `_b_build.json` reports). The translation chain is one for every game, so a translator change is tested only on the games its author owns; shaders that translated before and fail now are listed in `logs/shader_regressions.log` and stop the build ([GitHub issue #272](https://github.com/seedds/nxnative/issues/272)). Report them; `--allow-shader-regressions` (`ALLOW_SHADER_REGRESSIONS = True` in Spyder) packs the app without them.
|
||||
7. It calls `build_ipa.sh`. Xcode builds the app in the game's own build folder (`<id>_build/ipa/build/ios/pkg/dd`: `build_ipa.sh` sets `SYMROOT` and `OBJROOT`, which a custom build location in Xcode's settings does not override), so a repeat build compiles only what changed and two games built at once never write the same app. Then `dm/ios/tools/pack_ipa.py` packs it with the shader libraries, the add-on content and the RomFS straight from where they are. It reads and deflates files on all cores and writes at about the T7's write speed (300 MB/s): Breath of the Wild's 16 GB IPA takes 57 s, Info-ZIP's copy and zip took 2 min 50 s. A repeat pack reuses the previous IPA through `<ipa>.idx`, which records each packed file's size, times and inode: the unchanged leading entries stay in place in an APFS clone of the old IPA, and after the first changed entry, an unchanged file is copied compressed from it (both only when the source folder is on APFS; elsewhere every file is deflated again). `build_ipa.sh` passes the RomFS, the add-on content, the pipeline archive and the shader libraries before the app, so after a host fix only the app is written: Breath of the Wild repacks in 12-23 s instead of 105-163 s.
|
||||
|
||||
|
||||
@@ -449,6 +449,14 @@ Finding, keying and translating shaders (`dm/gfx/tools/shader_split.py`, `dmsh_b
|
||||
- **Found on:** [Breath of the Wild](../../dm/games/01007EF00011E000/README.md#found-on-this-game), [issue #242](https://github.com/seedds/nxnative/issues/242). The report used an untested compiler, but whether that caused the corrupted picture remains **open**. The cache failures were reproduced with stand-in libraries; this does not establish the rendering cause.
|
||||
- **Check:** `test_own_compilers.py` checks enforcement and the explicit Metal override. `test_shader_toolchain_cache.py` first restored an untested library after switching compiler identities, for both main shaders and fetch variants, and now rejects it. It also checks stage invalidation on actual Metal, SDK and selected converter changes. `test_spirv_cross_pin.py` checks the shipped binary, pin, lock, architectures and licences.
|
||||
|
||||
### Metal compiler of a newer Xcode
|
||||
|
||||
- **Symptom:** after an Xcode update the build stops with `[RED] this Mac's Metal compiler is not the one the shaders were tested with (dm/gfx/tools/dmsh_chain.lock): metal_macosx Apple metal version 32023.922 …`; `xcodebuild -downloadComponent MetalToolchain`, as the message said, downloads the same untested compiler again.
|
||||
- **Cause:** since Xcode 26 the Metal toolchain is a system asset that each Xcode downloads in its own build and `xcrun` takes for the selected Xcode (`xcodebuild -showComponent MetalToolchain` names it), whatever the macOS version: macOS 27.2 with Xcode 27.1 selected gives the tested 32023.921, with Xcode 27.2 selected 32023.922. The message named the Xcode to install but not that it must be the selected one, and README linked the App Store, which offers only the newest Xcode.
|
||||
- **Fix:** the stop message names the selected Xcode and its folder, and says to install the tested Xcode from Apple's download page (beside a newer one as `Xcode-<version>.app`), select it (`xcode-select -s` or `DEVELOPER_DIR`), then download its Metal toolchain; README says the same. The lock stays at the one tested compiler: another one needs a regression run before it is recorded, and the lock is part of the chain version. Whether two installed toolchain assets each follow their own Xcode is inferred from `-showComponent`, not yet tried with both installed (**open**).
|
||||
- **Found on:** no game: [GitHub issue #717](https://github.com/seedds/nxnative/issues/717), on macOS 27.2 with Xcode 27.2 (Metal Toolchain 27B47).
|
||||
- **Check:** `test_own_compilers.py` (the selection step before the download), `test_ci_toolchain.py` (the message's and README's Xcode are CI's).
|
||||
|
||||
### SPIRV-Cross parse failures
|
||||
|
||||
- **Symptom:** SPIRV-Cross can't parse the SPIR-V (`nullptr` exception).
|
||||
|
||||
Reference in new issue
Block a user