include(BuildBoost)
build_boost(1.87
COMPONENTS ${BOOST_COMPONENTS} ${BOOST_HEADER_COMPONENTS})
+ if(WITH_ASAN)
+ # Boost.Context is built ucontext-only here (context-impl=ucontext); define
+ # the matching backend tree-wide so every Boost.Context/Coroutine2 consumer
+ # agrees on it, instead of relying on per-target propagation that is easy to miss.
+ # Except riscv64: its ASan mis-handles ucontext, so it keeps fcontext.
+ if(CMAKE_SYSTEM_PROCESSOR MATCHES "riscv")
+ add_compile_definitions(BOOST_USE_ASAN)
+ else()
+ add_compile_definitions(BOOST_USE_ASAN BOOST_USE_UCONTEXT)
+ endif()
+ endif()
endif()
include_directories(BEFORE SYSTEM ${Boost_INCLUDE_DIRS})
add_library(Boost::asio INTERFACE IMPORTED)
endif()
set(b2_targets headers stage)
set(b2_install_targets install)
- if(WITH_ASAN)
+ # Except riscv64: its ASan mis-handles ucontext, so it keeps fcontext.
+ if(WITH_ASAN AND NOT (CMAKE_SYSTEM_PROCESSOR MATCHES "riscv"))
list(APPEND b2 context-impl=ucontext)
# `context-impl` is declared in libs/context/build/Jamfile.v2; the headers/stage
# and install targets never load it, so b2 aborts with `unknown feature
set_target_properties(Boost::${c} PROPERTIES
INTERFACE_COMPILE_DEFINITIONS "BOOST_USE_VALGRIND")
endif()
- if((c MATCHES "context") AND (WITH_ASAN))
- set_target_properties(Boost::${c} PROPERTIES
- INTERFACE_COMPILE_DEFINITIONS "BOOST_USE_ASAN;BOOST_USE_UCONTEXT")
- endif()
+ # ASan's BOOST_USE_ASAN/BOOST_USE_UCONTEXT are defined tree-wide in the
+ # top-level CMakeLists.txt, not per-target.
list(APPEND Boost_LIBRARIES ${Boost_${upper_c}_LIBRARY})
endforeach()
foreach(c ${Boost_BUILD_COMPONENTS})