Commit 694e3cf
package-macos: bundle Homebrew dylibs into Contents/Frameworks (#43)
The macOS package script copied the BattleShip / torch binaries verbatim
into Contents/MacOS without bundling their Homebrew runtime
dependencies, so the resulting .app embedded absolute load commands like
/opt/homebrew/opt/sdl2/lib/libSDL2-2.0.0.dylib. On any Mac without
Homebrew at the developer's prefix and exact package versions, dyld
bails before main() with `Library not loaded: /opt/homebrew/*/libSDL2-
2.0.0.dylib` — verbatim crash from issue #43 (Apple M4, macOS Tahoe
26.3).
Linux and Windows packaging already handle this (linuxdeploy walks
NEEDED for AppImage; vcpkg drops SDL2.dll next to the .exe). macOS was
the only platform shipping host-locked binaries.
Fix uses the standard `dylibbundler` Homebrew package: walks the binaries'
transitive Homebrew deps, stages each into Contents/Frameworks/, rewrites
each dylib's id to @executable_path/../Frameworks/lib*.dylib, retargets
the binaries' load commands via install_name_tool, and replaces the
inherited Homebrew rpaths with @executable_path/../Frameworks/. Using
the absolute @executable_path form (rather than @rpath + LC_RPATH) avoids
dylibbundler's existing-rpath rewrite stomping the LC_RPATH with literal
`@rpath/`, which produces a recursive load command dyld can't resolve.
The post-bundle adhoc `codesign --deep --force --sign -` already in the
script picks up the new Frameworks/ tree and re-signs both the dylibs
and the now-modified executables (install_name_tool invalidates the
linker signature). Added a sanity check after dylibbundler that scans
the binaries for any remaining /opt/homebrew or /usr/local/Cellar load
commands and fails the build loudly if one slips through, rather than
shipping a host-locked .app to users.
Verified locally on a copy of dist/BattleShip.app: every Homebrew
reference replaced with @executable_path/../Frameworks/, dylib ids
match, codesign --verify --deep --strict passes.
CI: added `dylibbundler` to the brew install line in
.github/workflows/release.yml so macos-14 runners have the tool.
Closes #43.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 64c705e commit 694e3cf
2 files changed
Lines changed: 52 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
43 | | - | |
| 43 | + | |
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
135 | 135 | | |
136 | 136 | | |
137 | 137 | | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
138 | 189 | | |
139 | 190 | | |
140 | 191 | | |
| |||
0 commit comments