Index: libcxx/cmake/caches/zos.cmake =================================================================== --- /dev/null +++ libcxx/cmake/caches/zos.cmake @@ -0,0 +1 @@ +set(LLVM_EXTERNAL_UNWIND_SOURCE_DIR "$ENV{LLVM_BASE}/zos-unwind" CACHE PATH "The path to the external unwind source directory.") Index: libcxxabi/CMakeLists.txt =================================================================== --- libcxxabi/CMakeLists.txt +++ libcxxabi/CMakeLists.txt @@ -130,6 +130,8 @@ result in the library being named libc++abi.x.y.dylib, along with the \ usual symlinks pointing to that.") +set(LLVM_EXTERNAL_UNWIND_SOURCE_DIR "" CACHE PATH "The path to the external unwind source directory.") + # Default to building a shared library so that the default options still test # the libc++abi that is being built. There are two problems with testing a # static libc++abi. In the case of a standalone build, the tests will link the Index: libcxxabi/src/CMakeLists.txt =================================================================== --- libcxxabi/src/CMakeLists.txt +++ libcxxabi/src/CMakeLists.txt @@ -47,6 +47,13 @@ ../include/cxxabi.h ) +if (ZOS) + list(APPEND LIBCXXABI_HEADERS + ${LLVM_EXTERNAL_UNWIND_SOURCE_DIR}/unwind.h + ) + include_directories("${LLVM_EXTERNAL_UNWIND_SOURCE_DIR}") +endif() + # Add all the headers to the project for IDEs. if (MSVC_IDE OR XCODE) # Force them all into the headers dir on MSVC, otherwise they end up at Index: libcxxabi/src/cxa_exception.cpp =================================================================== --- libcxxabi/src/cxa_exception.cpp +++ libcxxabi/src/cxa_exception.cpp @@ -436,6 +436,11 @@ ( static_cast<_Unwind_Exception*>(unwind_exception) ); + +#if defined(__MVS__) + _UnwindZOS_PopException(); +#endif + if (native_exception) { // Increment the handler count, removing the flag about being rethrown Index: libcxxabi/src/cxa_personality.cpp =================================================================== --- libcxxabi/src/cxa_personality.cpp +++ libcxxabi/src/cxa_personality.cpp @@ -613,7 +613,7 @@ results.reason = _URC_FATAL_PHASE1_ERROR; return; } - // Start scan by getting exception table address + // Start scan by getting exception table address. const uint8_t *lsda = (const uint8_t *)_Unwind_GetLanguageSpecificData(context); if (lsda == 0) { @@ -903,6 +903,8 @@ _LIBCXXABI_FUNC_VIS _Unwind_Reason_Code #ifdef __USING_SJLJ_EXCEPTIONS__ __gxx_personality_sj0 +#elif defined(__MVS__) +__zos_cxx_personality_v2 #else __gxx_personality_v0 #endif