Skip to content

Commit

Permalink
separate debug symbols into a dbg file (#1476)
Browse files Browse the repository at this point in the history
* separate debug symbols into a separate .dbg file when TBB_LINUX_SEPARATE_DBG is set.
  • Loading branch information
sarathnandu authored Aug 20, 2024
1 parent 2d516c8 commit 2543c7f
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@ option(TBB_DISABLE_HWLOC_AUTOMATIC_SEARCH "Disable HWLOC automatic search by pkg
option(TBB_ENABLE_IPO "Enable Interprocedural Optimization (IPO) during the compilation" ON)
option(TBB_FUZZ_TESTING "Enable fuzz testing" OFF)
option(TBB_INSTALL "Enable installation" ON)
if(LINUX)
option(TBB_LINUX_SEPARATE_DBG "Enable separation of the debug symbols during the build" OFF)
endif()
if(APPLE)
option(TBB_BUILD_APPLE_FRAMEWORKS "Build as Apple Frameworks" OFF)
endif()
Expand Down
27 changes: 26 additions & 1 deletion src/tbb/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,25 @@ target_link_libraries(tbb
${TBB_COMMON_LINK_LIBS}
)

# Strip debug symbols into a separate .dbg file
if(TBB_LINUX_SEPARATE_DBG)
if(NOT CMAKE_BUILD_TYPE STREQUAL "release")
find_program(OBJCOPY_COMMAND objcopy)
if(NOT OBJCOPY_COMMAND)
message(WARNING "objcopy command not found in the system")
else()
add_custom_command(TARGET tbb POST_BUILD
COMMAND objcopy --only-keep-debug $<TARGET_FILE:tbb> $<TARGET_FILE:tbb>.dbg
COMMAND objcopy --strip-debug $<TARGET_FILE:tbb>
COMMAND objcopy --add-gnu-debuglink=$<TARGET_FILE:tbb>.dbg $<TARGET_FILE:tbb>
COMMENT "Creating and associating .dbg file with tbb"
)
endif()
else()
message(WARNING " TBB_LINUX_SEPARATE_DBG flag is not used on release config")
endif()
endif()

if(TBB_BUILD_APPLE_FRAMEWORKS)
set_target_properties(tbb PROPERTIES
FRAMEWORK TRUE
Expand Down Expand Up @@ -158,7 +177,13 @@ if (TBB_INSTALL)
COMPONENT devel
)
endif()

if(TBB_LINUX_SEPARATE_DBG)
install(FILES
$<TARGET_FILE:tbb>.dbg
DESTINATION lib
COMPONENT devel
)
endif()
set(_tbb_pc_lib_name tbb)

if (WIN32)
Expand Down

0 comments on commit 2543c7f

Please sign in to comment.