Skip to content

fix: inject Homebrew library paths into configure on macOS - #30

Merged
skipbit merged 3 commits into
mainfrom
fix-macos-homebrew-configure
Mar 22, 2026
Merged

fix: inject Homebrew library paths into configure on macOS#30
skipbit merged 3 commits into
mainfrom
fix-macos-homebrew-configure

Conversation

@skipbit

@skipbit skipbit commented Mar 22, 2026

Copy link
Copy Markdown
Owner

Summary

Fix macOS GCC configure failure caused by missing Homebrew library paths.

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.

Changes

After verifying Homebrew prerequisites exist (Step 6), auto-detect the Homebrew
prefix and inject --with-gmp/mpfr/mpc/isl flags into configure_args:

  • Bash 3.2 compatible: Uses case statement (not declare -A)
  • Autoconf-only: Guarded by [[ -x ./configure ]] to avoid CMake contamination
  • Override-safe: Skips injection if mold already specifies --with-xxx, --with-xxx=*, --without-xxx, or --without-xxx=*
  • Portable: Uses brew --prefix with fallback to /opt/homebrew (ARM) and /usr/local (Intel)

Background

GCC 15.2.0 build failed on macos-14 (Apple Silicon) with:

configure: error: Building GCC requires GMP 4.2+, MPFR 3.1.0+ and MPC 0.8.0+.

The prerequisite header check (Step 6) passed, but configure could not find
the libraries because Homebrew paths were not forwarded.

Test plan

  • Re-run ingot-cast workflow_dispatch with molds/gcc/15.2.0 — macOS configure should pass
  • Linux builds unaffected (this code only runs in the macOS branch)
  • PR validation passes

skipbit added 3 commits March 22, 2026 10:35
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
@skipbit
skipbit merged commit 1ddc739 into main Mar 22, 2026
5 checks passed
@skipbit
skipbit deleted the fix-macos-homebrew-configure branch March 22, 2026 01:49
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