[cfe-dev] Clang Plugins on Windows

Hans Wennborg via cfe-dev cfe-dev at lists.llvm.org
Wed Oct 2 04:29:24 PDT 2019


On Mon, Sep 30, 2019 at 2:41 PM Christopher Baish via cfe-dev
<cfe-dev at lists.llvm.org> wrote:
>
> Good Afternoon All,
>
> I have written a plugin for Clang which does additional type checking around format strings. It is currently running as a plugin on Linux and macOS machines.
> We are hoping to also run it on our Windows builds, in order to boost our coverage, however I understand that the 'normal' way to use a clang plugin doesn't work on Windows.
>
> The plugin currently works via a RecursiveASTVisitor, and then having found an instance of a var-args function call runs the custom type checker.
>
> This (https://stackoverflow.com/questions/25657586/how-to-enable-dll-building-for-windows-in-llvm) implies that it would be possible to alter something in the build system to compile in the plugin library statically. This would be ideal for our use case, because we are building clang from source already, and we are only using it with the plugin, never alone.
> Unfortunately I can't find any information on how to go about statically linking the library into the main executable, or about other ways we could go about getting this working.
>
> I am more than happy to modify the existing code to a new architecture if necessary, either on all 3 OSs or just on Windows,
>
> Thanks very much for any help offered

In Chromium, we use a hack to add the plugin sources to the "clang"
CMake target, see
https://cs.chromium.org/chromium/src/tools/clang/blink_gc_plugin/CMakeLists.txt?sq=package:chromium&dr&g=0&l=31



More information about the cfe-dev mailing list