Skip to content

[recipes] Ship libLLVM and libclang-cpp dylibs alongside the static libs#81

Open
vgvassilev wants to merge 1 commit into
compiler-research:mainfrom
vgvassilev:llvm-recipes-build-dylib
Open

[recipes] Ship libLLVM and libclang-cpp dylibs alongside the static libs#81
vgvassilev wants to merge 1 commit into
compiler-research:mainfrom
vgvassilev:llvm-recipes-build-dylib

Conversation

@vgvassilev

Copy link
Copy Markdown
Contributor

The recipes link clang as a fully-static binary, so the linker drops any TU that no in-tree caller references. clang::TypeName functions (QualTypeNames.o) are the canonical victim: nothing inside clang itself calls them, but plugins (clad, CppInterOp, ...) do, and the plugin's symbol lookup then fails at load time. apt's distribution clang doesn't have the problem because it ships the umbrella dylib.

Add LLVM_BUILD_LLVM_DYLIB / LLVM_LINK_LLVM_DYLIB / CLANG_LINK_CLANG_DYLIB to llvm-release, llvm-asan, and llvm-msan. The static archives stay in install/lib; libLLVM-N.so and libclang-cpp-N.so are shipped beside them and clang is linked against the dylib so its full symbol surface is loaded at startup. This is the layout Debian and Fedora use.

llvm-root and llvm-wasm intentionally untouched: cling expects to link statically against LLVM/Clang, and the wasm path is its own emscripten-driven shape -- both can opt in separately if needed.

@vgvassilev vgvassilev force-pushed the llvm-recipes-build-dylib branch 5 times, most recently from 0e3cfb5 to c27f9c2 Compare June 15, 2026 18:55
…ibs.

The recipes link clang as a fully-static binary, so the linker drops
any TU that no in-tree caller references. clang::TypeName functions
(QualTypeNames.o) are the canonical victim: nothing inside clang
itself calls them, but plugins (clad, CppInterOp, ...) do, and the
plugin's symbol lookup then fails at load time. apt's distribution
clang doesn't have the problem because it ships the umbrella dylib.

Add a small llvm_build.dylib_flags() helper that returns
LLVM_BUILD_LLVM_DYLIB / LLVM_LINK_LLVM_DYLIB / CLANG_LINK_CLANG_DYLIB
on Linux and macOS, and an empty list on Windows -- where
LLVM_LINK_LLVM_DYLIB is force-OFF and setting
CLANG_LINK_CLANG_DYLIB=ON then trips clang's consistency check. Call
it from llvm-release, llvm-asan, and llvm-msan. Static archives stay
in install/lib; the dylibs are shipped beside them, and clang is
linked against the dylib so its full symbol surface is loaded at
startup. This is the layout Debian and Fedora use.

llvm-root and llvm-wasm intentionally untouched: cling expects to
link statically against LLVM/Clang, and the wasm path is its own
emscripten-driven shape -- both can opt in separately if needed.
@vgvassilev vgvassilev force-pushed the llvm-recipes-build-dylib branch from c27f9c2 to 6d9a197 Compare June 15, 2026 19:07
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

Successfully merging this pull request may close these issues.

1 participant