Files
datastore/cmake/xray_instrumentation.cmake
Raúl MarínandClaude Sonnet 4.6 1b5e468647 Stop using system compiler-rt headers; build compiler-rt from source by default
Previously, `<sanitizer/asan_interface.h>`, `<sanitizer/msan_interface.h>`,
`<xray/xray_interface.h>` and similar headers were taken from the host
compiler's resource directory.  When sanitizers are enabled, XRay is
disabled, so the include path added by `xray_instrumentation.cmake` was
absent and the compiler's own headers were used silently.

This change:
- Adds `contrib/llvm-project/compiler-rt/include` as a global `-isystem`
  path in `cmake/sanitize.cmake` (which is always included).  The compiler
  searches `-isystem` paths before its implicit resource directory, so our
  bundled headers take precedence without breaking `#include_next` chains
  that libcxx relies on.
- Removes the now-redundant `include_directories` call from
  `cmake/xray_instrumentation.cmake`, which previously only covered the
  case when XRay was enabled.
- Changes the default of `USE_SYSTEM_COMPILER_RT` from `ON` to `OFF` so
  that compiler-rt libraries are always built from our bundled source
  instead of whatever the host compiler ships.

Related: https://github.com/ClickHouse/ClickHouse/issues/91475

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
2026-02-20 16:08:38 +00:00

16 lines
677 B
CMake

# https://llvm.org/docs/XRay.html
if (TARGET ch_contrib::llvm)
# The target clang must support XRay, otherwise it should error on invalid option
# Explicitly disable all XRay modes to avoid linking against xray-basic and xray-fdr.
# Emit instrumentation only for function-entry and function-exit.
set (XRAY_FLAGS "-fxray-instrument -fxray-modes=none -fxray-instrumentation-bundle=function")
set (USE_XRAY 1)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${XRAY_FLAGS}")
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${XRAY_FLAGS}")
message (STATUS "Using LLVM XRay")
else()
message (STATUS "Not using LLVM XRay because LLVM is not built along")
endif()