This is an archive of the discontinued LLVM Phabricator instance.

[libc++abi] fix compilation in C++17 mode
ClosedPublic

Authored by rsmith on Feb 6 2018, 3:05 PM.

Details

Summary

C++17 removes std::unexpected_handler, but libc++abi needs it to define __cxa_exception. When building against libc++, this is easily rectified by telling libc++ we're building the library. We already do this in the other places where we need these symbols.

Diff Detail

Repository
rL LLVM

Event Timeline

rsmith created this revision.Feb 6 2018, 3:05 PM

I'm fine with this, though I wonder if using the more specific _LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS might be a better thing to define.

EricWF accepted this revision.Feb 7 2018, 2:20 PM

I agree with Marshall. This should define _LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS instead of _LIBCPP_BUILDING_LIBRARY. Other than that, this LGTM.

This revision is now accepted and ready to land.Feb 7 2018, 2:20 PM
rsmith added a comment.Feb 7 2018, 3:21 PM

I defined _LIBCPP_BUILDING_LIBRARY instead to match the existing code in libc++abi (stdlib_exception.cpp, stdlib_new_delete.cpp), which uses the _BUILDING_LIBRARY macro as a general way to say "give me all the symbols because I'm building the library". That seemed to match the semantics of this code better than a macro whose purpose is "I am writing user code that is still using this removed symbol".

But I don't really care. If you two prefer the other macro, that's fine with me :)

(Would there be any interest in a patch that just unconditionally defines _LIBCPP_BUILDING_LIBRARY throughout the libc++abi compilation instead of this change?)

This revision was automatically updated to reflect the committed changes.
EricWF added a comment.Feb 8 2018, 1:04 AM

@rsmith. Sorry, you're right. I didn't notice that we already used _LIBCPP_BUILDING_LIBRARY in libc++abi. I wasn't sure if _BUILDING_LIBRARY changed the linkage or of any symbols, or changed their explicit instantiation.
And, indeed, on Windows there's a problem with DLL import/export macros. I'll fix and cleanup the usage of _BUILDING_LIBRARY in the next couple days.