Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for MinGW #190

Closed
wants to merge 11 commits into from
Prev Previous commit
Next Next commit
More MinGW exception fixes.
The test personality function that attempts to understand the structure
of the C++ exception is now correctly set up, though it is not yet
called.
davidchisnall authored and triplef committed Jul 25, 2021
commit 7327be8bd7f5895da650fb0f910003162ab9dfa4
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -326,7 +326,7 @@ if (ENABLE_OBJCXX)
list(APPEND EH_PERSONALITY_FLAGS "-fPIC")
endif ()
add_custom_command(OUTPUT eh_trampoline.s
COMMAND ${CMAKE_CXX_COMPILER} ARGS ${EH_PERSONALITY_FLAGS} -S "${CMAKE_SOURCE_DIR}/eh_trampoline.cc" -o - -fexceptions -fno-inline | sed "s/__gxx_personality_v0/test_eh_personality/g" > "${CMAKE_BINARY_DIR}/eh_trampoline.s"
COMMAND ${CMAKE_CXX_COMPILER} ARGS ${EH_PERSONALITY_FLAGS} -S "${CMAKE_SOURCE_DIR}/eh_trampoline.cc" -o - -fexceptions -fno-inline | sed "s/__gxx_personality_v0/test_eh_personality/g" | sed "s/__gxx_personality_seh0/test_eh_personality/g" > "${CMAKE_BINARY_DIR}/eh_trampoline.s"
MAIN_DEPENDENCY eh_trampoline.cc)
list(APPEND libobjc_ASM_SRCS eh_trampoline.s)
list(APPEND libobjc_CXX_SRCS objcxx_eh.cc)
10 changes: 9 additions & 1 deletion eh_personality.c
Original file line number Diff line number Diff line change
@@ -13,6 +13,7 @@

EXCEPTION_DISPOSITION _GCC_specific_handler(PEXCEPTION_RECORD, void *, PCONTEXT,
PDISPATCHER_CONTEXT, void *);
DECLARE_PERSONALITY_FUNCTION(test_eh_personality_internal);
#endif

#ifndef DEBUG_EXCEPTIONS
@@ -192,7 +193,7 @@ static void cleanup(_Unwind_Reason_Code reason, struct _Unwind_Exception *e)
*/
}

void objc_exception_rethrow(struct _Unwind_Exception *e);
OBJC_PUBLIC void objc_exception_rethrow(struct _Unwind_Exception *e);

/**
* Throws an Objective-C exception. This function is, unfortunately, used for
@@ -604,6 +605,13 @@ __gnu_objc_personality_seh0(PEXCEPTION_RECORD ms_exc, void *this_frame,
return _GCC_specific_handler(ms_exc, this_frame, ms_orig_context, ms_disp,
__gnustep_objc_personality_v0);
}
PRIVATE EXCEPTION_DISPOSITION
test_eh_personality(PEXCEPTION_RECORD ms_exc, void *this_frame,
PCONTEXT ms_orig_context, PDISPATCHER_CONTEXT ms_disp)
{
return _GCC_specific_handler(ms_exc, this_frame, ms_orig_context, ms_disp,
test_eh_personality_internal);
}
#endif

OBJC_PUBLIC id objc_begin_catch(struct _Unwind_Exception *exceptionObject)
4 changes: 4 additions & 0 deletions objcxx_eh.cc
Original file line number Diff line number Diff line change
@@ -448,7 +448,11 @@ PRIVATE void cxx_throw()
*/
extern "C"
PRIVATE
#ifdef __SEH__
BEGIN_PERSONALITY_FUNCTION(test_eh_personality_internal)
#else
BEGIN_PERSONALITY_FUNCTION(test_eh_personality)
#endif
// Don't bother with a mutex here. It doesn't matter if two threads set
// these values at the same time.
if (!done_setup)