From 8bee0c4a7711c9b901e8233658fce07eb9fc0fcf Mon Sep 17 00:00:00 2001
From: Iain Sandoe <iain@sandoe.co.uk>
Date: Fri, 4 Sep 2020 19:24:28 +0100
Subject: [PATCH] Darwin, Arm64 : Implement darwinpcs mangling for va_list.

The darwinpcs says this must be mangled as char * (Pc) and not
presented in the std:: namespace.

(cherry picked from commit 6ef6b24b71943beee3797be012c3cfd13a4d123a)
Signed-off-by: Kirill A. Korinsky <kirill@korins.ky>
---
 gcc/config/aarch64/aarch64.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git gcc/config/aarch64/aarch64.c gcc/config/aarch64/aarch64.c
index cc69f6ad73e..92ae9bc1f40 100644
--- gcc/config/aarch64/aarch64.c
+++ gcc/config/aarch64/aarch64.c
@@ -17869,6 +17869,12 @@ aarch64_autovectorize_vector_modes (vector_modes *modes, bool)
 static const char *
 aarch64_mangle_type (const_tree type)
 {
+  /* The darwinpcs ABI documents say that "__va_list" has to be
+     mangled as char *.  */
+  if (TARGET_MACHO
+      && lang_hooks.types_compatible_p (CONST_CAST_TREE (type), va_list_type))
+    return "Pc";
+
   /* The AArch64 ABI documents say that "__va_list" has to be
      mangled as if it is in the "std" namespace.  */
   if (lang_hooks.types_compatible_p (CONST_CAST_TREE (type), va_list_type))
-- 
2.42.1

