[PATCH] D55595: [clang-tidy] Share the forced linking code between clang-tidy tool and plugin
Jonas Toth via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Dec 12 03:30:10 PST 2018
JonasToth added a comment.
In D55595#1328154 <https://reviews.llvm.org/D55595#1328154>, @steveire wrote:
> 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.
That sounds like a better solution, but i think the current pattern is common in LLVM, maybe @aaron.ballman or @alexfh could share their opinion on this one?
Repository:
rCTE Clang Tools Extra
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D55595/new/
https://reviews.llvm.org/D55595
More information about the cfe-commits
mailing list