Fix dyld libzstd/libunwind errors in distributed macOS binaries#105
Closed
jucasoliveira wants to merge 2 commits into
Closed
Fix dyld libzstd/libunwind errors in distributed macOS binaries#105jucasoliveira wants to merge 2 commits into
jucasoliveira wants to merge 2 commits into
Conversation
…ebrew refs The previous approach (copying libzstd.a to an isolated dir) failed because LLVM's own -L flags from llvm-config still pointed the linker to the original directory containing the .dylib. And removing the .dylib broke llvm-config itself since libLLVM dynamically links to libzstd. New approach: move .dylib files to /tmp/dylib-runtime and set DYLD_LIBRARY_PATH so LLVM tools still find them at runtime, while the linker only sees .a archives in the original directories. Also moves LLVM's libunwind.dylib on aarch64. Verification step now checks for ANY /opt/homebrew or /usr/local/opt references, not just libzstd. CI updated: removed x86_64-apple-darwin (needs cross-compilation, only tested in release), added linux-aarch64 and macos dynamic-dep visibility check. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Collapse nested `if` conditions into match arm guards as suggested by clippy::collapsible_match. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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
oitecon macOS without Homebrew hitdyld: Library not loaded: libzstd.1.dylib(andlibunwind.1.dylib) at runtime/opt/homebrew/opt/....dylibfiles to a temp directory and setDYLD_LIBRARY_PATHso LLVM tools (llvm-config → libLLVM) still work during the build, while the linker only finds.astatic archivesWhy previous attempts failed
Removing→ broke.dylibbefore buildllvm-config(it loadslibLLVM.dylibwhich chains tolibzstd.1.dylib)Copying→ LLVM's own.ato isolated dir-Lflags (fromllvm-config --ldflags) still pointed the linker to the original dir containing the.dylibWhat works now
Move the
.dylibfiles out of linker search paths →DYLD_LIBRARY_PATHmakes them available for process execution (build scripts) → linker only sees.a→ static linkChanges
release.ymllibzstd*.dylibandlibunwind*.dylibto/tmp/dylib-runtime, exportsDYLD_LIBRARY_PATH/opt/homebrewor/usr/local/optreferences in the binary, not just libzstdci.ymllinux-x86_64,linux-aarch64,macos-aarch64x86_64-apple-darwinfrom CI (requires cross-compilation setup, tested only in release)libzstd-devto Linux CI (was missing vs release)otool -Lcheck on macOS CI buildsTest plan
otool -Lverification passes (no/opt/homebrew, no/usr/local/opt, nolibzstd)🤖 Generated with Claude Code