Repository navigation
Build PETSc on macOS without the Homebrew library path - #961
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, and the manual configure command in the troubleshooting guide no longer adds the Homebrew library path.
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.
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.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #961 +/- ##
=======================================
Coverage 93.57% 93.58%
=======================================
Files 127 127
Lines 21186 21186
Branches 3597 3597
=======================================
+ Hits 19824 19826 +2
+ Misses 941 940 -1
+ Partials 421 420 -1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
timlichtenberg
added a commit
to FormingWorlds/SPIDER
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 installation page has a troubleshooting entry for this failure, including the Intel Mac limit where /usr/local/lib is on the default search path. The same change for the PROTEUS copy of the script is FormingWorlds/PROTEUS#961.
Closed
5 of 8 tasks
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.
Description
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.set -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. The two tests of the removed prefix logic go. 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).On an Intel Mac, Homebrew installs into
/usr/local/lib, which the linker searches by default, so a Homebrew SUNDIALS can still hide PETSc's there; the troubleshooting entry says so. The same change for the standalone SPIDER script is in FormingWorlds/SPIDER#19.Validation of changes
Full PETSc builds from this branch with Homebrew Open MPI 5.0.11: configure, build and the PETSc check examples (ex19 on 1 and 2 MPI ranks) pass; with the old flags configure fails on the same Mac with a Homebrew SUNDIALS 7.9 installed.
tests/tools/test_install_scripts.py: 102 passed; the new test fails when a Homebrew-LorLIBRARY_PATHis put back.Tested on an M1 Ultra, macOS 26.6.2, Python 3.12.
Checklist