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@19 links against wrong libc++ library version #925

Closed
2 tasks done
ibis-hdl opened this issue Jan 6, 2025 · 1 comment
Closed
2 tasks done

llvm@19 links against wrong libc++ library version #925

ibis-hdl opened this issue Jan 6, 2025 · 1 comment

Comments

@ibis-hdl
Copy link

ibis-hdl commented Jan 6, 2025

  • your problem was from running the official install or uninstall script?
  • after installation: ran brew config and brew doctor and included their output with your issue? If you couldn't install: provided your OS version with the output of your issue?
------------- brew configbrew doctor ------------
HOMEBREW_VERSION: 4.4.15
ORIGIN: https://github.com/Homebrew/brew
HEAD: b6fafba4864d65acabf966415e14b2dd86d81e1a
Last commit: 33 hours ago
Branch: stable
Core tap JSON: 06 Jan 11:30 UTC
Core cask tap JSON: 06 Jan 11:30 UTC
HOMEBREW_PREFIX: /opt/homebrew
HOMEBREW_CASK_OPTS: ["--no-quarantine"]
HOMEBREW_COLOR: set
HOMEBREW_MAKE_JOBS: 3
HOMEBREW_NO_AUTO_UPDATE: set
HOMEBREW_NO_INSTALL_CLEANUP: set
Homebrew Ruby: 3.3.6 => /opt/homebrew/Library/Homebrew/vendor/portable-ruby/3.3.6/bin/ruby
CPU: 3-core 64-bit dunno
Clang: 16.0.0 build 1600
Git: 2.47.1 => /opt/homebrew/bin/git
Curl: 8.7.1 => /usr/bin/curl
macOS: 15.2-arm64
CLT: 16.2.0.0.1.1733547573
Xcode: 16.0 => /Applications/Xcode_16.app/Contents/Developer
Rosetta 2: false
---
Your system is ready to brew.

What you were trying to do (and why)

I'm using clang-19 on Github's macos-15 runner, installed by homebrew by:

  brew update
  brew install ninja llvm@19
  echo "$(brew --prefix llvm@19)/bin" >> $GITHUB_PATH

The image has pre-installed clang-18, also via homebrew, see Readme. My CMake Project uses clang++ 19 and is linked against libc++, but if I check the linked lib I see:

What happened (include command output)

$ otool -L .../gha-clang19
...
    /usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 1800.101.0)
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1351.0.0)

I would expect libc++.1.dylib (... current version 190106). Did something went wrong at CMake's configure time?

What you expected to happen

Linked against the right libc++

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

Compile main.cpp with e.g.

std::cout << std::format("LibC++ {:d}\n", _LIBCPP_VERSION);

and run the binary, which shows

LibC++ 190106

So obviously the header version is correct, but isn't linked correctly.

I added ~/.config/clang file with:

# See note on brew install llvm@19
-I/opt/homebrew/opt/llvm/include
-L/opt/homebrew/opt/llvm/lib/c++
-L/opt/homebrew/opt/llvm/lib/unwind -lunwind

On CMake's side, additionally I configured as shown from brew install llvm@19, using CMake's inherited preset

        {
            "name": "settings-stdlib-libc++",
            "cacheVariables": {
                "CMAKE_CXX_FLAGS_INIT": "-stdlib=libc++ -I/opt/homebrew/opt/llvm/include",
                "CMAKE_EXE_LINKER_FLAGS_INIT": "-stdlib=libc++ -L/opt/homebrew/opt/llvm/lib",
                "CMAKE_SHARED_LINKER_FLAGS_INIT": "-stdlib=libc++ -L/opt/homebrew/opt/llvm/lib"
            }
        },
...
        {
            "name": "compiler-clang-libc++",
            "inherits": [ "settings-stdlib-libc++" ],
            "cacheVariables": {
                "CMAKE_C_COMPILER": "clang",
                "CMAKE_CXX_COMPILER": "clang++"
            }
        }
...
        {
            "name": "clang-libc++",
            "inherits": [
                "compiler-clang-libc++",
                "condition-linux-or-macos",
                ...
            ]
        },

The complete (to clang-19 reduced/related) project (also devcontainer / Linux) can be found here.

@MikeMcQuaid
Copy link
Member

Please repost this in Homebrew discussions. This definitely isn't a Homebrew/install issue and it's not clear that it's a Homebrew issue at all.

@MikeMcQuaid MikeMcQuaid closed this as not planned Won't fix, can't repro, duplicate, stale Jan 6, 2025
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

2 participants