Bug 233664 - enable LLVM libunwind for armv7, armv6, arm
Summary: enable LLVM libunwind for armv7, armv6, arm
Status: New
Alias: None
Product: Base System
Classification: Unclassified
Component: misc (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Only Me
Assignee: freebsd-toolchain mailing list
Depends on:
Blocks: 233094
  Show dependency treegraph
Reported: 2018-11-30 13:57 UTC by Ed Maste
Modified: 2019-07-29 17:20 UTC (History)
1 user (show)

See Also:


Note You need to log in before you can comment on or make changes to this bug.
Description Ed Maste freebsd_committer 2018-11-30 13:57:25 UTC
arm currently uses Clang and LLD, but LLVM_LIBUNWIND is not enabled.

For armv7 there are a couple of minor conflicts with other unwind helpers, and we need to update the symbol version map.  The hack below gets it to build, but needs to be cleaned up.

arm and armv6 fail with:
/.../arm.arm/tmp/usr/lib/libcxxrt.so: undefined reference to `__gnu_unwind_frame@GCC_3.5'
/.../arm.arm/tmp/usr/lib/libcxxrt.so: undefined reference to `_Unwind_VRS_Set@GCC_3.5'
/.../arm.arm/tmp/usr/lib/libcxxrt.so: undefined reference to `_Unwind_VRS_Get@GCC_3.5'

armv7 hack patch:

diff --git a/contrib/compiler-rt/lib/builtins/gcc_personality_v0.c b/contrib/compiler-rt/lib/builtins/gcc_personality_v0.c
index 0bc765624564..034d323814c4 100644
--- a/contrib/compiler-rt/lib/builtins/gcc_personality_v0.c
+++ b/contrib/compiler-rt/lib/builtins/gcc_personality_v0.c
@@ -145,6 +145,7 @@ static uintptr_t readEncodedPointer(const uint8_t** data, uint8_t encoding)
 #if defined(__arm__) && !defined(__USING_SJLJ_EXCEPTIONS__) &&                 \
 #define USING_ARM_EHABI 1
+struct _Unwind_Exception;
 _Unwind_Reason_Code __gnu_unwind_frame(struct _Unwind_Exception *,
                                        struct _Unwind_Context *);
diff --git a/contrib/compiler-rt/lib/builtins/unwind-ehabi-helpers.h b/contrib/compiler-rt/lib/builtins/unwind-ehabi-helpers.h
index ccb0765975a9..864dba716e9b 100644
--- a/contrib/compiler-rt/lib/builtins/unwind-ehabi-helpers.h
+++ b/contrib/compiler-rt/lib/builtins/unwind-ehabi-helpers.h
@@ -39,8 +39,6 @@
 #define _URC_OK       0
 #define _URC_FAILURE  9
-typedef uint32_t _Unwind_State;
 #define _US_UNWIND_FRAME_STARTING ((_Unwind_State)1)
diff --git a/lib/libgcc_s/Version.map b/lib/libgcc_s/Version.map
index 622732edb447..42a3b757d513 100644
--- a/lib/libgcc_s/Version.map
+++ b/lib/libgcc_s/Version.map
@@ -126,6 +126,12 @@ GCC_3.4.4 {
 } GCC_3.4.2;
+GCC_3.5 {
+       __aeabi_unwind_cpp_pr0;
+       __aeabi_unwind_cpp_pr1;
+       __aeabi_unwind_cpp_pr2;
 GCC_4.0.0 {
Comment 1 Dimitry Andric freebsd_committer 2019-05-21 19:29:50 UTC
Ed, I'm OK with the version map changes, but I don't see where struct _Unwind_Exception comes from normally?  The continueUnwind function just below your change also uses a _Unwind_Exception pointer, and it seems to compile just fine on other platforms... 

I see _Unwind_Exception is declared in unwind-arm.h and unwind-itanium.h, but the former is not included in case of arm, for some reason?

Similar for _Unwind_State, this is declared in unwind-arm.h, so it clearly includes that file, if there's a conflict?
Comment 2 Ed Maste freebsd_committer 2019-07-29 17:20:42 UTC
(In reply to Dimitry Andric from comment #1)

The version map changes need a slight change, we want to include them only on arm. I think I need to:

- rename libgcc_s Version.map to Symbol.map, add a Symbol.arm.map
- In Makefile set SYMBOL_MAPS=Symbol.map, and +=Symbol.arm.map on arm only