-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[cmake] Add a new flag MERGE_INTO_LLVM_DYLIB to llvm_add_library #158023
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
base: main
Are you sure you want to change the base?
Conversation
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`.
|
Which combinations of flags This seems very redundant with Is the problem that |
I've tested
Other configurations are going on.
Just dropping Treating statically linked plugins as Thus, we need a flag that behaves like |
|
Is it correct that this is supposed to fix Polly with It currently is not clear to me when
llvm-lit prints this warning when it does not find any unittest executables in the unittest build dir. |
|
I really do not like this direction. We already have the proper tools for this in CMake: Object Libraries. We should explicitly create the object library which will effectively "merge" the libraries. All of this custom scaffolding in LLVM makes it harder for newcomers to the project and prevents the use of the existing documentation from being useful. |
I fully agree, this change is adding more complexity making it harder to understand and maintain the LLVM build system. We should be instead looking for opportunities to simplify our build system by leveraging standard CMake mechanisms like object libraries which seems to be the best fit for what you're trying to achieve with this change. |
In case of dylib build (i.e.
-DLLVM_LINK_LLVM_DYLIB),add_llvm_pass_pluginwithLLVM_${plugin}_LINK_INTO_TOOLSembeds the plugin into libLLVM usingllvm_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_DYLIBtollvm_add_library, to support embedding a plugin byadd_llvm_pass_pluginwithLLVM_${plugin}_LINK_INTO_TOOLS.