fix(build): do not build libSceAddressSanitizer in an ASan or TSan build #12894
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/12894"
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 xXPBSXx on 2026-10-29T13:37:01Z.
What
An
ANYPS5_ENABLE_ASANorANYPS5_ENABLE_TSANbuild fails to compilelibSceAddressSanitizer(added in #12106): its 301 stubs areextern "C" intfunctions, 204 of them named__asan_*and 55__ubsan_*, and with a sanitizer enabled the compiler already declares functions of those names with other signatures, so it stops with "new declaration ... ambiguates built-in declaration" inApi.hpp. The nightly Sanitizers workflow fails with this error in its run of 29 October, the first one after the library was added (run 40813774822).This skips the library in those two builds (
core/libs/CMakeLists.txt, three lines, the same waylibkernelleaves a target out underANYPS5_ENABLE_ASAN). Other builds are unchanged and still buildlibSceAddressSanitizer.prx.Alternatives: renaming the functions would change the export names of the 301 stubs, which are the names a title imports.
-fpermissivedoes not help: with it GCC 13.3 turns the 95 declaration errors into warnings, but the 95 definition errors remain and the file still does not compile. Side effect: in an ASan or TSan build a title that importslibSceAddressSanitizerdoes not find it; before #12106 it did not exist there either.Tested
ANYPS5_ENABLE_ASANbuild with UBSan: onmain8efa579b15the build oflibSceAddressSanitizerfails with the error above (190 lines of it). With this change on the samemainthe build finishes with exit code 0, andctest(without the AGC and video-out tests,setarch x86_64 -R) runs 1731 tests, 1721 passed. The 10 that failed are not in this area: six stop at UBSan'svptrcheck in the C++ exception runtime (the nightly workflow builds with-fno-sanitize=vptr), two at an out-of-bounds index in the FreeType submodule, one at a left shift of a negative value in the Vorbis submodule, andguest_freebsd_clocks, which assumes the host zone is UTC and passes withTZ=UTC0(#12660, #12747 and #12809 already change it).ANYPS5_ENABLE_TSANbuild: onmain8efa579b15the build oflibSceAddressSanitizerfails with the same error (190 lines). With this change the build of 135 thread-related test targets finishes with exit code 0 and the tests run; the ThreadSanitizer reports and failures there are in other code and not part of this change.libSceAddressSanitizer.prxis built (ninja exit code 0), andninja -t targets alllists the library there but not in the ASan or TSan build of this change.libSceAddressSanitizer.prxis built.check_conventions --base upstream/mainpasses, andgit merge-treeagainstmainis clean.Overlap
I took the changed files of each of the 1393 open PRs from
git diff --name-onlyagainst its merge base: 34 changecore/libs/CMakeLists.txtand none changeslibSceAddressSanitizer/.git diff -U0of those 34 shows no change to a line that names AddressSanitizer,ENABLE_ASANorENABLE_TSAN.git merge-treeof this head with each of them conflicts for 8, and all 8 already conflict withmainon their own, so no real pair conflict remains. Re-checked when opening against the open PRs created since then: #12782 and #12778 also changecore/libs/CMakeLists.txt, and both merge cleanly with this branch.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)AI-assisted (Claude Code).
🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-30T19:00:31Z.
Review: COMMENTED
Ran the nightly Sanitizers recipe with this PR on bare-metal Linux, since the PR notes that the workflow itself was not run.
Setup: Ubuntu 26.04, i7-8700 (bare-metal), GCC 15.2. Head
e41323717amerged ontomain6a3afa4deb. Configure and run steps as in.github/workflows/sanitizers.yml: Release,-DANYPS5_ENABLE_ASAN=ON,-g1 -fsanitize=undefined -fno-sanitize=vptr, the sameANYPS5_AGC_EXECUTION_TESTS,cmake --build -- -k 0and then--target libs, and ctest withASAN_OPTIONS=detect_leaks=0,UBSAN_OPTIONS=print_stacktrace=1:halt_on_error=1,APS5_SKIP_TIMING_TESTS=1,--timeout 300 --parallel 4. The only differences: no ccache, and ctest with-E "^agc|gpu|vulkan|video_out"(1835 tests), because this machine's GPU was in use.Without the PR (
main6a3afa4deb):check_test_registration.pypasses.libSceAddressSanitizer/Export.cpp.o, with 190 lines of "ambiguates built-in declaration" fromApi.hpp, the same error as the nightly.guest_freetype_*(22),guest_jxr_lookup*(7),guest_libressl_protocol(_nid),patched_libraries,host_libstdcxx_exceptionandnet_ipv6only_patched.With the PR:
check_test_registration.pypasses.guest_freetype_module_propertiesand_nid, stop at UBSan3rdparty/freetype/src/autofit/afglobal.c:254:54: index 65535 out of bounds for type 'AF_StyleClassRec *[88]'. The test leaves an invalid autofitterdefault-scriptset, which #13512 fixes.So once this lands the nightly should see these two FreeType failures, and nothing else new, unless #13512 lands first.
precise_waitpasses in both runs here (and 10 of 10 unchanged under ASan without the variable). With its 90 us bound lowered to 5 us in a local copy, it fails 5 of 5 withoutAPS5_SKIP_TIMING_TESTSand with=0, and passes 5 of 5 with=1("Skipping strict median bound"). That is the behaviour #13325 relies on in the nightly.Not run: Clang, the GPU and
agctests, and the workflow on the hosted runner.Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.