2021-04-24 19:47:52 +00:00
|
|
|
set(LIBUNWIND_SOURCE_DIR "${ClickHouse_SOURCE_DIR}/contrib/libunwind")
|
2019-07-08 23:58:14 +00:00
|
|
|
|
|
|
|
set(LIBUNWIND_CXX_SOURCES
|
2021-04-24 19:47:52 +00:00
|
|
|
"${LIBUNWIND_SOURCE_DIR}/src/libunwind.cpp"
|
|
|
|
"${LIBUNWIND_SOURCE_DIR}/src/Unwind-EHABI.cpp"
|
|
|
|
"${LIBUNWIND_SOURCE_DIR}/src/Unwind-seh.cpp")
|
2019-07-08 23:58:14 +00:00
|
|
|
if (APPLE)
|
2021-04-24 19:47:52 +00:00
|
|
|
set(LIBUNWIND_CXX_SOURCES ${LIBUNWIND_CXX_SOURCES} "${LIBUNWIND_SOURCE_DIR}/src/Unwind_AppleExtras.cpp")
|
2019-07-08 23:58:14 +00:00
|
|
|
endif ()
|
|
|
|
|
|
|
|
set(LIBUNWIND_C_SOURCES
|
2021-04-24 19:47:52 +00:00
|
|
|
"${LIBUNWIND_SOURCE_DIR}/src/UnwindLevel1.c"
|
|
|
|
"${LIBUNWIND_SOURCE_DIR}/src/UnwindLevel1-gcc-ext.c"
|
|
|
|
"${LIBUNWIND_SOURCE_DIR}/src/Unwind-sjlj.c"
|
2019-11-28 10:59:21 +00:00
|
|
|
# Use unw_backtrace to override libgcc's backtrace symbol for better ABI compatibility
|
|
|
|
unwind-override.c)
|
2019-07-08 23:58:14 +00:00
|
|
|
set_source_files_properties(${LIBUNWIND_C_SOURCES} PROPERTIES COMPILE_FLAGS "-std=c99")
|
|
|
|
|
|
|
|
set(LIBUNWIND_ASM_SOURCES
|
2021-04-24 19:47:52 +00:00
|
|
|
"${LIBUNWIND_SOURCE_DIR}/src/UnwindRegistersRestore.S"
|
|
|
|
"${LIBUNWIND_SOURCE_DIR}/src/UnwindRegistersSave.S")
|
2020-11-22 09:18:51 +00:00
|
|
|
|
2023-11-25 01:54:41 +00:00
|
|
|
enable_language(ASM)
|
2019-07-08 23:58:14 +00:00
|
|
|
|
|
|
|
set(LIBUNWIND_SOURCES
|
|
|
|
${LIBUNWIND_CXX_SOURCES}
|
|
|
|
${LIBUNWIND_C_SOURCES}
|
|
|
|
${LIBUNWIND_ASM_SOURCES})
|
|
|
|
|
2019-08-28 20:49:37 +00:00
|
|
|
add_library(unwind ${LIBUNWIND_SOURCES})
|
2021-10-17 20:10:01 +00:00
|
|
|
set_target_properties(unwind PROPERTIES FOLDER "contrib/libunwind-cmake")
|
2019-07-08 23:58:14 +00:00
|
|
|
|
2019-08-28 20:49:37 +00:00
|
|
|
target_include_directories(unwind SYSTEM BEFORE PUBLIC $<BUILD_INTERFACE:${LIBUNWIND_SOURCE_DIR}/include>)
|
2024-05-15 11:43:54 +00:00
|
|
|
target_compile_definitions(unwind PRIVATE -D_LIBUNWIND_NO_HEAP=1)
|
|
|
|
# NOTE: from this macros sizeof(unw_context_t)/sizeof(unw_cursor_t) is depends, so it should be set always
|
|
|
|
target_compile_definitions(unwind PUBLIC -D_LIBUNWIND_IS_NATIVE_ONLY)
|
2022-12-24 19:31:04 +00:00
|
|
|
|
|
|
|
# We should enable optimizations (otherwise it will be too slow in debug)
|
|
|
|
# and disable sanitizers (otherwise infinite loop may happen)
|
|
|
|
target_compile_options(unwind PRIVATE -O3 -fno-exceptions -funwind-tables -fno-sanitize=all $<$<COMPILE_LANGUAGE:CXX>:-nostdinc++ -fno-rtti>)
|
2019-08-28 20:49:37 +00:00
|
|
|
|
2023-11-14 05:55:06 +00:00
|
|
|
target_compile_options(unwind PRIVATE -Wno-unused-but-set-variable)
|
2019-12-20 01:59:24 +00:00
|
|
|
|
2020-08-01 15:10:47 +00:00
|
|
|
# The library is using register variables that are bound to specific registers
|
|
|
|
# Example: DwarfInstructions.hpp: register unsigned long long x16 __asm("x16") = cfa;
|
2023-11-14 05:55:06 +00:00
|
|
|
target_compile_options(unwind PRIVATE "$<$<COMPILE_LANGUAGE:CXX>:-Wno-register>")
|
2020-08-01 15:10:47 +00:00
|
|
|
|
2019-10-24 20:55:41 +00:00
|
|
|
install(
|
|
|
|
TARGETS unwind
|
|
|
|
EXPORT global
|
|
|
|
LIBRARY DESTINATION lib
|
|
|
|
ARCHIVE DESTINATION lib
|
|
|
|
)
|