fix: inject Homebrew library paths into configure on macOS - #30
Merged
Conversation
GNU build systems (autoconf) need explicit --with-xxx paths to find libraries installed via Homebrew, since /opt/homebrew is not in the default search path. After verifying Homebrew prerequisites exist, detect the Homebrew prefix (/opt/homebrew for ARM, /usr/local for Intel) and inject --with-gmp/mpfr/mpc/isl flags into configure_args automatically. Mold-specified --with-xxx flags take precedence (skip injection).
- Replace declare -A (requires bash 4.0+) with case statement (macOS ships bash 3.2, GitHub Actions macos-14 also uses 3.2) - Only inject --with-xxx for autoconf projects (guard on ./configure) - Detect --with-xxx, --with-xxx=*, and --without-xxx as overrides - Prefer brew --prefix for path detection, fallback to known paths
- Fall back to hardcoded paths if brew --prefix fails or returns empty - Detect --without-xxx=* in addition to --without-xxx
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.
Summary
Fix macOS GCC configure failure caused by missing Homebrew library paths.
GNU build systems (autoconf) need explicit
--with-xxxpaths to find librariesinstalled via Homebrew, since
/opt/homebrewis not in the default search path.Changes
After verifying Homebrew prerequisites exist (Step 6), auto-detect the Homebrew
prefix and inject
--with-gmp/mpfr/mpc/islflags into configure_args:casestatement (notdeclare -A)[[ -x ./configure ]]to avoid CMake contamination--with-xxx,--with-xxx=*,--without-xxx, or--without-xxx=*brew --prefixwith fallback to/opt/homebrew(ARM) and/usr/local(Intel)Background
GCC 15.2.0 build failed on macos-14 (Apple Silicon) with:
The prerequisite header check (Step 6) passed, but configure could not find
the libraries because Homebrew paths were not forwarded.
Test plan
molds/gcc/15.2.0— macOS configure should pass