]> granicus.if.org Git - llvm/commitdiff
build: add option to disable unwind tables
authorSaleem Abdulrasool <compnerd@compnerd.org>
Thu, 2 May 2019 19:37:26 +0000 (19:37 +0000)
committerSaleem Abdulrasool <compnerd@compnerd.org>
Thu, 2 May 2019 19:37:26 +0000 (19:37 +0000)
The unwind tables (`.eh_frame`, `.arm.extab`) add a significant chunk of data to
the final binaries.  These should not be needed normally, particularly when
exceptions are disabled.  This enables shrinking `lldb-server` by ~18% (3 MiB)
when built with gold.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@359819 91177308-0d34-0410-b5e6-96231b3b80d8

CMakeLists.txt
cmake/modules/AddLLVM.cmake
docs/CMake.rst

index 80d58d78a3538eb9617e0932201e886dacafee64..0164d3eaa8fac0844698f9b6cb802f90f15ded14 100644 (file)
@@ -351,6 +351,8 @@ if(LLVM_ENABLE_BACKTRACES)
   set(ENABLE_BACKTRACES 1)
 endif()
 
+option(LLVM_ENABLE_UNWIND_TABLES "Emit unwind tables for the libraries" ON)
+
 option(LLVM_ENABLE_CRASH_OVERRIDES "Enable crash overrides." ON)
 if(LLVM_ENABLE_CRASH_OVERRIDES)
   set(ENABLE_CRASH_OVERRIDES 1)
index 2fefe838ee49e2a85a9fd8c9018e8dcadf85af65..d10831ff028147d1bf9e3328efd85a16385d0c4d 100644 (file)
@@ -21,6 +21,10 @@ 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)
+        list(APPEND LLVM_COMPILE_FLAGS "-fno-unwind-tables")
+        list(APPEND LLVM_COMPILE_FLAGS "-fno-asynchronous-unwind-tables")
+      endif()
     elseif(MSVC)
       list(APPEND LLVM_COMPILE_DEFINITIONS _HAS_EXCEPTIONS=0)
       list(APPEND LLVM_COMPILE_FLAGS "/EHs-c-")
index d62c42c32f8658efe2bbef29eeff4decf5df917f..92e7b9c2a473470e3d304fdf506c52f63afe82d8 100644 (file)
@@ -266,6 +266,10 @@ LLVM-specific variables
 **LLVM_ENABLE_THREADS**:BOOL
   Build with threads support, if available. Defaults to ON.
 
+**LLVM_ENABLE_UNWIND_TABLES**:BOOL
+  Enable unwind tables in the binary.  Disabling unwind tables can reduce the
+  size of the libraries.  Defaults to ON.
+
 **LLVM_CXX_STD**:STRING
   Build with the specified C++ standard. Defaults to "c++11".