Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do something about the findability of zstd for the macOS builds #8

Open
dabrahams opened this issue Feb 28, 2024 · 1 comment
Open

Comments

@dabrahams
Copy link
Collaborator

dabrahams commented Feb 28, 2024

dave@DaveA-MBP14-5 Swifty-LLVM % ~/Downloads/llvm-17.0.6-arm64-apple-darwin23.3.0-Debug/bin/llvm-config 
~/Downloads/llvm-17.0.6-arm64-apple-darwin23.3.0-Debug/bin/llvm-config 
dyld[27721]: Library not loaded: /opt/local/lib/libzstd.1.dylib
  Referenced from: <80280D10-861C-3C78-A1C8-3E5E93E9E2B9> /Users/dave/Downloads/llvm-17.0.6-arm64-apple-darwin23.3.0-Debug/bin/llvm-config
  Reason: tried: '/opt/local/lib/libzstd.1.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/opt/local/lib/libzstd.1.dylib' (no such file), '/opt/local/lib/libzstd.1.dylib' (no such file), '/usr/local/lib/libzstd.1.dylib' (no such file), '/usr/lib/libzstd.1.dylib' (no such file, not in dyld cache)
zsh: abort      ~/Downloads/llvm-17.0.6-arm64-apple-darwin23.3.0-Debug/bin/llvm-config

Workaround for me is:

zstd_dir="$(pkg-config --libs-only-L libzstd)"
export DYLD_LIBRARY_PATH="${zstd_dir#-L}:$DYLD_LIBRARY_PATH"

but you have to embed it in the script invoking llvm-config because of this security feature.

dabrahams added a commit to hylo-lang/Swifty-LLVM that referenced this issue Feb 28, 2024
This finds zstd using pkg-config instead of relying on the RUNPATH embedded in llvm-config.
dabrahams added a commit to hylo-lang/Swifty-LLVM that referenced this issue Feb 28, 2024
Work around hylo-lang/llvm-build#8

This finds libzstd using `pkg-config` instead of relying on the `RUNPATH` embedded in `llvm-config`, if `llvm-config` doesn't run without help.
@dabrahams
Copy link
Collaborator Author

dabrahams commented Feb 29, 2024

I think part of the deal is that homebrew installs its libraries in a nonstandard location on Apple Silicon (/opt/homebrew/lib)—but not on Intel. It's not in the default search path for libraries, so anything that is built without brew specifically in mind will fail to find dynamic libs installed by brew. It might not be the most principled approach, but I'm thinking of taking suggestion #1, if there's a way to get CMAKE to inject /opt/homebrew/lib at the end of all RUNPATHs it creates.

https://cmake.org/cmake/help/latest/prop_tgt/INSTALL_RPATH.html. When that's done we can undo hylo-lang/Swifty-LLVM@2ac3ac714af

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant