Skip to content

[Comgr] Select static LLVM components independently of LLVM's default linkage - #3915

Open
martin-luecke wants to merge 1 commit into
amd-stagingfrom
users/mluecke/comgr-static-closure-2927
Open

[Comgr] Select static LLVM components independently of LLVM's default linkage#3915
martin-luecke wants to merge 1 commit into
amd-stagingfrom
users/mluecke/comgr-static-closure-2927

Conversation

@martin-luecke

Copy link
Copy Markdown

When LLVM is configured to link consumers against libLLVM, the exported Clang and LLD static targets still carry libLLVM in their link interfaces. Changing LLVM_LINK_LLVM_DYLIB later in COMGR therefore cannot produce a complete static compiler closure.

Teach llvm_add_library to expose a consumer-selectable static component interface alongside the normal libLLVM interface. COMGR_STATIC_LLVM selects that interface for the shared amd_comgr target and records COMGR's effective LLVM and Clang linkage without mutating package-wide variables. Normal LLVM, Clang, and LLD consumers retain their configured dylib linkage, while shared COMGR embeds the required LLVM, Clang, and LLD archives without depending on libLLVM or libclang-cpp.

I verified build-tree and installed-package consumption, the default dylib-linked COMGR configuration, a TheRock-equivalent configuration, and integration with #3720. The resulting libamd_comgr.so loads directly, exports only the COMGR API, and has no libLLVM or libclang-cpp DT_NEEDED entries or unresolved LLVM, Clang, or LLD symbols.

Addresses #2927.

@github-actions github-actions Bot added the comgr Related to Code Object Manager label Aug 14, 2026
@martin-luecke
martin-luecke force-pushed the users/mluecke/comgr-static-closure-2927 branch from 22249e4 to 2499e97 Compare August 14, 2026 12:02
Add a consumer-selectable static LLVM component interface to static libraries created through add_llvm_library, while direct llvm_add_library users opt in. Consumers that do not select it keep their configured libLLVM linkage. Clang and LLD opt in through their library helpers because they call llvm_add_library directly.

Have COMGR_STATIC_LLVM select this interface on the final shared library and capture COMGR's effective LLVM and Clang linkage independently of repeated package discovery. This embeds the complete static LLVM, Clang, and LLD closure, including external libraries built through add_llvm_library, without changing the producer-wide default for other consumers.

This addresses #2927.
@martin-luecke
martin-luecke force-pushed the users/mluecke/comgr-static-closure-2927 branch from 2499e97 to fc38256 Compare August 14, 2026 16:45

@lamb-j lamb-j left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The LLVM side changes need to go upstream

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comgr Related to Code Object Manager

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants