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.
Details
Diff Detail
- Repository
- rL LLVM
Event Timeline
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.
I agree with Marshall. This should define _LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS instead of _LIBCPP_BUILDING_LIBRARY. Other than that, this LGTM.
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?)
@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.