[libunwind] [libunwind][cmake] Compile _Unwind* routines with -fexceptions (PR #121819)

via cfe-commits cfe-commits at lists.llvm.org
Mon Jan 6 11:16:20 PST 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-libunwind

Author: Paul Kirth (ilovepi)

<details>
<summary>Changes</summary>

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`. This causes miscompiles, and the
incorrect generation of unwind tables (see #<!-- -->120657).

In #<!-- -->56825, it was pointed out that these C routines should be compiled
with `-fexceptions`, to prevent this from happening. Since we only add
the `-fexceptions` flag to C sources, there shouldn't be any conflict
with any C++ sources or interactions with libcxx/libcxxabi.

Fixes #<!-- -->56825 #<!-- -->120657


---
Full diff: https://github.com/llvm/llvm-project/pull/121819.diff


1 Files Affected:

- (modified) libunwind/src/CMakeLists.txt (+1-1) 


``````````diff
diff --git a/libunwind/src/CMakeLists.txt b/libunwind/src/CMakeLists.txt
index e7ea57734cca97..72dd3f5bca9960 100644
--- a/libunwind/src/CMakeLists.txt
+++ b/libunwind/src/CMakeLists.txt
@@ -20,7 +20,7 @@ set(LIBUNWIND_C_SOURCES
     )
 set_source_files_properties(${LIBUNWIND_C_SOURCES}
                             PROPERTIES
-                              COMPILE_FLAGS "-std=c99")
+                              COMPILE_FLAGS "-std=c99 -fexceptions")
 
 set(LIBUNWIND_ASM_SOURCES
     UnwindRegistersRestore.S

``````````

</details>


https://github.com/llvm/llvm-project/pull/121819


More information about the cfe-commits mailing list