Skip to content

Commit ae331be

Browse files
dance858claude
andcommitted
Compile the extension with the engine's explicit Release flags
The _sparsediffengine target was only optimized because CMake's default CMAKE_C_FLAGS_RELEASE happens to be -O3 -DNDEBUG. Pin cmake.build-type to Release in pyproject.toml and give the extension the same per-config target_compile_options block the engine applies to dnlp_diff, so the optimization level no longer depends on toolchain defaults. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CUDtSX6BT4SiDzfPKVZF9C
1 parent adb16be commit ae331be

2 files changed

Lines changed: 19 additions & 0 deletions

File tree

‎CMakeLists.txt‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,24 @@ python3_add_library(_sparsediffengine MODULE
1818
sparsediffpy/_bindings/bindings.c
1919
)
2020

21+
# Match the engine's per-config optimization flags so the extension doesn't rely on
22+
# the toolchain's default CMAKE_C_FLAGS_RELEASE.
23+
if(MSVC)
24+
target_compile_options(_sparsediffengine PRIVATE
25+
$<$<CONFIG:Debug>:/Od /Zi>
26+
$<$<CONFIG:Release>:/O2 /DNDEBUG>
27+
$<$<CONFIG:RelWithDebInfo>:/O2 /Zi /DNDEBUG>
28+
$<$<CONFIG:MinSizeRel>:/Os /DNDEBUG>
29+
)
30+
else()
31+
target_compile_options(_sparsediffengine PRIVATE
32+
$<$<CONFIG:Debug>:-g -O0>
33+
$<$<CONFIG:Release>:-O3 -DNDEBUG>
34+
$<$<CONFIG:RelWithDebInfo>:-O2 -g -DNDEBUG>
35+
$<$<CONFIG:MinSizeRel>:-Os -DNDEBUG>
36+
)
37+
endif()
38+
2139
target_include_directories(_sparsediffengine PRIVATE
2240
${CMAKE_CURRENT_SOURCE_DIR}/SparseDiffEngine/include
2341
${CMAKE_CURRENT_SOURCE_DIR}/SparseDiffEngine/include/atoms

‎pyproject.toml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ content-type = "text/markdown"
1616

1717
[tool.scikit-build]
1818
cmake.version = ">=3.15"
19+
cmake.build-type = "Release"
1920
wheel.packages = ["sparsediffpy"]
2021
# Persistent build dir: avoids scikit-build-core's TemporaryDirectory, whose cleanup
2122
# intermittently fails on Windows CI with WinError 32 (lingering mspdbsrv/AV handle).

0 commit comments

Comments
 (0)