This is an archive of the discontinued LLVM Phabricator instance.

Remove incorrect explicit instantiation declarations for valarray
ClosedPublic

Authored by rsmith on Apr 24 2019, 6:33 PM.

Details

Reviewers
EricWF
ldionne
Summary

libc++ ABI v1 provides three valarray symbols as part of the shared library:

valarray<size_t>::valarray(size_t)
valarray<size_t>::~valarray()
valarray<size_t>::resize(size_t, size_t)

The first two of these appear to be intended to be removed in V2 of the ABI: they're attributed _LIBCPP_HIDE_FROM_ABI_AFTER_V1, and looking through the commit history it appears that the intention is that these symbols from the library are not used even when building using the V1 ABI. However, there are explicit instantiation declarations for all three symbols in the header, which are wrong as we do not intend to find an instantiation of these functions that is provided elsewhere.

(A recent change to clang to properly diagnose explicit instantiation declarations of internal linkage functions -- required by [temp.explicit]p13 -- had to be rolled back because it diagnosed these explicit instantiations.)

Remove the explicit instantiation declarations, and remove the explicit instantiation definitions for V2 of the libc++ ABI onwards.

Diff Detail

Event Timeline

rsmith created this revision.Apr 24 2019, 6:33 PM
EricWF accepted this revision.Apr 24 2019, 10:42 PM
This revision is now accepted and ready to land.Apr 24 2019, 10:42 PM
ldionne accepted this revision.Apr 25 2019, 7:16 AM
ldionne added inline comments.
src/valarray.cpp
13

Can you add a comment explaining why we're doing this here?

rsmith updated this revision to Diff 196707.Apr 25 2019, 1:02 PM
rsmith marked 2 inline comments as done.
rsmith added inline comments.
src/valarray.cpp
13

Done, but I'm not sure why these are removed from the V2 ABI so I'm afraid it's a little vague.

rsmith closed this revision.Apr 25 2019, 2:29 PM

Committed as r359243.

ldionne added inline comments.Apr 25 2019, 2:50 PM
src/valarray.cpp
13

Well, they're removed because they will never be used (since there's no explicit instantiation declaration), right? My understanding is that the only reason for providing them in ABI v1 is to avoid removing symbols (and code) that already-compiled binaries might depend on, however newly compiled code will never use it. If that is incorrect, then I did not understand this patch.

rsmith added inline comments.Apr 25 2019, 3:13 PM
src/valarray.cpp
13

Well... I agree, but that doesn't really explain why we don't want these to be part of the V2 ABI, which is what I think I'd want to know as a reader of this code. (Why were these deemed suitable for inclusion in the V1 ABI but not in the V2 ABI? Why is valarray<size_t>::resize still part of the V2 ABI?)

ldionne added inline comments.Apr 30 2019, 1:07 PM
src/valarray.cpp
13

How about we remove valarray from the dylib completely in ABI v2? Is there evidence that we're gaining from including it in the dylib?