From 408c65d0916fda2c50f291fa952ec7bfeb15fae0 Mon Sep 17 00:00:00 2001 From: kimstik Date: Sat, 19 Sep 2026 08:52:08 +0200 Subject: [PATCH 1/6] Generate on all cores The default of N_PROC follows the machine; -DN_PROC still overrides it. --- CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ea536dcc4..38a0f7471 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,8 +1,9 @@ cmake_minimum_required(VERSION 3.29) project(OCP) +cmake_host_system_information(RESULT N_CORES QUERY NUMBER_OF_LOGICAL_CORES) set(N_PROC - 2 + ${N_CORES} CACHE STRING "Number of processes used for generating code") set(DLL_EXT dll From 2e802285977f09a202e335a32afa62ca350184b3 Mon Sep 17 00:00:00 2001 From: kimstik Date: Sat, 19 Sep 2026 09:34:29 +0200 Subject: [PATCH 2/6] Update pywrap OSX target when generating on another host, symbol lookups by bisection (pandas is no longer used), one preamble parse per process, smaller collections chunks. --- environment.devenv.yml | 1 - pywrap | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/environment.devenv.yml b/environment.devenv.yml index 5c8995b36..c0290ac75 100644 --- a/environment.devenv.yml +++ b/environment.devenv.yml @@ -15,7 +15,6 @@ dependencies: - click - jinja2 - logzero - - pandas - path - pyparsing - schema diff --git a/pywrap b/pywrap index 76a16d0ca..2d61ed23f 160000 --- a/pywrap +++ b/pywrap @@ -1 +1 @@ -Subproject commit 76a16d0ca37aa097b7b86a614c37e91c9374d19f +Subproject commit 2d61ed23f2d7b706ffde44493df37aadafcd7c0b From 65fa47e4ffb3d2420b1850647437670d6fb6ece2 Mon Sep 17 00:00:00 2001 From: kimstik Date: Sat, 19 Sep 2026 12:31:29 +0200 Subject: [PATCH 3/6] Generate the OSX bindings on Linux Same recipe as Windows: the OSX headers come from the SDK the job already downloads, the symbols from the osx-64 occt package (the virtual __osx package has to be declared on a Linux host). The SDK is the sysroot, so that the host's glibc stays out of the include path; the include layout is chosen by PLATFORM, which the native macOS job still sets from the host. The occt version of the symbol dumps is read from environment.devenv.yml, the one place it is pinned; the Windows dump had stayed at 8.0.0, and members new in 8.0.1 were missing from the Windows bindings. --- .github/workflows/bindings.yml | 3 ++- .github/workflows/build-job.yml | 23 ++++++++++++++++++++--- CMakeLists.txt | 2 +- ocp.toml | 2 +- 4 files changed, 24 insertions(+), 6 deletions(-) diff --git a/.github/workflows/bindings.yml b/.github/workflows/bindings.yml index 4c02218d6..b7a803dde 100644 --- a/.github/workflows/bindings.yml +++ b/.github/workflows/bindings.yml @@ -34,7 +34,8 @@ jobs: uses: ./.github/workflows/build-job.yml with: name: OSX - runner_generate: macos-15-intel # Using 13 for x86_64 compatibility or latest as needed + # NB: cross-generating for OSX on Linux + runner_generate: ubuntu-22.04 runner_compile: macos-15-intel platform: OSX secrets: diff --git a/.github/workflows/build-job.yml b/.github/workflows/build-job.yml index a08a314c3..94be077c3 100644 --- a/.github/workflows/build-job.yml +++ b/.github/workflows/build-job.yml @@ -40,11 +40,12 @@ jobs: - uses: ./.github/actions/micromamba - name: SDK install and symlink (Mac) - if: contains(inputs.runner_generate, 'mac') + if: inputs.platform == 'OSX' run: | curl -L -O https://github.com/phracker/MacOSX-SDKs/releases/download/11.3/MacOSX11.3.sdk.tar.xz sudo mkdir -p /opt sudo tar -xf MacOSX11.3.sdk.tar.xz -C /opt + sudo ln -s /opt/MacOSX11.3.sdk /opt/MacOSX.sdk sudo mkdir -p /opt/usr/local/ sudo ln -s /opt/MacOSX11.3.sdk/usr/include /opt/usr/local/include sudo ln -s /opt/MacOSX11.3.sdk/System/Library/Frameworks/OpenGL.framework/Headers /usr/local/include/OpenGL @@ -59,6 +60,7 @@ jobs: env micromamba run mamba info micromamba run mamba-devenv -f environment.devenv.yml + echo "OCCT=$(sed -n 's/^ *- occt=\([0-9.]*\).*/\1/p' environment.devenv.yml)" >> $GITHUB_ENV - name: Read output dir id: conf @@ -69,7 +71,7 @@ jobs: - name: Generate (Windows on Linux) if: inputs.platform == 'Windows' run: | - micromamba create --yes --platform win-64 --no-deps --prefix ./occt occt=8.0.0 + micromamba create --yes --platform win-64 --no-deps --prefix ./occt occt=${OCCT:?} micromamba run -n bindgen cmake -S . -B . -G Ninja \ -DPython_ROOT_DIR=$CONDA_PREFIX \ -DPython3_ROOT_DIR=$CONDA_PREFIX \ @@ -80,8 +82,23 @@ jobs: cmake --build . -- -v ls -lRht + - name: Generate (OSX on Linux) + if: inputs.platform == 'OSX' + run: | + CONDA_OVERRIDE_OSX=11.0 micromamba create --yes --platform osx-64 --no-deps --prefix ./occt occt=${OCCT:?} + micromamba run -n bindgen cmake -S . -B . -G Ninja \ + -DPython_ROOT_DIR=$CONDA_PREFIX \ + -DPython3_ROOT_DIR=$CONDA_PREFIX \ + -DPython_FIND_VIRTUALENV=ONLY \ + -DPython3_FIND_VIRTUALENV=ONLY \ + -DOCCT_LIB_DIR=./occt/lib/ \ + -DDLL_EXT=dylib \ + -DPLATFORM=OSX + cmake --build . -- -v + ls -lRht + - name: Generate (Standard) - if: inputs.platform != 'Windows' + if: inputs.platform != 'Windows' && inputs.platform != 'OSX' run: | micromamba run -n bindgen cmake -S . -B . -G Ninja \ -DPython_ROOT_DIR=$CONDA_PREFIX \ diff --git a/CMakeLists.txt b/CMakeLists.txt index 38a0f7471..8b28c56d4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -69,7 +69,7 @@ message(STATUS "Include dirs: ${VTK_INCLUDE_DIR}") message(STATUS "Include dirs: ${CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES}") # OSX -if(${CMAKE_SYSTEM_NAME} STREQUAL "Darwin") +if(PLATFORM STREQUAL "OSX" OR ${CMAKE_SYSTEM_NAME} STREQUAL "Darwin") list(APPEND CXX_INCLUDES -i /opt/usr/local/include/c++/v1/ -i /opt/usr/local/include/) diff --git a/ocp.toml b/ocp.toml index b841e0d7e..e5771b406 100644 --- a/ocp.toml +++ b/ocp.toml @@ -1417,7 +1417,7 @@ class Adaptor3d_Surface; [OSX] modules = ["Cocoa"] symbols = "symbols_mangled_mac.dat" - prefix = "/usr/local/miniconda/envs/cpp-py-bindgen" + prefix = "/opt/MacOSX.sdk" includes = ['/usr/local/Cellar/gcc@8/8.3.0_2/lib/gcc/8/gcc/x86_64-apple-darwin19/8.3.0/../../../../../../include/c++/8.3.0', '/usr/local/Cellar/gcc@8/8.3.0_2/lib/gcc/8/gcc/x86_64-apple-darwin19/8.3.0/../../../../../../include/c++/8.3.0/x86_64-apple-darwin19', '/usr/local/Cellar/gcc@8/8.3.0_2/lib/gcc/8/gcc/x86_64-apple-darwin19/8.3.0/../../../../../../include/c++/8.3.0/backward', From be7a67c08f80dad4da495cd4e54f1b72bd1e6009 Mon Sep 17 00:00:00 2001 From: kimstik Date: Sat, 19 Sep 2026 08:52:09 +0200 Subject: [PATCH 4/6] Generate reproducibly The generator walks sets in many places; with hash randomisation every run orders enums, members and collection chunks differently, and one V3d member came and went. Pinning the seed at the command that runs bindgen covers CI and local builds alike. --- CMakeLists.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8b28c56d4..72fd3ff07 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -119,7 +119,7 @@ set(ENV{PYTHONPATH} ${CMAKE_SOURCE_DIR}/pywrap) add_custom_command( OUTPUT ${CMAKE_BINARY_DIR}/tmp.pkl COMMAND - ${CMAKE_COMMAND} -E env "PYTHONPATH=${CMAKE_SOURCE_DIR}/pywrap" + ${CMAKE_COMMAND} -E env "PYTHONPATH=${CMAKE_SOURCE_DIR}/pywrap" PYTHONHASHSEED=0 ${Python_EXECUTABLE} -m bindgen -n ${N_PROC} -l ${LIBCLANG_PATH} -i ${VTK_INCLUDE_DIR}/ # -i ${OPENGL_INCLUDE_DIRS} @@ -137,7 +137,7 @@ add_custom_target(pywrap_parse ALL DEPENDS ${CMAKE_BINARY_DIR}/tmp.pkl) add_custom_command( OUTPUT ${CMAKE_BINARY_DIR}/tmp_filtered.pkl COMMAND - ${CMAKE_COMMAND} -E env "PYTHONPATH=${CMAKE_SOURCE_DIR}/pywrap" + ${CMAKE_COMMAND} -E env "PYTHONPATH=${CMAKE_SOURCE_DIR}/pywrap" PYTHONHASHSEED=0 ${Python_EXECUTABLE} -m bindgen -n ${N_PROC} -l ${LIBCLANG_PATH} -i ${VTK_INCLUDE_DIR}/ # -i ${OPENGL_INCLUDE_DIRS} @@ -156,7 +156,7 @@ add_custom_target(pywrap_transform ALL add_custom_command( OUTPUT ${CMAKE_BINARY_DIR}/OCP/CMakeLists.txt COMMAND - ${CMAKE_COMMAND} -E env "PYTHONPATH=${CMAKE_SOURCE_DIR}/pywrap" + ${CMAKE_COMMAND} -E env "PYTHONPATH=${CMAKE_SOURCE_DIR}/pywrap" PYTHONHASHSEED=0 ${Python_EXECUTABLE} -m bindgen -n ${N_PROC} -l ${LIBCLANG_PATH} -i ${VTK_INCLUDE_DIR}/ # -i ${OPENGL_INCLUDE_DIRS} From bc766f9bd45009276a28880eca3d9c05c6c42533 Mon Sep 17 00:00:00 2001 From: kimstik Date: Sat, 19 Sep 2026 12:31:30 +0200 Subject: [PATCH 5/6] Compile with four jobs The five collections chunks of 100 were 5 GB translation units each and met at the end of the build; at 25 the largest unit is 3.2 GB and four jobs fit the runners. The Mac step had a space after its line continuation, which ended the cmake command before the build type and the SDK: OSX was compiled without optimisation. --- .github/workflows/build-job.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build-job.yml b/.github/workflows/build-job.yml index 94be077c3..0ce4ed6b5 100644 --- a/.github/workflows/build-job.yml +++ b/.github/workflows/build-job.yml @@ -138,7 +138,7 @@ jobs: env: OCP_src: OCP_src_${{ inputs.platform }} - n_cores: 2 + n_cores: 4 PYTHON_VERSION: 3.${{ matrix.py_min }} STAGE: "compile" ANACONDA_TOKEN: ${{ secrets.ANACONDA_TOKEN }} @@ -177,16 +177,16 @@ jobs: run: | micromamba run -n bindgen cmake -B build -S "../${OCP_src}" -G Ninja \ -DCMAKE_BUILD_TYPE=Release - micromamba run -n bindgen cmake --build build -j 2 -- -k 0 + micromamba run -n bindgen cmake --build build -j $n_cores -- -k 0 rm -rf build/CMakeFiles - name: Compile (Mac) if: contains(inputs.runner_compile, 'mac') run: | - micromamba run -n bindgen cmake -B build -S "../${OCP_src}" -G Ninja \ + micromamba run -n bindgen cmake -B build -S "../${OCP_src}" -G Ninja \ -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_OSX_SYSROOT=/opt/MacOSX10.15.sdk/ - micromamba run -n bindgen cmake --build build -j 2 -- -k 0 + micromamba run -n bindgen cmake --build build -j $n_cores -- -k 0 rm -rf build/CMakeFiles - name: Compile (Windows) @@ -199,7 +199,7 @@ jobs: -DPython3_FIND_STRATEGY=LOCATION ` -DPython3_ROOT_DIR=$env:CONDA_PREFIX ` -DCMAKE_LINKER=lld-link.exe - micromamba run -n bindgen cmake --build build -j 1 -- -v -k 0 + micromamba run -n bindgen cmake --build build -j $env:n_cores -- -v -k 0 micromamba run -n bindgen cmake -E rm -rf build\CMakeFiles env: CXX: "cl.exe" From 12fba1c8547d88a0e7aea23347371da565ab789b Mon Sep 17 00:00:00 2001 From: kimstik Date: Sat, 19 Sep 2026 08:52:09 +0200 Subject: [PATCH 6/6] Cache compiled objects between runs sccache with the GitHub Actions cache backend. The generation is reproducible, so the translation units a commit does not touch are hits. SCCACHE_GHA_VERSION namespaces the keys: bumping it starts from an empty cache. --- .github/workflows/build-job.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/build-job.yml b/.github/workflows/build-job.yml index 0ce4ed6b5..58a2a0db1 100644 --- a/.github/workflows/build-job.yml +++ b/.github/workflows/build-job.yml @@ -138,6 +138,9 @@ jobs: env: OCP_src: OCP_src_${{ inputs.platform }} + CMAKE_CXX_COMPILER_LAUNCHER: sccache + SCCACHE_GHA_ENABLED: "true" + SCCACHE_GHA_VERSION: 1 # bump to start from an empty cache n_cores: 4 PYTHON_VERSION: 3.${{ matrix.py_min }} STAGE: "compile" @@ -172,6 +175,8 @@ jobs: micromamba create -n bindgen micromamba run mamba-devenv -f environment.devenv.yml + - uses: mozilla-actions/sccache-action@v0.0.11 + - name: Compile (Ubuntu) if: contains(inputs.runner_compile, 'ubuntu') run: | @@ -204,6 +209,9 @@ jobs: env: CXX: "cl.exe" + - name: Cache statistics + run: sccache --show-stats + - name: Upload Compilation Artifacts uses: actions/upload-artifact@v7 with: