[cfe-dev] Big Clang DLL, plug-in mechanism revision

Cédric Venet cedric.venet at laposte.net
Tue May 10 05:17:30 PDT 2011


Hi,

> 1. Plug-in registration.  The current plug-in mechanism doesn't work 
> on Windows.  Shared libraries work differently on Windows, such that 
> building a plug-in DLL on windows doesn't create a connection to the 
> plug-in registry in the libraries used in the Clang executable.  The 
> result is that in running a plug-in like the PrintFunctionNames 
> plug-in, there is no output becase the plug-in is adding an entry to a 
> registry that exists only in it's own data space.
> My solution for this was to dumb-down the registry a bit, and to have 
> the plug-in export a function to be called that creates and returns 
> the plug-in action object.

"fixing" the current implementation for dll is not to hard (I think) but 
need a little work. On would need to remove the following lines from the 
end of llvm/include/llvm/Support/Registry.h

==========
     // Since these are defined in a header file, plugins must be sure 
to export
     // these symbols.

     template <typename T, typename U>
     typename Registry<T,U>::node *Registry<T,U>::Head;

     template <typename T, typename U>
     typename Registry<T,U>::node *Registry<T,U>::Tail;

     template <typename T, typename U>
     typename Registry<T,U>::listener *Registry<T,U>::ListenerHead;

     template <typename T, typename U>
     typename Registry<T,U>::listener *Registry<T,U>::ListenerTail;
==========

and instead to instanciate them in a cpp file (or multiple file) for 
each combination of T and U used. Those files would be part of the big DLL.
I don't know how many registry exist in llvm, but probably not that 
much. Also, adding a registry is a rare occurence. greping the files for 
Registry should show the needed instanciation.

Regards,
Cédric



More information about the cfe-dev mailing list