Build: host-only test executables under core/libs keep failing to link on MinGW after merge (__gxx_personality_v0) #11287

Closed
opened 2026-10-26 00:12:16 +00:00 by ycbuzi · 0 comments
ycbuzi commented 2026-10-26 00:12:16 +00:00 (Migrated from github.com)
Contributor

Imported from boykopovar/AnyPS5. Originally posted by ycbuzi on 2026-10-26T00:12:16Z.


What happens

On the supported MinGW toolchain, a test executable under core/libs that links no guest libc fails to link with undefined reference to `__gxx_personality_v0'. Pull requests never see this, because the Windows product build doesn't run on pull requests. It has now happened at least four times.

Title, test or build step

Linking test executables under core/libs. The four cases I found:

where executable fix
#75 guest_json_tests, fiber_tests after #87
#7732 spirv_validator_exit_tests #7733 links libc on MinGW
#9626 (open) agc_driver_registration_prepare_budget_tests not yet
#10953 (open) guest_sigvec_modules_tests the author changed its flags

AnyPS5 commit

main acb900c194, plus #9626 7610b45905 for the reproduction below.

System

Windows 11 Home 10.0.26200, WinLibs GCC 15.2.0 r7 (MinGW-w64 UCRT, posix-seh, DWARF exceptions), Ninja, Release, BUILD_TESTING=ON.

Steps to reproduce

Merge #9626 onto main, configure as build.yml does, then:

ninja -C build agc_driver_registration_prepare_budget_tests

Log

RegistrationPrepareBudget.cpp.obj:RegistrationPrepareBudget.cpp:(.data+0x10): undefined reference to `__gxx_personality_v0'
collect2.exe: error: ld returned 1 exit status

What was checked

Why it fails. On a DWARF-exception MinGW toolchain, core/libs/CMakeLists.txt:50 compiles everything after it with -fno-asynchronous-unwind-tables. C++ objects with exception landing pads then refer to __gxx_personality_v0, which the guest libc provides. An executable that links neither libc (directly or through another in-tree library) nor its own unwind runtime fails to link. That happens only when one of its objects has a landing pad. Several host-only test executables on main link no libc and are fine, so the problem can't be found reliably from the CMake files alone: whether an object needs the personality depends on its code.

Why CI doesn't catch it. The windows job in build.yml (line 558) runs only on pushes to main and on workflow_dispatch. A pull request that adds such an executable passes CI and breaks the Windows build when it merges, unless someone builds it on Windows first. That is how #9626 and #10953 were found.

The fixes already in the tree:

  1. Link libc on MinGW (#7733 for spirv_validator_exit_tests).
  2. Native SEH unwind tables and a static runtime: -fasynchronous-unwind-tables and -static -static-libgcc -static-libstdc++ (patched_libraries_tests, core/libs/CMakeLists.txt:328-329). On #10953 this pattern made GCC 15.2 stop with internal compiler error: in choose_baseaddr in a source with sysv_abi calls. The author then compiled that one source with -fno-exceptions -fno-asynchronous-unwind-tables.

Options, if you want to prevent the next one:

  • A helper and a convention: a small function, say configure_host_test_executable(target), applying one of the two fixes on MinGW, mentioned in BUILD or CONVENTIONS for test executables that link no guest library.
  • A cheap pull-request check: the relinker (windows-latest, g++) job already runs on pull requests with the same toolchain. It could also configure with BUILD_TESTING=ON and build only the core/libs executables that link no in-tree library, found through the CMake File API. Because it's a real link, it can't report a false positive. The cost is a full configure plus those few small targets.
  • Leave it as is: Windows contributors keep catching these by hand.

I can implement either of the first two if you say which you'd prefer.

AI-assisted: yes (Claude Code)

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:6030973139 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/11287). Originally posted by [ycbuzi](https://github.com/ycbuzi) on 2026-10-26T00:12:16Z. --- ### What happens On the supported MinGW toolchain, a test executable under `core/libs` that links no guest `libc` fails to link with ``undefined reference to `__gxx_personality_v0'``. Pull requests never see this, because the Windows product build doesn't run on pull requests. It has now happened at least four times. ### Title, test or build step Linking test executables under `core/libs`. The four cases I found: | where | executable | fix | |---|---|---| | #75 | `guest_json_tests`, `fiber_tests` | after #87 | | #7732 | `spirv_validator_exit_tests` | #7733 links `libc` on MinGW | | #9626 (open) | `agc_driver_registration_prepare_budget_tests` | not yet | | #10953 (open) | `guest_sigvec_modules_tests` | the author changed its flags | ### AnyPS5 commit `main` `acb900c194`, plus #9626 `7610b45905` for the reproduction below. ### System Windows 11 Home 10.0.26200, WinLibs GCC 15.2.0 r7 (MinGW-w64 UCRT, posix-seh, DWARF exceptions), Ninja, Release, `BUILD_TESTING=ON`. ### Steps to reproduce Merge #9626 onto `main`, configure as `build.yml` does, then: ``` ninja -C build agc_driver_registration_prepare_budget_tests ``` ### Log ``` RegistrationPrepareBudget.cpp.obj:RegistrationPrepareBudget.cpp:(.data+0x10): undefined reference to `__gxx_personality_v0' collect2.exe: error: ld returned 1 exit status ``` ### What was checked **Why it fails.** On a DWARF-exception MinGW toolchain, `core/libs/CMakeLists.txt:50` compiles everything after it with `-fno-asynchronous-unwind-tables`. C++ objects with exception landing pads then refer to `__gxx_personality_v0`, which the guest `libc` provides. An executable that links neither `libc` (directly or through another in-tree library) nor its own unwind runtime fails to link. That happens only when one of its objects has a landing pad. Several host-only test executables on `main` link no `libc` and are fine, so the problem can't be found reliably from the CMake files alone: whether an object needs the personality depends on its code. **Why CI doesn't catch it.** The `windows` job in `build.yml` (line 558) runs only on pushes to `main` and on `workflow_dispatch`. A pull request that adds such an executable passes CI and breaks the Windows build when it merges, unless someone builds it on Windows first. That is how #9626 and #10953 were found. **The fixes already in the tree:** 1. Link `libc` on MinGW (#7733 for `spirv_validator_exit_tests`). 2. Native SEH unwind tables and a static runtime: `-fasynchronous-unwind-tables` and `-static -static-libgcc -static-libstdc++` (`patched_libraries_tests`, `core/libs/CMakeLists.txt:328-329`). On #10953 this pattern made GCC 15.2 stop with `internal compiler error: in choose_baseaddr` in a source with `sysv_abi` calls. The author then compiled that one source with `-fno-exceptions -fno-asynchronous-unwind-tables`. **Options, if you want to prevent the next one:** - **A helper and a convention:** a small function, say `configure_host_test_executable(target)`, applying one of the two fixes on MinGW, mentioned in BUILD or CONVENTIONS for test executables that link no guest library. - **A cheap pull-request check:** the `relinker (windows-latest, g++)` job already runs on pull requests with the same toolchain. It could also configure with `BUILD_TESTING=ON` and build only the `core/libs` executables that link no in-tree library, found through the CMake File API. Because it's a real link, it can't report a false positive. The cost is a full configure plus those few small targets. - **Leave it as is:** Windows contributors keep catching these by hand. I can implement either of the first two if you say which you'd prefer. AI-assisted: yes (Claude Code)
Sign in to join this conversation.
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5#11287
No description provided.