Skip to content

Commit 20488e9

Browse files
bm1549claude
andcommitted
fix: propagate only sanitizer flags to yaml-cpp, not warning flags
The previous approach propagated all INTERFACE_COMPILE_OPTIONS from dd-trace-cpp-specs to yaml-cpp, which included -WX and -W4. This caused yaml-cpp's own code (binary.cpp) to fail with C4244 warnings treated as errors. Now we add only the -fsanitize flags directly. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
1 parent 32d2d5b commit 20488e9

1 file changed

Lines changed: 10 additions & 10 deletions

File tree

cmake/deps/yaml.cmake

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,16 @@ FetchContent_MakeAvailable(yaml-cpp)
2121
set(CMAKE_POLICY_VERSION_MINIMUM "${_yaml_saved_policy_min}")
2222

2323
# Ensure yaml-cpp is compiled with the same sanitizer flags as the main
24-
# project. The sanitizers are set on dd-trace-cpp-specs as INTERFACE
25-
# properties, which yaml-cpp doesn't link against. Without this, MSVC
26-
# ASAN annotation mismatches cause linker errors (LNK2038).
24+
# project. Without this, MSVC ASAN annotation mismatches cause linker
25+
# errors (LNK2038). We add only the sanitizer flags — not the full set
26+
# of compile options from dd-trace-cpp-specs (which includes -WX and
27+
# warning levels that would break yaml-cpp's own code).
2728
if (DD_TRACE_ENABLE_SANITIZE AND TARGET yaml-cpp)
28-
get_target_property(_sanitize_opts dd-trace-cpp-specs INTERFACE_COMPILE_OPTIONS)
29-
if (_sanitize_opts)
30-
target_compile_options(yaml-cpp PRIVATE ${_sanitize_opts})
31-
endif()
32-
get_target_property(_sanitize_link dd-trace-cpp-specs INTERFACE_LINK_LIBRARIES)
33-
if (_sanitize_link)
34-
target_link_libraries(yaml-cpp PRIVATE ${_sanitize_link})
29+
if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC" OR (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND CMAKE_CXX_COMPILER_FRONTEND_VARIANT MATCHES "MSVC"))
30+
target_compile_options(yaml-cpp PRIVATE /fsanitize=address)
31+
target_link_options(yaml-cpp PRIVATE /fsanitize=address)
32+
else()
33+
target_compile_options(yaml-cpp PRIVATE -fsanitize=address,undefined)
34+
target_link_options(yaml-cpp PRIVATE -fsanitize=address,undefined)
3535
endif()
3636
endif()

0 commit comments

Comments
 (0)