Page MenuHomeFreeBSD

Support use of LLVM's libunwind instead of GCC's unwinder
ClosedPublic

Authored by emaste on Jan 4 2016, 9:58 PM.
Tags
None
Referenced Files
F108105224: D4787.diff
Tue, Jan 21, 10:54 AM
Unknown Object (File)
Fri, Jan 10, 9:21 PM
Unknown Object (File)
Wed, Jan 8, 3:01 PM
Unknown Object (File)
Nov 23 2024, 2:49 AM
Unknown Object (File)
Nov 8 2024, 9:22 PM
Unknown Object (File)
Nov 8 2024, 8:18 PM
Unknown Object (File)
Nov 5 2024, 3:47 AM
Unknown Object (File)
Nov 3 2024, 3:49 PM
Subscribers

Details

Summary

It is enabled by setting WITH_LLVM_LIBUNWIND in src.conf(5). It is currently built in libgcc_s.so and libgcc_eh.a to simplify the transition.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

emaste retitled this revision from to Support use of LLVM's libunwind instead of GCC's unwinder.
emaste updated this object.
emaste edited the test plan for this revision. (Show Details)
emaste added reviewers: andrew, dim.
emaste added inline comments.
share/mk/src.opts.mk
234 ↗(On Diff #11927)

@br this is a todo we'd need for RISC-V

Add compiler-rt's __gcc_personality_v0 for WITH_LLVM_LIBUNWIND

Add int_util.c to provide compilerrt_abort_impl

I ran nm --dynamic over a copy of libgcc_s.so built with and without this patch, here is the diff (after stripping addresses). The orig file is the current code, the new file is with this patch.

--- nm_orig_noaddr.txt  2016-01-08 16:53:09.888377000 +0000
+++ nm_new_noaddr.txt   2016-01-08 16:53:17.568408000 +0000
@@ -24,32 +24,30 @@
  T _Unwind_Resume_or_Rethrow
  T _Unwind_SetGR
  T _Unwind_SetIP
+ U __assert
  T __bswapdi2
  T __bswapsi2
  T __clear_cache
  w __cxa_finalize
  T __deregister_frame
- T __deregister_frame_info
- T __deregister_frame_info_bases
  T __divsc3
  T __enable_execute_stack
  T __gcc_personality_v0
  T __mulsc3
  T __powisf2
  T __register_frame
- T __register_frame_info
- T __register_frame_info_bases
- T __register_frame_info_table
- T __register_frame_info_table_bases
- T __register_frame_table
+ U __stderrp
  U abort
  U dl_iterate_phdr
+ U dladdr
+ U fprintf
  U free
+ U fwrite
+ U getenv
  U malloc
  U memcpy
  U memset
- w pthread_mutex_lock
- w pthread_mutex_unlock
- w pthread_once
- U puts
- U strlen
+ U pthread_rwlock_rdlock
+ U pthread_rwlock_unlock
+ U pthread_rwlock_wrlock
+ U snprintf

frame registration functions

T __deregister_frame_info
T __deregister_frame_info_bases
T __register_frame_info
T __register_frame_info_bases
T __register_frame_info_table
T __register_frame_info_table_bases
T __register_frame_table

I think these are all fine as previously built binaries carry a weak stub.

string and misc libc functions

- U puts
- U strlen
+ U dladdr
+ U fprintf
+ U fwrite
+ U getenv
+ U snprintf

An artifact of different implementations, should be fine.

+ U __assert
+ U __stderrp

I think this is fine.

- w pthread_mutex_lock
- w pthread_mutex_unlock
- w pthread_once
+ U pthread_rwlock_rdlock
+ U pthread_rwlock_unlock
+ U pthread_rwlock_wrlock

Switch from mutex to rwlock is fine. I suspect the weak ones date from before libc carried weak versions of pthread functions and this is acceptable now.

@kan can you comment on the symbol changes introduced here (specifically wrt. the weak thread functions)?

andrew edited edge metadata.

I'm happy with this on arm64, it may need more work for other architectures but this shouldn't stop us using it now.

This revision is now accepted and ready to land.Jan 8 2016, 7:08 PM

In discussion on IRC we did discover that old GCCs don't put the eh into a separate segment and therefore require __register_frame_info et al. It is still unclear whether this is an issue that needs to be solved.

This revision was automatically updated to reflect the committed changes.