[libcxx-commits] [libcxx] [libcxxabi] [ASan][libc++] std::basic_string annotations (PR #72677)
Louis Dionne via libcxx-commits
libcxx-commits at lists.llvm.org
Tue Dec 12 10:33:43 PST 2023
================
@@ -543,6 +543,18 @@ function(cxx_add_basic_build_flags target)
# library.
target_compile_definitions(${target} PRIVATE -D_LIBCPP_BUILDING_LIBRARY)
+ # Define _LIBCPP_INSTRUMENTED_WITH_ASAN while building the library with ASan.
+ # Normally, the _LIBCPP_INSTRUMENTED_WITH_ASAN flag is used to keep information whether
+ # dylibs are built with AddressSanitizer. However, when building libc++,
+ # this flag needs to be defined so that the resulting dylib has all ASan functionalities normally guarded by this flag.
+ # If the _LIBCPP_INSTRUMENTED_WITH_ASAN flag is not defined, then parts of the ASan instrumentation code in libc++
+ # will not be compiled into it resulting in true positives.
+ # For context, read: https://github.com/llvm/llvm-project/pull/72677#pullrequestreview-1765402800
+ string(FIND "${LLVM_USE_SANITIZER}" "Address" building_with_asan)
+ if (NOT "${building_with_asan}" STREQUAL "-1")
+ target_compile_definitions(${target} PRIVATE -D_LIBCPP_INSTRUMENTED_WITH_ASAN)
+ endif()
----------------
ldionne wrote:
You don't need this part since you are encoding it in the `__config_site` header. You can remove this but move the comment to below.
https://github.com/llvm/llvm-project/pull/72677
More information about the libcxx-commits
mailing list