joltc-sys: add cross-platform-deterministic cargo feature#15
Open
Solidor777 wants to merge 1 commit into
Open
Conversation
JoltPhysics gates three FP-determinism decisions on the `CROSS_PLATFORM_DETERMINISTIC` CMake variable (Build/CMakeLists.txt:185-198, 226-244 + Jolt/Jolt.cmake:615-678): - MSVC: /fp:fast (default) → /fp:precise - Clang ≥14: + -ffp-contract=off (so mul+add doesn't fold into FMA inside JPH_PRECISE_MATH_OFF blocks) - x86: USE_FMADD AND NOT CROSS_PLATFORM_DETERMINISTIC flips FMADD off joltc-sys's build.rs never plumbed this through, so the C++ build picked the platform default — most acutely problematic on Windows MSVC where /fp:fast meant the same git SHA produced non-deterministic floating-point output across machines / runs / toolchain versions. P2P-deterministic netcode + rollback-replayable simulation can't build on top of joltc-sys without a workaround. Adds a new `cross-platform-deterministic` cargo feature on joltc-sys (default-off; ~10% perf cost) that defines `CROSS_PLATFORM_DETERMINISTIC=ON` during the joltc CMake build. Mirrors the `enhanced-determinism` shape on rapier3d. With the feature on, four-platform CI tests (Win-x64 MSVC + Linux-x64 Clang + macOS-ARM64 Apple Clang + Linux-ARM64 Clang) produce bit-identical output for a fixed scene/step count — verified empirically downstream.
Solidor777
added a commit
to Solidor777/Titan
that referenced
this pull request
May 9, 2026
…ture PR filed 2026-05-09 from Solidor777:cross-platform-deterministic against SecondHalfGames/jolt-rust:main: SecondHalfGames/jolt-rust#15 TODO.md + VENDORING.md updated to reference the PR. When upstream merges, sync our vendored crates/third_party/joltc-sys/ from upstream + drop the TITAN PATCH entry from VENDORING.md "Local patches". Patch shape unchanged from the in-repo version: ~14 lines (Cargo.toml feature entry + build.rs CMake var). Body of the upstream PR references our 4-platform CI sweep (Win-x64 MSVC + Linux-x64 Clang + macOS-ARM64 Apple Clang + Linux-ARM64 Clang) as bit-identical verification of the determinism contract.
Solidor777
added a commit
to Solidor777/Titan
that referenced
this pull request
May 17, 2026
…ture PR filed 2026-05-09 from Solidor777:cross-platform-deterministic against SecondHalfGames/jolt-rust:main: SecondHalfGames/jolt-rust#15 TODO.md + VENDORING.md updated to reference the PR. When upstream merges, sync our vendored crates/third_party/joltc-sys/ from upstream + drop the TITAN PATCH entry from VENDORING.md "Local patches". Patch shape unchanged from the in-repo version: ~14 lines (Cargo.toml feature entry + build.rs CMake var). Body of the upstream PR references our 4-platform CI sweep (Win-x64 MSVC + Linux-x64 Clang + macOS-ARM64 Apple Clang + Linux-ARM64 Clang) as bit-identical verification of the determinism contract.
Solidor777
added a commit
to Solidor777/Titan
that referenced
this pull request
Jun 4, 2026
…ture PR filed 2026-05-09 from Solidor777:cross-platform-deterministic against SecondHalfGames/jolt-rust:main: SecondHalfGames/jolt-rust#15 TODO.md + VENDORING.md updated to reference the PR. When upstream merges, sync our vendored crates/third_party/joltc-sys/ from upstream + drop the TITAN PATCH entry from VENDORING.md "Local patches". Patch shape unchanged from the in-repo version: ~14 lines (Cargo.toml feature entry + build.rs CMake var). Body of the upstream PR references our 4-platform CI sweep (Win-x64 MSVC + Linux-x64 Clang + macOS-ARM64 Apple Clang + Linux-ARM64 Clang) as bit-identical verification of the determinism contract.
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.
JoltPhysics gates three FP-determinism decisions on the
CROSS_PLATFORM_DETERMINISTICCMake variable(
Build/CMakeLists.txt:185-198, 226-244+Jolt/Jolt.cmake:615-678):/fp:fast(default) →/fp:precise+ -ffp-contract=off(so mul+add doesn't fold into FMA insideJPH_PRECISE_MATH_OFFblocks)USE_FMADD AND NOT CROSS_PLATFORM_DETERMINISTICflips FMADD offjoltc-sys'sbuild.rsnever plumbed this through, so the C++ build picked the platform default — most acutely problematic on Windows MSVC where/fp:fastmeant the same git SHA produced non-deterministic floating-point output across machines / runs / toolchain versions. P2P-deterministic netcode and rollback-replayable simulation can't reliably build on top ofjoltc-syswithout a workaround.This PR adds a new
cross-platform-deterministiccargo feature onjoltc-sys(default-off; ~10% perf cost) that definesCROSS_PLATFORM_DETERMINISTIC=ONduring the joltc CMake build. Mirrors theenhanced-determinismshape onrapier3d.Verification
Downstream consumer (
Solidor777/Titan'stools/titan-determinismharness) ran a 4-platform CI sweep with the feature on:All four platforms produced bit-identical output for a fixed scene (5 dynamic bodies + halfspace ground) stepped 60 frames at fixed 1/60s timestep. Determinism contract holds.
Default-off rationale
P2P-deterministic netcode is opt-in (most projects ship server-authoritative or single-player). The ~10% perf cost (FMA disabled, more conservative FP rules) shouldn't be paid by projects that don't need it.