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 "") 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