Repository navigation
fix(tests): stage linked .prx runtime files next to test executables on Windows - #7645
Conversation
|
I rechecked the submitted diff against the cross-target reproduction from #7637. The PR currently still uses |
|
One more edge case from the same cross-target: a test target with no linked runtime DLLs also fails in the submitted form. |
8ee1664 to
d2fbfd9
Compare
|
I tested the updated |
|
Thanks for the fast re-verification on the 3.25.1 cross-target - good that the |
|
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.
Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
|
MarcZX10
left a comment
There was a problem hiding this comment.
One compatibility issue to resolve before merging: the root CMakeLists.txt declares cmake_minimum_required(VERSION 3.20), but $<TARGET_RUNTIME_DLLS:...> was added in CMake 3.21 (CMake 3.21 release notes). On Windows with CMake 3.20 this generator expression is evaluated during generation and is unknown, so the newly added if(WIN32) command can make configuration fail for a version the project currently claims to support. Could you either preserve 3.20 compatibility (for example, gate an alternate staging path by CMake version) or raise the project minimum to 3.21 and update the documented/tooling requirement? The current CMake 4.4.4 validation does not cover the declared minimum.
|
Overlap bot report checked: all 13 shared-file PRs touch |
d2fbfd9 to
ee69ac6
Compare
MarcZX10
left a comment
There was a problem hiding this comment.
Thanks for checking the real CMake 3.20.5 behavior; the version gate correctly avoids the unknown-generator-expression failure. One remaining scope point: on 3.20 the staging command is disabled, so a test registration without the manual PATH prepend can still hit the same loader dialog, and direct-running the exe still lacks the new guarantee. Could you either add a 3.20-compatible staging fallback, or state that this general protection applies only with CMake >=3.21 (and retain the per-test PATH setup as required below that)? The current reported CMake 3.20 validation proves configuration/build, not the no-PATH runtime behavior.
|
Good catch — fixed in if(WIN32 AND NOT CMAKE_VERSION VERSION_LESS 3.21)
add_custom_command(TARGET ${target} POST_BUILD ...)
endif()Chose the gate over bumping the minimum so this fix stays scoped. On <3.21 the command is never created, so the unknown genex can't fail generation — and the per-test Verified against a real CMake 3.20.5 binary (PyPI wheel) with a minimal fixture replicating the pattern:
Side note for context, not pushback: the repo already relies on |
MarcZX10
left a comment
There was a problem hiding this comment.
The current head addresses the CMake 3.20 generator-expression failure by gating the staging command at 3.21, and the updated body clearly records that the existing per-test PATH setup remains in effect below that version. The reported MinGW staging checks cover linked and no-runtime-DLL targets, and the current conventions, relinker platform, and ASan checks pass. I approve this focused test-infrastructure change.
|
Fair point — taken the second option and scoped the claim in the PR body: staging applies on One nuance worth noting on the fallback side: A true 3.20 fallback would need |
|
Full-suite Windows run, to cover every test executable now that each one gets the staging step (the description lists a 14-test sweep). Windows 11 Pro 26200, NVIDIA GeForce RTX 4080 (driver 617.42), WinLibs GCC 15.2.0 r7, CMake from WinLibs, Ninja, Release, bundled dependencies,
I did not repeat the scrubbed- AI-assisted: yes (runs done with Claude Code). |
THEMANnt
left a comment
There was a problem hiding this comment.
Reviewed ee69ac6d0e6f1fb9a08c9a6d9790b12d35da6985 against 8d17389a73852ee0e462c640589b47d49c68e8d6. No actionable findings in this focused review.
Source review: Inspected the complete helper change and its existing runtime output/wrapped-main setup. Windows CMake 3.21+ stages linked runtime dependencies beside the test. COMMAND_EXPAND_LISTS preserves the DLL list, VERBATIM handles paths, and including the executable itself keeps copy_if_different valid when the dependency list is empty. Older CMake and non-Windows behavior are unchanged.
Validation: Windows, CMake 4.3.1 / MinGW GCC 15.2: a disposable project using the exact head helper and WindowsTestExit source built a shared .prx plus linked and standalone tests in directories containing spaces. Both head executables ran with exit 0; the linked .prx was staged. The same baseline fixture built but did not stage that file. Conventions and whitespace passed. This older script-registration CLI rejects --scripts; no registration pass is claimed. Effective hosted relinker matrix and ASan succeeded; full-product jobs were skipped.
Scope: Actual bounded CMake/build/runtime fixture; full AnyPS5 libraries and all test targets were not rebuilt locally.
|
@akkadbakkad89 thanks for this. One concern before it can go in: the exe directory is searched before PATH, and the files this stages are the unpatched build outputs. Several tests deliberately put ${PATCHED_DIR} on PATH (core/libs/CMakeLists.txt:322, libSceFreeType, libSceFreeTypeOl, libSceJxr, libSceLibreSsl), so with this change they could load the unpatched DLLs instead. Could you run those on Windows with this change (full ctest on a clean build) and show they still load the patched libraries? Also, how are parallel copies of the same DLL into the shared test directory kept safe when tests build in parallel? |
ee69ac6 to
a3ea1b9
Compare
|
@oneandonlydean Confirmed the concern on the previous head, then fixed it - Before the fix, on the staging-only head: After the opt-out, with Parallel copies: every POST_BUILD copies the same |
|
You called it — the shadowing was real, and
Fix in Tested on native Windows 11 + MinGW after a full
On parallel copies into the shared dir: the full |
|
@akkadbakkad89 thanks for chasing that down; building the opted-out tests into
Could you merge main, add |
b54f34d to
a7ef6a9
Compare
63298da to
bada308
Compare
|
Rebased onto |
|
The Windows failure on
Re-audited every The Windows relinker job also timed out on |
|
Verified locally on |
✅ AMD GPU test: passedPR head
Unstable on main (7, these also failed in recent main runs on this machine; not counted against this PR)Failing on main too (11, not counted against this PR)Validation IDs already present on main (4 IDs in 812 tests)Skipped (70)ReproduceAutomated build and test on a contributor's AMD machine; it does not replace upstream CI. A new comment is posted for each new push. Full logs. |
|
A real-world check of this change on Windows (WinLibs GCC 15.2 UCRT, Release). The newly opened #17627 adds
So this removes the need for that per-test property, which new PRs keep missing: in the last day #17261, #17259 and #17555 to #17558 hit the same AI-assisted: yes. |
|
Correction and caveat to my comment above: with this PR there's also a regression on Windows. It stages the unpatched
So staging needs to leave out the modules that these patched-path tests load from AI-assisted: yes. |
…on Windows Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
…mits Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
…ntime staging guest_legacy_freetype_metadata_tests, guest_freetype_postscript_private_tests, guest_freetype_stroker_outputs_tests, guest_freetype_ot_tests, guest_freetype_ot_outline_tests, guest_libressl3_ecdsa_sig_tests, guest_libressl3_rsa_getters_tests, guest_kernel_process_exports_tests and guest_kernel_resident_fmem_export_tests each register a patched variant that prepends PATCHED_DIR on PATH, so their staged unpatched libc.prx shadows dependency resolution for the patched modules they load.
8f82309 to
02c30d7
Compare
|
@JJenkx Confirmed and fixed — your report was right. Windows resolves an imported The branch is rebased onto current Verified on this machine (Windows, MinGW GCC 15.2.0): Head |
|
A staged copy goes stale after a change inside a library: the POST_BUILD copy runs only when the test executable relinks, and the libraries under Measured on To reproduce (the test needs a Vulkan GPU): #17895 adds a step to the POST_BUILD of each library that calls Not covered here: Linux and macOS, which this staging does not apply to, and generators other than Ninja. AI-assisted: yes. Claude Code ran the builds and the test and drafted this comment; a separate review agent checked it. |
What
add_test_executablegains a POST_BUILD step that copies$<TARGET_RUNTIME_DLLS>next to the test exe on Windows. The step is gated onCMAKE_VERSION >= 3.21(the generator expression's floor) so the declaredcmake_minimum_required(VERSION 3.20)keeps configuring; on <3.21 the step is absent and the existing per-testENVIRONMENT_MODIFICATIONPATH prepends apply unchanged (note the prepend property itself is a 3.22 feature that ctest silently ignores on 3.20-3.21, so this widens rather than narrows the working range; the loader trap below 3.22 predates this PR). The executable directory outranks PATH in the DLL search order, so a test whose registration forgot theENVIRONMENT_MODIFICATION "PATH=path_list_prepend:$<TARGET_FILE_DIR:libc>"boilerplate still resolveslibc.prx/libkernel.prx/libSceAgcDriver.prxat load - instead of spawning a modal "entry point not found" (0xC0000139) dialog that blocks until ctest reports a timeout.The prepend is manual per-test boilerplate repeated across ~95 CMakeLists files; new registrations keep missing it (live instance fixed in #7627's
agc_driver_depth_bounds_state). With staging, no registration needs it, future omissions stop mattering, and hand-running a test exe works with no environment setup. ExistingENVIRONMENT_MODIFICATIONlines stay harmless for every exe that does not opt out.Twenty-one test executables opt out with the new
NO_RUNTIME_DLL_STAGINGargument, in two classes. Class one (guest_dinkumware_fetch_tests,guest_freetype_outline_border_tests,guest_freetype_pfr_tests,guest_freetype_module_properties_tests,guest_freetype_postscript_info_tests,guest_freetype_memory_record_tests,guest_freetype_stream_tests,guest_jxr_lookup_tests,guest_libressl_protocol_tests,guest_floating_prefix_tests,guest_libressl_cmac_patched_tests,guest_libressl_bio_patched_tests) loads patched-vs-unpatched library variants selected by a${PATCHED_DIR}/UNPATCHED_DIRPATH prepend and by explicit library paths, and asserts the loaded module's on-disk path (std::filesystem::equivalenton the module handle,startup == library). Any fixed copy staged next to the exe would shadow exactly one of the two variants - an unpatched stage breaks the patched variants' asserts and keeps the patched library's NID-shaped imports from resolving against the already-loaded unpatched siblings.Class two (
guest_update_env_tests,guest_raise_except_tests,guest_floating_point_tests,guest_gets_tests,guest_index_tests,guest_fwide_tests,guest_set_env_tests,guest_timed_join_tests,guest_termios_speed_tests) both links the.prximport library and receives the same module as a$<TARGET_FILE:...>argv path. With staging, the exe's import table bindstests\libc.prx/libkernel.prxat startup whileLoadLibraryA(unpatched/...)maps a second copy of the same module at a different base - the loader dedups full-path loads by path, not by basename, so the process ends up with two module instances and split per-module state (errno, stdio FILE tables, registered unwind info).guest_getsfailed on the stdio split (gets: byte read pointer- the GetProcAddress'dgetsran in the second instance's stdio state), and the fenv tests failed because the second instance's_Unwind_RaiseExceptionnever registered the host exe's.ehfram, so astd::invalid_argumentthrown across the prx boundary unwound off the top instead of reaching the exe'scatch. Opting out restores the single-instance layout their PATH prepends already provided. Every other exe keeps the staging.Tested
Windows 11, MinGW (WinLibs GCC 15.2.0), Release, RTX 3070 (driver 617.42).
0f5d53553d, before the opt-out):ctest -R guest_dinkumware_fetch18/18 failed (startup == library/equivalentasserts - the stagedtests\libc.prxis neitherunpatched/libc.prxnorlibs/libc.prx);guest_freetype_outline_border8/8 failed including the raw variants;guest_freetype_pfr_*_patched3/3 failed;guest_freetype_module_properties_nidfastfailed (0xc0000409);guest_jxr_lookup_*_patched3/3 failed atLoadLibraryA- the patched module's NID imports cannot resolve against the staged unpatchedlibc.prx/libkernel.prx.a3ea1b93b7, cleantests/dir - all staged.prxremoved first):guest_dinkumware_fetch_*18/18,guest_freetype_outline_border_*8/8,guest_freetype_pfr_*6/6,guest_freetype_module_properties*2/2,guest_jxr_lookup_*6/6,guest_libressl_protocol*2/2 - 42/42 pass. These tests assert the loaded module's path themselves (equivalent,GetModuleHandleW("libc.prx")vsrequested/libc.prx,startup == library), so a pass is direct proof the patched libraries are the ones loaded.guest_posix_scalar_io_testsre-stagedlibc.prx+libkernel.prxand passed withPATHscrubbed toC:\Windows\System32;C:\Windows.$<TARGET_RUNTIME_DLLS>form fails generation (Expression did not evaluate to a known generator expression); the gated form configures, generates and builds clean.ebecf4e71677(CI run 41276557688windowsjob: 6 fail-fast aborts) and locally:guest_update_env/guest_raise_except/guest_floating_pointabort on the gueststd::invalid_argumentthat the exe must catch (unhandled exception 'St16invalid_argument'-> terminate -> 0xc0000409);guest_getsaborts ongets: byte read pointer;guest_timed_join_normal/_coarseabort the same way. A probe exe linking thelibcimplib thenLoadLibraryA(unpatched/libc.prx)reports two distinct module bases (tests\libc.prx+unpatched\libc.prx) - the dual-instance mechanism, confirmed directly.ctest -R guest_update_env|guest_raise_except|guest_floating_point$|guest_gets$|guest_timed_join|guest_index$|guest_set_env|guest_termios_speed- 42/42 pass on Windows 11 (excludes the three latent exes' own unchanged assertions which now also run single-instance);guest_timed_join_import_libkernel_sys/_webpass fromtests/nostage/(the per-test$<TARGET_FILE_DIR:...>copies/PATH prepends follow the exe automatically).python3 tools/check_conventions.py --base origin/main: clean;git diff --check: clean.Parallel copies: every staging POST_BUILD copies from the same
unpatched/source file into the sharedtests/dir, so concurrent copies write identical bytes.cmake -E copy_if_differentcompares first and is a no-op once the destination matches; when two builders race on a first write the destination file is opened non-shared, so the loser gets a sharing violation and the POST_BUILD fails loudly at build time - a transient retryable error, never a torn DLL, and nothing maps the file during the build (tests only run under ctest afterwards).Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)