aboutsummaryrefslogtreecommitdiffstats
path: root/testing/ponyc/fix-aarch64.patch
blob: e8680cba09de68132bea2903bf9e4b1d78969375 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
From 62dee527de27d0899331ebeb0362b60cd39cfcdd Mon Sep 17 00:00:00 2001
From: Vassil Kovatchev <vkovatchev@deloitte.com>
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 <string.h>
 #include <stdio.h>
 #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*);