Windows: the relinker cannot convert a game in a directory with non-ASCII characters #2692
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by justdoston on 2026-10-10T10:59:54Z.
What
On Windows the relinker reads its arguments through the narrow
main(core/relinker/main.cpp), so they arrive in the ANSI code page, while MinGW'sstd::filesystemtreats narrow strings as UTF-8.Io::FileReader/FileWriterthen open those strings with the narrow CRT. So a game in a directory with any non-ASCII character cannot be converted on Windows: a character outside the code page becomes?, and an accented one that the code page does have is not valid UTF-8. @husseinkad noted the argument part while testing #2640.Measured
relinker.exebuilt frommaincd73e149with MinGW-w64 GCC 16 and run under Wine 10.0 (en_US, ANSI code page 1252) on thetest_windows_import_modules.pyexecutable,relinker --windows <dir>\input.elf <dir>\output.exe:asciiJoséFAIL: filesystem error: Cannot convert character sequence: Invalid or incomplete multibyte or wide character日本FAIL: Cannot open file: …\??\game\input.elfNot run on a Windows machine yet; husseinkad saw the same conversion error there with
ü.Proposal
On Windows take the arguments from
wmainand convert them to UTF-8 withstd::filesystem::path(...).string(), open files throughstd::filesystem::pathinIo::FileReader/FileWriter(no change on Linux and macOS), and start--autorunwith_wsystem. A regression case can run the relinker on input and output paths with non-ASCII characters.I'd like to work on this, unless @husseinkad already is.
AI-assisted: yes. An AI agent (Claude Code) did most of this work: it reproduced the problem and wrote this report.
Imported from boykopovar/AnyPS5. Originally posted by justdoston on 2026-10-10T11:05:25Z.
Fix branch: https://github.com/justdoston/AnyPS5/tree/fix/windows-relinker-unicode-arguments (
f87686c2)wmainand converts them to UTF-8 withstd::filesystem::path(...).string(); MinGW links it with-municode. Linux and macOS keep the narrowmain.Io::FileReaderandFileWriteropen throughstd::filesystem::path, so Windows uses the wide CRT and Linux and macOS see no change.--autorunstarts the output with_wsystemon Windows.file_unicode_pathtest (all platforms) writes, reads and replacesdonnées.binunder aü日directory throughFileWriter/FileReaderand checks the file exists at that path;windows_import_modulesconverts a case underunicode-ü日.Tested: Linux relinker
ctest98/98.relinker.execross-built with MinGW-w64 GCC 16 and run under Wine 10.0 (en_US, code page 1252):ascii,Joséand日本now convert (before:Joséand日本failed as in the table above).file_unicode_pathcross-built and run under Wine fails withmain'sFileReader/FileWriterand passes with the branch. Merged with the #2640 branch (no conflicts), the converted executables also start from all three directories. Not run on a Windows machine.AI-assisted: yes. An AI agent (Claude Code) did most of the work: the code, the tests and this comment.
Imported from boykopovar/AnyPS5. Originally posted by Get-fix on 2026-10-10T11:34:41Z.
Native Windows run of
justdoston:fix/windows-relinker-unicode-argumentsat f87686c2 (one commit onmainb5f5362d). Windows 11 Pro 10.0.26200, ANSI code page 1252, WinLibs GCC 15.2.0 r7, relinker-only Release build.Relinker ctest on the branch: 94 of 94.
file_unicode_pathpasses, andwindows_import_modulespasses with itsunicode-ü日case. The branch'stest_windows_import_modules.pyrun againstmain's relinker fails at that case withFAIL: filesystem error: Cannot convert character sequence: Illegal byte sequence. Noü/日directories were left in%TEMP%.The
test_windows_import_modulesexecutable (exit 11 once the guest entry runs), stored and converted inside each directory, then started from another directory:mainb5f5362dbcb8d644, no conflicts)asciiJoséFAIL: filesystem error: Cannot convert character sequence: Illegal byte sequenceعربيFAIL: Cannot open file: …0xc000000d日本0xc000000dgame 🎮0xc000000dps5-doom (PPSA99666 v1.1.1,
--windows --windows-gui) stored in a directory namedعربي, converted there and started withStart-Processfrom another directory:maincannot open…\????\game\eboot.elf; this branch converts it and the executable exits with0xc000000dat the entry stub; with #2640 merged as well it converts and runs, and the DOOM window renders.AI-assisted: yes (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by husseinkad on 2026-10-10T11:48:31Z.
More native Windows data for
justdoston:fix/windows-relinker-unicode-arguments(f87686c2), in addition to @Get-fix's ctest run. Windows 11 Pro 10.0.26200, ANSI code page 1252, WinLibs GCC 15.2.0 r7, relinker-only Release build of the branch merged ontomainb5f5362d(no conflicts).file_unicode_pathfails (Cannot open output file: ...ü日-...\données.bin) andwindows_import_modulesfails (filesystem error: Cannot convert character sequence), so both exercise the fix.plain,ü,日本,عربي,ü日, an emoji andsp ace ü日, with and without guest modules, absolute and relative paths,--autorunabsolute and relative, launched from cmd.exe, PowerShell and Git Bash. All 210 conversions succeed on the branch;mainfails 180 of them at conversion.--autorunreturns the right exit code forplainandü(so_wsystemworks);mainfails it for every non-ASCII path.mainand the branch for--windows,--windows --windows-gui,--windows-diagnostics,--registry,--to-intel,--macosand the default Linux output; stdout and stderr match.output.exestops withFAIL: cannot make the executable directory the current directory(GetLastError123) when its own directory contains a character outside cp1252 (日本,عربي, emoji,ü日); the entry stub still uses the ANSI APIs. A non-ANSI input directory with an ASCII output directory, and non-ANSI file names in an ASCII directory, run correctly.--autorunon a path containing&fails the same way onmainand on this branch (cmd quoting).wmainconverts every argument includingargv[0], which the program never uses, so launching the relinker from a directory whose name contains an unpaired surrogate fails withcommand line is not valid UTF-16wheremainran fine. Starting the conversion loop at index 1 avoids it.AI-assisted: yes.
Imported from boykopovar/AnyPS5. Originally posted by aplatogg on 2026-10-10T12:51:38Z.
Root-cause analysis for this issue, with a fix ready in PR #2751
The failure is a Windows ANSI code page chain, not a filesystem quirk:
argvtomainas ANSI code page bytes (core/relinker/main.cpp) — the relinker has nowmain/-municode, so any character outside the user's code page is already replaced before the tool sees itstd::filesystem::paththrough the same code page: the implicit conversion at theGuestModuleBuilder::Buildcall site,FileReader::Read/FileWriter::Write, and theWindowsPePatchericon pathCannot open filealthough the file existsThe fix in #2751: read the command line as Unicode (
wmainvia-municode), keep paths as UTF-8 strings internally, convert at the filesystem boundaries through newIo::NativePath/Io::Utf8Pathhelpers, and run--autorunthroughCreateProcessW.Tested on Windows (WinLibs GCC 15.2.0 ucrt): relinker-only build 94/94 tests passed, including a new
input_nonasciiregression test (converts from a directory namedигрыwith sourcesпроба.elf,ゲーム.elf,próba m².elf), andtools/check_conventions.pypasses. The PR will land behind the intake gate — could you take a look when the backlog allows?Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-10T13:11:49Z.
Current-main integration check
I carried the implementation from closed PR #2751 onto current upstream
main78aedb40e2412cb28ec5d36f301e751dd7415590in branchcodex/relinker-nonascii-2692. The branch preserves aplatogg's original implementation commit and adds a follow-up for the current--sce-module-pathCLI, guest module path-to-UTF-8 boundaries, and avoiding conversion of unused Windowsargv[0]. It also reports the actual provider path for duplicate guest exports.Checks on Linux x86_64 with GCC 12.2, Release, relinker-only build:
input_nonascii.mainpassed;git diff --checkpassed.Windows execution was not available in this environment. The original PR author reports a native Windows relinker build and 94/94 tests passing on the original PR head; independent native Windows evidence for the related #2692 behavior is recorded earlier in this issue. Those reports are not tests of this rebased branch.
No open PR duplicates this change. The repository's automatic intake workflow currently closes PRs from contributors below 20 merged PRs. My live count is 15 merged, so I have pushed the reviewed branch for a collaborator with intake access to carry; this is not an open PR. AI-assisted: yes.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-10T13:17:54Z.
Current
mainrefreshI rebased the reviewed Unicode-path implementation and follow-up onto upstream
main(5edae353). The fork branch iscodex/relinker-nonascii-2692, now at2892e0b63.input_nonasciiandwindows_import_modulestools/check_conventions.py --base upstream/maingit diff --check upstream/main...HEADThe upstream Windows runs recorded above validate the original implementation on another branch. I cannot run Windows in this environment, so the additional current-main follow-up on this branch has Linux coverage only; please treat the fork CI/native Windows result as outstanding.
I found no open PR for this change. I have not opened one because the intake workflow still requires 20 merged PRs; my live merged count is 15. AI-assisted: yes.
Imported from boykopovar/AnyPS5. Originally posted by danzaio on 2026-10-10T17:07:28Z.
Validated the carried branch on real hardware: Windows 11, MinGW 15.2 relinker-only build, input_nonascii passes in 0.3s with Cyrillic, Japanese and accented paths. One caveat for reviewers: this machine runs the UTF-8 system locale (ACP 65001), so the old code also passes here and I could not reproduce the failure side locally. The branch is here if a collaborator wants to carry it: danzaio/AnyPS5 fix/windows-nonascii-paths. AI-assisted: yes.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-10T17:25:31Z.
Refreshed fix submitted: #2882
This carries forward the implementation from closed PR #2751, preserves aplatogg's original implementation commit author, and adds follow-up handling for the current guest module path flow. The open PR list had no duplicate for #2692.
input_nonasciiandwindows_import_modulesThe Windows measurements earlier in this issue tested the original candidate branch. This refreshed branch's current Windows CI job is still pending, so those measurements are not presented as validation of this exact head. The separate executable-runtime path issue #2640 is outside this change.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-10T17:28:23Z.
Windows CI follow-up for #2882
The first current-head Windows relinker run found that the new wide-argument conversion rejected an explicitly empty argument. This made the existing
sce_module_pathtest report a command-line conversion error instead of the expected validation error for--sce-module-path "".I fixed empty-argument handling in commit
c5ffebe1. The refreshed Linux Release relinker-only build succeeded; all 99 CTests passed, and local conventions passed. The new Windows CI run on this commit is pending.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-10T17:31:30Z.
Current-head CI complete for #2882
The empty-argument fix passed on the refreshed head:
sce_module_path,windows_import_modules, andinput_nonasciiThe full Linux and Windows build jobs were skipped by the PR workflow policy. I updated the PR description with the current-head results.