Skip to content

Make macOS build work on Apple Silicon (arm64) Homebrew#345

Open
jakeobsen wants to merge 1 commit into
alexkay:masterfrom
jakeobsen:arm64-macos-build
Open

Make macOS build work on Apple Silicon (arm64) Homebrew#345
jakeobsen wants to merge 1 commit into
alexkay:masterfrom
jakeobsen:arm64-macos-build

Conversation

@jakeobsen
Copy link
Copy Markdown

Summary

The macOS bundling glue assumed Intel Homebrew's /usr/local prefix and hardcoded the wxWidgets 3.2 series, so on Apple Silicon (Homebrew at /opt/homebrew) the bundle silently produced a broken .app — no Frameworks/ libs were copied in, every wx translation was reported missing, and on a clean machine the resulting bundle crashed at launch with a missing @rpath/libsharpyuv.0.dylib.

This PR makes dist/osx/bundle.sh reproducible on both Intel and Apple Silicon Homebrew without hand-edits, and tolerates the wx 3.2 → 3.3 bump.

Changes

dist/osx/bundle.sh

  • Discover BREW_PREFIX via brew --prefix and the wx series via wx-config --release, replacing the hardcoded /usr/local and 3.2 references.
  • Export ACLOCAL_PATH so aclocal finds wxwin.m4 inside Homebrew's wxwidgets keg, removing the manual symlink workaround that the old README asked maintainers to do.
  • Export CPPFLAGS/LDFLAGS for Homebrew's keg-only gettext, so configure doesn't disable NLS and silently drop the .gmo files (which then made the per-language copy step fail).
  • Extend the dependency-walking loop to also resolve @rpath/... library references (e.g. libwebplibsharpyuv) instead of only matching the Homebrew prefix; an unresolved @rpath ref previously slipped through and the resulting .app crashed at launch on a clean machine.

src/Makefile.am

  • Pass $(AVFORMAT_CFLAGS)/$(AVCODEC_CFLAGS)/$(AVUTIL_CFLAGS) to the spek binary too, not just libspek.a. spek-spectrogram.cc transitively includes <libavutil/mem.h> via spek-fft.h; on Intel /usr/local/include was on clang's default search path so this was masked, but on Apple Silicon /opt/homebrew/include is not, and the build failed with 'libavutil/mem.h' file not found.

dist/osx/README.md

  • Drop the manual /usr/local symlink and the hardcoded brotli install_name_tool stanza; bundle.sh now handles both automatically. Keep the brotli note as an example for the rare case where a Homebrew dylib still uses @loader_path siblings.

INSTALL.md

  • Drop "Intel-based Mac" wording and reflect the current minimum versions (10.15+ on Intel per Info.plist, 11+ on Apple Silicon).

Backward compatibility

Fully backward-compatible on Intel: brew --prefix returns /usr/local there, wx-config --release returns whatever wx is installed, and the @rpath branch only fires for libs that actually use @rpath references. No behaviour change for an Intel maintainer running bundle.sh.

Dependency on #338

This PR alone is not sufficient to build against current Homebrew, because Homebrew now ships FFmpeg 8 which removed the avfft.h API src/spek-fft.cc uses. To verify these changes locally I applied #338 (hannesbraun:ffmpeg-8) on top of this branch — together they produce a working arm64 .app and .dmg. I deliberately did not include the FFmpeg 8 fix here to avoid duplicating an open PR.

Test plan

  • ./dist/osx/bundle.sh runs to completion on macOS 26.4 / Apple Silicon (M5) with current Homebrew (FFmpeg 8.1, wxWidgets 3.3.2, gettext, automake) plus Fix compatibility with FFmpeg 8 #338 applied.
  • lipo -archs dist/osx/Spek.app/Contents/MacOS/Spek reports arm64.
  • otool -L on the binary and every bundled dylib shows no /opt/homebrew, /usr/local, or @rpath references — everything resolves to @executable_path/../Frameworks/....
  • 26 wxstd-3.3.mo and 34 spek.mo translation files bundled.
  • Ad-hoc-signed .app launches and stays running against tests/samples/2ch-44100Hz-16bps.wav.
  • Spek.dmg (~19 MB) created.
  • Cross-check on Intel Homebrew (no Intel Mac available to me; review of the diff should confirm brew --prefix/usr/local is the only behavioural delta).

The macOS bundling glue assumed Intel Homebrew's /usr/local prefix and
hardcoded the wxWidgets 3.2 series, so on Apple Silicon (where Homebrew
lives at /opt/homebrew) the bundle silently produced a broken .app — no
Frameworks/ libs were copied in, and every wx translation was reported
missing. This commit makes the bundling reproducible on both Intel and
Apple Silicon Homebrew without hand-edits.

dist/osx/bundle.sh:
 * Discover BREW_PREFIX via `brew --prefix` and the wx series via
   `wx-config --release`, replacing the hardcoded /usr/local and 3.2
   references.
 * Export ACLOCAL_PATH so aclocal finds wxwin.m4 inside Homebrew's
   wxwidgets keg, removing the manual symlink workaround.
 * Export CPPFLAGS/LDFLAGS for Homebrew's keg-only gettext, so configure
   doesn't disable NLS and silently drop the .gmo files (which then made
   the per-language copy step fail).
 * Extend the dependency-walking loop to also resolve @rpath/... library
   references (e.g. libwebp -> libsharpyuv) instead of only matching the
   Homebrew prefix; an unresolved @rpath ref previously slipped through
   and the resulting .app crashed at launch on a clean machine.

src/Makefile.am:
 * Pass \$(AVFORMAT_CFLAGS)/\$(AVCODEC_CFLAGS)/\$(AVUTIL_CFLAGS) to the
   spek binary too, not just libspek.a. spek-spectrogram.cc transitively
   includes <libavutil/mem.h> via spek-fft.h; on Intel /usr/local/include
   was on clang's default search path so this was masked, but on Apple
   Silicon /opt/homebrew/include is not, and the build failed.

dist/osx/README.md:
 * Drop the manual /usr/local symlink and the hardcoded brotli
   install_name_tool stanza; bundle.sh now handles both automatically.
   Keep the brotli note as an example for the rare case where a Homebrew
   dylib still uses @loader_path siblings that the loop can't resolve.

INSTALL.md:
 * Drop "Intel-based Mac" wording and reflect the current minimum
   versions (10.15+ on Intel per Info.plist, 11+ on Apple Silicon).

Note: this depends on PR alexkay#338 (hannesbraun:ffmpeg-8) being merged for
the build to actually compile against current Homebrew, since FFmpeg 8
removed the avfft API spek-fft.cc uses. That FFmpeg 8 change is not
included here to avoid duplicating the open PR.
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