From d0cff378521a26510d80a9acfd47fa63569fcd52 Mon Sep 17 00:00:00 2001
From: Iain Sandoe <iain@sandoe.co.uk>
Date: Thu, 3 Sep 2020 19:49:39 +0100
Subject: [PATCH] Darwin, Arm64 : Darwin should use an OS call to clear caches.

The sys_icache_invalidate() function is the right one to use.

The fixes issue #17

(cherry picked from commit d425e8b9b0ac44415053104bf2db1edc018866bc)
Signed-off-by: Kirill A. Korinsky <kirill@korins.ky>
---
 gcc/config/aarch64/darwin.h | 5 +++++
 libgcc/config.host          | 1 -
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git gcc/config/aarch64/darwin.h gcc/config/aarch64/darwin.h
index b605b94f97f..c645c7df9cb 100644
--- gcc/config/aarch64/darwin.h
+++ gcc/config/aarch64/darwin.h
@@ -229,3 +229,8 @@ along with GCC; see the file COPYING3.  If not see
 
 #undef ASM_OUTPUT_DEF_FROM_DECLS
 
+#undef CLEAR_INSN_CACHE
+#define CLEAR_INSN_CACHE(beg, end)				\
+  extern void sys_icache_invalidate(void *start, size_t len);	\
+  sys_icache_invalidate ((beg), (size_t)((end)-(beg)))
+
diff --git libgcc/config.host libgcc/config.host
index dfaf5594d56..e4019e41522 100644
--- libgcc/config.host
+++ libgcc/config.host
@@ -421,7 +421,6 @@ aarch64*-*-elf | aarch64*-*-rtems*)
 	;;
 aarch64*-*darwin* | arm64*-*darwin* )
 	extra_parts="$extra_parts crtfastmath.o"
-	tmake_file="${tmake_file} ${cpu_type}/t-aarch64"
 	tmake_file="${tmake_file} ${cpu_type}/t-lse "
 	tmake_file="${tmake_file} t-crtfm"
 	# No soft float for now because our long double is DF not TF.
-- 
2.42.1

