Skip to content

Conversation

kikairoya
Copy link
Contributor

In case of dylib build (i.e. -DLLVM_LINK_LLVM_DYLIB), add_llvm_pass_plugin with LLVM_${plugin}_LINK_INTO_TOOLS embeds the plugin into libLLVM using llvm_add_library(... DISABLE_LLVM_LINK_LLVM_DYLIB ...), which enables preprocessor macro -DLLVM_BUILD_STATIC.
This definition is correct for a library or an executable which is built on top of libLLVM, but wrong for a plugin which is embedded into libLLVM.

This patch adds a new flag MERGE_INTO_LLVM_DYLIB to llvm_add_library, to support embedding a plugin by add_llvm_pass_plugin with LLVM_${plugin}_LINK_INTO_TOOLS.

In case of dylib build (i.e. `-DLLVM_LINK_LLVM_DYLIB`), `add_llvm_pass_plugin`
with `LLVM_${plugin}_LINK_INTO_TOOLS` embeds the plugin into libLLVM using
`llvm_add_library(... DISABLE_LLVM_LINK_LLVM_DYLIB ...)`, which enables
preprocessor macro `-DLLVM_BUILD_STATIC`.
This definition is correct for a library or an executable which is built on top
of libLLVM, but wrong for a plugin which is embedded into libLLVM.

This patch adds a new flag `MERGE_INTO_LLVM_DYLIB` to `llvm_add_library`, to
support embedding a plugin by `add_llvm_pass_plugin` with
`LLVM_${plugin}_LINK_INTO_TOOLS`.
@llvmbot llvmbot added the cmake Build system in general and CMake in particular label Sep 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cmake Build system in general and CMake in particular

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants