Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CH] Support separate debug symbols from so file #8083

Merged
merged 1 commit into from
Nov 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions cpp-ch/local-engine/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,26 @@ else()
set(LOCALENGINE_SHARED_LIB_NAME "libch.so")
endif()

option(ENABLE_SEPARATE_SYMBOLS "support separate debug symbols from so" OFF)
if(ENABLE_SEPARATE_SYMBOLS)
set(SYMBOL_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/debug_symbols)
file(MAKE_DIRECTORY ${SYMBOL_OUTPUT_DIRECTORY})
function(separate_symbols target)
add_custom_command(
TARGET ${target}
POST_BUILD
COMMAND ${CMAKE_OBJCOPY} --only-keep-debug $<TARGET_FILE:${target}>
${SYMBOL_OUTPUT_DIRECTORY}/$<TARGET_FILE_NAME:${target}>.debug
COMMAND ${CMAKE_OBJCOPY} --strip-debug $<TARGET_FILE:${target}>
COMMAND
${CMAKE_OBJCOPY}
--add-gnu-debuglink=${SYMBOL_OUTPUT_DIRECTORY}/$<TARGET_FILE_NAME:${target}>.debug
$<TARGET_FILE:${target}>
COMMENT "Separating debug symbols for target: ${target}")
endfunction()
separate_symbols(${LOCALENGINE_SHARED_LIB})
endif()

add_custom_command(
OUTPUT ${LOCALENGINE_SHARED_LIB_NAME}
COMMAND ${CMAKE_COMMAND} -E rename $<TARGET_FILE:${LOCALENGINE_SHARED_LIB}>
Expand Down