From b2cd25658951a4d0227f56df2942fffb59e6c4cc Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bernhard=20Rosenkr=C3=A4nzer?=
 <bernhard.rosenkraenzer.ext@huawei.com>
Date: Wed, 30 Jun 2021 02:47:57 +0200
Subject: [PATCH] meta-ohos-core: Fix building bind if _Unwind_GetIP is a macro
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

bind assumes _Unwind_GetIP is a function; this is not necessarily
true, in some implementations of libunwind (e.g. arm32 version of
gcc builtin) it's a macro.

Signed-off-by: Bernhard Rosenkränzer <bernhard.rosenkraenzer.ext@huawei.com>
---
 .../bind/bind-9.11.32-libunwind-header.patch  | 32 +++++++++++++++++++
 .../recipes-connectivity/bind/bind_%.bbappend |  6 ++++
 2 files changed, 38 insertions(+)
 create mode 100644 meta-ohos-core/recipes-connectivity/bind/bind/bind-9.11.32-libunwind-header.patch
 create mode 100644 meta-ohos-core/recipes-connectivity/bind/bind_%.bbappend

diff --git a/meta-ohos-core/recipes-connectivity/bind/bind/bind-9.11.32-libunwind-header.patch b/meta-ohos-core/recipes-connectivity/bind/bind/bind-9.11.32-libunwind-header.patch
new file mode 100644
index 00000000..1f0401e0
--- /dev/null
+++ b/meta-ohos-core/recipes-connectivity/bind/bind/bind-9.11.32-libunwind-header.patch
@@ -0,0 +1,32 @@
+# SPDX-FileCopyrightText: Huawei Inc.
+#
+# SPDX-License-Identifier: Apache-2.0
+
+From bernhard.rosenkraenzer.ext@huawei.com Tue Jun 29 22:01:00 2021
+From: Bernhard Rosenkraenzer <bernhard.rosenkraenzer.ext@huawei.com>
+Date: Tue, 29 Jun 2021 22:01:00 +0100
+Subject: [PATCH] Don't assume libunwind implementation details
+
+lib/isc/backtrace.c currently assumes _Unwind_Backtrace and _Unwind_GetIP are
+implemented as functions.
+This is not always true -- some versions of libunwind (such as the 32-bit ARM
+implementation built into some versions of gcc) implement _Unwind_GetIP as a
+macro, resulting in an undefined reference to _Unwind_GetIP instead of
+expanding the macro.
+
+Signed-off-by: Bernhard Rosenkraenzer <bernhard.rosenkraenzer.ext@huawei.com>
+Upstream-Status: Pending
+
+diff -up bind-9.11.32/lib/isc/backtrace.c.omv~ bind-9.11.32/lib/isc/backtrace.c
+--- bind-9.11.32/lib/isc/backtrace.c.omv~	2021-06-29 21:39:37.700104599 +0200
++++ bind-9.11.32/lib/isc/backtrace.c	2021-06-29 21:39:59.488413798 +0200
+@@ -81,8 +81,7 @@ isc_backtrace_gettrace(void **addrs, int
+ 	return (ISC_R_SUCCESS);
+ }
+ #elif defined(BACKTRACE_GCC)
+-extern int _Unwind_Backtrace(void* fn, void* a);
+-extern void* _Unwind_GetIP(void* ctx);
++#include <unwind.h>
+ 
+ typedef struct {
+ 	void **result;
diff --git a/meta-ohos-core/recipes-connectivity/bind/bind_%.bbappend b/meta-ohos-core/recipes-connectivity/bind/bind_%.bbappend
new file mode 100644
index 00000000..040b13c4
--- /dev/null
+++ b/meta-ohos-core/recipes-connectivity/bind/bind_%.bbappend
@@ -0,0 +1,6 @@
+# SPDX-FileCopyrightText: Huawei Inc.
+#
+# SPDX-License-Identifier: Apache-2.0
+
+FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
+SRC_URI += "file://bind-9.11.32-libunwind-header.patch"
-- 
GitLab