From 0a409817548fca30a14f81edf05fcbe5fd5971a0 Mon Sep 17 00:00:00 2001 From: orzel320 <52106515+orzel320@users.noreply.github.com> Date: Sun, 13 Sep 2026 21:47:49 +0200 Subject: [PATCH 1/7] Restored gcc update to newest version in buildwheels, explicitly build nanobind in CMakeLists --- .github/workflows/buildwheels.yml | 12 ++++++------ README.md | 11 ++++++++++- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/.github/workflows/buildwheels.yml b/.github/workflows/buildwheels.yml index 68169218..b31990de 100644 --- a/.github/workflows/buildwheels.yml +++ b/.github/workflows/buildwheels.yml @@ -54,7 +54,7 @@ jobs: uses: msys2/setup-msys2@v2 with: msystem: MINGW64 - update: false + update: true install: >- mingw-w64-x86_64-gcc-fortran mingw-w64-x86_64-ninja @@ -364,17 +364,17 @@ jobs: - if: matrix.os == 'windows-latest' uses: msys2/setup-msys2@v2 with: - msystem: UCRT64 - update: false + msystem: MINGW64 + update: true install: >- - mingw-w64-ucrt-x86_64-gcc - mingw-w64-ucrt-x86_64-ninja + mingw-w64-x86_64-gcc + mingw-w64-x86_64-ninja m4 - if: matrix.os == 'windows-latest' shell: msys2 {0} run: | - echo "$(cygpath -m /ucrt64/bin)" >> $GITHUB_PATH + echo "$(cygpath -m /mingw64/bin)" >> $GITHUB_PATH echo "$(cygpath -m /usr/bin)" >> $GITHUB_PATH echo "CMAKE_GENERATOR=Ninja" >> $GITHUB_ENV echo "CMAKE_ARGS=-DNC_M4=$(cygpath -m $(which m4))" >> $GITHUB_ENV diff --git a/README.md b/README.md index 2a584c84..5c129362 100644 --- a/README.md +++ b/README.md @@ -259,8 +259,17 @@ set(PyPartMC_DIR "${PYPARTMC_CMAKE_DIR}") find_package(PyPartMC REQUIRED) +execute_process( + COMMAND ${Python_EXECUTABLE} -m nanobind --cmake_dir + OUTPUT_VARIABLE nanobind_ROOT + OUTPUT_STRIP_TRAILING_WHITESPACE +) +list(APPEND CMAKE_PREFIX_PATH "${nanobind_ROOT}") +find_package(nanobind CONFIG REQUIRED) +nanobind_build_library(nanobind-static) + add_executable(my_test test.cpp) -target_link_libraries(my_test PRIVATE PyPartMC::PyPartMC) +target_link_libraries(my_test PRIVATE PyPartMC::PyPartMC nanobind-static) pypartmc_setup_runtime(my_test) add_test(NAME maketest COMMAND my_test) From 7b6b1051e370ad87fba1951b13b2a0f7cc13411b Mon Sep 17 00:00:00 2001 From: orzel320 <52106515+orzel320@users.noreply.github.com> Date: Sun, 13 Sep 2026 23:56:56 +0200 Subject: [PATCH 2/7] Switched back to UCRT64 in readme_cpp compilation --- .github/workflows/buildwheels.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/buildwheels.yml b/.github/workflows/buildwheels.yml index b31990de..09fb4aa7 100644 --- a/.github/workflows/buildwheels.yml +++ b/.github/workflows/buildwheels.yml @@ -364,7 +364,7 @@ jobs: - if: matrix.os == 'windows-latest' uses: msys2/setup-msys2@v2 with: - msystem: MINGW64 + msystem: UCRT64 update: true install: >- mingw-w64-x86_64-gcc @@ -374,7 +374,7 @@ jobs: - if: matrix.os == 'windows-latest' shell: msys2 {0} run: | - echo "$(cygpath -m /mingw64/bin)" >> $GITHUB_PATH + echo "$(cygpath -m /ucrt64/bin)" >> $GITHUB_PATH echo "$(cygpath -m /usr/bin)" >> $GITHUB_PATH echo "CMAKE_GENERATOR=Ninja" >> $GITHUB_ENV echo "CMAKE_ARGS=-DNC_M4=$(cygpath -m $(which m4))" >> $GITHUB_ENV From fcb01ee890b39ad6a2f11f46d19ceca17916e46f Mon Sep 17 00:00:00 2001 From: Sylwester Arabas Date: Fri, 18 Sep 2026 18:38:25 +0200 Subject: [PATCH 3/7] try if removing explicit nanobind linkage from the C++ example is OK Removed nanobind configuration and linking from CMake. --- README.md | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/README.md b/README.md index 5c129362..2a584c84 100644 --- a/README.md +++ b/README.md @@ -259,17 +259,8 @@ set(PyPartMC_DIR "${PYPARTMC_CMAKE_DIR}") find_package(PyPartMC REQUIRED) -execute_process( - COMMAND ${Python_EXECUTABLE} -m nanobind --cmake_dir - OUTPUT_VARIABLE nanobind_ROOT - OUTPUT_STRIP_TRAILING_WHITESPACE -) -list(APPEND CMAKE_PREFIX_PATH "${nanobind_ROOT}") -find_package(nanobind CONFIG REQUIRED) -nanobind_build_library(nanobind-static) - add_executable(my_test test.cpp) -target_link_libraries(my_test PRIVATE PyPartMC::PyPartMC nanobind-static) +target_link_libraries(my_test PRIVATE PyPartMC::PyPartMC) pypartmc_setup_runtime(my_test) add_test(NAME maketest COMMAND my_test) From 423b067cb600cfd1334c2c36c444251214a36e90 Mon Sep 17 00:00:00 2001 From: Sylwester Arabas Date: Sat, 19 Sep 2026 14:09:11 +0200 Subject: [PATCH 4/7] Add NOSTRIP option to nanobind_add_module --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b15456c7..804b2464 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -559,7 +559,7 @@ else() set(PYPARTMC_MODULE_TYPE MODULE) endif() -nanobind_add_module(_PyPartMC ${PYPARTMC_MODULE_TYPE} STABLE_ABI ${PyPartMC_sources}) +nanobind_add_module(_PyPartMC ${PYPARTMC_MODULE_TYPE} STABLE_ABI NOSTRIP ${PyPartMC_sources}) add_dependencies(_PyPartMC partmclib) set(PYPARTMC_INCLUDE_DIRS "${CMAKE_BINARY_DIR}/include;" From 1c4cfa41c9b06a1a5637fd454228faf9c6435bfd Mon Sep 17 00:00:00 2001 From: Sylwester Arabas Date: Sat, 19 Sep 2026 17:34:36 +0200 Subject: [PATCH 5/7] try disabling LTO Adjust nanobind_add_module call and link options for non-Windows. --- CMakeLists.txt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 804b2464..cb2a8355 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -559,7 +559,7 @@ else() set(PYPARTMC_MODULE_TYPE MODULE) endif() -nanobind_add_module(_PyPartMC ${PYPARTMC_MODULE_TYPE} STABLE_ABI NOSTRIP ${PyPartMC_sources}) +nanobind_add_module(_PyPartMC ${PYPARTMC_MODULE_TYPE} STABLE_ABI ${PyPartMC_sources}) add_dependencies(_PyPartMC partmclib) set(PYPARTMC_INCLUDE_DIRS "${CMAKE_BINARY_DIR}/include;" @@ -583,7 +583,9 @@ if (WIN32) target_link_libraries(_PyPartMC PRIVATE -static gcc stdc++ winpthread quadmath -dynamic) endif() if(CMAKE_CXX_COMPILER_ID STREQUAL GNU) - target_link_options(_PyPartMC PRIVATE -flto=auto) + if(NOT WIN32) + target_link_options(_PyPartMC PRIVATE -flto=auto) + endif() endif() ### pedantics ###################################################################################### From 726242b1648f1d466cb33116168e5a7f773e2204 Mon Sep 17 00:00:00 2001 From: Sylwester Arabas Date: Sat, 19 Sep 2026 23:33:16 +0200 Subject: [PATCH 6/7] try using --whole-archive for Windows --- CMakeLists.txt | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index cb2a8355..6443e761 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -581,11 +581,10 @@ if (APPLE) endif() if (WIN32) target_link_libraries(_PyPartMC PRIVATE -static gcc stdc++ winpthread quadmath -dynamic) + target_link_options(_PyPartMC PRIVATE --whole-archive) endif() if(CMAKE_CXX_COMPILER_ID STREQUAL GNU) - if(NOT WIN32) - target_link_options(_PyPartMC PRIVATE -flto=auto) - endif() + target_link_options(_PyPartMC PRIVATE -flto=auto) endif() ### pedantics ###################################################################################### From 9cfbcc76c5cc738e562e4af6f27aca53e216e51a Mon Sep 17 00:00:00 2001 From: Sylwester Arabas Date: Sun, 20 Sep 2026 00:35:59 +0200 Subject: [PATCH 7/7] Fix target link options syntax for Windows --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6443e761..8012fe71 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -581,7 +581,7 @@ if (APPLE) endif() if (WIN32) target_link_libraries(_PyPartMC PRIVATE -static gcc stdc++ winpthread quadmath -dynamic) - target_link_options(_PyPartMC PRIVATE --whole-archive) + target_link_options(_PyPartMC PRIVATE -Wl,--whole-archive) endif() if(CMAKE_CXX_COMPILER_ID STREQUAL GNU) target_link_options(_PyPartMC PRIVATE -flto=auto)