[PATCH] D55595: Share the forced linking code between clang-tidy tool and plugin
Stephen Kelly via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Dec 12 03:18:54 PST 2018
steveire added a comment.
FYI, CMake target property `INTERFACE_SOURCES` is designed to make this easy.
For each module you would generate a file containing
extern volatile int ${MODULE_NAME}ModuleAnchorSource;
static int LLVM_ATTRIBUTE_UNUSED ${MODULE_NAME}ModuleAnchorDestination =
${MODULE_NAME}ModuleAnchorSource;
and then put that generated file in the `INTERFACE_SOURCES` of each module.
target_sources(${MODULE_NAME} INTERFACE ${THE_GENERATED_FILE}.cpp)
Then, you don't need to maintain it in C++ like this. It is DRY because the `target_link_libraries` entry for the library is what causes the symbol to be used.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D55595/new/
https://reviews.llvm.org/D55595
More information about the cfe-commits
mailing list