Skip to content

Use PETSc CXX for C++ extension builds#103

Open
gthyagi wants to merge 2 commits intounderworldcode:developmentfrom
gthyagi:fixbug/setup-petsc-cxx-build
Open

Use PETSc CXX for C++ extension builds#103
gthyagi wants to merge 2 commits intounderworldcode:developmentfrom
gthyagi:fixbug/setup-petsc-cxx-build

Conversation

@gthyagi
Copy link
Copy Markdown
Contributor

@gthyagi gthyagi commented Mar 31, 2026

Summary

  • read CXX from PETSc petscvariables in setup.py
  • export CXX alongside the existing CC override

Why this is important

Pre-fix, setup.py only forced PETSc's CC. That meant C builds followed PETSc, but C++ builds could still fall back to the ambient environment compiler.

In practice, this can send underworld3.ckdtree through a different or broken C++ toolchain than the PETSc/MPI build, especially in Pixi/OpenMPI environments.

Using both PETSc CC and CXX keeps the Underworld extension build aligned with the PETSc toolchain.

Validation

  • python3 -m py_compile setup.py
  • OMPI_CC=/usr/bin/clang OMPI_CXX=/usr/bin/clang++ pixi run -e amr-dev pip install . --no-build-isolation

@gthyagi gthyagi requested a review from lmoresi as a code owner March 31, 2026 03:00
@gthyagi
Copy link
Copy Markdown
Contributor Author

gthyagi commented Mar 31, 2026

Added a follow-up fix for runtime JIT builds. The earlier change made package builds use PETSc's , but was still spawning temporary builds without that compiler environment. This commit now passes PETSc-derived into the JIT subprocess and sets when the OpenMPI wrapper points to a missing compiler name. Verified by rerunning the three previously failing collection-time tests: , , and ().

@gthyagi
Copy link
Copy Markdown
Contributor Author

gthyagi commented Mar 31, 2026

Added a follow-up fix for runtime JIT builds.

The earlier setup.py change made package builds use PETSc CC/CXX, but _jitextension.py was still spawning temporary setup.py build_ext --inplace builds without that compiler environment. This commit now passes PETSc-derived CC/CXX into the JIT subprocess and sets OMPI_CC/OMPI_CXX when the OpenMPI wrapper points to a missing compiler name.

Verified by rerunning the three previously failing collection-time tests:

  • tests/test_0050_utils.py
  • tests/test_1004_DarcyCartesian.py
  • tests/test_1011_stokesSph.py

Result: 6 passed.

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.

1 participant