[CMake] Enforce LLVM_ENABLE_UNWIND_TABLES
authorLuís Marques <luismarques@lowrisc.org>
Mon, 6 Mar 2023 12:08:28 +0000 (13:08 +0100)
committerLuís Marques <luismarques@lowrisc.org>
Mon, 6 Mar 2023 12:14:20 +0000 (12:14 +0000)
In D61448 the cmake option `LLVM_ENABLE_UNWIND_TABLES` was added.
Despite the name suggesting that the option enables unwind tables, that
patch only uses it to disable them. That makes a difference for
architectures where unwind tables aren't enabled by default. The lack of
unwind tables impacts backtraces and the current handling of the option
doesn't allow enabling them. This patch makes an ON value of
`LLVM_ENABLE_UNWIND_TABLES` actually enable unwind tables.

Differential Revision: https://reviews.llvm.org/D144178

llvm/cmake/modules/AddLLVM.cmake

index 7508388..c4c9b37 100644 (file)
@@ -25,7 +25,9 @@ function(llvm_update_compile_flags name)
   else()
     if(LLVM_COMPILER_IS_GCC_COMPATIBLE)
       list(APPEND LLVM_COMPILE_FLAGS "-fno-exceptions")
-      if(NOT LLVM_ENABLE_UNWIND_TABLES)
+      if(LLVM_ENABLE_UNWIND_TABLES)
+        list(APPEND LLVM_COMPILE_FLAGS "-funwind-tables")
+      else()
         list(APPEND LLVM_COMPILE_FLAGS "-fno-unwind-tables")
         list(APPEND LLVM_COMPILE_FLAGS "-fno-asynchronous-unwind-tables")
       endif()