Skip to content

Commit cbc872a

Browse files
committed
unwind: disable RTTI during the build of libunwind
Disable the type information emission for libunwind. libunwind does not use `dynamic_cast`. This results in a smaller binary, and more importantly, avoids the dependency on libc++abi. This ensures that we have complete symbol resolution of symbols on ELF targets without linking to the C++ runtime support library. This change avoids the emission of a reference to `__si_class_type_info`.
1 parent a8ccb48 commit cbc872a

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

libunwind/src/CMakeLists.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,11 @@ set_property(SOURCE ${LIBUNWIND_C_SOURCES}
111111
# Build the shared library.
112112
if (LIBUNWIND_ENABLE_SHARED)
113113
add_library(unwind_shared SHARED ${LIBUNWIND_SOURCES} ${LIBUNWIND_HEADERS})
114+
if(CMAKE_C_COMPILER_ID STREQUAL MSVC)
115+
target_compile_options(unwind_shared PRIVATE /GR-)
116+
else()
117+
target_compile_options(unwind_shared PRIVATE -fno-rtti)
118+
endif()
114119
if(COMMAND llvm_setup_rpath)
115120
llvm_setup_rpath(unwind_shared)
116121
endif()
@@ -142,6 +147,11 @@ endif()
142147
# Build the static library.
143148
if (LIBUNWIND_ENABLE_STATIC)
144149
add_library(unwind_static STATIC ${LIBUNWIND_SOURCES} ${LIBUNWIND_HEADERS})
150+
if(CMAKE_C_COMPILER_ID STREQUAL MSVC)
151+
target_compile_options(unwind_static PRIVATE /GR-)
152+
else()
153+
target_compile_options(unwind_static PRIVATE -fno-rtti)
154+
endif()
145155
target_link_libraries(unwind_static PRIVATE ${LIBUNWIND_LIBRARIES})
146156
set_target_properties(unwind_static
147157
PROPERTIES

0 commit comments

Comments
 (0)