Skip to content

Compile z_bgcheck.c on arm64 macOS with -ffp-contract=off#6584

Open
agamache wants to merge 1 commit into
HarbourMasters:developfrom
agamache:nofpcontract-bgcheck
Open

Compile z_bgcheck.c on arm64 macOS with -ffp-contract=off#6584
agamache wants to merge 1 commit into
HarbourMasters:developfrom
agamache:nofpcontract-bgcheck

Conversation

@agamache
Copy link
Copy Markdown
Contributor

@agamache agamache commented May 1, 2026

When compiling for arm64 and x86_64, compiler optimizations for contracting floating point operations to fused-multiply-add instructions behave differently, producing code that is not IEEE 754 compliant on arm64 macOS. In some specific scenarios, these inconsistencies result in different behavior from the base game, such as not being able to enter Bottom of the Well as adult using a weirdshot.

This pull request adds the compiler flag "-ffp-contract=off" only on arm64 macOS to disable these optimizations in z_bgcheck.c, restoring IEEE 754 compliant behavior for those specific interactions.

Build Artifacts

Copy link
Copy Markdown
Member

@serprex serprex left a comment

Choose a reason for hiding this comment

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

tbh we should apply this to all files in soh/src

@serprex
Copy link
Copy Markdown
Member

serprex commented May 5, 2026

thinking more, we can apply this flag globally
(fast-math things may be useful for audio stuff or interpolation, but doesn't seem critical)

@agamache
Copy link
Copy Markdown
Contributor Author

agamache commented May 5, 2026

I know audio stuttering has been an issue on the macOS version in the past, but I can try running a version with the flag applied globally to get a quick idea of any effects on performance when I get home from work this evening

@serprex
Copy link
Copy Markdown
Member

serprex commented May 5, 2026

mac stuttering was caused by calling sleep with too large a duration

@agamache agamache force-pushed the nofpcontract-bgcheck branch from 1142edf to 8369c56 Compare May 5, 2026 23:36
@agamache
Copy link
Copy Markdown
Contributor Author

agamache commented May 5, 2026

I just tested a build with the flag applied globally in the top-level CMakeLists.txt and didn't observe any performance regressions

@serprex serprex requested a review from Malkierian May 5, 2026 23:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants