Skip to content

Commit a7c766b

Browse files
committed
build: add option to disable unwind tables
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. llvm-svn: 359819
1 parent 3662127 commit a7c766b

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

llvm/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,8 @@ if(LLVM_ENABLE_BACKTRACES)
351351
set(ENABLE_BACKTRACES 1)
352352
endif()
353353

354+
option(LLVM_ENABLE_UNWIND_TABLES "Emit unwind tables for the libraries" ON)
355+
354356
option(LLVM_ENABLE_CRASH_OVERRIDES "Enable crash overrides." ON)
355357
if(LLVM_ENABLE_CRASH_OVERRIDES)
356358
set(ENABLE_CRASH_OVERRIDES 1)

llvm/cmake/modules/AddLLVM.cmake

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ function(llvm_update_compile_flags name)
2121
else()
2222
if(LLVM_COMPILER_IS_GCC_COMPATIBLE)
2323
list(APPEND LLVM_COMPILE_FLAGS "-fno-exceptions")
24+
if(NOT LLVM_ENABLE_UNWIND_TABLES)
25+
list(APPEND LLVM_COMPILE_FLAGS "-fno-unwind-tables")
26+
list(APPEND LLVM_COMPILE_FLAGS "-fno-asynchronous-unwind-tables")
27+
endif()
2428
elseif(MSVC)
2529
list(APPEND LLVM_COMPILE_DEFINITIONS _HAS_EXCEPTIONS=0)
2630
list(APPEND LLVM_COMPILE_FLAGS "/EHs-c-")

llvm/docs/CMake.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,10 @@ LLVM-specific variables
266266
**LLVM_ENABLE_THREADS**:BOOL
267267
Build with threads support, if available. Defaults to ON.
268268

269+
**LLVM_ENABLE_UNWIND_TABLES**:BOOL
270+
Enable unwind tables in the binary. Disabling unwind tables can reduce the
271+
size of the libraries. Defaults to ON.
272+
269273
**LLVM_CXX_STD**:STRING
270274
Build with the specified C++ standard. Defaults to "c++11".
271275

0 commit comments

Comments
 (0)