-
Notifications
You must be signed in to change notification settings - Fork 121
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
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
e964e41
Use MSVC EH only when using MSVC.
triplef bf4bcde
Added personality function for SEH.
triplef 0f9e44c
Add MinGW to CI.
triplef 208d6e9
Use CFG only when using MSVC.
triplef 6a2e14f
Fix Win32 objc_msgSend exports for MinGW.
triplef 385a9d4
Export personality functions in DLL.
triplef cb280cf
Fix building with MinGW.
davidchisnall 7327be8
More MinGW exception fixes.
davidchisnall 3b2019c
Fix SEH ABI issues.
davidchisnall 56d6b31
CI: use MSYS2 CLANG64 environment instead of MinGW32/64
triplef 381fc79
Attempt fixing MSYS2 CLANG64 builds
triplef File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -7,6 +7,15 @@ | |||||
#include "class.h" | ||||||
#include "objcxx_eh.h" | ||||||
|
||||||
#if defined(__SEH__) && !defined(__USING_SJLJ_EXCEPTIONS__) | ||||||
#include <windows.h> | ||||||
#include <winnt.h> | ||||||
|
||||||
EXCEPTION_DISPOSITION _GCC_specific_handler(PEXCEPTION_RECORD, void *, PCONTEXT, | ||||||
PDISPATCHER_CONTEXT, void *); | ||||||
DECLARE_PERSONALITY_FUNCTION(test_eh_personality_internal); | ||||||
#endif | ||||||
|
||||||
#ifndef DEBUG_EXCEPTIONS | ||||||
#define DEBUG_LOG(...) | ||||||
#else | ||||||
|
@@ -184,14 +193,14 @@ 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 | ||||||
* rethrowing caught exceptions too, even in @finally() blocks. Unfortunately, | ||||||
* this means that we have some problems if the exception is boxed. | ||||||
*/ | ||||||
void objc_exception_throw(id object) | ||||||
OBJC_PUBLIC void objc_exception_throw(id object) | ||||||
{ | ||||||
struct thread_data *td = get_thread_data(); | ||||||
DEBUG_LOG("Throwing %p, in flight exception: %p\n", object, td->lastThrownObject); | ||||||
|
@@ -391,7 +400,10 @@ static inline _Unwind_Reason_Code internal_objc_personality(int version, | |||||
#ifndef NO_OBJCXX | ||||||
if (cxx_exception_class == 0) | ||||||
{ | ||||||
#ifndef __SEH__ | ||||||
// FIXME: This is currently broken with MinGW | ||||||
test_cxx_eh_implementation(); | ||||||
#endif | ||||||
} | ||||||
|
||||||
if (exceptionClass == cxx_exception_class) | ||||||
|
@@ -535,25 +547,29 @@ static inline _Unwind_Reason_Code internal_objc_personality(int version, | |||||
} | ||||||
} | ||||||
|
||||||
_Unwind_SetIP(context, (unsigned long)action.landing_pad); | ||||||
_Unwind_SetIP(context, (uintptr_t)action.landing_pad); | ||||||
_Unwind_SetGR(context, __builtin_eh_return_data_regno(0), | ||||||
(unsigned long)(isNew ? exceptionObject : object)); | ||||||
(uintptr_t)(isNew ? exceptionObject : object)); | ||||||
_Unwind_SetGR(context, __builtin_eh_return_data_regno(1), selector); | ||||||
|
||||||
DEBUG_LOG("Installing context, selector %d\n", (int)selector); | ||||||
get_thread_data()->cxxCaughtException = NO; | ||||||
return _URC_INSTALL_CONTEXT; | ||||||
} | ||||||
|
||||||
OBJC_PUBLIC | ||||||
BEGIN_PERSONALITY_FUNCTION(__gnu_objc_personality_v0) | ||||||
return internal_objc_personality(version, actions, exceptionClass, | ||||||
exceptionObject, context, NO); | ||||||
} | ||||||
|
||||||
OBJC_PUBLIC | ||||||
BEGIN_PERSONALITY_FUNCTION(__gnustep_objc_personality_v0) | ||||||
return internal_objc_personality(version, actions, exceptionClass, | ||||||
exceptionObject, context, YES); | ||||||
} | ||||||
|
||||||
OBJC_PUBLIC | ||||||
BEGIN_PERSONALITY_FUNCTION(__gnustep_objcxx_personality_v0) | ||||||
#ifndef NO_OBJCXX | ||||||
if (cxx_exception_class == 0) | ||||||
|
@@ -569,11 +585,11 @@ BEGIN_PERSONALITY_FUNCTION(__gnustep_objcxx_personality_v0) | |||||
} | ||||||
// We now have two copies of the _Unwind_Exception object (which stores | ||||||
// state for the unwinder) in flight. Make sure that they're in sync. | ||||||
COPY_EXCEPTION(ex->cxx_exception, exceptionObject) | ||||||
COPY_EXCEPTION(ex->cxx_exception, exceptionObject); | ||||||
exceptionObject = ex->cxx_exception; | ||||||
exceptionClass = cxx_exception_class; | ||||||
int ret = CALL_PERSONALITY_FUNCTION(__gxx_personality_v0); | ||||||
COPY_EXCEPTION(exceptionObject, ex->cxx_exception) | ||||||
COPY_EXCEPTION(exceptionObject, ex->cxx_exception); | ||||||
if (ret == _URC_INSTALL_CONTEXT) | ||||||
{ | ||||||
get_thread_data()->cxxCaughtException = YES; | ||||||
|
@@ -584,7 +600,24 @@ BEGIN_PERSONALITY_FUNCTION(__gnustep_objcxx_personality_v0) | |||||
return CALL_PERSONALITY_FUNCTION(__gxx_personality_v0); | ||||||
} | ||||||
|
||||||
id objc_begin_catch(struct _Unwind_Exception *exceptionObject) | ||||||
#if defined(__SEH__) && !defined(__USING_SJLJ_EXCEPTIONS__) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
OBJC_PUBLIC EXCEPTION_DISPOSITION | ||||||
__gnu_objc_personality_seh0(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, | ||||||
__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) | ||||||
{ | ||||||
struct thread_data *td = get_thread_data(); | ||||||
DEBUG_LOG("Beginning catch %p\n", exceptionObject); | ||||||
|
@@ -656,7 +689,7 @@ id objc_begin_catch(struct _Unwind_Exception *exceptionObject) | |||||
return (id)((char*)exceptionObject + sizeof(struct _Unwind_Exception)); | ||||||
} | ||||||
|
||||||
void objc_end_catch(void) | ||||||
OBJC_PUBLIC void objc_end_catch(void) | ||||||
{ | ||||||
struct thread_data *td = get_thread_data_fast(); | ||||||
// If this is a boxed foreign exception then the boxing class is | ||||||
|
@@ -702,7 +735,7 @@ void objc_end_catch(void) | |||||
} | ||||||
} | ||||||
|
||||||
void objc_exception_rethrow(struct _Unwind_Exception *e) | ||||||
OBJC_PUBLIC void objc_exception_rethrow(struct _Unwind_Exception *e) | ||||||
{ | ||||||
struct thread_data *td = get_thread_data_fast(); | ||||||
// If this is an Objective-C exception, then | ||||||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The second of these is never defined.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I copied those lines from libcxxabi, but I’d be fine with removing that second check if we can’t come up with a reason for having it.