Skip to content

Play your own Switch games on iPhone/iPad — one-click macOS app, no terminal. | 把 Switch 游戏装进 iPhone:图形界面一键构建,不用命令行。Bring your own game.

Windows: the link probe's failure report survives the panel, and names the one suspect

LNPANDYab4c767efc53
diff --git a/frontend-qt/nspb_qt/localization.py b/frontend-qt/nspb_qt/localization.py
index 1e251d41..7645a951 100644
--- a/frontend-qt/nspb_qt/localization.py
+++ b/frontend-qt/nspb_qt/localization.py
@@ -634,6 +634,8 @@ TABLE: dict[str, tuple[str, str, str]] = {
'dep.fix.brewMissing': ('没装 Homebrew:从 brew.sh 安装(安装程序会要你的密码),再点「重新检测」。', 'Homebrew is not installed: install it from brew.sh (the installer asks for your password), then press Check again.', 'Homebrew är inte installerat. Installera från brew.sh. Installationsprogrammet ber om ditt lösenord. Välj sedan ”Kontrollera igen”.'),
'dep.fix.xcodeLicense': ('Xcode 的许可协议还没接受:运行 sudo xcodebuild -license accept。', "Xcode's license is not accepted yet: run sudo xcodebuild -license accept.", 'Xcodes licensavtal är inte godkänt. Kör sudo xcodebuild -license accept.'),
'dep.fix.network': ('下载失败了:检查网络(代理或 VPN 可能拦住了 Homebrew 的域名),再试一次。', "The download failed: check the network (a proxy or VPN can block Homebrew's hosts) and try again.", 'Hämtningen misslyckades. Kontrollera nätverket; proxy eller VPN kan blockera Homebrews domäner. Försök sedan igen.'),
+ 'dep.fix.nonascii': ('SDK 所在路径含非英文字符(比如用户名里的中文):ld64.lld 在 Windows 上可能因此打不开 SDK 文件。把整个 SDK 文件夹拷到一个纯英文路径(如 C:\\\\NSPB\\\\sdk),然后在依赖面板用「选择文件夹…」指向它。', "The SDK path contains non-ASCII characters (a Chinese username, for example): ld64.lld on Windows may fail to open it. Copy the whole SDK folder to an ASCII-only path (e.g. C:\\\\NSPB\\\\sdk) and point the dependencies panel's Choose folder… at it.", "The SDK path contains non-ASCII characters (a Chinese username, for example): ld64.lld on Windows may fail to open it. Copy the whole SDK folder to an ASCII-only path (e.g. C:\\\\NSPB\\\\sdk) and point the dependencies panel's Choose folder… at it."),
+ 'dep.row.log': ('依赖 %@:[%@] %@', 'dependency %@: [%@] %@', 'dependency %@: [%@] %@'),
'dep.fix.diskspace': ('磁盘空间不足:清理后(SDK 和工具链解压需要数 GB)再点「安装」。', 'The disk is full: free some space (the SDK and toolchains unpack to several GB) and press Install again.', 'The disk is full: free some space (the SDK and toolchains unpack to several GB) and press Install again.'),
'dep.fix.log': ('完整输出在 Mac/iPhone 选择下面的日志里。', 'The full output is in the log under the Mac/iPhone choice.', 'Fullständig utdata finns i loggen under Mac/iPhone-valet.'),
'dep.python.missing': ('%@ 缺包', '%@ is missing packages', '%@ saknar paket'),
diff --git a/frontend-qt/nspb_qt/model.py b/frontend-qt/nspb_qt/model.py
index a27838c0..c1e0e53a 100644
--- a/frontend-qt/nspb_qt/model.py
+++ b/frontend-qt/nspb_qt/model.py
@@ -299,6 +299,13 @@ class Model(QObject):
d.last_error, d.fix_hint = p.last_error, p.fix_hint
self.deps = deps
+ # The panel can only show one row at a time; the log keeps every detail, so a report sent
+ # from a handheld always carries the full probe text (the truncated link row is why this
+ # exists).
+ for d in deps:
+ if not d.ok and d.detail:
+ self.log(self.t('dep.row.log', d.title_key.replace('dep.', 'dep.').replace('.hint', ''),
+ d.detail.replace('\n', ' | ')) + '\n')
if not pu.IS_WIN:
# On Windows `_windows_deps` already set python_path (the interpreter the app
# installed, which find_python without its candidates cannot see) and dotnet_path
diff --git a/frontend-qt/nspb_qt/ui.py b/frontend-qt/nspb_qt/ui.py
index 6309c7ed..40214792 100644
--- a/frontend-qt/nspb_qt/ui.py
+++ b/frontend-qt/nspb_qt/ui.py
@@ -486,6 +486,21 @@ class MainWindow(QMainWindow):
detail = self.m.t(detail)
elif detail:
detail = pu.short_path(detail)
+ # A long detail (the link probe's three-attempt report) would be elided to nothing on
+ # one line: it moves into its own wrapped block under the row, where it is readable.
+ if len(detail) > 140 or '\n' in detail:
+ head = QLabel(detail[:120] + '…')
+ head.setObjectName('mono')
+ head.setTextInteractionFlags(Qt.TextSelectableByMouse)
+ h.addWidget(head, 1)
+ note = QLabel(detail)
+ note.setObjectName('mono')
+ note.setWordWrap(True)
+ note.setTextInteractionFlags(Qt.TextSelectableByMouse)
+ note.setContentsMargins(20, 0, 0, 4)
+ self.deps_container.addWidget(row)
+ self.deps_container.addWidget(note)
+ continue
lab = QLabel(detail)
lab.setObjectName('mono')
lab.setTextInteractionFlags(Qt.TextSelectableByMouse)
diff --git a/frontend-qt/nspb_qt/win/toolchain.py b/frontend-qt/nspb_qt/win/toolchain.py
index 508f650a..9bdee0f5 100644
--- a/frontend-qt/nspb_qt/win/toolchain.py
+++ b/frontend-qt/nspb_qt/win/toolchain.py
@@ -939,6 +939,32 @@ def probe_metal(sdk: Path) -> tuple[bool, str]:
return True, f'{lib.stat().st_size} byte metallib for {tgt}'
+def link_attempt_summary(r: subprocess.CompletedProcess) -> str:
+ """One failed strategy: the exit code plus the output's last lines (all of them, not just
+ one — '(no output)' alone was the report's whole diagnostic)."""
+ lines = (r.stderr or r.stdout or '').strip().splitlines() or ['(no output)']
+ tail = ' | '.join(l.strip() for l in lines[-3:])
+ return f'exit {r.returncode} (0x{r.returncode & 0xFFFFFFFF:08x}): {tail[:500]}'
+
+
+def link_failure_summary(attempts: list[tuple[str, str, list[str]]], lld_line: str,
+ base: list[str], sdk: Path) -> str:
+ """Every failed strategy, the linker's self-check, the exact command to try by hand, and —
+ when the SDK lives under a non-ASCII path — the one hint that has fixed this exact shape
+ before: ld64.lld's Windows port can fail to open narrow-char paths silently, while clang's
+ front end (the compile probe) handles them fine.
+ """
+ parts = [f'link failed {len(attempts)} ways; ld64.lld self-check: {lld_line[:140]}']
+ for how, summary, _cmd in attempts:
+ parts.append(f'{how}: {summary}')
+ parts.append('try by hand: ' + ' '.join([*base, '-fuse-ld=lld', '-o', '%TEMP%\\probe.exe', '<probe.c>']))
+ try:
+ str(sdk).encode('ascii')
+ except UnicodeEncodeError:
+ parts.append('dep.fix.nonascii')
+ return ' — '.join(parts)
+
+
def probe_link(sdk: Path) -> tuple[bool, str]:
"""Link a tiny executable for iOS and check it is an arm64 MH_EXECUTE with an iOS platform.
@@ -971,41 +997,27 @@ def probe_link(sdk: Path) -> tuple[bool, str]:
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:
+ # Strategies, in order: the build's own shape first (build_app.link drives the linker
+ # with -fuse-ld=lld and the linker's folder on PATH — if the probe cannot link that way,
+ # neither can the build), then naming the linker directly, then -B as clang's last
+ # resort. Each failure is kept; all three failing produces the full report.
+ attempts: list[tuple[str, str, list[str]]] = [] # (strategy, summary, command)
+ for how, extra, env in (
+ ('fuse-ld (build-style)', ['-fuse-ld=lld'], None),
+ ('ld-path', ['-fuse-ld=lld', f'--ld-path={lld}'], None),
+ ('-B dir', [f'-B{lld.parent}', '-fuse-ld=lld'], None)):
+ run_env = dict(os.environ) # a child on Windows needs the full env (SystemRoot etc.)
+ if extra[:1] == ['-fuse-ld=lld'] and how.startswith('fuse-ld'):
+ run_env['PATH'] = str(lld.parent) + os.pathsep + run_env.get('PATH', '')
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"; an empty stream pair stays honest as (no output)
- tail = ((r.stderr or r.stdout or '').strip().splitlines() or ['(no output)'])[-1]
- 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))
+ r = subprocess.run(cmd, capture_output=True, text=True, timeout=180,
+ env=run_env, **no_window())
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}')
+ how_ok = how
+ break
+ attempts.append((how, link_attempt_summary(r), cmd))
+ else:
+ return False, link_failure_summary(attempts, lld_line, base, sdk)
try:
data = out.read_bytes()
except OSError as e:
@@ -1020,7 +1032,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 ({how})'
+ return True, f'arm64 MH_EXECUTE{"" if plat is None else f", platform {plat}"}, {len(data)} bytes ({how_ok})'
def macho_platform(data: bytes) -> int | None:
diff --git a/frontend-qt/tests/test_win.py b/frontend-qt/tests/test_win.py
index c1206e48..4b6a150e 100644
--- a/frontend-qt/tests/test_win.py
+++ b/frontend-qt/tests/test_win.py
@@ -1684,11 +1684,27 @@ class LinkProbeStrategyTest(unittest.TestCase):
'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,
+ self.assertIn("run_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')
+ def test_the_failure_summary_names_everything_and_flags_a_non_ascii_sdk(self) -> None:
+ from nspb_qt.win import toolchain as tc
+ attempts = [('fuse-ld', 'exit 1 (0x00000001): (no output)', ['clang', '-fuse-ld=lld']),
+ ('ld-path', 'exit 1 (0x00000001): (no output)', ['clang', '--ld-path=x']),
+ ('-B dir', 'exit 1 (0x00000001): (no output)', ['clang', '-Bx'])]
+ plain = Path('C:/sdks/iPhoneOS26.0.sdk')
+ summary = tc.link_failure_summary(attempts, 'LLD 23.1.4', ['clang'], plain)
+ for part in ('link failed 3 ways', 'LLD 23.1.4', 'fuse-ld:', 'ld-path:', '-B dir:',
+ 'try by hand:'):
+ self.assertIn(part, summary, part)
+ self.assertNotIn('dep.fix.nonascii', summary)
+ # The owner's machine: C:\Users\QC-北\... — the SDK itself sits under a non-ASCII path
+ nonascii = Path('C:/Users/QC-北/AppData/Local/NS Port Builder/sdks/iPhoneOS26.0.sdk')
+ hinted = tc.link_failure_summary(attempts, 'LLD 23.1.4', ['clang'], nonascii)
+ self.assertIn('dep.fix.nonascii', hinted)
+
class InstallFailureHintTest(unittest.TestCase):
"""The row's fix hint after a failed install (Mac parity: name the fix, not the traceback)."""
diff --git a/frontend/Sources/NSPortBuilder/Localization.swift b/frontend/Sources/NSPortBuilder/Localization.swift
index 36f8dbf2..69b22fe2 100644
--- a/frontend/Sources/NSPortBuilder/Localization.swift
+++ b/frontend/Sources/NSPortBuilder/Localization.swift
@@ -735,6 +735,9 @@ enum L10n {
"Xcode's license is not accepted yet: run sudo xcodebuild -license accept."),
"dep.fix.network": ("下载失败了:检查网络(代理或 VPN 可能拦住了 Homebrew 的域名),再试一次。",
"The download failed: check the network (a proxy or VPN can block Homebrew's hosts) and try again."),
+ "dep.fix.nonascii": ("SDK 所在路径含非英文字符(比如用户名里的中文):ld64.lld 在 Windows 上可能因此打不开 SDK 文件。把整个 SDK 文件夹拷到一个纯英文路径(如 C:\\NSPB\\sdk),然后在依赖面板用「选择文件夹…」指向它。",
+ "The SDK path contains non-ASCII characters (a Chinese username, for example): ld64.lld on Windows may fail to open it. Copy the whole SDK folder to an ASCII-only path (e.g. C:\\NSPB\\sdk) and point the dependencies panel's Choose folder… at it."),
+ "dep.row.log": ("依赖 %@:[%@] %@", "dependency %@: [%@] %@"),
"dep.fix.diskspace": ("磁盘空间不足:清理后(SDK 和工具链解压需要数 GB)再点「安装」。",
"The disk is full: free some space (the SDK and toolchains unpack to several GB) and press Install again."),
"dep.fix.log": ("完整输出在 Mac/iPhone 选择下面的日志里。",