Skip to content

Commit 92f1f99

Browse files
ilovepipetrhosek
andauthored
[libunwind][cmake] Compile _Unwind* routines with -fexceptions (#121819)
When building libunwind with LTO, we found that routines, like _Unwind_RaiseException were marked `nounwind`. This causes problems when libunwind is then used with exception throwing code, since many of the routines are marked `nounwind` and the compiler infers that something like a try/catch block cannot throw resulting in a miscompile (see #120657). Similarly, in #56825, it was pointed out that marking _Unwind_Resume as `nounwind` causes bad exception table generation. This patch adds the `-fexceptions` flag to the build of the C files that define these routines, as proposed in #56825. Fixes #56825 #120657 --------- Co-authored-by: Petr Hosek <[email protected]>
1 parent 7ea5f19 commit 92f1f99

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

libunwind/src/CMakeLists.txt

+6-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,12 @@ set(LIBUNWIND_C_SOURCES
2020
)
2121
set_source_files_properties(${LIBUNWIND_C_SOURCES}
2222
PROPERTIES
23-
COMPILE_FLAGS "-std=c99")
23+
# We need to set `-fexceptions` here so that key
24+
# unwinding functions, like
25+
# _UNWIND_RaiseException, are not marked as
26+
# `nounwind`, which breaks LTO builds of
27+
# libunwind. See #56825 and #120657 for context.
28+
COMPILE_FLAGS "-std=c99 -fexceptions")
2429

2530
set(LIBUNWIND_ASM_SOURCES
2631
UnwindRegistersRestore.S

0 commit comments

Comments
 (0)