Repository navigation
Build PETSc on macOS without the Homebrew library path - #19
Merged
Merged
Conversation
With -L$(brew --prefix)/lib in LDFLAGS, a Homebrew SUNDIALS (7.x) sits ahead of the SUNDIALS 2.5 that PETSc downloads, so configure cannot link CVDense and CVSpgmr and stops with "Downloaded sundials2 could not be used". The system MPI does not need the path: mpicc adds its own -L. LDFLAGS now only carries -Wl,-w, which keeps the macOS 26 linker warnings from failing configure.
The test now looks at every code line of get_petsc.sh for a -L library path instead of two exact LDFLAGS values.
The test runs the shipped platform and configure steps of get_petsc.sh as macOS with a system MPI and a stub configure, and checks that no argument carries -L and that LDFLAGS=-Wl,-w arrives, which catches any spelling of a library path.
The stub configure also records its environment, the shipped steps run under set -euo pipefail as in the script, and the test checks that --download-sundials2 reaches configure.
The macOS configure test checks that LDFLAGS, LIBRARY_PATH, LIBS and CPATH stay unset and that no exported variable names the Homebrew library directory. The troubleshooting docs describe the "Downloaded sundials2 could not be used" failure that a Homebrew SUNDIALS causes, and that Intel Macs can still hit it. The install docs say the script uses the MPI on PATH.
8 tasks done
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
The test lacks required edge/error-path coverage, and the Intel troubleshooting entry omits recovery instructions.
Review effort: Balanced
Findings: 1
Open (2)
What changed in this PR
Removes the Homebrew library path from macOS PETSc configuration to avoid selecting incompatible SUNDIALS versions.
Changes:
- Uses only
-Wl,-wfor macOS linker flags. - Adds a stubbed configuration test.
- Documents the SUNDIALS conflict.
| File | Description |
|---|---|
tools/get_petsc.sh |
Removes Homebrew’s library path from PETSc linker flags. |
tests/test_get_petsc_ldflags.py |
Tests macOS configure arguments and environment. |
docs/How-to/installation.md |
Adds troubleshooting guidance for SUNDIALS conflicts. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Without mpicc on PATH, configure gets --download-mpich and still only LDFLAGS=-Wl,-w with no library path; without xcrun, the script stops with its install hint before configure runs. Both cases run with PATH limited to the stub tools.
timlichtenberg
added a commit
to FormingWorlds/PROTEUS
that referenced
this pull request
Oct 7, 2026
On macOS, tools/get_petsc.sh no longer puts the Homebrew library directory into PETSc's LDFLAGS. With a Homebrew SUNDIALS 7 installed, that -L made the linker pick it up before the SUNDIALS 2.5 that PETSc downloads, and configure failed with "Downloaded sundials2 could not be used". LDFLAGS is now only -Wl,-w; the system MPI still links because mpicc adds its own library path. The architecture check for the Homebrew prefix goes with it. A test runs the macOS platform and configure steps of the script with stub tools and checks the configure arguments and the exported environment, with cases for a missing mpicc and a missing xcrun. The troubleshooting page has an entry for this failure, including the Intel Mac limit where /usr/local/lib is on the default search path. The same change for the standalone SPIDER script is FormingWorlds/SPIDER#19.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


On macOS,
tools/get_petsc.shno longer puts the Homebrew library directory into PETSc'sLDFLAGS. With a Homebrew SUNDIALS 7 installed, that-Lmade the linker pick it up before the SUNDIALS 2.5 that PETSc downloads, and configure failed with "Downloaded sundials2 could not be used" (CVDenseandCVSpgmrmissing).LDFLAGSis now only-Wl,-w; the system MPI still links, becausempiccadds its own library path.-L.tests/test_get_petsc_ldflags.pyruns the macOS platform and configure steps of the script with stub tools, underset -euo pipefail, and checks that configure getsLDFLAGS=-Wl,-wand--download-sundials2, that no argument carries-L, and thatLDFLAGS,LIBRARY_PATH,LIBSandCPATHare not exported with the Homebrew library directory. Two more cases cover the script without mpicc (configure gets --download-mpich with the same flags) and without xcrun (the script stops with its message before configure)./usr/local/lib, which the linker searches by default, so a Homebrew SUNDIALS can still hide PETSc's there.The same change for the PROTEUS copy of the script is in FormingWorlds/PROTEUS#961.
Testing: a full PETSc build from this branch with Homebrew Open MPI 5.0.11 passes configure, build and the PETSc check examples (ex19 on 1 and 2 MPI ranks); the new test fails when a Homebrew
-LorLIBRARY_PATHis put back. Tested on an M1 Ultra, macOS 26.6.2.