Skip to content

Fix local macOS OpenMPI PETSc toolchain setup - #145

Merged
lmoresi merged 1 commit into
underworldcode:developmentfrom
gthyagi:bugfix/macos-openmpi-petsc-toolchain
Apr 28, 2026
Merged

lmoresi merged 1 commit into
underworldcode:developmentfrom
gthyagi:bugfix/macos-openmpi-petsc-toolchain

Conversation

@gthyagi

@gthyagi gthyagi commented Apr 25, 2026

Copy link
Copy Markdown
Contributor

Summary

This PR makes the local macOS OpenMPI PETSc build setup use a coherent compiler/toolchain configuration.

Motivation

On macOS, local OpenMPI PETSc builds can mix pixi/conda compiler wrappers, Apple clang, Homebrew gfortran, and SDK/deployment-target settings. That can produce an inconsistent PETSc configure/build environment.

Changes

  • Applies only for CLUSTER=local, Darwin, and OpenMPI.
  • Selects the external Fortran compiler consistently.
  • Derives SDK/deployment target information from the selected compiler environment.
  • Clears conflicting pixi/conda compiler variables for this local macOS path.
  • Sets OpenMPI wrapper compiler variables explicitly before PETSc configure/build/test/petsc4py steps.

Scope

This path is local macOS/OpenMPI-specific. It should not affect Gadi/HPC builds, Linux local builds, or MPICH builds.

Local environment where this was needed

  • macOS arm64
  • Apple clang 21.0.0
  • Homebrew gfortran 14.2.0_1
  • pixi OpenMPI 5.0.10

Local AMR PETSc builds on macOS were failing in PETSc configure because the pixi OpenMPI toolchain was not coherent for mixed C/C++/Fortran checks.

The local build path previously relied on --with-mpi-dir alone, which left PETSc to pick up a combination of conda compiler environment variables, OpenMPI wrapper defaults, Apple clang, and pixi gfortran settings. On Apple Silicon this surfaced as mpif90 wrapper failures, misleading standard-header and math-check failures, and mixed-link problems during PETSc configure.

Add a macOS/OpenMPI-specific setup path that runs for local builds only. It selects an external gfortran (preferring Homebrew), derives SDKROOT and the macOS deployment target from that Fortran toolchain, clears conflicting pixi/conda compiler environment variables, and forces the OpenMPI wrappers onto /usr/bin/clang, /usr/bin/clang++, and the chosen gfortran with explicit OMPI_*FLAGS.

Also pass mpicc/mpicxx/mpif90 explicitly to PETSc configure for local builds and reuse the same setup for PETSc build, test, and petsc4py installation so the wrapper/compiler selection stays consistent across the full local PETSc workflow.
@gthyagi
gthyagi requested a review from lmoresi as a code owner April 25, 2026 17:32

@lmoresi lmoresi left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems clean - merging

@lmoresi
lmoresi merged commit c98c4a1 into underworldcode:development Apr 28, 2026
2 checks 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.

2 participants