[LLVMdev] Explicit template instantiations in libc++

Justin Bogner mail at justinbogner.com
Thu Aug 14 10:57:49 PDT 2014


Bob Wilson <bob.wilson at apple.com> writes:
>> On Aug 12, 2014, at 2:17 PM, Justin Bogner <mail at justinbogner.com> wrote:
>> 
>> Most of libc++ doesn't have explicit template instantiations, which
>> leads to a pretty significant build time and code size cost when using
>> libc++, since a large number of common templates will be emitted by the
>> compiler and coalesced by the linker. Notably, in include/__config, we
>> have:
>> 
>>    #ifndef _LIBCPP_EXTERN_TEMPLATE
>>    #define _LIBCPP_EXTERN_TEMPLATE(...)
>>    #endif
>> 
>> whereas before r189601 this was:
>
> I think you mean r189610

Yep, typo :)

>> 
>>    #define _LIBCPP_EXTERN_TEMPLATE(...) extern template __VA_ARGS__;
>> 
>> This was apparently done to fix http://llvm.org/bugs/show_bug.cgi?id=17027,
>> but disabling explicit instantiations seems like a pretty big hammer
>> considering the drawbacks.
>> 
>> I'd like to restore these instantiations. Any thoughts on how to handle
>> things like pr17027 in a less heavy handed way?
>
> As far as I can tell, the issue in pr17027 was that we had a bug in
> libc++ and the libc++ dylib on some versions of OS X shipped with that
> bug. Disabling extern templates “fixed” that by causing the newer code
> from the headers to be used instead of the older code in the dylib on
> the system. The real solution here is to fix the bug in the dylib and
> ship a newer version. There may still be a lag in the time it takes us
> to release fixes in the dylib, but that is just the way it goes.

Alright, given this and the obvious performance difference, I think I'll
go ahead and revert r189610. I'll keep an eye out for any pr17027-like
fallout and fix them up if they come up.




More information about the llvm-dev mailing list