Play your own Switch games on iPhone/iPad — one-click macOS app, no terminal. | 把 Switch 游戏装进 iPhone:图形界面一键构建,不用命令行。Bring your own game.
Swift apple-siliconcustom-formathomebrewiosipaipadipadosiphonemetalnative-portnintendo-switchnxnativeromfsswitch-games
Windows: the link probe tries the build's own invocation and names every step
LNPANDY24ad3c029365
diff --git a/frontend-qt/nspb_qt/win/toolchain.py b/frontend-qt/nspb_qt/win/toolchain.pyindex c7eefcb8..508f650a 100644--- a/frontend-qt/nspb_qt/win/toolchain.py+++ b/frontend-qt/nspb_qt/win/toolchain.py@@ -951,31 +951,61 @@ def probe_link(sdk: Path) -> tuple[bool, str]:return False, 'no clang.exe'if not lld:return False, note or 'no ld64.lld'++ # Step 0: run the linker by itself. A silent clang failure (the report: exit 1, no output on+ # either stream) cannot say whether the linker is broken or clang's drive of it is, and the+ # two have different fixes. lld --version is the smallest probe that separates them.+ v = subprocess.run([str(lld), '--version'], capture_output=True, text=True, timeout=60,+ **no_window())+ lld_self = (v.stdout or v.stderr or '').strip().splitlines()+ lld_line = lld_self[0] if lld_self else f'exit {v.returncode}, no output'+ if v.returncode != 0:+ return False, (f'{lld.name} does not run by itself (exit {v.returncode}): {lld_line[:200]}'+ ' — reinstall LLVM-MinGW')+src = '#include <stdio.h>\nint main(void) { puts("probe"); return 0; }\n'with ascii_temp_dir('nspb-link-') as td:c = Path(td) / 'probe.c'out = Path(td) / 'probe'c.write_text(src, encoding='utf-8')- # --ld-path names the linker directly. -fuse-ld=lld + PATH prepend worked on the machines- # that probed green, but the report's machine failed with exit 1 and no output — on Windows- # clang's linker lookup has more moving parts (PATHEXT, the llvm-mingw driver config), so- # name the binary and let the failure say what actually went wrong.- cmd = [str(clang), '-target', f'arm64-apple-ios{IOS_DEPLOYMENT}', '-isysroot', str(sdk),- '-fuse-ld=lld', f'--ld-path={lld}', '-o', str(out), str(c)]- try:- r = subprocess.run(cmd, capture_output=True, text=True, timeout=180,- env=dict(os.environ), # a child on Windows needs the full env (SystemRoot etc.)- **no_window())- except subprocess.TimeoutExpired:- return False, 'link timed out'- except OSError as e:- return False, f'cannot run clang: {e}'- if r.returncode != 0:+ target = f'-target arm64-apple-ios{IOS_DEPLOYMENT}'.split()+ base = [str(clang), *target, '-isysroot', str(sdk)]++ def run(extra: list[str], env: dict[str, str] | None) -> subprocess.CompletedProcess:+ cmd = [*base, *extra, '-o', str(out), str(c)]+ return subprocess.run(cmd, capture_output=True, text=True, timeout=180,+ env=env, **no_window())++ def summary(r: subprocess.CompletedProcess) -> str:# the exit code is the evidence: 0xC0000135 (STATUS_DLL_NOT_FOUND) reads as "a DLL is- # missing", not "the linker is bad" — the report's "link failed: no output" carried- # neither, because an empty output tail replaced the code+ # missing", not "the linker is bad"; an empty stream pair stays honest as (no output)tail = ((r.stderr or r.stdout or '').strip().splitlines() or ['(no output)'])[-1]- return False, f'link exit {r.returncode} (0x{r.returncode & 0xFFFFFFFF:08x}): {tail[:400]}'+ return f'exit {r.returncode} (0x{r.returncode & 0xFFFFFFFF:08x}): {tail[:400]}'++ # Strategy 1 — the build's own shape (build_app.link): -fuse-ld=lld and the linker's+ # folder on PATH. If the machine's PATH handling differs from the probe's assumptions,+ # this is what the build would do, so it is the first thing to try.+ env = dict(os.environ) # a child on Windows needs the full env (SystemRoot etc.)+ env['PATH'] = str(lld.parent) + os.pathsep + env.get('PATH', '')+ r = run(['-fuse-ld=lld'], env)+ if r.returncode == 0:+ how = 'fuse-ld (build-style)'+ else:+ first = summary(r)+ # Strategy 2 — name the linker directly (--ld-path), bypassing every lookup.+ r = run(['-fuse-ld=lld', f'--ld-path={lld}'], dict(os.environ))+ if r.returncode == 0:+ how = 'ld-path'+ else:+ second = summary(r)+ # Strategy 3 — -fuse-ld=full or the absolute path as -B: clang's last resort+ r = run([f'-B{lld.parent}', '-fuse-ld=lld'], dict(os.environ))+ if r.returncode == 0:+ how = '-B dir'+ else:+ third = summary(r)+ return False, (f'link failed 3 ways; ld64.lld self-check: {lld_line[:120]}; '+ f'fuse-ld {first}; ld-path {second}; -B {third}')try:data = out.read_bytes()except OSError as e:@@ -990,7 +1020,7 @@ def probe_link(sdk: Path) -> tuple[bool, str]:plat = macho_platform(data)if plat is not None and plat != PLATFORM_IOS:return False, f'platform {plat} is not iOS ({PLATFORM_IOS})'- return True, f'arm64 MH_EXECUTE{"" if plat is None else f", platform {plat}"}, {len(data)} bytes'+ return True, f'arm64 MH_EXECUTE{"" if plat is None else f", platform {plat}"}, {len(data)} bytes ({how})'def macho_platform(data: bytes) -> int | None:diff --git a/frontend-qt/tests/test_win.py b/frontend-qt/tests/test_win.pyindex 4ce0c7b2..bb46a121 100644--- a/frontend-qt/tests/test_win.py+++ b/frontend-qt/tests/test_win.py@@ -1585,6 +1585,28 @@ class SaveConfigTest(unittest.TestCase):self.assertTrue(matches and all(tc.is_sdk_dir(m) for m in matches))+class LinkProbeStrategyTest(unittest.TestCase):+ """probe_link's three strategies and the step-0 linker self-check.++ The Windows-only subprocess calls cannot run here; what is testable is the *shape*: the+ strategy list (build-style fuse-ld first, then --ld-path, then -B), and that a silent+ failure now names all three attempts plus the linker's own self-check instead of one+ empty '(no output)'.+ """++ def test_the_strategy_order_is_build_style_first(self) -> None:+ src = (QT / 'nspb_qt' / 'win' / 'toolchain.py').read_text()+ body = src[src.index('def probe_link'):]+ self.assertLess(body.index("'-fuse-ld=lld'"), body.index('f\'--ld-path={lld}\''),+ 'the build\'s own invocation must be tried before --ld-path')+ self.assertLess(body.index('f\'--ld-path={lld}\''), body.index("f'-B{lld.parent}'"),+ '--ld-path before the -B fallback')+ self.assertIn("env['PATH'] = str(lld.parent)", body,+ 'the build-style try must put the linker folder on PATH (build_app.link does)')+ self.assertIn('does not run by itself', body,+ 'a linker that cannot start is its own message, before any strategy runs')++class InstallFailureHintTest(unittest.TestCase):"""The row's fix hint after a failed install (Mac parity: name the fix, not the traceback)."""