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

llvm@16's version of llvm-config doesn't include the correct -L flag for zstd when passed --link-static on Apple-silicon-based Macs #158534

Closed
4 tasks done
jordydickinson opened this issue Dec 29, 2023 · 2 comments
Labels
bug Reproducible Homebrew/homebrew-core bug outdated PR was locked due to age stale No recent activity upstream issue An upstream issue report is needed

Comments

@jordydickinson
Copy link

brew gist-logs <formula> link OR brew config AND brew doctor output

% brew gist-logs llvm@16
Error: No logs.
% brew config
HOMEBREW_VERSION: 4.2.0
ORIGIN: https://github.com/Homebrew/brew
HEAD: ff899e5b3ff6731208564ef502db237e2627e8ba
Last commit: 11 days ago
Core tap JSON: 25 Dec 19:29 UTC
HOMEBREW_PREFIX: /opt/homebrew
HOMEBREW_CASK_OPTS: []
HOMEBREW_MAKE_JOBS: 8
Homebrew Ruby: 3.1.4 => /opt/homebrew/Library/Homebrew/vendor/portable-ruby/3.1.4/bin/ruby
CPU: octa-core 64-bit dunno
Clang: 15.0.0 build 1500
Git: 2.39.3 => /Library/Developer/CommandLineTools/usr/bin/git
Curl: 8.4.0 => /usr/bin/curl
macOS: 14.2.1-arm64
CLT: 15.1.0.0.1.1700200546
Xcode: 15.1
Rosetta 2: false
% brew doctor
Your system is ready to brew.

Verification

  • My "brew doctor output" says Your system is ready to brew. and am still able to reproduce my issue.
  • I ran brew update and am still able to reproduce my issue.
  • I have resolved all warnings from brew doctor and that did not fix my problem.
  • I searched for recent similar issues at https://github.com/Homebrew/homebrew-core/issues?q=is%3Aissue and found no duplicates.

What were you trying to do (and why)?

I was trying to use the OCaml LLVM bindings (package llvm) available via OPAM. This depends on conf-llvm which in turn depends on the Homebrew installation of llvm@16.

What happened (include all command output)?

The OPAM package fails to install (see here) due to not being able to find zstd. Moreover, /opt/homebrew/Cellar/llvm@16/16.0.6/bin/llvm-config --cflags --system-libs --ldflags --link-static --libs Core fails to provide the correct linker flags for zstd. (In particular, it is missing the flag -L/opt/homebrew/opt/zstd/lib.)

What did you expect to happen?

I expected the output of /opt/homebrew/Cellar/llvm@16/16.0.6/bin/llvm-config --cflags --system-libs --ldflags --link-static --libs Core to include the flag -L/opt/homebrew/opt/zstd/lib.

Step-by-step reproduction instructions (by running brew commands)

% brew install llvm@16
==> Downloading https://ghcr.io/v2/homebrew/core/llvm/16/manifests/16.0.6-1
Already downloaded: /Users/jordydickinson/Library/Caches/Homebrew/downloads/6d953f5e2900ae03526365fe19bb6b07931a3ff7d59b0432827a91fb42348015--llvm@16-16.0.6-1.bottle_manifest.json
==> Fetching llvm@16
==> Downloading https://ghcr.io/v2/homebrew/core/llvm/16/blobs/sha256:9bab38bfbe
Already downloaded: /Users/jordydickinson/Library/Caches/Homebrew/downloads/08c2413cfd17a6c2d04c8fe386b5c301f4dfb24d275ae55a936ff68ca2491b2a--llvm@16--16.0.6.arm64_sonoma.bottle.1.tar.gz
==> Pouring llvm@16--16.0.6.arm64_sonoma.bottle.1.tar.gz
==> Caveats
To use the bundled libc++ please add the following LDFLAGS:
  LDFLAGS="-L/opt/homebrew/opt/llvm@16/lib/c++ -Wl,-rpath,/opt/homebrew/opt/llvm@16/lib/c++"

llvm@16 is keg-only, which means it was not symlinked into /opt/homebrew,
because this is an alternate version of another formula.

If you need to have llvm@16 first in your PATH, run:
  echo 'export PATH="/opt/homebrew/opt/llvm@16/bin:$PATH"' >> ~/.zshrc

For compilers to find llvm@16 you may need to set:
  export LDFLAGS="-L/opt/homebrew/opt/llvm@16/lib"
  export CPPFLAGS="-I/opt/homebrew/opt/llvm@16/include"
==> Summary
🍺  /opt/homebrew/Cellar/llvm@16/16.0.6: 6,767 files, 1.5GB
==> Running `brew cleanup llvm@16`...
Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.
Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).
% /opt/homebrew/Cellar/llvm@16/16.0.6/bin/llvm-config --cflags --system-libs --ldflags --link-static --libs Core
-I/opt/homebrew/Cellar/llvm@16/16.0.6/include  -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
-L/opt/homebrew/Cellar/llvm@16/16.0.6/lib -Wl,-search_paths_first -Wl,-headerpad_max_install_names
-lLLVMCore -lLLVMRemarks -lLLVMBitstreamReader -lLLVMBinaryFormat -lLLVMTargetParser -lLLVMSupport -lLLVMDemangle
-lm /opt/homebrew/lib/libz3.dylib -lz -lzstd -lcurses -lxml2
@Bo98
Copy link
Member

Bo98 commented Dec 29, 2023

This is likely an upstream llvm-config issue unfortunately.

With z3 it just takes the full path: https://github.com/llvm/llvm-project/blob/64f0681e97c6046912dc0d80bc56709f72045338/llvm/lib/Support/CMakeLists.txt#L91

However with zstd it strips that down to the basename but never adds a -L to compensate anywhere: https://github.com/llvm/llvm-project/blob/64f0681e97c6046912dc0d80bc56709f72045338/llvm/lib/Support/CMakeLists.txt#L312-L323

--system-libs is just a simple wrapper that outputs that LLVMSupport LLVM_SYSTEM_LIBS property.

The comments in that file suggest the long-term ambition is to deprecate llvm-config, but that's probably tricky for your case: https://github.com/llvm/llvm-project/blob/64f0681e97c6046912dc0d80bc56709f72045338/llvm/lib/Support/CMakeLists.txt#L297-L298. llvm-config has been largely broken in various ways, particularly on macOS, for a while, e.g. llvm/llvm-project#39599. The CMake config has however always worked.

Copy link
Contributor

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

@github-actions github-actions bot added the stale No recent activity label Jan 21, 2024
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Jan 28, 2024
@github-actions github-actions bot added the outdated PR was locked due to age label Feb 28, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 28, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Reproducible Homebrew/homebrew-core bug outdated PR was locked due to age stale No recent activity upstream issue An upstream issue report is needed
Projects
None yet
Development

No branches or pull requests

2 participants