Skip to content

Commit 7e0f7bd

Browse files
pdepetrometa-codesync[bot]
authored andcommitted
Build libzstd from source for macOS release wheels
Summary: Fixes a `delocate.libsana.DelocationError` in the macOS leg of the release workflow. After the prior fix (pinning cibuildwheel to v3.4.1 and installing libzstd via `brew install zstd`), the macOS run got past the build step but failed at `delocate-wheel` with: Library dependencies do not satisfy target MacOS version 11.0: tintype/.dylibs/libzstd.1.5.7.dylib has a minimum target of 15.0 Root cause: `macos-latest` runners now run macOS 15 (Sequoia), and Homebrew bottles on those runners are built targeting the runner OS. But cibuildwheel tags arm64 wheels with a minimum macOS of 11.0 by default, and delocate refuses to bundle a dylib whose LC_VERSION_MIN is higher than the wheel's. Fix: replace `brew install zstd` in `CIBW_BEFORE_ALL_MACOS` with a CMake source build of libzstd 1.5.6 producing a universal2 (arm64 + x86_64) dylib explicitly targeting macOS 11.0, installed to `/usr/local`. `setup.py`'s `find_zstd()` searches `/usr`, `/usr/local`, `/opt/homebrew` in that order, so installing to `/usr/local` takes precedence over any leftover Homebrew install. The `brew uninstall` before the build is defensive cleanup. Also sets `CIBW_ENVIRONMENT_MACOS: MACOSX_DEPLOYMENT_TARGET=11.0`. Without this, cibuildwheel would default the x86_64 leg to 10.13 — which is lower than the vendored libzstd's 11.0 target and would trigger the same DelocationError in the opposite direction. Trade-off: wheels now require macOS 11.0 (Big Sur, Nov 2020) or newer on both architectures. Previously arm64 required 11.0 (unchanged) and x86_64 defaulted to 10.13. This is fine in practice — macOS 11 is >5 years old. Reviewed By: aperez Differential Revision: D103472663 fbshipit-source-id: 8d3d456cddbbacf4b4a45213e5b353a97c80df97
1 parent 5e30213 commit 7e0f7bd

1 file changed

Lines changed: 27 additions & 4 deletions

File tree

.github/workflows/release.yml

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,33 @@ jobs:
6262
# Install libzstd inside the manylinux container (mirrors ci.yml's
6363
# `apt install libzstd-dev` but adapted for the CentOS-based image).
6464
CIBW_BEFORE_ALL_LINUX: "yum install -y libzstd-devel"
65-
# macOS: zstd is needed at build time. brew provides it for the
66-
# runner's native arch; the x86_64 cross-compile leg may need
67-
# additional work if the linker can't find an Intel build.
68-
CIBW_BEFORE_ALL_MACOS: "brew install zstd"
65+
# macOS: the macos-latest runner (macOS 15+) ships Homebrew bottles
66+
# targeting macOS 15, but cibuildwheel tags our wheel as macOS 11.
67+
# delocate refuses to bundle a dylib with a higher min target than
68+
# the wheel, so we build libzstd from source as a universal2 dylib
69+
# targeting macOS 11.0. setup.py's find_zstd() searches
70+
# /usr, /usr/local, /opt/homebrew in order, so /usr/local wins over
71+
# any leftover Homebrew install.
72+
CIBW_BEFORE_ALL_MACOS: |
73+
brew uninstall --ignore-dependencies zstd 2>/dev/null || true
74+
ZSTD_VERSION=1.5.6
75+
curl -fL "https://github.com/facebook/zstd/releases/download/v${ZSTD_VERSION}/zstd-${ZSTD_VERSION}.tar.gz" | tar -xz -C /tmp
76+
cmake -S "/tmp/zstd-${ZSTD_VERSION}/build/cmake" -B /tmp/zstd-build \
77+
-DCMAKE_BUILD_TYPE=Release \
78+
-DCMAKE_OSX_DEPLOYMENT_TARGET=11.0 \
79+
-DCMAKE_OSX_ARCHITECTURES="arm64;x86_64" \
80+
-DZSTD_BUILD_SHARED=ON \
81+
-DZSTD_BUILD_STATIC=OFF \
82+
-DZSTD_BUILD_PROGRAMS=OFF \
83+
-DZSTD_BUILD_TESTS=OFF \
84+
-DCMAKE_INSTALL_PREFIX=/usr/local
85+
cmake --build /tmp/zstd-build --parallel
86+
sudo cmake --install /tmp/zstd-build
87+
# Pin both x86_64 and arm64 legs to the same minimum macOS target
88+
# that our vendored libzstd was built against (otherwise the x86_64
89+
# default of 10.13 would be lower than the dylib's 11.0 and delocate
90+
# would fail again).
91+
CIBW_ENVIRONMENT_MACOS: MACOSX_DEPLOYMENT_TARGET=11.0
6992

7093
- name: Upload wheels artifact
7194
uses: actions/upload-artifact@v4

0 commit comments

Comments
 (0)