This is an archive of the discontinued LLVM Phabricator instance.

libcxx: Use vcruntime declarations for typeinfo on Windows.
ClosedPublic

Authored by pcc on Jan 17 2018, 5:21 PM.

Details

Summary

We need to use the vcruntime declarations on Windows to avoid an ODR
violation involving rtti.obj, which provides the definition of the runtime function
implementing dynamic_cast and depends on the vcruntime implementations of
bad_cast and bad_typeid.

Diff Detail

Repository
rCXX libc++

Event Timeline

pcc created this revision.Jan 17 2018, 5:21 PM

Is this really a "fix" or does it just hide the ODR issue?

I'd like to call attention to http://libcxxabi.llvm.org, specifically the FAQ entry: Why are the destructors for the standard exception classes defined in libc++abi? They're just empty, can't they be defined inline?

pcc added a comment.Jan 17 2018, 6:04 PM

Is this really a "fix" or does it just hide the ODR issue?

You're right, there is an ODR issue. I'll see if it can be solved by using the definitions of these classes from vcruntime_typeinfo.h on Windows. Fixing this in the case where _LIBCPP_NO_VCRUNTIME is defined seems more tricky; I'll leave the situation as is there.

I'd like to call attention to http://libcxxabi.llvm.org, specifically the FAQ entry: Why are the destructors for the standard exception classes defined in libc++abi? They're just empty, can't they be defined inline?

I have read that FAQ entry, but it doesn't seem directly applicable on Windows whose ABI uses a string comparison for type_info comparisons.

pcc updated this revision to Diff 130343.Jan 17 2018, 6:33 PM
  • Use typeinfo declarations from vcruntime
pcc retitled this revision from libcxx: Move bad_cast and bad_typeid member functions inline on Windows. to libcxx: Use vcruntime declarations for typeinfo on Windows..Jan 17 2018, 6:37 PM
pcc edited the summary of this revision. (Show Details)
compnerd accepted this revision.Jan 25 2018, 5:07 PM

I think that this is reasonable to unblock the use of libc++ with and without vcruntime headers. The one thing that I wish was slightly cleaner is not your fault.

libcxx/src/typeinfo.cpp
53 ↗(On Diff #130343)

I wish that there was a reasonable way to split this logic up.

This revision is now accepted and ready to land.Jan 25 2018, 5:07 PM
This revision was automatically updated to reflect the committed changes.