Repository navigation
Conversation
|
Windows relinker CI fails: The new The condition is also very broad: one unmatched module with no placed library, plus one host import, loads every DT_NEEDED library. Could it be narrowed to the libraries that actually export one of the unmatched NIDs? AI-assisted: yes. Written with AI assistance (Claude Code); I reviewed it. |
|
The previous Windows run exposed that an unscoped import with no declared module could leave an empty entry in UnmatchedImportModules, causing the startup stub to load unrelated native dependencies. I changed the reader to ignore empty declared-module names. Locally, the relinker builds with GCC 12.2 and the windows_import_modules test passes under Linux CTest (1/1). That Linux run does not execute the test Windows-only generated executable case; the new Windows CI run will validate that path. |
|
I traced the Windows CI failure to unscoped imports whose guest export names include symbol suffixes (for example, |
|
Follow-up pushed as 2cade45. The Windows failure was caused by marking every native dependency as required for unscoped imports, which made a missing optional |
|
The Windows CI failure was from the skip-SCE-module host import case: an absent native dependency must stay fatal when no guest module provider is known. This follow-up passes the skip-SCE-module mode into the Windows entry stub and keeps that strict check scoped to unplaced unscoped host imports.\n\nValidation: the Linux relinker CTest suite passed 114/114, including |
Dextroid17
left a comment
There was a problem hiding this comment.
Verified on Linux — the effect is visible in the produced artifact (6 of the 9 new cases emit a different PE), and the Windows job in this PR's own CI is what runs the assertions that catch it.
Head 036aa2dd, merged onto my checkout's upstream/main at 752db7da (145 commits ahead of this PR's own GitHub base 0a8b1d32). The API reports MERGEABLE.
What the change does, measured rather than read
I built relinker twice — once at the head, once with all nine implementation files at upstream/main (everything except the test) — and ran the test's own fixture machinery with a persistent work directory in place of its TemporaryDirectory, then hashed every produced file:
files produced: PR=294 control=294
identical: 288 differing: 6
host-provider-1/output.exe PR=63ecc442b5c6ca3f ctl=85629dc2624839c5
host-provider-2/output.exe PR=08f504f104145b39 ctl=340ca644a785daed
host-provider-3/output.exe PR=ec1123ceb2396f5c ctl=bd37f946745a9c31
host-provider-4/output.exe PR=ed41b85d282806b2 ctl=5b8b77f2c03c0a91
host-provider-7/output.exe PR=1add0c5088cd8634 ctl=d5570bb4c0452696
host-provider-8/output.exe PR=75828bb46b6c3fe3 ctl=5fa500c35aba9caa
All six are cases this PR adds (the whole host-provider-0..8 loop is new); the other 288 of the 294 files are byte-identical, which is the regression statement for the surrounding behaviour. Sizes match for every one of the six (275,968 and 310,784 bytes). Besides the stub body, exactly two derived fields move — both by the same 20 bytes:
.entry VirtualSize in the section table @0x208 control 0x22dd -> head 0x22c9
.entry end-address in .startup @0x30e4c control 0x452aa -> head 0x45296
and in the stub body itself, at file offset 269074:
head : 48 8d 0d 14 69 ff ff | ff 15 a9 d8 fc ff | 48 85 c0 lea rcx,[rip+…]; call [rip+…]; test rax,rax
control : 8b 05 e4 e8 fe ff | 83 f8 7e | 0f 84 … mov eax,[rip+…]; cmp eax,0x7e; je …
So the control's stub guards the load behind cmp eax,0x7e; je … where the head's reaches the call directly — the retained entry changes which path the stub takes. That is a static reading; the runtime difference is exactly what the assertions below test. Note that no library-name string is added to the PE (I checked unused.prx in both ASCII and UTF-16 — absent in both), so an assertion on the name would find nothing here.
What the Linux arms do and do not prove
ctest --test-dir build -R '^windows_import_modules$'→ head 1/1 Passed (~0.10 s) and control 1/1 Passed — identical, because the new outcome assertions sit insideif os.name == 'nt'. The block'sassert result.returncode == 0calls do run on Linux (the relink still has to succeed), but nothing on Linux asserts the retention itself, so the Linux suite is not coverage for this change.- Neighbouring module-resolution tests on the head:
guest_module_identity,guest_needed_modules,guest_symbol_names,windows_working_directory→ 4/4 Passed. --skip-sce-moduleis not new: it is already parsed onmain(core/relinker/main.cpp), so the test does not depend on the flag arriving with this change.
The coverage is better than the description says — and this PR's own job has already proved it bites
"The Windows-only import-loading scenarios are not exercised on Linux" is true, but it reads as though nothing runs them. The relinker job is not gated the way linux/windows are (those report skipping on a PR); it runs on windows-latest here, with -DANYPS5_RELINKER_ONLY=ON -DBUILD_TESTING=ON, and the file registers windows_import_modules with no OS guard. From this PR's head run (38184891028, job 114605106512):
Start 100: windows_import_modules
100/119 Test #100: windows_import_modules ......................... Passed 1.41 sec
1.41 s against ~0.10 s locally is the produced .exes being executed — the part only Windows can do. And the job has already caught a regression in this very PR: on commit 2cade451 the same test failed on the same runner,
100/119 Test #100: windows_import_modules .........................***Failed 1.30 sec
File ".../test_windows_import_modules.py", line 455, in main
assert run.returncode != 0 and 'Failed to load module:' in run.stderr and 'unused.prx' in run.stderr, (index, ...)
which is the new assertion, failing on a real defect rather than by plumbing. That pair of lines is worth more in the description than the current caveat.
One question about intent — bae3a2f8 says "ignore empty unmatched import modules", but only the reader does. That commit touches GuestImageReader.cpp alone (it is the hunk adding && !name.empty()), while RelinkerPipeline.cpp:353 still inserts the declared module unconditionally, so an empty string reaches UnmatchedImportModules whenever a ref has no library and no declared module — which DeclaredImportModule returns by design in both cases (domain/ImportModule.hpp:21-23). On the stub side the set's emptiness is itself a condition (WindowsEntryStubBuilder.cpp:184, unmatched.empty() || …): an empty member cannot flip the already-empty case (that disjunct was already true), but where every real unmatched module is among the searched libraries, the disjunct is false and the any_of at :185 finds no library whose stem is "", so unplacedModule becomes true. I could not reach that state from the suite, and the Windows job is green, so this is a question about intent rather than a defect I can demonstrate: was the pipeline's unconditional insert meant to keep the empty value, or to drop it the way the reader now does?
Not verified, so it is not claimed: the title run (the issue reports a partial one that stopped later on a shared-memory limitation), and Windows execution by me — the Windows evidence here is the CI log above.
Hermes Agent 🤖 at your service
|
One clarification to my review above, having now read the thread. @MarcZX100's account of the earlier Windows failure already names this area — "an unscoped import with no declared module could leave an empty entry in
So an empty member can still reach the set the stub reads at Hermes Agent 🤖 at your service |
|
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
|
What
Carries David's fix for #3369, preserving his original commit author. Windows relinking now retains host libraries in the load list when an unmatched import can be searched in any host library and its module name does not identify a needed library. This fixes the case where a provider such as
libSceAppContent.prxwas omitted because the import module had a different name.The change leaves the existing optional diagnostic for a missing, unused dependency available. A follow-up commit restores its string because the skip path still references it.
Tested
tools/check_conventions.py --base upstream/mainandgit diff --checkpass.windows_import_modulesandguest_module_identitypassed five repetitions, and the relinker-only suite passed 105/105 on Windows. Their title check reports Middle Ages Ping Pong progressed beyond its prior unresolved import and stopped later on a shared-memory limitation; it was not a complete title run.Checklist
mainDepends on: none