Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions crates/joltc-sys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,24 @@ double-precision = []
# Changes ObjectLayer and related types to be u32 instead of u16.
object-layer-u32 = []

# Pins JoltPhysics' floating-point flags to the cross-platform-deterministic
# settings JPH gates on its `CROSS_PLATFORM_DETERMINISTIC` CMake variable
# (see JoltPhysics' `Build/CMakeLists.txt` + `Jolt/Jolt.cmake`):
# - 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
#
# Required for cross-platform-deterministic builds (P2P-deterministic netcode,
# rollback-replayable simulation). Without this feature, the C++ build picks
# the platform default — most acutely problematic on Windows MSVC where
# `/fp:fast` is the default, producing non-deterministic floating point even
# at the same git SHA on the same machine when toolchain settings differ.
#
# Default-off; ~10% perf cost (FMA disabled, more conservative FP rules).
# Mirrors the `enhanced-determinism` cargo feature shape on rapier3d.
cross-platform-deterministic = []

[dependencies]

[build-dependencies]
Expand Down
11 changes: 11 additions & 0 deletions crates/joltc-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,17 @@ fn build_joltc() {
config.define("USE_ASSERTS", "ON");
}

// Pin JoltPhysics' floating-point flags to the cross-platform-
// deterministic settings JPH gates on the same-named CMake var
// (see Build/CMakeLists.txt + Jolt/Jolt.cmake). MSVC swaps
// /fp:fast → /fp:precise; Clang ≥14 adds -ffp-contract=off; x86
// disables FMADD. Required for cross-platform-deterministic
// builds (P2P-deterministic netcode, rollback-replayable sims).
// ~10% perf cost; mirrors rapier3d's `enhanced-determinism`.
if cfg!(feature = "cross-platform-deterministic") {
config.define("CROSS_PLATFORM_DETERMINISTIC", "ON");
}

let mut dst = config.build();

// Jolt and JoltC put libraries in the 'lib' subfolder. This goes against
Expand Down