Skip to content

fix(libc): compute cbrtl with FreeBSD msun's ld80 code as the bundled libc.prx does - #11632

Merged
oneandonlydean merged 7 commits into
boykopovar:mainfrom
AlexFigas:fix/libc-cbrtl-msun-ld80
Nov 4, 2026
Merged

oneandonlydean merged 7 commits into
boykopovar:mainfrom
AlexFigas:fix/libc-cbrtl-msun-ld80

Conversation

@AlexFigas

@AlexFigas AlexFigas commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

What

cbrtl returned the host's cbrtl. On 20,000,000 random 80-bit encodings, glibc's result differs from the console's on 2,038,367 of them. For example, cbrtl(0x8659809ec6db32bc:401d) is 0x82151d1b393fd44d:4009 on the console and …44e on the host.

The evidence is the libc.prx bundled with PPSA21564, build J03093718, the library's own code. Its cbrtl (0x42360, no calls) is FreeBSD msun's s_cbrtl.c for ld80, instruction for instruction:

  • Special values. ±∞ and NaN return x + x; ±0 returns x.
  • Subnormals. These are scaled by 2^514 (fmul by 0x6010000000000000) before the exponent is read.
  • Reduction. The mantissa gets exponent 0x3fff. It is doubled or quadrupled by k % 3, with C's truncating % and / (16-bit imul 0x5556 in the binary). The scale v keeps the argument's sign and gets exponent 0x3fff + k / 3.
  • Double-precision estimates.
    • The float conversion (fst dword) gives the 5-bit estimate (hx & 0x7fffffff) / 3 + B1, with B1 = 709958130.
    • Two Newton steps follow, dt * (dx + dx + dr) / (dx + dr + dr), in SSE doubles with no fused operations.
  • Rounding. t = dt + (2^32 + 2^-31) - 2^32 on the x87. The binary adds 2^32 + 2^-31 at run time from two stack doubles, msun's volatile vd2 and vd1, so this port reads them through volatile as well.
  • Final step. One Newton step on the x87, t + t * ((x/t² - t) / (2t + x/t²)), then t * v.

The new JoinExtended builds an 80-bit value from its mantissa and sign-exponent, the counterpart of SplitExtended.

The binary has no control-word instruction, since msun's ENTERI changes the precision only on i386 (math_private.h). It runs at the caller's x87 precision, and so does this port. The precision a guest thread starts with is #11849.

The debt list of host-computed long double functions drops cbrtl. A new entry records what is left: other SDK versions and the system libSceLibcInternal are not compared.

Licence. s_cbrtl.c's notice is copied verbatim at the top of Math.cpp, after the notices #12541 added and before the first #include, behind a Derived from FreeBSD lib/msun/src/s_cbrtl.c (release/11.4.0) line in #12541's form.

Tested

On Ubuntu 24.04 under WSL2 (GCC 13.3, Release). Head b2a99b1 merges main a4eca2a into the previous head 5ab9b29 (main e0caf13). The merge has one conflict, in docs/dev/debt/libc.md: main has #11849's shorter asinl entry and still lists cbrtl among the host-computed functions, so the resolution keeps main's asinl, drops cbrtl from the list and keeps this PR's cbrtl entry. Before that, 5ab9b29 merged into 02c5868 (main 8a4fc62), which merged into 77b2461, which had merged main f1e340b, and 9d91493 before it main da026c7 and with it #12541. The native comparison and precision runs below were first made on the earlier head a180cc0, whose cbrtl is the same; the first bullet repeats the comparison with the binary on this head.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none (docs(libc): add upstream licence notices to ported math and siglist code #12541 has merged)
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed exact head 490bd42d523538b1796a60156b3064d30ba00044. Changes requested for a runtime precision-control mismatch.

[P1] cbrtl_nid_postfix: the console-bit match does not hold under the guest thread’s default x87 precision. The implementation performs its final rounding and Newton step with x87 long double arithmetic, so its result depends on the x87 precision-control field. The PR’s own debt entry says it matches the bundled console code only at 64-bit precision, while Windows guest threads started by _beginthreadex use 53-bit precision (0x027f). This leaves the newly implemented export returning different bits on the normal Windows guest-thread state; the current known-answer tests only exercise the 64-bit state and therefore miss that case. Please make the result match the console independently of the caller’s precision mode (while preserving the caller’s floating-point environment as required), and add a regression that starts from 53-bit precision and verifies both the expected result and the restored control word/status. If this limitation is intentional, it should not be presented as a completed console-compatible implementation without an explicit scope decision.

The PR’s reported 20-million-input native comparison is useful, but it is explicitly at 64-bit precision; the hosted product jobs are skipped by path policy, and the relinker/ASan checks are still running at review time.

@github-actions

github-actions Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

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.

Pull request Shared files not compared
PR 5021 docs/dev/debt/libc.md
PR 5303 docs/dev/debt/libc.md
PR 6295 core/libs/prx/libc/src/Math.cpp
core/libs/tests/GuestMath.cpp
PR 6819 docs/dev/debt/libc.md
PR 7081 docs/dev/debt/libc.md
PR 7386 docs/dev/debt/libc.md
PR 7447 docs/dev/debt/libc.md
PR 7715 docs/dev/debt/libc.md
PR 8150 docs/dev/debt/libc.md
PR 8965 docs/dev/debt/libc.md
PR 9340 docs/dev/debt/libc.md
PR 9371 docs/dev/debt/libc.md
PR 9447 docs/dev/debt/libc.md
PR 9526 docs/dev/debt/libc.md
PR 9929 docs/dev/debt/libc.md
PR 10158 docs/dev/debt/libc.md
PR 10165 docs/dev/debt/libc.md
PR 10200 docs/dev/debt/libc.md
PR 10405 docs/dev/debt/libc.md
PR 10780 docs/dev/debt/libc.md
PR 10987 docs/dev/debt/libc.md
PR 11332 docs/dev/debt/libc.md
PR 11621 docs/dev/debt/libc.md
PR 11664 docs/dev/debt/libc.md
PR 11724 docs/dev/debt/libc.md
PR 11726 docs/dev/debt/libc.md
PR 11831 docs/dev/debt/libc.md
PR 12053 core/libs/prx/libc/src/Math.cpp
core/libs/tests/GuestMath.cpp
docs/dev/debt/libc.md
PR 12397 docs/dev/debt/libc.md
PR 12510 docs/dev/debt/libc.md
PR 12511 docs/dev/debt/libc.md
PR 12514 docs/dev/debt/libc.md
PR 12518 docs/dev/debt/libc.md
PR 12574 docs/dev/debt/libc.md
PR 12594 docs/dev/debt/libc.md
PR 12598 docs/dev/debt/libc.md
PR 12622 docs/dev/debt/libc.md
PR 12627 docs/dev/debt/libc.md
PR 12704 docs/dev/debt/libc.md
PR 13449 docs/dev/debt/libc.md
PR 13486 core/libs/prx/libc/src/Math.cpp
docs/dev/debt/libc.md
PR 13793 docs/dev/debt/libc.md
PR 13794 docs/dev/debt/libc.md
PR 13804 docs/dev/debt/libc.md
PR 13809 docs/dev/debt/libc.md
PR 14212 docs/dev/debt/libc.md
PR 14235 docs/dev/debt/libc.md
PR 14588 docs/dev/debt/libc.md

@github-actions github-actions Bot added libc docs needs rebase Conflicts with main, rebase needed labels Oct 27, 2026
@AlexFigas
AlexFigas force-pushed the fix/libc-cbrtl-msun-ld80 branch 2 times, most recently from 940015a to a180cc0 Compare October 27, 2026 10:14
@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Oct 27, 2026
@AlexFigas

Copy link
Copy Markdown
Contributor Author

@MarcZX10 The console's cbrtl does not fix the precision either. The binary (0x42360–0x4250b) has no fldcw, fnstcw or fldenv, because msun's ENTERI and RETURNI switch to 64 bits only on i386 (math_private.h). It computes at the caller's precision, so forcing 64 bits would differ from the console whenever a title lowers the precision itself. This PR now matches the binary at every precision instead (a180cc0):

  • The port had folded 2^32 + 2^-31 at compile time, where the binary adds msun's volatile vd2 and vd1 at run time. That changed 105 of 2,000,000 results at 53 bits. It now reads them through volatile.
  • Against the binary, 20,000,000 encodings at 64, 53 and 24 bits, each under all four rounding modes, give the same result, errno and flags, and the control word is unchanged after every call.
  • CheckCbrtlConsoleBits sets the control word itself: 17 cases at 0x037f and 8 at 0x027f. Each requires the binary's result and its x87 and SSE flags, the same control word afterwards, and errno unchanged. With the folded constant it fails at 53 bits.

The precision a guest thread starts with is a libkernel matter. #11849 starts created guest threads at 0x037f, FreeBSD 11's start state. The initial thread still keeps the host's control word (0x027f on Windows); like MXCSR in #7594, that belongs in the entry stub.

@oneandonlydean oneandonlydean self-assigned this Oct 27, 2026
@AlexFigas
AlexFigas requested a review from MarcZX10 October 27, 2026 10:37

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reviewed the exact head a180cc0. The port follows the stated FreeBSD msun sequence, and the committed known-answer cases exercise positive/negative values, subnormals, non-canonical encodings, infinities, NaNs, and both 64-bit and 53-bit precision. I found no specific arithmetic defect in this pass.

Independent local check: I built the exact guest_math_tests target on Linux with the repository-pinned dependencies and ran it natively; it exited 0. The host cannot run the full product suite because it lacks AVX2/FMA. The hosted Windows check and Ubuntu/Windows relinker plus ASan checks pass; macOS compiler, register-context Debug, and one write-watch job are still queued, while the full Linux product job is skipped by path policy. I am leaving this as a comment review until those macOS jobs finish and the required platform coverage is complete.

@maskym

maskym commented Oct 27, 2026

Copy link
Copy Markdown
Contributor

Windows result for head 77d43c5de5, merged into main 75f3702aed (the PR's Tested section names no Windows run).

Host: Windows 11 26300, Intel i7-12700K, WinLibs GCC 15.2.0 (x86_64-ucrt-posix-seh, r6), Release, BUILD_TESTING=ON, Ninja. long double is the 80-bit x87 type on this toolchain, as on the console.

The tree also carried the open libc PRs #11270, #11283, #11634, all merged cleanly, so the run is a joint one; the test of this PR is guest_math. ctest --test-dir build -R "^(guest_math|guest_math_exact|guest_dinkumware_internals)$": 3/3 passed, guest_math in 0.05 s. An earlier head of this PR passed the same test on main 1089f2bbfd together with #11260, #11262, #11266, #11278 and #10929. Build clean. Not run on a PS5.

AI-assisted: yes (Claude Code), the runs and the numbers above are from this machine.

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reviewed the exact head a180cc0. The port follows the stated FreeBSD msun sequence, and the committed known-answer cases exercise positive/negative values, subnormals, non-canonical encodings, infinities, NaNs, and both 64-bit and 53-bit precision. I found no specific arithmetic defect in this pass.

Independent local check: I built the exact guest_math_tests target on Linux with the repository-pinned dependencies and ran it natively; it exited 0. The host cannot run the full product suite because it lacks AVX2/FMA. The hosted Windows check and Ubuntu/Windows relinker plus ASan checks pass; macOS compiler, register-context Debug, and one write-watch job are still queued, while the full Linux product job is skipped by path policy. I am leaving this as a comment review until those macOS jobs finish and the required platform coverage is complete.

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The arithmetic review did not find a defect in the cbrtl port. I also built and ran guest_math and guest_math_exact three times each using the PR's changed Math.cpp and GuestMath.cpp applied to a clean build based on this PR's original base; the tests passed. The combined build also contained unrelated #11213 exception changes, so this is focused local evidence rather than a build of this exact commit.

I cannot approve the current branch because its contribution/landing coordination is incomplete. A merge preview of the current #11632 and #11849 heads conflicts in docs/dev/debt/libc.md. #11849 narrows the asinl debt entry; this PR reorganizes the same long-double math section to document cbrtl. The PR overlap workflow currently reported only #11634, and this PR's checklist says “Depends on: none,” so the #11849 overlap and landing order are not declared. CONTRIBUTING.md asks authors to agree which overlapping PR goes first and declare that dependency.

Please coordinate the order with #11849 and update the dependency/overlap information, then rebase or otherwise show a clean merge preview against the agreed order. This request concerns the documented debt-file conflict and landing sequence; it is not a request to change the reviewed arithmetic.

@JJenkx

JJenkx commented Oct 27, 2026

Copy link
Copy Markdown
Contributor

A runtime differential of this head against the libc.prx that titles ship.

Setup:

  • A scratch loader runs the decrypted libc.prx of PPSA07923 and PPSA05916 natively on Windows 11 and calls their cbrtl by NID. Neither copy is an FMA build.
  • It compares them with cbrtl from the libc.prx DLL built from this PR's exact head 77d43c5de5 (WinLibs GCC 15.2.0 UCRT r7, Release). guest_math passes on that build.
  • There are 100,000 arguments per title, evenly spread over ±20,000 in steps of 0.001. Each call compares the full 80-bit result.

Results:

  • Current main differs from the titles on 11540 of the 100,000.
  • This PR differs on none, on both titles.

Only finite arguments in that range were covered: no NaNs, infinities, subnormals or arguments of large magnitude.

AI-assisted: yes (Claude Code).

@AlexFigas

Copy link
Copy Markdown
Contributor Author

@MarcZX10 Order: #11632, then #11634, then #11849, which also waits for #10253. #11849 now declares Depends on: #10253, #11632, #11634, and both bodies' Overlap sections say so. This PR stays Depends on: none.

Merge preview in that order:

I'll rebase #11849 once these land.

@AlexFigas
AlexFigas requested a review from MarcZX10 October 27, 2026 18:07

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I re-reviewed exact head 77d43c5 after the overlap follow-up. The landing order is now explicit: #11632, then #11634, then #11849; #11849 declares both math PRs as dependencies, and the author documented the one debt-file conflict and how to preserve both entries. This satisfies the repository's overlap-order requirement. The current-main merge preview for this PR is clean.

The focused guest_math build and repeated tests passed in my earlier review. The hosted checks on this head are green apart from the Linux product job being skipped; the author also supplied Windows and binary-comparison evidence. I found no implementation defect in the reviewed cbrtl path. Approved; retain the declared #11077 dependency and the stated landing order.

@AlexFigas

Copy link
Copy Markdown
Contributor Author

@oneandonlydean @MarcZX10 Moved in 3688e03. The s_cbrtl.c block is unchanged and now opens Math.cpp, above the first #include, after a /* Derived from FreeBSD lib/msun/src/s_cbrtl.c (release/11.4.0) */ line in #12541's form. Nothing is left above cbrtl, and git diff --check passes. #11634 moves e_hypotl.c's block below it the same way.

The head is rebased onto main 1b580f1, and it merges cleanly with current main 1d8fd64. On this head guest_math passes 3 runs, and the cbrtl sweeps against the bundled libc.prx are clean in all 12 rounding-mode and precision combinations (20M arguments each).

#12541 inserts its notices at the same place, so the two conflict there; I asked on #12541 which should land first.

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-checked — changes requested

The source notice is now placed in the requested form, and the update reports three guest_math runs plus the bundled-libc comparison. That resolves the prior notice-placement finding. However, the branch is based on 1b580f13cf, while current main is ba5b5330b3; current main has changed Math.cpp, GuestMath.cpp and the libc debt file touched by this PR. Please integrate current main and rerun the focused math tests and cbrtl comparison on the resulting exact head. The reported earlier-head results do not cover these intervening code/test changes.

@AlexFigas

Copy link
Copy Markdown
Contributor Author

@MarcZX10 Merged main 98ddd9c, which is still current main: head 554c60b. On this head guest_math passes 3 runs, and the 12 cbrtl sweeps against the bundled libc.prx are clean (20M arguments each).

@AlexFigas
AlexFigas requested a review from MarcZX10 October 30, 2026 09:49

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-checked — changes requested

Reviewed exact head 554c60b29f5bd03b9b4cee33a653f9960bcd0b91; the remaining blocker is the maintainer-directed landing order with #12541, which is not reflected in this PR's checklist.

What I ran

The PR base is 98ddd9c1792bbab016ceed5db267a93d1d61f00a; current main is 07253ec3794121657a8d9a2229a6224651b0c8f5. The head merges cleanly into current main. Local no-build checks ran on Linux (Debian, Python 3.11.2, GCC 12.2.0); I did not configure or build.

python3 tools/pr_precheck.py --repo boykopovar/AnyPS5 --pr 11632
git diff --check 98ddd9c1792bbab016ceed5db267a93d1d61f00a...554c60b29f5bd03b9b4cee33a653f9960bcd0b91
git merge-tree --write-tree refs/remotes/upstream/main 554c60b29f5bd03b9b4cee33a653f9960bcd0b91

Results

Check Result
Diff check Passed; no whitespace errors.
Conventions Passed with a non-failing debt-length warning on docs/dev/debt/libc.md.
Current-main merge preview Clean despite a current-main change to docs/dev/debt/libc.md.
Hosted CI on this head Relinker and register-context jobs passed; Windows passed; Linux product tests were skipped; two macOS write-watch jobs failed.
guest_math and bundled-libc comparison The author reports three exact-head test runs and 240 million cbrtl comparisons across precisions/rounding modes; I did not independently run them.
Precheck tooling Overall precheck reported failure because the isolated checkout lacks the local ABI/test-quality helper scripts, and its stack parser reports a cycle inconsistent with the live checklist dependencies. The actual declared order is #11632 → #11634.
Selected unedited output
docs/dev/debt/libc.md:158: warning: [debt-length] Technical debt entry over 1000 characters: state the gap first (what differs from the console, what is unverified, what throws) and keep only the behaviour it needs: 1439 characters
1 findings, 0 errors; GitHub shows at most 10 error annotations, the job summary lists all
fb48b8585bbbe74cee5f8582fcc5fca3e07b86b3
- PR #11632: Declared dependency cycle involving PRs [11632, 11634]

Findings

Blocking

The current checklist says Depends on: none, but maintainer direction on #12541 is to land #12541 first and declare Depends on: #12541 on both #11632 and #11634. This PR's FreeBSD license notice shares the top-of-file insertion point with #12541, so the order needs to be recorded before approval. Please update this checklist now; after #12541 merges, rebase this PR onto current main, preserve both notice blocks, and obtain fresh CI.

Non-blocking

The conventions check warns that the modified libc debt entry is 1,439 characters, above its 1,000-character guidance. It is not a conventions error and does not block this review request.

Sources

Not verified

I did not build or run guest_math or the bundled-library comparison locally. The author-reported math runs are on the exact PR head; the physical console was not tested. CI statuses above are from the exact-head snapshot and may change after this review.

To get this to a good state

Update the checklist to Depends on: #12541. Once #12541 merges, rebase this PR onto current main, keep both license blocks at the top of Math.cpp, and rerun fresh CI plus the focused math validation. I will rerun the same available no-build checks and inspect the new head before reviewing again.

@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Oct 30, 2026
# Conflicts:
#	core/libs/prx/libc/src/Math.cpp
@AlexFigas

Copy link
Copy Markdown
Contributor Author

@oneandonlydean @MarcZX10 #12541 has merged, so I merged main da026c7 into the branch: head 9d91493. #12541's notices stay unchanged at the top of Math.cpp, and this PR's s_cbrtl.c block follows them, before the first #include. git diff --check passes, and the checklist records Depends on: none (#12541 has merged).

On this head guest_math passes 3 runs, and the 12 cbrtl sweeps against the bundled libc.prx are clean (20M arguments each).

@AlexFigas
AlexFigas requested a review from MarcZX10 October 30, 2026 13:55

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-checked — new head, changes requested

The #12541 landing-order finding is resolved and the current-main merge preview is clean, but this branch still does not include current main as required by the repository rules.

What I ran

Reviewed head 9d91493c28768bfaa7e63d5eb6c92263835139f7 against PR base da026c70655a132031d45e2008c24f993870d801 on Debian 12 x86_64, Python 3.11.2, GCC 12.2.0. Current main is ed1e0ed08fc2452192df91793a33dd0cc7ad5212; merging the head into it previews cleanly.

python3 tools/pr_precheck.py --repo boykopovar/AnyPS5 --pr 11632
git diff --check refs/remotes/upstream/main...9d91493c28768bfaa7e63d5eb6c92263835139f7
git merge-tree --write-tree refs/remotes/upstream/main 9d91493c28768bfaa7e63d5eb6c92263835139f7
gh pr checks 11632 --repo boykopovar/AnyPS5

Results

Check Result
Conventions Hosted check passed.
Merge preview Clean onto current main; preview tree 680dae1c5824ce047dab5e6d1300bec736d969e6.
Diff check Reports trailing whitespace in the verbatim Sun Microsystems notice at Math.cpp:61; the hosted conventions check passes.
Math validation The author reports three guest_math runs on this head and 240 million comparisons across precision/rounding combinations; I did not independently run them.
Hosted CI Ubuntu and Windows relinker, Ubuntu register-context, Windows, ASan, conventions, eligibility, library-portability, labels and report passed. Linux product tests were skipped; macOS relinker, register-context and write-watch jobs remain queued.
Precheck helpers ABI audit and test-quality scripts are absent from the isolated PR checkout; the stack checker reports a false-positive dependency cycle despite the live checklist/order being #11632 → #11634.
Selected unedited output
core/libs/prx/libc/src/Math.cpp:61: trailing whitespace.
+ * software is freely granted, provided that this notice 
680dae1c5824ce047dab5e6d1300bec736d969e6
relinker (ubuntu-latest, g++)	pass
relinker (windows-latest, g++)	pass
relinker (macos-latest, clang++)	pending
register-context (ubuntu-latest, Debug)	pass
register-context (macos-15-intel, Debug)	pending
write-watch (macos-15-intel)	pending
linux	skipping
windows	pass

Negative control

Not independently exercised. The author reports CheckCbrtlConsoleBits detects the prior folded-constant regression; I did not build or run the exact-head binary.

Findings

Blocking

The head contains main only through da026c70655a132031d45e2008c24f993870d801, while current main is ed1e0ed08fc2452192df91793a33dd0cc7ad5212. CONTRIBUTING.md requires keeping branches up to date. The changed paths have no later-main edits and the merge preview is clean, but this branch remains behind. Please merge current main into this PR and rerun the focused math tests on the resulting head.

Non-blocking

The copied upstream license notice has one trailing space; the hosted conventions check passes. The precheck's stack-cycle result is inconsistent with the actual checklist and clean dependency preview. MacOS hosted jobs are still pending, and the author-reported comparison runs are not independent verification.

Sources

Not verified

No local build or CTest run; no PS5-console run. The hosted macOS jobs remain queued.

To get this to a good state

Merge current main into #11632, preserve the #11632 → #11634 → #11849 landing order, and rerun the focused math tests on the exact updated head. I will repeat the no-build checks and re-review that head.

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-checked — new head, changes requested

Correction to my preceding review: git diff --check passes for the PR diff against its base; the trailing-space line I reported was from comparing the older reviewed head to the new head. The current-main synchronization finding remains.

What I ran

Reviewed head 9d91493c28768bfaa7e63d5eb6c92263835139f7 against PR base da026c70655a132031d45e2008c24f993870d801 on Debian 12 x86_64, Python 3.11.2, GCC 12.2.0. Current main is ed1e0ed08fc2452192df91793a33dd0cc7ad5212; the merge preview is clean.

git diff --check da026c70655a132031d45e2008c24f993870d801...9d91493c28768bfaa7e63d5eb6c92263835139f7
git merge-tree --write-tree refs/remotes/upstream/main 9d91493c28768bfaa7e63d5eb6c92263835139f7
gh pr checks 11632 --repo boykopovar/AnyPS5

Results

Check Result
Diff check Passed.
Conventions Hosted check passed.
Merge preview Clean onto current main; preview tree 680dae1c5824ce047dab5e6d1300bec736d969e6.
Math validation The author reports three guest_math runs on this head and 240 million comparisons across precision/rounding combinations; I did not independently run them.
Hosted CI Ubuntu and Windows relinker, Ubuntu register-context, Windows, ASan, conventions, eligibility, library-portability, labels and report passed. Linux product tests were skipped; macOS relinker, register-context and write-watch jobs remain queued.
Precheck helpers ABI audit and test-quality scripts are absent from the isolated PR checkout; the stack checker reports a false-positive dependency cycle despite the live checklist/order being #11632 → #11634.
Selected unedited output
exit=0
680dae1c5824ce047dab5e6d1300bec736d969e6
relinker (ubuntu-latest, g++)	pass
relinker (windows-latest, g++)	pass
relinker (macos-latest, clang++)	pending
register-context (ubuntu-latest, Debug)	pass
register-context (macos-15-intel, Debug)	pending
write-watch (macos-15-intel)	pending
linux	skipping
windows	pass

Negative control

Not independently exercised. The author reports CheckCbrtlConsoleBits detects the prior folded-constant regression; I did not build or run the exact-head binary.

Findings

Blocking

The head contains main only through da026c70655a132031d45e2008c24f993870d801, while current main is ed1e0ed08fc2452192df91793a33dd0cc7ad5212. CONTRIBUTING.md requires keeping branches up to date. The changed paths have no later-main edits and the merge preview is clean, but this branch remains behind. Please merge current main into this PR and rerun the focused math tests on the resulting head.

Non-blocking

The precheck's stack-cycle result is inconsistent with the actual checklist and clean dependency preview. MacOS hosted jobs are still pending, and the author-reported comparison runs are not independent verification.

Sources

Not verified

No local build or CTest run; no PS5-console run. The hosted macOS jobs remain queued.

To get this to a good state

Merge current main into #11632, preserve the #11632 → #11634 → #11849 landing order, and rerun the focused math tests on the exact updated head. I will repeat the no-build checks and re-review that head.

@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Oct 30, 2026
@AlexFigas

Copy link
Copy Markdown
Contributor Author

@MarcZX10 Merged main 8a4fc62: head 02c5868. main changed GuestMath.cpp since the previous head, and the merge is clean. On this head guest_math and guest_math_exact pass 3 runs each, and the 12 console-differential sweeps of cbrtl (20,000,000 encodings at 64, 53 and 24 bits under each rounding mode) show no difference in result, NaN bits, errno, flags or control word. check_conventions.py has no errors, and each of the uncomparable overlapping PRs gives the same git merge-tree conflicts with this head as with main, except the formatting change #14212. #11634 is refreshed on this head; the order stays #11632 → #11634 → #11849.

@AlexFigas
AlexFigas requested a review from MarcZX10 November 1, 2026 00:59

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-checked — new head, looks good

I found no new blocking issue at head 02c58684e5413be99fbbd9d635c86927db187b9c; the current-main merge preview is clean and the Windows workflow passed.

What I ran

Reviewed head 02c58684e5413be99fbbd9d635c86927db187b9c against base 8a4fc62318a4b73b6895bf20a024c625efeb7c3b on Debian 12 x86_64, Python 3.11.2 and GCC 12.2.0. The preview onto current main (7c4dcf0ad84de7a473ce97bb21644c614f1c3bd3) merged cleanly.

python3 tools/pr_precheck.py --repo boykopovar/AnyPS5 --pr 11632
git diff --check 8a4fc62318a4b73b6895bf20a024c625efeb7c3b...02c58684e5413be99fbbd9d635c86927db187b9c
git merge-tree --write-tree upstream/main refs/anyps5/review/11632
git log --oneline 8a4fc62318a4b73b6895bf20a024c625efeb7c3b..upstream/main -- core/libs/prx/libc/src/Math.cpp core/libs/tests/GuestMath.cpp docs/dev/debt/libc.md
gh pr checks 11632 --repo boykopovar/AnyPS5

Results

Check Result
Diff and current-main preview Passed; preview tree 8713d650d8b51e7fa0af9b0f204a4588a45db36f. No newer main commits touch the changed math, test, or debt paths.
Conventions Hosted check passed. The local precheck also reported a non-blocking debt-entry-length warning.
Hosted CI Windows, Linux/macOS relinker, ASan, and register-context jobs passed. Linux product tests were skipped. Two macOS write-watch jobs failed during CMake configuration because that test project registers duplicate names; the failure is outside this PR's changed paths.
Focused math validation The author reports guest_math and guest_math_exact passing three runs each, plus 12 console-differential cbrtl sweeps of 20 million encodings per sweep across x87 precisions and rounding modes. I did not run these locally.
Precheck tooling The isolated checkout lacks the local-only ABI and test-quality helper scripts; its stack checker reverses the dependency direction. I independently confirmed the declared dependency state and clean preview.
Selected unedited output
8713d650d8b51e7fa0af9b0f204a4588a45db36f
write-watch (macos-15)	fail	42s	https://github.com/boykopovar/AnyPS5/actions/runs/41256620235/job/124701723596
write-watch (macos-15-intel)	fail	51s	https://github.com/boykopovar/AnyPS5/actions/runs/41256620235/job/124701723534
windows	pass	10m12s	https://github.com/boykopovar/AnyPS5/actions/runs/41256620235/job/124701723647
linux	skipping	0	https://github.com/boykopovar/AnyPS5/actions/runs/41256620235/job/124701724802
CMake Error at CMakeLists.txt:42 (add_test):
  add_test given test NAME "write_watch_execute-fault" which already exists
CMake Error at CMakeLists.txt:42 (add_test):
  add_test given test NAME "write_watch_read-fault" which already exists

Sources

Not verified

No local C++ build or CTest run, no Linux product test, and no physical-console run. The extensive console-differential results above are author-reported, not independently reproduced.

@AlexFigas

Copy link
Copy Markdown
Contributor Author

@MarcZX10 Head 5ab9b29 merges current main e0caf13 into the approved 02c5868; the merge is clean. main changed Math.cpp, GuestMath.cpp and the debt file since the approved head (#9867's tanhf and others), and it now has the write-watch fix (#13220), so the macOS jobs can run again. On this head guest_math and guest_math_exact pass 3 runs each, the 12 console-differential sweeps of cbrtl (20,000,000 encodings at 64, 53 and 24 bits under each rounding mode) show no difference, and git diff --check is clean. #11634 is refreshed on this head; the order stays #11632 → #11634 → #11849.

@AlexFigas

Copy link
Copy Markdown
Contributor Author

@MarcZX10 Head b2a99b1 merges current main a4eca2a into the approved branch. The one conflict was in docs/dev/debt/libc.md: main has #11849's shorter asinl entry and still lists cbrtl as host-computed, so I kept main's asinl, dropped cbrtl from the list and kept this PR's cbrtl entry. On this head guest_math and guest_math_exact pass 3 runs each, and the 12 console-differential sweeps of cbrtl (20,000,000 encodings at 64, 53 and 24 bits under each rounding mode) show no difference in result, NaN bits, errno, flags or control word. git diff --check and check_conventions.py pass with 0 errors (the one length warning is the host-computed entry, 1446 characters on main, 1439 here). #11849 landed first, so the description no longer lists it as waiting. #11634 is refreshed on this head.

@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Nov 2, 2026
@AlexFigas AlexFigas closed this Nov 2, 2026
@AlexFigas AlexFigas reopened this Nov 2, 2026
@oneandonlydean
oneandonlydean merged commit cecb4b2 into boykopovar:main Nov 4, 2026
41 of 43 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants