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

John Thompson john.thompson.jtsoftware at gmail.com
Mon May 16 11:40:02 PDT 2011


Thanks, Cedric.

However, I still have the problem of how to export these members using the
VC++ __declspec(dllexport) directive.

For example, for simplicity, if I define AST_LINKAGE as follows:

#define AST_LINKAGE __declspec(dllexport)

I get the following compile results for the following permutations (showing
just the first declaration of the quadruple as an example):

1:
AST_LINKAGE template <>
llvm::Registry<clang::PluginASTAction,llvm::RegistryTraits<clang::PluginASTAction>
>::node*

llvm::Registry<clang::PluginASTAction,llvm::RegistryTraits<clang::PluginASTAction>
>::Head;

1>..\Frontend\FrontendAction.cpp(386) : warning C4091:
'__declspec(dllexport)' : ignored on left of 'int' when no variable is
declared
1>..\Frontend\FrontendAction.cpp(386) : error C2143: syntax error : missing
';' before ''template<''

2:
template <>
AST_LINKAGE
llvm::Registry<clang::PluginASTAction,llvm::RegistryTraits<clang::PluginASTAction>
>::node*

llvm::Registry<clang::PluginASTAction,llvm::RegistryTraits<clang::PluginASTAction>
>::Head;

1>..\Frontend\FrontendAction.cpp(388) : error C2370: 'Head' : redefinition;
different storage class
1>        D:\Clang\llvmdll\include\llvm/Support/Registry.h(76) : see
declaration of 'Head'

3:
template <>
llvm::Registry<clang::PluginASTAction,llvm::RegistryTraits<clang::PluginASTAction>
>::node*
  AST_LINKAGE
llvm::Registry<clang::PluginASTAction,llvm::RegistryTraits<clang::PluginASTAction>
>::Head;

1>..\Frontend\FrontendAction.cpp(388) : error C2059: syntax error :
'__declspec(dllexport)'
It seems that #2 is the likely candidate, but it conflicts with the
declaration of Head in the Registry class.

Any ideas?

Thanks.

-John

On Sat, May 14, 2011 at 2:19 AM, Cédric Venet <cedric.venet at laposte.net>wrote:

> Le 11/05/2011 22:04, John Thompson a écrit :
>
> I'm afraid I'm a bit template-dumb and don't know how to do those
>> declarations.  Every syntax combination I tried either didn't compile there,
>> or elsewhere, the latter because the exported declarations would conflict
>> with the "static node *Head, *Tail;" and "static listener *ListenerHead,
>> *ListenerTail;" definitions inside the Registry template class.  Can you
>> give me an example?
>> Template trickiness like this is why I felt a less sophisticated plug-in
>> registry mechanism would be better.  But if you can show me how to do it per
>> your suggestion, I'll give it a try.
>>
>>
> Here are patches for clang and llvm which should solve the registration
> problem. I tested them on win7 VS2010 without dll and the test are ok [1].
> Turn out there was only 3 registries, so very small code change. On linux,
> there may be some more, I didn't check. Also these patch are not commit
> quality (line length, CRLF, comment/placement of the code). However, they
> should solve your problem. Let me know if you still have undefined or
> duplicated symbol when using your dll.
>
> Thank you for tackling the dll problem on windows and hopping this make it
> into trunk sometime soon.
>
> Cédric
>
> [1] I have 3 llvm test failling and 1 clang test but it was before I made
> any change
>



-- 
John Thompson
John.Thompson.JTSoftware at gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20110516/0dce5538/attachment.html>


More information about the cfe-dev mailing list