This is an archive of the discontinued LLVM Phabricator instance.

[MinGW] Fix dllexport of explicit template instantiation
ClosedPublic

Authored by mstorsjo on Apr 25 2019, 12:19 AM.

Details

Summary

Contrary to MSVC, GCC/MinGW needs to have the dllexport attribute on the template instantiation declaration, not on the definition.

Previously clang never marked explicit template instantiations as dllexport in MinGW mode, if the instantiation had a previous declaration, regardless of where the attribute was placed. This makes Clang behave like GCC in this regard, and allows using the same attribute form for both MinGW compilers.

This fixes PR40256.

Diff Detail

Repository
rL LLVM

Event Timeline

mstorsjo created this revision.Apr 25 2019, 12:19 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 25 2019, 12:19 AM

LGTM, though I'd wait for Hans and/or Reid too.

I like the GCC/MinGW behavior here much more than the MSVC behavior. Having to mark the definitions only in the explicit instantiations case (for MSVC) whereas everything else requires you to mark the declarations is a weird inconsistency.

hans accepted this revision.Apr 25 2019, 1:42 AM

Looks good to me.

This revision is now accepted and ready to land.Apr 25 2019, 1:42 AM
mstorsjo updated this revision to Diff 196704.Apr 25 2019, 12:53 PM
mstorsjo edited the summary of this revision. (Show Details)

Adjusted the patch to not warn if there is no previous declaration of the instantiation, allowing the dllexport attribute on the definition in that case.

This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptApr 26 2019, 1:08 AM