From fc18fba11fd2b6ce13fa879576741f5eb05c7439 Mon Sep 17 00:00:00 2001 From: arekbr Date: Wed, 5 Aug 2026 07:06:49 +0200 Subject: [PATCH] fix: macOS CI -- build static SDL2 from source, brew's sdl2 is now sdl2-compat The macOS job dies in MTEngineSDL's Libtool step: libtool: could not find 'libSDL2.a' for option -lSDL2 Root cause is outside the repo: Homebrew's 'sdl2' formula has become an alias for sdl2-compat (a dynamic shim over SDL3) and no longer ships a static libSDL2.a. The 'brew install sdl2' step (added in afbc20a, back when the formula was real SDL2) still succeeds -- it just installs something else now. The last green run was in June, before the formula switch; pinning the runner image would not help, since homebrew-core is shared across images. Fix: build static SDL2 2.32.10 from source in build-macos.sh and stage libSDL2.a into MTEngineSDL/platform/MacOS/libs/ -- the exact pattern already used for uSockets.a two lines above. With the file present, Xcode passes libtool a full path (as it does for uSockets.a in the failing log), so nothing depends on how the new Xcode 26.6 libtool resolves -L/-l. Success criterion in the CI log: the Libtool command line shows .../libs/libSDL2.a as a full path instead of -lSDL2. The staging happens in build-macos.sh rather than the workflow because the script clones MTEngineSDL only when the directory does not exist -- a workflow step preparing that path first would skip the clone and break the build. Also works for local developer builds, not just CI. --- .github/workflows/build-macos.yml | 12 ++++++------ build-macos.sh | 18 ++++++++++++++++++ 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build-macos.yml b/.github/workflows/build-macos.yml index 4ccc291..1b63660 100644 --- a/.github/workflows/build-macos.yml +++ b/.github/workflows/build-macos.yml @@ -15,12 +15,12 @@ jobs: - name: Checkout RetroDebugger uses: actions/checkout@v6 - # SDL2 is the only external (Homebrew) dependency of the macOS build; it - # provides libSDL2.a, which the MTEngineSDL static lib merges in (libtool). - # llama.cpp / ftxui / mbedtls are built by MTEngineSDL's Xcode script phases, - # and uSockets is built by build-macos.sh — neither needs Homebrew here. - - name: Install macOS dependencies - run: brew install sdl2 + # No Homebrew dependencies anymore. `brew install sdl2` used to provide + # libSDL2.a, but the formula is nowadays an alias for sdl2-compat (a dynamic + # shim over SDL3) which ships no static archive — the libtool step of + # MTEngineSDL then failed with "could not find 'libSDL2.a'". Static SDL2 is + # now built from source and staged by build-macos.sh, next to uSockets.a. + # llama.cpp / ftxui / mbedtls are built by MTEngineSDL's Xcode script phases. - name: Build and package release id: release diff --git a/build-macos.sh b/build-macos.sh index b31ca1a..573a1ac 100755 --- a/build-macos.sh +++ b/build-macos.sh @@ -30,6 +30,24 @@ echo "Building uSockets and staging uSockets.a for MTEngineSDL (macOS)" mkdir -p "$CURRENT_DIR/../MTEngineSDL/platform/MacOS/libs/" cp -f "$CURRENT_DIR/../uSockets/uSockets.a" "$CURRENT_DIR/../MTEngineSDL/platform/MacOS/libs/" +# SDL2: Homebrew's "sdl2" formula is nowadays an alias for sdl2-compat (a dynamic +# shim over SDL3) and no longer ships a static libSDL2.a, so `brew install sdl2` +# stopped providing the archive MTEngineSDL's libtool step merges in. Build static +# SDL2 from source and stage it next to uSockets.a — with the file present, Xcode +# hands libtool a full path (same as uSockets.a) instead of relying on -L/-lSDL2. +SDL2_VER=2.32.10 +SDL2_A="$CURRENT_DIR/../MTEngineSDL/platform/MacOS/libs/libSDL2.a" +if [ ! -f "$SDL2_A" ]; then + echo "Building static SDL2 $SDL2_VER and staging libSDL2.a for MTEngineSDL (macOS)" + curl -fL -o "$CURRENT_DIR/../SDL2-src.tar.gz" "https://github.com/libsdl-org/SDL/releases/download/release-$SDL2_VER/SDL2-$SDL2_VER.tar.gz" + tar xzf "$CURRENT_DIR/../SDL2-src.tar.gz" -C "$CURRENT_DIR/.." + cmake -S "$CURRENT_DIR/../SDL2-$SDL2_VER" -B "$CURRENT_DIR/../sdl2-build" \ + -DSDL_STATIC=ON -DSDL_SHARED=OFF -DSDL_TEST=OFF \ + -DCMAKE_BUILD_TYPE=Release -DCMAKE_OSX_DEPLOYMENT_TARGET=10.15 + cmake --build "$CURRENT_DIR/../sdl2-build" -j"$(sysctl -n hw.ncpu)" + cp -f "$CURRENT_DIR/../sdl2-build/libSDL2.a" "$SDL2_A" +fi + # --- build RetroDebugger via Xcode --- cd "$CURRENT_DIR" DERIVED="$CURRENT_DIR/build-macos"