[PATCH] D52662: [libc++] Make sure we can build libc++ with -fvisibility=hidden

Shoaib Meenai via Phabricator reviews at reviews.llvm.org
Wed Oct 3 17:40:29 PDT 2018


smeenai added a comment.

In https://reviews.llvm.org/D52662#1254561, @ldionne wrote:

> In https://reviews.llvm.org/D52662#1254545, @smeenai wrote:
>
> > In https://reviews.llvm.org/D52662#1251942, @ldionne wrote:
> >
> > > In https://reviews.llvm.org/D52662#1251867, @smeenai wrote:
> > >
> > > > In https://reviews.llvm.org/D52662#1251866, @ldionne wrote:
> > > >
> > > > > We'd need to give default visibility to the vtable and the RTTI, which requires using an attribute.
> > > >
> > > >
> > > > Isn't that what `__attribute__((type_visibility("default")))` accomplishes?
> > >
> > >
> > > The problem is that it requires applying the attribute to the class template itself as opposed to a single instantiation of it.  Unless I am wrong?
> >
> >
> > Thinking about this more, I guess you can't really have a key function for a class template anyway, since you need to define all your methods inline for clients to be able to use your class.
>
>
> You're right. I guess we _might_ be able to come up with a twisted way to achieve this with `type_visibility`, for example: declare (but not define) the key function in the template, then define it out-of-line, but add an explicit instantiation declaration of the key function for the specific instantiation of the class template we're interested in. And then apply the `type_visibility("default")` attribute to an explicit instantiation declaration of the instantiation of the class template we're interested in. IDK whether this would work, and I don't care. It's messy and too complicated, and this area of the language is already crazy enough.


Yeah, having a direct way to instantiate the vague linkage types does seem like a much better solution :)


Repository:
  rCXX libc++

https://reviews.llvm.org/D52662





More information about the libcxx-commits mailing list