Skip to content

ci(macos): link mrbind against libclang-cpp + libLLVM dylibs#6101

Open
Fedr wants to merge 10 commits into
masterfrom
ci/macos-link-clang-cpp-dylib
Open

ci(macos): link mrbind against libclang-cpp + libLLVM dylibs#6101
Fedr wants to merge 10 commits into
masterfrom
ci/macos-link-clang-cpp-dylib

Conversation

@Fedr
Copy link
Copy Markdown
Contributor

@Fedr Fedr commented May 14, 2026

Summary

Pass -DMRBIND_LINK_CLANG_CPP_DYLIB=ON to mrbind's cmake configure in scripts/mrbind/install_mrbind_macos.sh. Bumps the thirdparty/mrbind submodule to a commit that exposes the new flag (MeshInspector/mrbind#35).

Why

mrbind's parser currently statically pulls in clangTooling on macOS (and Ubuntu, Windows-MSYS2). The resulting binary is ~30 MiB stripped. On Rocky Linux the toolchain happens to take the alternative dynamic-link branch (clang-cpp + LLVM shared libs), giving a ~5 MiB stripped binary.

Homebrew's llvm@N is built with LLVM_LINK_LLVM_DYLIB=ON, which means we can safely take the dynamic path on macOS without the LLVM ERROR: inconsistency in registered CommandLine options runtime crash that apt-clang/Ubuntu hits. MeshInspector/mrbind#35 adds an opt-in flag (MRBIND_LINK_CLANG_CPP_DYLIB) for exactly this case; this PR turns it on for macOS.

The mrbind PR ended up needing two iterations: the naive target_link_libraries(... clang-cpp ...) propagated Homebrew's INTERFACE_INCLUDE_DIRECTORIES (/opt/homebrew/opt/llvm@N/include) into mrbind's compile commands and broke libc++'s <cstddef> include chain. Final shape uses find_library to resolve to absolute lib paths, which CMake links without any usage-requirement propagation.

Files changed

Linux and Windows are not affected — they continue to take the static clangTooling path because the option defaults to OFF.

Submodule pin

thirdparty/mrbind advances from b895ca0d… to MeshInspector/mrbind#35's HEAD. Will move to a master commit once that PR merges.

Test plan

  • macOS CI passes — verified on run 25877837374. All three macOS jobs (x64 Release, arm64 Release, arm64 Debug) green; Build MRBind, Generate C bindings, and Generate and build Python bindings all succeed. No LLVM ERROR: inconsistency in registered CommandLine options and no libc++ <cstddef> failures.

  • Cache footprint drops — all three macOS runners (two GitHub-hosted, one self-hosted) repopulated at the new size:

    Runner Cache key Before After
    GitHub-hosted x64 (macos-15-intel) mrbind-build-macos-15-intel-clang 13.0 MiB 2.0 MiB
    GitHub-hosted arm64 (macos-14) mrbind-build-macos-14-clang 12.4 MiB 2.1 MiB
    Self-hosted arm64 mrbind-build-self-hosted-arm-clang 12.4 MiB 2.1 MiB
    Total macOS footprint ~38 MiB ~6 MiB

    Matches Rocky's footprint, as predicted.

mrbind#35 adds an opt-in for linking against libclang-cpp.dylib + libLLVM.dylib
instead of statically pulling in clangTooling. Homebrew's llvm@N is built with
LLVM_LINK_LLVM_DYLIB=ON, so the dynamic path is safe there (the runtime
`LLVM ERROR: inconsistency in registered CommandLine options` only fires on
apt-clang/Ubuntu where the granular libs collide).

Pass the flag in install_mrbind_macos.sh. Expected effect:
  - mrbind binary shrinks ~6x on macOS
  - per-platform cache entry for the macos-{x64,arm}-build runners drops from
    ~13 MiB to ~2 MiB, matching Rocky's already-dynamic linkage

Submodule bumped to mrbind#35 HEAD; will move to a master commit once that PR
merges.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Fedr and others added 5 commits May 14, 2026 21:10
mrbind#35 commit 7f600ed1 wraps clang-cpp / LLVM / LLVMSupport in
`$<LINK_ONLY:...>` so their INTERFACE_INCLUDE_DIRECTORIES (specifically
Homebrew's `/opt/homebrew/opt/llvm@N/include`) don't get propagated to
mrbind sources at compile time. Without that, libc++'s `<cstddef>` can't
find its own `<stddef.h>` wrapper and the build dies at the first
source file.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The $<LINK_ONLY:...> attempt didn't stop the imported-target leakage
(libc++ <cstddef> still failed). mrbind#35 now resolves clang-cpp /
LLVM / LLVMSupport via find_library and links by absolute path, which
adds them to the link line without any INTERFACE_* propagation.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
No behaviour change vs the previous pin -- mrbind#35 now reorganizes
the CMakeLists so the OFF branch keeps the original
`clangTooling`-or-fallback shape verbatim, and the new find_library
path is gated behind `MRBIND_LINK_CLANG_CPP_DYLIB=ON`.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Diagnostic step that dumps the contents of `$BREW_PREFIX/opt/llvm@$CLANG_VER/lib`
on every macOS runner, separating `.a` static archives from `.dylib` dynamic
libs. Helps confirm what each runner has installed for the dynamic-link path.
Fedr added 3 commits May 15, 2026 16:05
mrbind master switched to unconditional dynamic linking of clang-cpp + LLVM,
so the opt-in flag no longer exists. Removing the now-dead cmake arg.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant