Index: head/devel/libcxxrt/Makefile =================================================================== --- head/devel/libcxxrt/Makefile (revision 416216) +++ head/devel/libcxxrt/Makefile (revision 416217) @@ -1,26 +1,27 @@ # $FreeBSD$ PORTNAME= libcxxrt PORTVERSION= 20131225 -PORTREVISION= 2 +PORTREVISION= 3 CATEGORIES= devel MAINTAINER= mokhi64@gmail.com COMMENT= Implementation of the Code Sourcery C++ ABI LICENSE= BSD2CLAUSE USE_GITHUB= yes GH_ACCOUNT= pathscale GH_TAGNAME= 2f150a6 USES= cmake compiler:c++11-lang +USE_LDCONFIG= yes CXXFLAGS+= -nostdlib do-install: ${INSTALL_LIB} ${WRKSRC}/lib/libcxxrt.so ${STAGEDIR}${PREFIX}/lib ${INSTALL_DATA} ${WRKSRC}/lib/libcxxrt.a ${STAGEDIR}${PREFIX}/lib @${MKDIR} ${STAGEDIR}${PREFIX}/include/cxxrt ${INSTALL_DATA} ${WRKSRC}/src/*.h ${STAGEDIR}${PREFIX}/include/cxxrt .include Index: head/devel/libcxxrt/files/patch-src_exception.cc =================================================================== --- head/devel/libcxxrt/files/patch-src_exception.cc (nonexistent) +++ head/devel/libcxxrt/files/patch-src_exception.cc (revision 416217) @@ -0,0 +1,48 @@ +--- src/exception.cc.orig 2013-12-26 03:11:27 UTC ++++ src/exception.cc +@@ -304,13 +304,17 @@ static pthread_key_t eh_key; + static void exception_cleanup(_Unwind_Reason_Code reason, + struct _Unwind_Exception *ex) + { +- __cxa_free_exception(static_cast(ex)); ++ // Exception layout: ++ // [__cxa_exception [_Unwind_Exception]] [exception object] ++ // ++ // __cxa_free_exception expects a pointer to the exception object ++ __cxa_free_exception(static_cast(ex + 1)); + } + static void dependent_exception_cleanup(_Unwind_Reason_Code reason, + struct _Unwind_Exception *ex) + { + +- __cxa_free_dependent_exception(static_cast(ex)); ++ __cxa_free_dependent_exception(static_cast(ex + 1)); + } + + /** +@@ -340,7 +344,8 @@ static void thread_cleanup(void* thread_ + if (info->foreign_exception_state != __cxa_thread_info::none) + { + _Unwind_Exception *e = reinterpret_cast<_Unwind_Exception*>(info->globals.caughtExceptions); +- e->exception_cleanup(_URC_FOREIGN_EXCEPTION_CAUGHT, e); ++ if (e->exception_cleanup) ++ e->exception_cleanup(_URC_FOREIGN_EXCEPTION_CAUGHT, e); + } + else + { +@@ -1270,12 +1275,13 @@ extern "C" void __cxa_end_catch() + + if (ti->foreign_exception_state != __cxa_thread_info::none) + { +- globals->caughtExceptions = 0; + if (ti->foreign_exception_state != __cxa_thread_info::rethrown) + { + _Unwind_Exception *e = reinterpret_cast<_Unwind_Exception*>(ti->globals.caughtExceptions); +- e->exception_cleanup(_URC_FOREIGN_EXCEPTION_CAUGHT, e); ++ if (e->exception_cleanup) ++ e->exception_cleanup(_URC_FOREIGN_EXCEPTION_CAUGHT, e); + } ++ globals->caughtExceptions = 0; + ti->foreign_exception_state = __cxa_thread_info::none; + return; + } Property changes on: head/devel/libcxxrt/files/patch-src_exception.cc ___________________________________________________________________ Added: fbsd:nokeywords ## -0,0 +1 ## +yes \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: head/devel/libcxxrt/files/patch-test_CMakeLists.txt =================================================================== --- head/devel/libcxxrt/files/patch-test_CMakeLists.txt (nonexistent) +++ head/devel/libcxxrt/files/patch-test_CMakeLists.txt (revision 416217) @@ -0,0 +1,24 @@ +--- test/CMakeLists.txt.orig 2013-12-26 03:11:27 UTC ++++ test/CMakeLists.txt +@@ -23,6 +23,11 @@ add_executable(cxxrt-test-shared ${CXXTE + set_property(TARGET cxxrt-test-shared PROPERTY LINK_FLAGS -nodefaultlibs) + target_link_libraries(cxxrt-test-shared cxxrt-shared pthread dl c) + ++include_directories(${CMAKE_SOURCE_DIR}/src) ++add_executable(cxxrt-test-foreign-exceptions test_foreign_exceptions.cc) ++set_property(TARGET cxxrt-test-foreign-exceptions PROPERTY LINK_FLAGS "-nodefaultlibs -Wl,--wrap,_Unwind_RaiseException") ++target_link_libraries(cxxrt-test-foreign-exceptions cxxrt-static gcc_s pthread dl c) ++ + add_test(cxxrt-test-static-test + ${CMAKE_CURRENT_SOURCE_DIR}/run_test.sh + ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/cxxrt-test-static +@@ -35,6 +40,9 @@ add_test(cxxrt-test-shared-test + ${CMAKE_CURRENT_BINARY_DIR}/expected_output.log + ${CMAKE_CURRENT_BINARY_DIR}/test-shared-output.log) + ++add_test(cxxrt-test-foreign-exceptions ++ ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/cxxrt-test-foreign-exceptions) ++ + set(valgrind "valgrind -q") + + if(TEST_VALGRIND) Property changes on: head/devel/libcxxrt/files/patch-test_CMakeLists.txt ___________________________________________________________________ Added: fbsd:nokeywords ## -0,0 +1 ## +yes \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: head/devel/libcxxrt/files/patch-test_test__foreign__exceptions.cc =================================================================== --- head/devel/libcxxrt/files/patch-test_test__foreign__exceptions.cc (nonexistent) +++ head/devel/libcxxrt/files/patch-test_test__foreign__exceptions.cc (revision 416217) @@ -0,0 +1,128 @@ +--- test/test_foreign_exceptions.cc.orig 2016-05-29 13:30:15 UTC ++++ test/test_foreign_exceptions.cc +@@ -0,0 +1,125 @@ ++#include ++#include ++#include "unwind.h" ++ ++#define EXCEPTION_CLASS(a,b,c,d,e,f,g,h) \ ++ ((static_cast(a) << 56) +\ ++ (static_cast(b) << 48) +\ ++ (static_cast(c) << 40) +\ ++ (static_cast(d) << 32) +\ ++ (static_cast(e) << 24) +\ ++ (static_cast(f) << 16) +\ ++ (static_cast(g) << 8) +\ ++ (static_cast(h))) ++ ++// using ld --wrap=_Unwind_RaiseException hook feature ++extern "C" _Unwind_Reason_Code __real__Unwind_RaiseException (_Unwind_Exception *e); ++extern "C" _Unwind_Reason_Code __wrap__Unwind_RaiseException (_Unwind_Exception *e); ++ ++extern "C" _Unwind_Reason_Code __wrap__Unwind_RaiseException (_Unwind_Exception *e) ++{ ++ // clobber exception class forcing libcxx own exceptions to be treated ++ // as foreign exception within libcxx itself ++ e->exception_class = EXCEPTION_CLASS('F','O','R','E','I','G','N','\0'); ++ __real__Unwind_RaiseException(e); ++} ++ ++_Unwind_Exception global_e; ++ ++enum test_status { ++ PENDING, PASSED, FAILED ++}; ++ ++const char test_status_str[][8] = { ++ "PENDING", "PASSED", "FAILED" ++}; ++ ++test_status test1_status = PENDING; ++test_status test2_status = PENDING; ++test_status test3_status = PENDING; ++ ++void test2_exception_cleanup(_Unwind_Reason_Code code, _Unwind_Exception *e) ++{ ++ fputs("(2) exception_cleanup called\n", stderr); ++ if (e != &global_e) { ++ fprintf(stderr, "(2) ERROR: unexpected ptr: expecting %p, got %p\n", &global_e, e); ++ test2_status = FAILED; ++ } ++ if (test2_status == PENDING) ++ test2_status = PASSED; ++} ++ ++struct test3_exception ++{ ++ static int counter; ++ ~test3_exception() ++ { ++ counter++; ++ fputs("(3) exception dtor\n", stderr); ++ } ++}; ++int test3_exception::counter = 0; ++ ++int main() ++{ ++ /////////////////////////////////////////////////////////////// ++ fputs("(1) foreign exception, exception_cleanup=nullptr\n", stderr); ++ try ++ { ++ global_e.exception_class = 0; ++ global_e.exception_cleanup = 0; ++ __real__Unwind_RaiseException(&global_e); ++ } ++ catch (...) ++ { ++ } ++ test1_status = PASSED; ++ fputs("(1) PASS\n", stderr); ++ ++ /////////////////////////////////////////////////////////////// ++ fputs("(2) foreign exception, exception_cleanup present\n", stderr); ++ try ++ { ++ global_e.exception_class = 0; ++ global_e.exception_cleanup = test2_exception_cleanup; ++ __real__Unwind_RaiseException(&global_e); ++ } ++ catch (...) ++ { ++ } ++ fprintf(stderr, "(2) %s\n", test_status_str[test2_status]); ++ ++ /////////////////////////////////////////////////////////////// ++ fputs("(3) C++ exception in foreign environment\n", stderr); ++ int counter_expected; ++ try ++ { ++ // throw was rigged such that the runtime treats C++ exceptions ++ // as foreign ones ++ throw test3_exception(); ++ } ++ catch (test3_exception&) ++ { ++ fputs("(3) ERROR: wrong catch\n", stderr); ++ test3_status = FAILED; ++ } ++ catch (...) ++ { ++ fputs("(3) catch(...)\n", stderr); ++ counter_expected = test3_exception::counter + 1; ++ // one more dtor immediately after we leave catch ++ } ++ if (test3_status == PENDING && test3_exception::counter != counter_expected) { ++ fputs("(3) ERROR: exception dtor didn't run\n", stderr); ++ test3_status = FAILED; ++ } ++ if (test3_status == PENDING) ++ test3_status = PASSED; ++ fprintf(stderr, "(3) %s\n", test_status_str[test3_status]); ++ ++ /////////////////////////////////////////////////////////////// ++ if (test1_status == PASSED && test2_status == PASSED && test3_status == PASSED) ++ return EXIT_SUCCESS; ++ else ++ return EXIT_FAILURE; ++} Property changes on: head/devel/libcxxrt/files/patch-test_test__foreign__exceptions.cc ___________________________________________________________________ Added: fbsd:nokeywords ## -0,0 +1 ## +yes \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: head/devel/libcxxrt/pkg-descr =================================================================== --- head/devel/libcxxrt/pkg-descr (revision 416216) +++ head/devel/libcxxrt/pkg-descr (revision 416217) @@ -1,8 +1,8 @@ This library implements the Code Sourcery C++ ABI, as documented here: -http://www.codesourcery.com/public/cxx-abi/abi.html +WWW: http://www.codesourcery.com/public/cxx-abi/abi.html It is intended to sit below an STL implementation, and provide features required by the compiler for implementation of the C++ language. WWW: https://github.com/pathscale/libcxxrt