Skip to content

Commit f85f860

Browse files
authored
fix: remove C++ exception ABI from vendored libunwind build. (#1544)
1 parent 63765bd commit f85f860

3 files changed

Lines changed: 27 additions & 23 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
**Fixes**:
1010

1111
- Fix use-after-free on allocation failure when merging scope tags, extra, and contexts into a captured event. ([#1539](https://github.com/getsentry/sentry-native/pull/1539))
12+
- Remove C++ exception ABI symbols (`_Unwind_Resume`, etc.) from vendored `libunwind` build. ([#1544](https://github.com/getsentry/sentry-native/pull/1544))
1213

1314
## 0.13.0
1415

vendor/libunwind/CMakeLists.txt

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,6 @@ set(UNWIND_COMMON_SOURCES
3939

4040
# Local sources (libunwind_la_SOURCES_local_nounwind + os_local)
4141
set(UNWIND_LOCAL_SOURCES
42-
# os_linux_local (CXX exceptions support - _ReadULEB/_ReadSLEB)
43-
${LIBUNWIND_SRC}/mi/_ReadULEB.c
44-
${LIBUNWIND_SRC}/mi/_ReadSLEB.c
4542
# local nounwind
4643
${LIBUNWIND_SRC}/mi/backtrace.c
4744
${LIBUNWIND_SRC}/mi/dyn-cancel.c
@@ -64,25 +61,10 @@ set(UNWIND_LOCAL_SOURCES
6461
${LIBUNWIND_SRC}/mi/Lset_iterate_phdr_function.c
6562
${LIBUNWIND_SRC}/mi/Lset_reg.c
6663
${LIBUNWIND_SRC}/mi/Lget_elf_filename.c
67-
# local unwind (CXX exception support)
68-
${LIBUNWIND_SRC}/unwind/Backtrace.c
69-
${LIBUNWIND_SRC}/unwind/DeleteException.c
70-
${LIBUNWIND_SRC}/unwind/FindEnclosingFunction.c
71-
${LIBUNWIND_SRC}/unwind/ForcedUnwind.c
72-
${LIBUNWIND_SRC}/unwind/GetBSP.c
73-
${LIBUNWIND_SRC}/unwind/GetCFA.c
74-
${LIBUNWIND_SRC}/unwind/GetDataRelBase.c
75-
${LIBUNWIND_SRC}/unwind/GetGR.c
76-
${LIBUNWIND_SRC}/unwind/GetIP.c
77-
${LIBUNWIND_SRC}/unwind/GetIPInfo.c
78-
${LIBUNWIND_SRC}/unwind/GetLanguageSpecificData.c
79-
${LIBUNWIND_SRC}/unwind/GetRegionStart.c
80-
${LIBUNWIND_SRC}/unwind/GetTextRelBase.c
81-
${LIBUNWIND_SRC}/unwind/RaiseException.c
82-
${LIBUNWIND_SRC}/unwind/Resume.c
83-
${LIBUNWIND_SRC}/unwind/Resume_or_Rethrow.c
84-
${LIBUNWIND_SRC}/unwind/SetGR.c
85-
${LIBUNWIND_SRC}/unwind/SetIP.c
64+
# NOTE: The src/unwind/ sources (C++ exception ABI: _Unwind_Resume,
65+
# _Unwind_RaiseException, etc.) are intentionally excluded. They conflict
66+
# with libgcc_eh.a when linking with -static-libgcc, and sentry-native
67+
# only needs the local unwinding API (_UL*_init_local, _UL*_step, etc.).
8668
)
8769

8870
# DWARF sources (local)

vendor/libunwind/VENDORING.md

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,12 @@ Linux without requiring users to install any external packages. Only the
2020
| x86 (i686, 32-bit) | `src/x86/` | `include/tdep-x86/` |
2121
| aarch64 | `src/aarch64/` | `include/tdep-aarch64/` |
2222

23-
Core shared code: `src/mi/`, `src/dwarf/`, `src/unwind/`, `src/os-linux.c`,
23+
Core shared code: `src/mi/`, `src/dwarf/`, `src/os-linux.c`,
2424
`src/dl-iterate-phdr.c`.
2525

26+
> **Note:** `src/unwind/` is present in the tree but is **not compiled**. See
27+
> [Excluded: C++ exception ABI sources](#excluded-c-exception-abi-sources) below.
28+
2629
## What Was Removed from the Release Tarball
2730

2831
The release tarball contains 911 files. 547 were removed (the vendor tree
@@ -81,9 +84,25 @@ custom `CMakeLists.txt`:
8184
|----------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------|
8285
| `src/arm/`, `include/tdep-arm/` | ARM 32-bit — kept for potential future use |
8386
| `src/riscv/`, `include/tdep-riscv/` | RISC-V — kept for potential future use |
87+
| `src/unwind/`, `src/mi/_ReadULEB.c`, `src/mi/_ReadSLEB.c` | C++ exception ABI conflicts with `libgcc_eh.a`; see [above](#excluded-c-exception-abi-sources) |
8488
| `include/libunwind-*.h` for removed arches | Referenced via `#ifdef` in `include/libunwind.h` — harmless dead code |
8589
| Autotools artifacts (`configure`, `configure.ac`, `Makefile.am`, `Makefile.in`, `aclocal.m4`, `INSTALL`) | Carried over from the release tarball. Not used by CMake, but `configure.ac` and `Makefile.am` are useful as reference for the build logic |
8690

91+
### Excluded: C++ exception ABI sources
92+
93+
The `src/unwind/` directory and `src/mi/_ReadULEB.c` / `src/mi/_ReadSLEB.c`
94+
are **present in the tree but excluded from the CMake build**. These files
95+
implement the Itanium C++ exception handling ABI (`_Unwind_Resume`,
96+
`_Unwind_RaiseException`, `_Unwind_ForcedUnwind`, etc.) — the same symbols
97+
that `libgcc_eh.a` provides.
98+
99+
When sentry-native is built as a static library (`SENTRY_BUILD_SHARED_LIBS=OFF`)
100+
and linked into a shared library whose toolchain uses `-static-libgcc`
101+
(e.g. godot-cpp), including these symbols causes **multiple definition** errors
102+
against `libgcc_eh.a`. Excluding them is safe because sentry-native only uses
103+
the local unwinding API (`_ULx86_64_init_local`, `_ULx86_64_step`, etc.) and
104+
never calls into the C++ exception ABI.
105+
87106
## Custom Additions (not in the upstream tarball)
88107

89108
| File | Purpose |
@@ -123,6 +142,8 @@ both GCC and Clang.
123142
removed architecture dirs listed above:
124143
- `src/` — keep only: `aarch64/`, `arm/`, `dwarf/`, `mi/`, `riscv/`,
125144
`unwind/`, `x86/`, `x86_64/`, and top-level `.c` / `.h` files
145+
(`src/unwind/` is kept for reference but **not compiled** — do not add it
146+
to `CMakeLists.txt`)
126147
- `include/` — keep only: `tdep/`, `tdep-aarch64/`, `tdep-arm/`,
127148
`tdep-riscv/`, `tdep-x86/`, `tdep-x86_64/`, and all top-level `.h` /
128149
`.h.in` files

0 commit comments

Comments
 (0)