feat(libharfbuzz): implement buffer exports with a pinned backend #14441
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/14441"
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 bipinkrish on 2026-11-01T13:45:35Z.
What
Implement the eleven declared
hb_buffer_*exports using a static HarfBuzz 10.0.1 backend pinned as3rdparty/harfbuzz(a1d9bfe62818ef0fa9cf63b6e6d51436b1c93cbc). This covers buffer creation/destruction, UTF-16 ingestion, length, direction/script settings, segment-property guessing, glyph info/position access, and reset. The other 24 exports still throw. The project scanner counts 2/35 as fully implemented and the other 9 buffer functions as partial because their unverified null-handle paths throw; all eleven implement their public API behavior for valid handles.The adapter uses System V guest calls, checks the public glyph-record layout, and brackets caller-supplied output lengths with
GuestArena::HostWrite. The backend is built from source with CMake, its symbols stay local, and its HarfBuzz and Microsoft USE notices are installed and included in both patched and unpatched ZIP/tar release archives. Guest symbols use_nid_postfixto avoid colliding with the backend while retaining their existing NIDs. Public headers do not include third-party headers.Signatures and behavior follow the pinned public buffer API and implementation, not console measurements. The unknown console revision/Unicode tables, host default language and opaque host handles are recorded in
docs/dev/debt/libharfbuzz.md. Null handles other than destruction throw because console behavior is unverified. No test asserts or pinsNotImplemented_nid_no_patchpaths.Tested
Ubuntu 24.04, Linux x86-64, GCC 13.3.0. Full project configured with Ninja,
BUILD_TESTING=ON; the already unpacked upstream FFmpeg package was supplied throughFFMPEG_PREBUILT_DIR.cmake --build /tmp/anyps5-harfbuzz-build --target guest_harfbuzz_buffer_tests --parallel 4passed.ctest --test-dir /tmp/anyps5-harfbuzz-build -R '^guest_harfbuzz_buffer_' --output-on-failure: 3/3 passed. The tests compare guest calls with separate native buffers from the pinned backend, with golden decoding/cluster and direction cases: all 65,536 UTF-16 units, surrogate boundaries, embedded NULs, substring offsets/lengths, 1,000 deterministic randomized cases, eight scripts, explicit property preservation, independent buffers, array lifetime/mutation and reset/reuse.ANYPS5_ENABLE_ASAN=ON: the same 3 tests passed withASAN_OPTIONS=detect_leaks=1. LeakSanitizer required execution outside the sandbox.ctest --test-dir /tmp/anyps5-harfbuzz-build -R '^public_headers' --output-on-failure -j 4: 65/65 passed.python3 tools/tests/test_package_release.pyran 80 tests successfully (5 platform-specific skips). New tests check both upstream notices in patched/unpatched ZIP and tar archives and reject missing notices before publishing output. CMake installation of both notices was verified against their original bytes.-Wall -Wextra -Werror -fsyntax-only;git diff --checkpassed.python3 tools/check_conventions.py --base origin/main: passed with 0 errors and 8 warnings in unrelated upstream libkernel/libSceVisionManager debt entries. Againstupstream/main: all checks passed on the final commit.Not tested: Windows, macOS, games, homebrew or PS5 hardware. The full all-libraries/package build was not completed; the integrated library/test target and direct NID patching were verified.
Overlap check:
python3 tools/pr_overlap.py --branch codex/harfbuzz-buffers --repo boykopovar/AnyPS5 --jobs 8checked 1,670 open PRs and found no verified conflicts or shared exports after the HarfBuzz submodule entry was placed next to FreeType. It exited 2 because stale #1835, #5021, #9855 and #13578 cannot merge into the base and share.gitmodules. Each was manually compared: #1835/#5021 add Capstone, pyelftools and ps5link-sdk; #9855 adds jemalloc; #13578 adds ICU. None adds HarfBuzz or changes its exports, and their submodule edits are separate from this entry. No functional dependency.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)Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-01T13:58:14Z.
Review: COMMENTED
Reviewed — no blocking findings
The eleven buffer adapters match the pinned HarfBuzz buffer API they call, the renamed
_nid_postfixexports keep the NIDs of the names they replace, and the new HarfBuzz notices are packaged and checked; hosted checks at this head are still queued, so this is a COMMENTED result, not an approval.What I ran
821d724d41c28b97110e417500a6b8de167422d6, basef1a7b02028(the PR base). The head moved fromd8a7e2cdffduring this review;d8a7e2cdffis the head I first triaged and it is not posted. The one new commit, "fix(release): include HarfBuzz redistribution notices", adds the notices totools/package_release.py, a CMake install line and two tests./usr/bin/python33.11.2, no build.python3 tools/pr_precheck.py --repo boykopovar/AnyPS5 --pr 14441 --output-dir /dev/shm/reviewer-run/precheck/14441python3 tools/pr_abi_audit.py --repo /marc/AnyPS5 --base f1a7b02028 --head 821d724d41c28b97110e417500a6b8de167422d6 --json(exit 0;passed_with_warnings; 70 findings, all of kinddefinition-not-foundorexport-removedfor renamed names). I also compared computed NIDs of each old name and its_nid_postfixname: all 35 pairs are equal.core/libs/tests/GuestHarfBuzzBuffer.cppandtools/tests/test_package_release.pyfrom a head extract: the first reports one literal-path registration heuristic (the test is registered incore/libs/prx/libharfbuzz/CMakeLists.txt); the second reports nothing.gh api:src/ms-use/COPYING(1141 bytes) and the rootCOPYING(1971 bytes) exist ata1d9bfe62818ef0fa9cf63b6e6d51436b1c93cbc, the paths the install line and the packaging use.Buffer.cppin full, theExport.cppandInventoryExports.hppchanges, andGuestHarfBuzzBuffer.cpp(theUtf16,PropertiesandLifetimefunctions).Results
Precheck report, checks table, unedited (
/dev/shm/reviewer-run/precheck/14441/report.md):The precheck deliberately does not configure, build, or compile AnyPS5.git diff --check f1a7b02028ae50adaf6c5aaaef892a51841b25bf...821d724d41c28b97110e417500a6b8de167422d6/usr/bin/python3 tools/check_conventions.py --base f1a7b02028ae50adaf6c5aaaef892a51841b25bf --head 821d724d41c28b97110e417500a6b8de167422d6 --title feat(libharfbuzz): implement buffer exports with a pinned backend --body /dev/shm/reviewer-run/precheck/14441/pr-body.md/usr/bin/python3 tools/pr_abi_audit.py --base f1a7b02028ae50adaf6c5aaaef892a51841b25bf --head 821d724d41c28b97110e417500a6b8de167422d6 --json/usr/bin/python3 -m py_compile tools/package_release.py/usr/bin/python3 -m unittest tools.tests.test_package_release/usr/bin/python3 tools/check_test_registration.py --scripts/usr/bin/python3 /marc/AnyPS5/tools/pr_stack_check.py 14441 --repo boykopovar/AnyPS5 --output-dir /dev/shm/reviewer-run/precheck/14441/stackNot run: C++ tests need exact-head binaries, which require a build; the precheck does not build./usr/bin/python3 /dev/shm/reviewer-run/precheck/14441/head-821d724d41c2-ad2dff4c/tools/pr_test_quality.py --root /dev/shm/reviewer-run/precheck/14441/head-821d724d41c2-ad2dff4c --json .gitmodules 3rdparty/harfbuzz core/libs/prx/libharfbuzz/Buffer.cpp core/libs/prx/libharfbuzz/CMakeLists.txt core/libs/prx/libharfbuzz/Export.cpp core/libs/prx/libharfbuzz/include/InventoryExports.hpp core/libs/tests/GuestHarfBuzzBuffer.cpp docs/dev/debt/libharfbuzz.md tools/package_release.py tools/tests/test_package_release.pyA pass means every candidate failed by assertion on base; a failure means at least one did not discriminate or could not run. See per-test results.Negative control
The precheck's negative control runs the release test file against base. On base the new HarfBuzz tests fail (two
Fand oneE), and the precheck reportsnot_executable; the failures are assertions and a missing-exception check, so the new tests discriminate the change.Findings
Blocking: none.
Non-blocking:
_nid_postfixnames are defined. The NID check above confirms that the renamed symbols keep the same computed NIDs, which is the point of the convention. The audit still cannot prove the NID encoding, so that rests on the repository's_nid_postfixconvention.GuestHarfBuzzBuffer.cppchecks the adapter against the same HarfBuzz backend it links, so it tests the adapter's argument and layout handling, not HarfBuzz's own shaping or Unicode rules. The expected code points and clusters for the UTF-16 case are hard-coded and I checked them by hand.NotImplemented_nid_no_patch, as the PR states; the debt file records them.Sources
github.com/boykopovar/AnyPS5@821d724d41/core/libs/prx/libharfbuzz/Buffer.cppgithub.com/boykopovar/AnyPS5@821d724d41/tools/package_release.py (L74-L77)github.com/harfbuzz/harfbuzz@a1d9bfe628/src/ms-use/COPYINGNot verified
static_assertlayout checks were not compiled.--exclude-libslink option and the install rules were not run.conventions,eligibility,library-portabilityandreportwere queued at this head.Imported from boykopovar/AnyPS5. Originally posted by BunnyFl on 2026-11-03T03:24:48Z.
Review: APPROVED
First Windows run, plus a comparison with the console's own HarfBuzz build.
Windows 11, WinLibs GCC,
BUILD_TESTING=ON, head821d724d41merged onto currentmain7feb37ee3e(clean merge), with3rdparty/harfbuzzat the pinneda1d9bfe628:guest_harfbuzz_buffer_utf16,_propertiesand_lifetimepass. The backend compiles with one-Wsuggest-attribute=formatwarning inhb-buffer-verify.ccand no errors.--exclude-libs,ALLworks on MinGW too. The unpatchedlibharfbuzz.prxexports 36 names, 35 of them the_nid_postfixadapters, and none of the backend's ownhb_*symbols.There's no negative control on
main: the test calls the new adapters, which don't exist there.Firmware 13.42
system_ex/common_ex/lib/libSceVshHarfBuzz.sprx(sha25648cbea0616729b66473528b1b234595b4117781b76910ef0511bd4f9465e9717) exports all eleven NIDs. This is disassembly only, not measured on a console. The bodies I read to their returns behave like the pinned upstream code this PR forwards to:hb_buffer_get_length(0xb520:mov 0x60(%rdi),%eax; ret) andhb_buffer_get_direction(0xb1e0:mov 0x38(%rdi),%eax; ret) are plain loads.hb_buffer_set_direction(0xb1d0) andhb_buffer_set_script(0xb1f0) store only when the object's writable flag at+4is set, with no validation of the value. That's upstream's immutability check.hb_buffer_get_glyph_infos(0xb530) writes*lengthonly for a non-null pointer, then returns the array.hb_buffer_create(0xac60) doescalloc(1, 0xf0), sets reference count and writable flag to 1, and sets limits0x3fffffff/0x1fffffff. Those match upstream'sHB_BUFFER_MAX_LEN_DEFAULT/HB_BUFFER_MAX_OPS_DEFAULT.hb_buffer_destroy(0xaef0) returns for null or an inert object,lock decls, and writes0xffff2153at zero. That's upstream'shb_object_destroy.So delegating to real HarfBuzz is a faithful model here. None of these console bodies checks for null (at
0xb520,get_lengthdereferences%rdidirectly), so the PR's null refusals are a host-safety choice. That fits the debt entry.Not read:
hb_buffer_add_utf16(0xbd70, 817 bytes),hb_buffer_reset(0xadd0),hb_buffer_get_glyph_positions(0xb540) and thehb_buffer_guess_segment_propertiestarget (0xa8d0). I also didn't determine the console's HarfBuzz version. Unicode-table differences in segment guessing are presumably possible and unchecked, which matches the "unknown console revision" debt entry.The merge with #15365 will need a manual resolution: both change
hb_ot_tag_to_script's stub lines inExport.cpp/InventoryExports.hpp.