Re: Status of /usr/include/libunwind.h

From: Dimitry Andric <dim_at_FreeBSD.org>
Date: Wed, 18 Jun 2025 11:00:50 UTC
On 18 Jun 2025, at 10:50, Gleb Popov <arrowd@freebsd.org> wrote:
> 
> I noticed that we install the /usr/include/libunwind.h file, which can
> be picked by ports, but symbols from this header are defined in the
> /usr/lib/libgcc_eh.a static library. I find this a bit surprising.
> 
> If this header is intended to be public, then we should have
> libunwind.so in base, so that programs can link to it. Otherwise, we
> should hide the header and make ports use devel/libunwind or
> devel/llvmXY instead.

We didn't install it into /usr/include before 2022 [1], but it was
located in /usr/include/c++/v1 since 2012 [2], and at that time there
was still a HP unwind.h somewhere in the tree.

The lib/libgcc_eh and libgcc_s directories were introduced in 2016 [3]
and [4], which was a step in bringing in the llvm libunwind
implementation, started in [5]. At that time, there was no libunwind in
base, as far as I know.

However, the actual unwinding functions are in libgcc_s.so.1:

$ nm -D -U /lib/libgcc_s.so.1 | grep Unwind
0000000000017400 T _Unwind_Backtrace@@GCC_3.3
00000000000185d0 T _Unwind_DeleteException@@GCC_3.0
0000000000017360 T _Unwind_FindEnclosingFunction@@GCC_3.3
0000000000017570 T _Unwind_Find_FDE@@GCC_3.0
0000000000018440 T _Unwind_ForcedUnwind@@GCC_3.0
0000000000017620 T _Unwind_GetCFA@@GCC_3.3
0000000000017280 T _Unwind_GetDataRelBase@@GCC_3.0
0000000000018630 T _Unwind_GetGR@@GCC_3.0
00000000000186f0 T _Unwind_GetIP@@GCC_3.0
0000000000017680 T _Unwind_GetIPInfo@@GCC_4.2.0
00000000000184d0 T _Unwind_GetLanguageSpecificData@@GCC_3.0
0000000000018560 T _Unwind_GetRegionStart@@GCC_3.0
00000000000172f0 T _Unwind_GetTextRelBase@@GCC_3.0
0000000000017a60 T _Unwind_RaiseException@@GCC_3.0
00000000000180c0 T _Unwind_Resume@@GCC_3.0
00000000000171f0 T _Unwind_Resume_or_Rethrow@@GCC_3.3
0000000000018690 T _Unwind_SetGR@@GCC_3.0
0000000000018750 T _Unwind_SetIP@@GCC_3.0

We could make a symlink called libunwind.so, maybe?

-Dimitry

[1] https://cgit.freebsd.org/src/commit/?id=c00d345665366a89aaba7244d6f078dc756f4c53
[2] https://cgit.freebsd.org/src/commit/?id=cd38c40872c4d4cda7744045ff4672e89d8bf714
[3] https://cgit.freebsd.org/src/commit/?id=49c5eacbbfd900aeb9f3e571e769d2b1ee48f212
[4] https://cgit.freebsd.org/src/commit/?id=c7fbd7722d7c6640bee5fbf8af3a0b1343eefd8b
[5] https://cgit.freebsd.org/src/commit/?id=b80f3546a8da40a0fe47415c8b6e107b21007684