MSYS2: Export forwarders for __cxa_begin_catch
, __cxa_end_catch
, __cxa_rethrow
and __gxx_personality_seh0
#3
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.
libobjc2 uses native C++ exceptions on MinGW. The clang compiler will emit references to
__cxa_begin_catch
,__cxa_end_catch
,__cxa_rethrow
and__gxx_personality_seh0
for Objective C code which uses Objective C exceptions.These symbols are defined in the C++ runtime, not in libobjc2. As a result, merely linking with libobjc2 is not sufficient. Objective C code such as GNUstep must be compiled with the
LDFLAGS="-lgcc_s -lstdc++"
orLDFLAGS="-lc++"
, depending on the environment.This is tedious. Additionally, specifying
-lc++
on the msys/clang64 environment causes linker errors:A similar error has been observed for other libraries
A solution for this is to define forwarding exports for
__cxa_begin_catch
,__cxa_end_catch
,__cxa_rethrow
and__gxx_personality_seh0
. This is implemented by adding aeh_forwards.def
file to the list of libobjc2 source files, which forwards the symbols to the actual C++ runtime. On MSYS2, the libstdc++ and libc++ runtimes are supported, which covers all MinGW environments: https://www.msys2.org/docs/environments/.Forwarding exports are discussed here: