Author: Paul Kirth Date: 2025-01-16T13:44:55-08:00 New Revision: 92f1f99d2ee9ff0f928741fef4fcb58e994302df
URL: https://github.com/llvm/llvm-project/commit/92f1f99d2ee9ff0f928741fef4fcb58e994302df DIFF: https://github.com/llvm/llvm-project/commit/92f1f99d2ee9ff0f928741fef4fcb58e994302df.diff LOG: [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 <pho...@google.com> Added: Modified: libunwind/src/CMakeLists.txt Removed: ################################################################################ diff --git a/libunwind/src/CMakeLists.txt b/libunwind/src/CMakeLists.txt index e7ea57734cca97..ecbd019bb29ea8 100644 --- a/libunwind/src/CMakeLists.txt +++ b/libunwind/src/CMakeLists.txt @@ -20,7 +20,12 @@ set(LIBUNWIND_C_SOURCES ) set_source_files_properties(${LIBUNWIND_C_SOURCES} PROPERTIES - COMPILE_FLAGS "-std=c99") + # We need to set `-fexceptions` here so that key + # unwinding functions, like + # _UNWIND_RaiseException, are not marked as + # `nounwind`, which breaks LTO builds of + # libunwind. See #56825 and #120657 for context. + COMPILE_FLAGS "-std=c99 -fexceptions") set(LIBUNWIND_ASM_SOURCES UnwindRegistersRestore.S _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits