This is an archive of the discontinued LLVM Phabricator instance.

Explicitly enumerate std::string external instantiations.
AbandonedPublic

Authored by EricWF on Nov 15 2019, 12:47 PM.

Details

Summary

The external instantiation of std::string is a problem for libc++.

Additions and removals of inline functions in string can cause ABI
breakages, including introducing new symbols.

This patch aims to:
  (1) Make clear which functions are explicitly instatiated.
  (2) Prevent new functions from being accidentally instantiated.
  (3) Allow a migration path for adding or removing functions from the
  explicit instantiation over time.

Although this new formulation is uglier, it is preferable from a
maintainability and readability standpoint because it explicitly
enumerates the functions we've chosen to expose in our ABI. Changing
this list is non-trivial and requires thought and planning.

(3) is achieved by making it possible to control the extern template declaration
separately from it's definition. Meaning we could add a new definition to
the dylib, wait for it to roll out, then add the extern template
declaration to the header. Similarly, we could remove existing extern
template declarations while still keeping the definition to prevent ABI
breakages.

Diff Detail

Event Timeline

EricWF created this revision.Nov 15 2019, 12:47 PM
ldionne accepted this revision.Nov 18 2019, 9:56 AM

I love this. It's more verbose but it also gives us more explicit control over our ABI list, which is great. We'll run into problems when wanting to explicitly instantiate the vtable of types that have one (if we eventually generalize this approach to other types). This is one of the reasons why I wrote http://wg21.link/p1263. However, none of this is needed for just std::string.

This revision is now accepted and ready to land.Nov 18 2019, 9:56 AM
EricWF updated this revision to Diff 237162.Jan 9 2020, 12:50 PM

Update and merge with master.

I'll be committing this shortly.

I think we went ahead with this approach in a different patch, didn't we? If so, can this be closed to clean up the review queue?

EricWF abandoned this revision.Mar 11 2020, 2:38 PM