FreeBSD AArch64 libunwind build (backtrace.c:71:7: error: no member named 'regs' in 'struct __mcontext')

Whistle

Ruhsuz Filozof
Site yetkilisi
Kurucu
Kurumsal Üye
Geliştirici
Yardımsever Üye
Mesaj
11.568
Çözümler
551
Beğeni
12.246
Puan
5.915
Ticaret Puanı
2
FreeBSD libunwind 1.6.2 sürümünü AArch64 için derleyince şöyle bir hata ile karşılaştım.
FreeBSD libunwind aarch64 build error.jpeg

Araştırmalarım sonucunda
Linkleri görebilmek için giriş yap veya kayıt ol.
belirtilen çözümü uyguladım.
Diff:
From 90023f56fa4d4093ec5839e0ce3aba4444fbcf58 Mon Sep 17 00:00:00 2001
From: Mikael Urankar <[email protected]>
Date: Wed, 16 Mar 2022 09:38:46 +0100
Subject: [PATCH] devel/libunwind: Fix build on aarch64

---
 .../files/patch-include_libunwind-aarch64.h   | 28 +++++++++++++++++++
 .../libunwind/files/patch-src_aarch64_Ginit.c | 20 +++++++++++++
 .../files/patch-src_aarch64_unwind__i.h       | 13 +++++++++
 3 files changed, 61 insertions(+)
 create mode 100644 devel/libunwind/files/patch-include_libunwind-aarch64.h
 create mode 100644 devel/libunwind/files/patch-src_aarch64_Ginit.c
 create mode 100644 devel/libunwind/files/patch-src_aarch64_unwind__i.h

diff --git a/devel/libunwind/files/patch-include_libunwind-aarch64.h b/devel/libunwind/files/patch-include_libunwind-aarch64.h
new file mode 100644
index 000000000000..b15e9f14f249
--- /dev/null
+++ b/devel/libunwind/files/patch-include_libunwind-aarch64.h
@@ -0,0 +1,28 @@
+--- include/libunwind-aarch64.h.orig    2021-12-01 00:46:39 UTC
++++ include/libunwind-aarch64.h
+@@ -226,15 +226,24 @@ typedef struct
+ #else
+ /* On AArch64, we can directly use ucontext_t as the unwind context.  */
+ typedef ucontext_t unw_tdep_context_t;
++#if defined(__FreeBSD__)
++typedef ucontext_t unw_fpsimd_context_t;
+ #endif
++#endif
+
+
+ #include "libunwind-common.h"
+ #include "libunwind-dynamic.h"
+
++#if defined(__FreeBSD__)
++#define UNW_BASE register uint64_t unw_base __asm__ ("x0") = (uint64_t) unw_ctx->uc_mcontext.mc_gpregs.gp_x[0];
++#else
++#define UNW_BASE register uint64_t unw_base __asm__ ("x0") = (uint64_t) unw_ctx->uc_mcontext.regs;
++#endif
++
+ #define unw_tdep_getcontext(uc) ({                    \
+   unw_tdep_context_t *unw_ctx = (uc);                    \
+-  register uint64_t unw_base __asm__ ("x0") = (uint64_t) unw_ctx->uc_mcontext.regs; \
++  UNW_BASE \
+   __asm__ __volatile__ (                            \
+      "stp x0, x1, [%[base], #0]\n" \
+      "stp x2, x3, [%[base], #16]\n" \
diff --git a/devel/libunwind/files/patch-src_aarch64_Ginit.c b/devel/libunwind/files/patch-src_aarch64_Ginit.c
new file mode 100644
index 000000000000..d4687b361b27
--- /dev/null
+++ b/devel/libunwind/files/patch-src_aarch64_Ginit.c
@@ -0,0 +1,20 @@
+--- src/aarch64/Ginit.c.orig    2021-11-30 17:12:31 UTC
++++ src/aarch64/Ginit.c
+@@ -47,9 +47,17 @@ static inline void *
+ uc_addr (unw_tdep_context_t *uc, int reg)
+ {
+   if (reg >= UNW_AARCH64_X0 && reg < UNW_AARCH64_V0)
++#if defined(__FreeBSD__)
++    return &uc->uc_mcontext.mc_gpregs.gp_x[reg];
++#else
+     return &uc->uc_mcontext.regs[reg];
++#endif
+   else if (reg >= UNW_AARCH64_V0 && reg <= UNW_AARCH64_V31)
++#if defined(__FreeBSD__)
++    return &GET_FPCTX(uc)->uc_mcontext.mc_fpregs.fp_q[reg - UNW_AARCH64_V0];
++#else
+     return &GET_FPCTX(uc)->vregs[reg - UNW_AARCH64_V0];
++#endif
+   else
+     return NULL;
+ }
diff --git a/devel/libunwind/files/patch-src_aarch64_unwind__i.h b/devel/libunwind/files/patch-src_aarch64_unwind__i.h
new file mode 100644
index 000000000000..aa1e8ccbc838
--- /dev/null
+++ b/devel/libunwind/files/patch-src_aarch64_unwind__i.h
@@ -0,0 +1,13 @@
+--- src/aarch64/unwind_i.h.orig    2020-04-28 15:49:14 UTC
++++ src/aarch64/unwind_i.h
+@@ -59,6 +59,10 @@ extern int aarch64_local_resume (unw_addr_space_t as,
+   } while (0)
+ #endif
+
++#if defined(__FreeBSD__)
++#define GET_FPCTX(uc) ((unw_tdep_context_t *)(&uc->uc_mcontext.mc_spare))
++#else
+ #define GET_FPCTX(uc) ((unw_fpsimd_context_t *)(&uc->uc_mcontext.__reserved))
++#endif
+
+ #endif /* unwind_i_h */
--
2.34.1

Daha sonra make komutunu girip aarch64 için libunwind'i başarıyla build edebilirsiniz.
FreeBSD libunwind aarch64 build.jpeg

Diff uygulanan dosyalar ve derlenmiş hali ektedir.
 

Dosya Eklentileri

  • libunwild-1.6.2-aarch64-freebsd-13.zip
    136 KB · Gösterim: 3
Geri
Üst