From 62dee527de27d0899331ebeb0362b60cd39cfcdd Mon Sep 17 00:00:00 2001 From: Vassil Kovatchev Date: Thu, 3 May 2018 09:48:52 -0400 Subject: [PATCH] Fix failing aarch64 (ARM64) build ARM64 systems do not use ARM Exception Handling ABI (EHABI), but rather the DWARF exception handling standard. The fix turns off special ARM handling of exceptions when the target platform is ARM64. This enables builds of the codebase on ARM64 systems with standard implementation of libunwind as shipped with gcc 5+. Patch-Source: https://github.com/ponylang/ponyc/pull/2688 --- a/src/common/platform.h +++ b/src/common/platform.h @@ -170,6 +170,11 @@ */ #if defined(ARMV2) || defined(__arm__) || defined(__aarch64__) # define PLATFORM_IS_ARM +# if defined(__aarch64__) +# define PLATFORM_IS_ARM64 +# else +# define PLATFORM_IS_ARM32 +# endif #elif defined(__i386__) || defined(_M_IX86) || defined(_X86_) || \ defined(__amd64__) || defined(__x86_64__) || defined(_M_X64) || \ defined(_M_AMD64) --- a/src/libponyrt/lang/posix_except.c +++ b/src/libponyrt/lang/posix_except.c @@ -9,7 +9,7 @@ PONY_EXTERN_C_BEGIN -#ifdef PLATFORM_IS_ARM +#ifdef PLATFORM_IS_ARM32 #include #include #endif @@ -26,7 +26,7 @@ PONY_API void pony_error() { -#ifdef PLATFORM_IS_ARM +#ifdef PLATFORM_IS_ARM32 memcpy(exception.exception_class, "Pony\0\0\0\0", 8); #else exception.exception_class = 0x506F6E7900000000; // "Pony" @@ -46,7 +46,9 @@ _Unwind_SetIP(context, landing_pad); } -#ifdef PLATFORM_IS_ARM +// Switch to ARM EHABI for ARM32 devices. +// Note that this does not apply to ARM64 devices which use DWARF Exception Handling. +#ifdef PLATFORM_IS_ARM32 _Unwind_Reason_Code __gnu_unwind_frame(_Unwind_Exception*, _Unwind_Context*);