[cfe-dev] Clang Plugins on Windows

Stephan Bergmann via cfe-dev cfe-dev at lists.llvm.org
Mon Sep 30 06:12:30 PDT 2019


On 30/09/2019 14:40, Christopher Baish via cfe-dev wrote:
> 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.

We're using such a dynamic library plugin for LibreOffice.  I can't 
remember all the details of how I got it working on Windows, but what 
probably is relevant is building LLVM/Clang with 
-DLLVM_EXPORT_SYMBOLS_FOR_PLUGINS=ON and maybe some of the options we 
pass to cl.exe (aka $(COMPILER_PLUGINS_CXX) in our makefile) when 
linking the plugin DLL at 
<https://opengrok.libreoffice.org/xref/core/compilerplugins/Makefile-clang.mk?r=db123aba#202>. 
  Maybe that helps a bit...




More information about the cfe-dev mailing list