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

chore(profiling): fix sanitizers on Linux #11424

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
25 changes: 17 additions & 8 deletions ddtrace/internal/datadog/profiling/cmake/AnalysisFunc.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,24 @@ function(add_ddup_config target)
# Some sanitizers (or the analysis--such as symbolization--tooling thereof) work better with frame pointers, so
# we include it here.
target_compile_options(${target} PRIVATE -fsanitize=${SANITIZE_OPTIONS} -fno-omit-frame-pointer)
target_link_options(${target} PRIVATE -fsanitize=${SANITIZE_OPTIONS})
target_link_options(${target} PRIVATE -fsanitize=${SANITIZE_OPTIONS} -shared-libsan)

# We need to do a little bit of work in order to ensure the dynamic *san libraries can be linked Procedure
# adapted from datadog/ddprof :)
execute_process(
COMMAND ${CMAKE_CXX_COMPILER} -print-file-name=
OUTPUT_VARIABLE LIBSAN_LIB_PATH
OUTPUT_STRIP_TRAILING_WHITESPACE COMMAND_ERROR_IS_FATAL ANY)
set_target_properties(${target} PROPERTIES INSTALL_RPATH ${LIBSAN_LIB_PATH} BUILD_RPATH ${LIBSAN_LIB_PATH})
# Locate all directories containing relevant `.so` files
execute_process(
COMMAND bash -c "find $(${CMAKE_CXX_COMPILER} -print-file-name=) -name '*.so' -exec dirname {} \; | uniq"
OUTPUT_VARIABLE LIBSAN_LIB_PATHS
OUTPUT_STRIP_TRAILING_WHITESPACE COMMAND_ERROR_IS_FATAL ANY)

# Print for debugging
message(STATUS "LIBSAN_LIB_PATHS: ${LIBSAN_LIB_PATHS}")

# Split the paths into a semicolon-separated list for CMake
string(REPLACE "\n" ";" LIBSAN_LIB_PATHS_LIST "${LIBSAN_LIB_PATHS}")

# Set RPATH to include all identified paths
set_target_properties(${target} PROPERTIES
BUILD_RPATH "${LIBSAN_LIB_PATHS_LIST}"
INSTALL_RPATH "${LIBSAN_LIB_PATHS_LIST}")
endif()

# If DO_FANALYZER is specified and we're using gcc, then we can use -fanalyzer
Expand Down
Loading