Make macOS build work on Apple Silicon (arm64) Homebrew#345
Open
jakeobsen wants to merge 1 commit into
Open
Conversation
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.
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
The macOS bundling glue assumed Intel Homebrew's
/usr/localprefix and hardcoded the wxWidgets 3.2 series, so on Apple Silicon (Homebrew at/opt/homebrew) the bundle silently produced a broken.app— noFrameworks/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.shreproducible on both Intel and Apple Silicon Homebrew without hand-edits, and tolerates the wx 3.2 → 3.3 bump.Changes
dist/osx/bundle.shBREW_PREFIXviabrew --prefixand the wx series viawx-config --release, replacing the hardcoded/usr/localand3.2references.ACLOCAL_PATHsoaclocalfindswxwin.m4inside Homebrew's wxwidgets keg, removing the manual symlink workaround that the old README asked maintainers to do.CPPFLAGS/LDFLAGSfor Homebrew's keg-onlygettext, so configure doesn't disable NLS and silently drop the.gmofiles (which then made the per-language copy step fail).@rpath/...library references (e.g.libwebp→libsharpyuv) instead of only matching the Homebrew prefix; an unresolved@rpathref previously slipped through and the resulting.appcrashed at launch on a clean machine.src/Makefile.am$(AVFORMAT_CFLAGS)/$(AVCODEC_CFLAGS)/$(AVUTIL_CFLAGS)to thespekbinary too, not justlibspek.a.spek-spectrogram.cctransitively includes<libavutil/mem.h>viaspek-fft.h; on Intel/usr/local/includewas on clang's default search path so this was masked, but on Apple Silicon/opt/homebrew/includeis not, and the build failed with'libavutil/mem.h' file not found.dist/osx/README.md/usr/localsymlink and the hardcoded brotliinstall_name_toolstanza;bundle.shnow handles both automatically. Keep the brotli note as an example for the rare case where a Homebrew dylib still uses@loader_pathsiblings.INSTALL.mdInfo.plist, 11+ on Apple Silicon).Backward compatibility
Fully backward-compatible on Intel:
brew --prefixreturns/usr/localthere,wx-config --releasereturns whatever wx is installed, and the@rpathbranch only fires for libs that actually use@rpathreferences. No behaviour change for an Intel maintainer runningbundle.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.hAPIsrc/spek-fft.ccuses. To verify these changes locally I applied #338 (hannesbraun:ffmpeg-8) on top of this branch — together they produce a working arm64.appand.dmg. I deliberately did not include the FFmpeg 8 fix here to avoid duplicating an open PR.Test plan
./dist/osx/bundle.shruns 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/Spekreportsarm64.otool -Lon the binary and every bundled dylib shows no/opt/homebrew,/usr/local, or@rpathreferences — everything resolves to@executable_path/../Frameworks/....wxstd-3.3.moand 34spek.motranslation files bundled..applaunches and stays running againsttests/samples/2ch-44100Hz-16bps.wav.Spek.dmg(~19 MB) created.brew --prefix→/usr/localis the only behavioural delta).