Skip to content

Joltphysics/5.6.0 - #30778

Open
sunbubble wants to merge 3 commits into
conan-io:masterfrom
sunbubble:joltphysics/5.6.0-simd
Open

Joltphysics/5.6.0#30778
sunbubble wants to merge 3 commits into
conan-io:masterfrom
sunbubble:joltphysics/5.6.0-simd

Conversation

@sunbubble

@sunbubble sunbubble commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Changes to recipe: joltphysics/5.6.0

Motivation

Two bugs in the existing recipe plus a new version:

  1. package_info() always exported JPH_USE_AVX2 and friends regardless of the actual build. These defines affect ABI (e.g. DVec3 uses __m256d under JPH_USE_AVX), so consumers and the library could silently disagree on struct layout.
  2. Jolt's EMIT_X86_INSTRUCTION_SET_DEFINITIONS() in its CMake is guarded on CMAKE_VS_PLATFORM_NAME, so under Ninja the library is compiled without the JPH_USE_* defines at all. The recipe worked around this by always hardcoding AVX2-level defines, but that left non-MSVC/non-Ninja generators and non-x86_64 builds broken.

Details

  • New version 5.6.0
  • Revamp and expose existing CMake options in conan recipe:
    • New simd option for x86 architectures (sse2 | sse41 | sse42 | avx | avx2 | avx512, default avx2 to match Jolt's own CMake defaults).
    • New options mapping the remaining Jolt CMake knobs: double_precision, object_layer_bits (16/32), cross_platform_deterministic, object_stream, enable_asserts, custom_allocator, use_std_vector, cpu_compute (requires ≥ 5.6.0), floating_point_exceptions (MSVC only).
    • Fixed generate(): injects JPH_USE_* preprocessor definitions and ISA compiler flags (-mavx2 / /arch:AVX2 etc.) directly, bypassing the generator-guarded CMake block. This is the only reliable way to ensure the defines and flags are present under Ninja.
    • Fixed package_info(): all JPH_USE_* defines and ISA cxxflags now track the selected simd option. Also propagates ISA flags to consumers so TUs including Jolt's SIMD-guarded headers compile correctly.
    • Fixed JPH_FLOATING_POINT_EXCEPTIONS_ENABLED: was unconditionally exported; now only emitted when it was actually compiled in (MSVC + Debug or Release build type, matching Jolt's cmake logic).
    • Disabled GPU compute backends (DX12, Vulkan, Metal) explicitly since they require optional external SDKs.

  • Read the contributing guidelines
  • Checked that this PR is not a duplicate: list of PRs by recipe
  • If this is a bug fix, please link related issue or provide bug details
  • Tested locally with at least one configuration using a recent version of Conan

@CLAassistant

CLAassistant commented Aug 12, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

sunbubble and others added 3 commits August 12, 2026 12:55
Register it in config.yml; also disable the GPU compute backends
(JPH_USE_DX12/VK/MTL/CPU_COMPUTE) introduced in 5.6.0 that default to
ON but require optional SDKs not managed by this recipe.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add a simd option (sse2/sse41/sse42/avx/avx2/avx512, default avx2,
matching Jolt's own CMake defaults) so the SIMD baseline is part of the
package identity and can be lowered by a consumer that cannot require
AVX2 at runtime, or that cannot afford the ABI consequences of the flags
this recipe propagates.

Wire the corresponding USE_* CMake variables so the compiled library
matches the selected level, and propagate matching cxxflags and defines
in package_info so consumer TUs that include Jolt's SIMD-guarded headers
compile correctly without extra profile configuration.

Set the JPH_USE_* defines and the ISA compiler flags from the toolchain
as well. Jolt emits both from a CMake branch guarded on
CMAKE_VS_PLATFORM_NAME, which is empty for every generator other than
Visual Studio, so under Ninja the library was compiled without them
while package_info() still exported them to consumers. JPH_USE_AVX
changes the layout of DVec3 and is not part of JPH_VERSION_ID, so
RegisterTypes() cannot catch that mismatch and it corrupts silently.
Setting them here makes them follow the selected option rather than the
generator.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Add Conan options for all user-facing CMake knobs that produce public
defines or affect the compiled ABI:

- double_precision (DOUBLE_PRECISION / JPH_DOUBLE_PRECISION)
- object_layer_bits 16|32 (OBJECT_LAYER_BITS / JPH_OBJECT_LAYER_BITS)
- cross_platform_deterministic (JPH_CROSS_PLATFORM_DETERMINISTIC)
- object_stream (ENABLE_OBJECT_STREAM / JPH_OBJECT_STREAM)
- enable_asserts (USE_ASSERTS / JPH_ENABLE_ASSERTS)
- custom_allocator (DISABLE_CUSTOM_ALLOCATOR / JPH_DISABLE_CUSTOM_ALLOCATOR)
- use_std_vector (USE_STD_VECTOR / JPH_USE_STD_VECTOR)
- cpu_compute (JPH_USE_CPU_COMPUTE)
- floating_point_exceptions (FLOATING_POINT_EXCEPTIONS_ENABLED /
  JPH_FLOATING_POINT_EXCEPTIONS_ENABLED), MSVC only, since that is the
  only toolchain Jolt ever defines it for

Also fix three latent bugs:
- OBJECT_LAYER_BITS was hardcoded to 16 in package_info() but never
  passed to CMake, so the define and the build could silently diverge.
- USE_FMADD and the -mfma consumer flag are now gated on both _has_avx2
  and not cross_platform_deterministic, matching Jolt's own CMake logic.
- JPH_FLOATING_POINT_EXCEPTIONS_ENABLED was exported for every MSVC
  build, but Jolt compiles it into the Debug and Release configurations
  only, so a RelWithDebInfo package exported a define the library was
  not built with. It is one of the JPH_VERSION_ID feature bits and
  RegisterTypesInternal() calls std::abort() on a mismatch, so the
  export now tracks the configuration that was actually compiled.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@sunbubble
sunbubble force-pushed the joltphysics/5.6.0-simd branch from cd6be6e to 9c7e407 Compare August 12, 2026 10:58
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