Repository navigation
feat(libc): keep the guest's x87 long double exactly in lifted builds - #12
Open
oberonlift wants to merge 2 commits into
Open
oberonlift wants to merge 2 commits into
oberonlift wants to merge 2 commits into
Conversation
12 tasks done
oberonlift
force-pushed
the
lifted-libc-long-double
branch
from
November 1, 2026 19:35
68aea15 to
2c7c036
Compare
oberonlift
force-pushed
the
lifted-libc-va-list
branch
from
November 1, 2026 19:35
d040a96 to
007ac0e
Compare
oberonlift
force-pushed
the
lifted-libc-long-double
branch
from
November 1, 2026 22:07
2c7c036 to
b7eea78
Compare
oberonlift
force-pushed
the
lifted-libc-va-list
branch
2 times, most recently
from
November 2, 2026 17:02
18527d4 to
c8cd394
Compare
oberonlift
force-pushed
the
lifted-libc-long-double
branch
from
November 2, 2026 17:02
b7eea78 to
2c34c7a
Compare
oberonlift
force-pushed
the
lifted-libc-va-list
branch
from
November 2, 2026 18:30
c8cd394 to
a7df5d7
Compare
oberonlift
force-pushed
the
lifted-libc-long-double
branch
3 times, most recently
from
November 3, 2026 16:34
84e7323 to
e405a49
Compare
oberonlift
force-pushed
the
lifted-libc-va-list
branch
from
November 3, 2026 16:34
24d0f1d to
ca2b1c4
Compare
Owner
Author
Review findings (unverified)Code review of
|
oberonlift
force-pushed
the
lifted-libc-va-list
branch
from
November 4, 2026 15:40
ca2b1c4 to
9ec5a9d
Compare
oberonlift
force-pushed
the
lifted-libc-long-double
branch
2 times, most recently
from
November 4, 2026 16:20
3e77693 to
c9c7bc4
Compare
oberonlift
force-pushed
the
lifted-libc-va-list
branch
from
November 4, 2026 16:20
9ec5a9d to
63dc196
Compare
12 tasks done
oberonlift
force-pushed
the
lifted-libc-va-list
branch
from
November 4, 2026 17:17
63dc196 to
48afcc4
Compare
oberonlift
force-pushed
the
lifted-libc-long-double
branch
from
November 4, 2026 17:17
c9c7bc4 to
093bf45
Compare
oberonlift
force-pushed
the
lifted-libc-va-list
branch
from
November 4, 2026 20:18
48afcc4 to
9cc882f
Compare
oberonlift
force-pushed
the
lifted-libc-long-double
branch
2 times, most recently
from
November 5, 2026 01:21
524b8de to
3bf0e50
Compare
oberonlift
force-pushed
the
lifted-libc-va-list
branch
from
November 5, 2026 01:21
9cc882f to
3b28a4c
Compare
oberonlift
force-pushed
the
lifted-libc-long-double
branch
from
November 5, 2026 15:34
3bf0e50 to
a68d0af
Compare
oberonlift
force-pushed
the
lifted-libc-va-list
branch
from
November 5, 2026 19:28
5f16ff9 to
915b304
Compare
oberonlift
force-pushed
the
lifted-libc-long-double
branch
from
November 5, 2026 19:28
a68d0af to
3bee83c
Compare
oberonlift
force-pushed
the
lifted-libc-va-list
branch
from
November 6, 2026 00:18
915b304 to
a0fa69d
Compare
oberonlift
force-pushed
the
lifted-libc-long-double
branch
2 times, most recently
from
November 6, 2026 15:35
ccbc82d to
e3c107e
Compare
oberonlift
force-pushed
the
lifted-libc-va-list
branch
from
November 6, 2026 15:35
a0fa69d to
d5241b5
Compare
Add GuestLongDouble to load and store the guest's x87 80-bit values, so the libc can compute with a host long double that is not x87 extended, such as aarch64's binary128, when built for a lifted guest. Formatting, scanning, strtold, modfl, _LDtest and the code that takes 80-bit values apart go through it; strtold parses with round-to-odd so that the final rounding is correct, and long double arguments that host callers pass through a va_list are rounded to the guest's precision. On an x87 host it only copies. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A lifted libc held the guest's x87 long double in the host's long double:
IEEE binary128 on Linux, which holds every 80-bit value but rounds each
step differently, and a plain double on macOS, which holds neither.
Lifted builds now keep it in GuestLongDouble, laid out as the guest stores
it. Its arithmetic, square root, integer rounding and conversions to
double, float and integers run through the ps5lift runtime's x87, so they
round, honour precision control and raise exceptions as the guest's
control and status words say. Comparisons, conversions from integers and
doubles, frexp, scalbn, fmod, remainder, remquo, modf, logb and the
fixed-direction roundings work on the bits. strtold and scanf("%Lf") parse
with exact big-integer arithmetic, correctly rounded in the guest's
rounding mode; the narrow scanner reads the field itself, with the wide
scanner's FloatFit, now shared. printf already formatted the exact digits.
On an x86-64 host with x87 behind the runtime's entry points, the parser
matched glibc's x87 strtold in 58,244 cases across the four rounding
modes, and the bit operations matched x87 libm in 5.6 million.
The transcendental l functions and fmal still compute in the host's
widest type and round the result, which on macOS keeps 53 bits; the debt
entry says so. long double complex results are left out of lifted builds,
where they were never bridged.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
oberonlift
force-pushed
the
lifted-libc-va-list
branch
from
November 6, 2026 17:39
d5241b5 to
f123e03
Compare
oberonlift
force-pushed
the
lifted-libc-long-double
branch
from
November 6, 2026 17:39
e3c107e to
e1e808c
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Open on AnyPS5 as boykopovar#15802; this copy follows it.
ps5lift is a static recompiler for PS5 executables: it lifts a game's x86-64 code to LLVM IR and compiles it ahead of time to aarch64, which runs on Linux against AnyPS5's own libraries with no interpreter or JIT. It runs AnyPS5's PS5-style test programs and a homebrew media player to its home screen; commercial games are not playable yet. Branch
ps5lift-previewmerges all of its PRs (how to try it); native Apple Silicon support is coming along fast. It is a separate approach from the ARM64 compiler in boykopovar#5021; boykopovar#1835 has an introduction.This is 6 of 8 PRs that let AnyPS5's libraries run a lifted program; the lifter itself follows them.
x86-64: behaviour unchanged. There
GuestLongDoubleislong doubleand its helpers are the standard functions, sostrtoldis stillstd::strtold;ldexplandscalbnlnow callstd::scalblnanddremcallsstd::remquo, which return the same values.What
A lifted libc held the guest's x87
long doublein the host's: IEEE binary128 on aarch64 Linux, which holds every 80-bit value but rounds each step differently, and a plain double on macOS, which holds neither.GuestLongDoubleloads and stores the guest's 80-bit values where libc takes them in and hands them out (formatting, scanning,strtold,modfl,_LDtest), and long doubles that host callers pass through ava_listare rounded to the guest's precision. On an x87 host it only copies.GuestLongDouble, laid out as the guest stores it. Arithmetic, square root, integer rounding and conversions to double, float and integers run through the ps5lift runtime's x87, so they round, honour precision control and raise exceptions as the guest's control and status words say. Comparisons, conversions from integers and doubles,frexp,scalbn,fmod,remainder,remquo,modf,logband the fixed-direction roundings work on the bits; a NaN operand or a domain error infmod,remainderandremquogoes through the x87, so the NaN propagates or invalid is raised as on the guest._LDint,_LDscale,_LDunscale,_LFpcompand_LPolyhelpers takeGuestLongDoubletoo; in lifted builds_LDscaleand_LDunscalescale and split the value on its bits.strtoldandscanf("%Lf")parse with exact big-integer arithmetic, correctly rounded in the guest's rounding mode.long doublewherever it is wider than 80 bits too, such as Emscripten's wasm64 target: therestrtoldis still the host's.cbrtlruns FreeBSD's x87 algorithm, as onmain, onGuestLongDouble, and in lifted buildsremainder,remainderf,remquoandremquoftake their result and quotient bits from its exact remainder instead offprem1.lfunctions andfmalstill compute in the host's widest type and round the result. The libc debt notes say so, and record that lifted builds don't build__mulxc3and__divxc3and that long double scans store the guest's format for host callers too.boykopovar#5021 also changes some of the same files:
Strings.cpp,WindowsFormatting.hpp.Tested
Compiled for x86-64 Linux before and after this PR (GCC 13, same flags): 130 of the 139 objects it reaches are byte-identical. libSceNet's
Export.cppdiffers only in the generated name of a switch table andStrings.cppin an out-of-line copy of the inlinestrtoldwrapper; the other seven are libc's long double, formatting and scanning sources.On a DGX Spark (aarch64 Linux, NVIDIA GB10, LLVM 18), with all eight PRs and ps5lift on top: every library builds for a lifted program, 2,288 of AnyPS5's own tests pass in that build on lavapipe, and ps5lift's 69 tests pass, among them its libc, exceptions, kernel, fiber and module-loading fixtures and upstream's libc test programs.
The conventions check passes on 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)🤖 Generated with Claude Code