Repository navigation
fix(libSceSsl): keep the bundled mbedtls symbols out of libSceSsl's exports on macOS - #10530
Conversation
…xports on macOS On Linux and MinGW, --exclude-libs keeps the statically linked mbedtls out of libSceSsl's dynamic exports. Apple's linker has no such option, so on macOS libSceSsl.prx exported 930 mbedtls and 155 PSA symbols, and libSceLibreSsl.prx 27 mbedtls symbols. A program that links its own mbedtls can then bind to libSceSsl's copy, which allocates from libSceSsl's own pool; guest_ssl_transport_kernel and guest_ssl_transport_net fail that way. Build the mbedtls libraries with hidden visibility on macOS instead. Co-authored-by: Ycaro Gabriel <280482597+ycarogabriel-lgtm@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MarcZX10
left a comment
There was a problem hiding this comment.
Reviewed the exact two-line CMake change and the reported export/test comparison. It applies hidden C visibility to the four bundled Mbed TLS targets only on Apple; Linux/MinGW retain --exclude-libs,ALL and other platforms are untouched. The earlier implementation is cited, but it is not in current upstream main, and the PR provides a macOS-specific report showing the resulting export set and SSL transport regression coverage. The automatic build jobs for this PR are skipped; I am relying on the described macOS run, not treating it as hosted CI.
|
Windows run of
Not run: a title. AI-assisted: yes (Claude Code) |
imellag
left a comment
There was a problem hiding this comment.
Tested head f5dffcb12f on Apple M4 Pro, macOS 27.0.1, Apple clang 21, x86-64 under Rosetta 2. The tree is main 61fc572cee plus the open macOS build PRs and the parts of mugurc's series that #7201 also carries. Only this change was toggled.
- Without it:
nm -gU libSceSsl.prxlists 1,085mbedtls_*/psa_*symbols.guest_ssl_transport_kernelandguest_ssl_transport_netfail 2 runs out of 2, ata server certificate without a loaded CA passed the initial verify options. - With it:
libSceSsl.prxexports 55 symbols and none of them ismbedtls_*orpsa_*.libSceLibreSsl.prxexports none either. Both transport tests pass 3 runs out of 3. ctest -R 'ssl|http|libressl|crypto|tls|x509'(63 tests): 61 pass without this change and all 63 with it. Only the two transport tests change.
AI-assisted: yes
Test report: #10530 (hide libSceSsl's bundled mbedtls symbols on macOS)Tested on: Apple M2 MacBook Air, macOS 27.2 (26B118), x86_64 Release build under Rosetta 2, AppleClang 21.0.0, Ninja.
The two transport tests already fail on this stack without the PR (net: "a server certificate without a loaded CA passed the initial verify options"). With the PR they no longer start: For comparison: on the same M2 and a similar stack, hiding the symbols at link time instead ( Broad run: Not checked: whether guest titles import any of the hidden symbols; AI-assisted: yes (Claude Code) |
|
@krishalivaibhav thanks for running it on your stack. I reran it on a tree built from
So the Could you check, on your stack, where that symbol binds in the test executable ( On AI-assisted: yes (Claude Code ran the A/B and wrote this reply). |
|
@maximilianfv you're right, and my earlier report was wrong: the dyld failure came from a stale link on my side, not from this PR. That run rebuilt I reran it with both targets rebuilt from this PR, on the same M2 and stack:
So this PR fixes both tests on M2 as well. Thanks also for the AI-assisted: yes (Claude Code) |
|
Checked the change against the target list at |
What
On Linux and MinGW,
--exclude-libs,ALLkeeps the statically linked Mbed TLS out of libSceSsl's dynamic exports. Apple's linker has no such option, so on macOSlibSceSsl.prxexports 930mbedtls_*and 155psa_*symbols (54 of its 1,139 exports are libSceSsl's own). A program that links its own Mbed TLS can then bind to libSceSsl's copy, which allocates from libSceSsl's context pool.guest_ssl_transport_kernelandguest_ssl_transport_netfail on macOS this way: their test TLS server links Mbed TLS itself. The analysis in #8658 (commit 8a4bd1e) traced this to the server'smbedtls_ssl_setupresolving to libSceSsl's copy and failing withMBEDTLS_ERR_SSL_ALLOC_FAILED.This builds the
mbedtls,mbedcrypto,mbedx509andp256mtargets with hidden C visibility on Apple. These targets are shared, so the change also reacheslibSceLibreSsl, which linksmbedcryptoand exported 27mbedtls_*symbols on macOS; it now exports none. The Linux and MinGW paths are unchanged.Prior art, credited:
mainas a standalone fix, with Ycaro as co-author.-unexported_symbol,_mbedtls_*and_psa_*linker options rather than hidden visibility. None of the PRs split from feat: macOS host support (Apple Silicon via Rosetta 2, Vulkan on MoltenVK) #8658 so far includes it._nid_names; the existingguest_ssl_transport_*tests cover this change.pr_overlap.py(run serially): no overlapping PRs. It could not compare #6044 because #6044 conflicts withmain. #6044 changescore/libs/prx/libSceSsl/CMakeLists.txtonly in theBUILD_TESTINGblock, not the lines changed here.Tested
Apple M1 Pro, macOS 27.0.1, x86_64 build under Rosetta 2.
mainalone does not build on macOS, so I tested on mugurc's macOS series (ci/macos-series-2, 27e9689) merged withmainat 1e20650, plus the macOS build parts of #10419, toggling only this change.nm -gU libSceSsl.prxmbedtls_, 155psa_)mbedtls_orpsa_nm -gU libSceLibreSsl.prxmbedtls_)mbedtls_ctest -R 'guest_ssl|guest_libressl|guest_http'(14 tests)guest_ssl_transport_kernelandguest_ssl_transport_netfail witha server certificate without a loaded CA passed the initial verify optionsThe five
guest_libressl*tests pass both ways. On the series alone (27e9689, without themainmerge), the same two transport tests failed without the change and all 9ssl|httptests passed with it.Not tested on Linux or Windows. Their CMake path is unchanged.
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)🤖 Generated with Claude Code