Index: compiler-rt/lib/asan/CMakeLists.txt =================================================================== --- compiler-rt/lib/asan/CMakeLists.txt +++ compiler-rt/lib/asan/CMakeLists.txt @@ -101,6 +101,10 @@ append_list_if(COMPILER_RT_HAS_LIBLOG log ASAN_DYNAMIC_LIBS) append_list_if(MINGW "${MINGW_LIBRARIES}" ASAN_DYNAMIC_LIBS) +if (TARGET cxx-headers OR HAVE_LIBCXX) + set(ASAN_DEPS cxx-headers) +endif() + # Compile ASan sources into an object library. add_compiler_rt_object_libraries(RTAsan_dynamic @@ -109,7 +113,8 @@ SOURCES ${ASAN_SOURCES} ${ASAN_CXX_SOURCES} ADDITIONAL_HEADERS ${ASAN_HEADERS} CFLAGS ${ASAN_DYNAMIC_CFLAGS} - DEFS ${ASAN_DYNAMIC_DEFINITIONS}) + DEFS ${ASAN_DYNAMIC_DEFINITIONS} + DEPS ${ASAN_DEPS}) if(NOT APPLE) add_compiler_rt_object_libraries(RTAsan @@ -117,26 +122,30 @@ SOURCES ${ASAN_SOURCES} ADDITIONAL_HEADERS ${ASAN_HEADERS} CFLAGS ${ASAN_CFLAGS} - DEFS ${ASAN_COMMON_DEFINITIONS}) + DEFS ${ASAN_COMMON_DEFINITIONS} + DEPS ${ASAN_DEPS}) add_compiler_rt_object_libraries(RTAsan_cxx ARCHS ${ASAN_SUPPORTED_ARCH} SOURCES ${ASAN_CXX_SOURCES} ADDITIONAL_HEADERS ${ASAN_HEADERS} CFLAGS ${ASAN_CFLAGS} - DEFS ${ASAN_COMMON_DEFINITIONS}) + DEFS ${ASAN_COMMON_DEFINITIONS} + DEPS ${ASAN_DEPS}) add_compiler_rt_object_libraries(RTAsan_preinit ARCHS ${ASAN_SUPPORTED_ARCH} SOURCES ${ASAN_PREINIT_SOURCES} ADDITIONAL_HEADERS ${ASAN_HEADERS} CFLAGS ${ASAN_CFLAGS} - DEFS ${ASAN_COMMON_DEFINITIONS}) + DEFS ${ASAN_COMMON_DEFINITIONS} + DEPS ${ASAN_DEPS}) file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/dummy.cc "") add_compiler_rt_object_libraries(RTAsan_dynamic_version_script_dummy ARCHS ${ASAN_SUPPORTED_ARCH} SOURCES ${CMAKE_CURRENT_BINARY_DIR}/dummy.cc CFLAGS ${ASAN_DYNAMIC_CFLAGS} - DEFS ${ASAN_DYNAMIC_DEFINITIONS}) + DEFS ${ASAN_DYNAMIC_DEFINITIONS} + DEPS ${ASAN_DEPS}) endif() # Build ASan runtimes shipped with Clang. @@ -231,7 +240,8 @@ ARCHS ${arch} SOURCES asan_win_weak_interception.cc CFLAGS ${ASAN_CFLAGS} -DSANITIZER_DYNAMIC - DEFS ${ASAN_COMMON_DEFINITIONS}) + DEFS ${ASAN_COMMON_DEFINITIONS} + DEPS ${ASAN_DEPS}) set(ASAN_DYNAMIC_WEAK_INTERCEPTION AsanWeakInterception UbsanWeakInterception @@ -276,7 +286,8 @@ SOURCES asan_globals_win.cc asan_win_dll_thunk.cc CFLAGS ${ASAN_CFLAGS} -DSANITIZER_DLL_THUNK - DEFS ${ASAN_COMMON_DEFINITIONS}) + DEFS ${ASAN_COMMON_DEFINITIONS} + DEPS ${ASAN_DEPS}) add_compiler_rt_runtime(clang_rt.asan_dll_thunk STATIC @@ -301,7 +312,8 @@ SOURCES asan_globals_win.cc asan_win_dynamic_runtime_thunk.cc CFLAGS ${ASAN_CFLAGS} ${DYNAMIC_RUNTIME_THUNK_CFLAGS} - DEFS ${ASAN_COMMON_DEFINITIONS}) + DEFS ${ASAN_COMMON_DEFINITIONS} + DEPS ${ASAN_DEPS}) add_compiler_rt_runtime(clang_rt.asan_dynamic_runtime_thunk STATIC Index: compiler-rt/lib/hwasan/CMakeLists.txt =================================================================== --- compiler-rt/lib/hwasan/CMakeLists.txt +++ compiler-rt/lib/hwasan/CMakeLists.txt @@ -61,6 +61,10 @@ append_list_if(COMPILER_RT_HAS_LIBM m HWASAN_DYNAMIC_LIBS) append_list_if(COMPILER_RT_HAS_LIBPTHREAD pthread HWASAN_DYNAMIC_LIBS) +if (TARGET cxx-headers OR HAVE_LIBCXX) + set(HWASAN_DEPS cxx-headers) +endif() + # Static runtime library. add_compiler_rt_component(hwasan) @@ -69,26 +73,30 @@ SOURCES ${HWASAN_RTL_SOURCES} ADDITIONAL_HEADERS ${HWASAN_RTL_HEADERS} CFLAGS ${HWASAN_RTL_CFLAGS} - DEFS ${HWASAN_DEFINITIONS}) + DEFS ${HWASAN_DEFINITIONS} + DEPS ${HWASAN_DEPS}) add_compiler_rt_object_libraries(RTHwasan_cxx ARCHS ${HWASAN_SUPPORTED_ARCH} SOURCES ${HWASAN_RTL_CXX_SOURCES} ADDITIONAL_HEADERS ${HWASAN_RTL_HEADERS} CFLAGS ${HWASAN_RTL_CFLAGS} - DEFS ${HWASAN_DEFINITIONS}) + DEFS ${HWASAN_DEFINITIONS} + DEPS ${HWASAN_DEPS}) add_compiler_rt_object_libraries(RTHwasan_dynamic ARCHS ${HWASAN_SUPPORTED_ARCH} SOURCES ${HWASAN_RTL_SOURCES} ${HWASAN_RTL_CXX_SOURCES} ADDITIONAL_HEADERS ${HWASAN_RTL_HEADERS} CFLAGS ${HWASAN_DYNAMIC_CFLAGS} - DEFS ${HWASAN_DEFINITIONS}) + DEFS ${HWASAN_DEFINITIONS} + DEPS ${HWASAN_DEPS}) file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/dummy.cc "") add_compiler_rt_object_libraries(RTHwasan_dynamic_version_script_dummy ARCHS ${HWASAN_SUPPORTED_ARCH} SOURCES ${CMAKE_CURRENT_BINARY_DIR}/dummy.cc CFLAGS ${HWASAN_DYNAMIC_CFLAGS} - DEFS ${HWASAN_DEFINITIONS}) + DEFS ${HWASAN_DEFINITIONS} + DEPS ${HWASAN_DEPS}) foreach(arch ${HWASAN_SUPPORTED_ARCH}) add_compiler_rt_runtime(clang_rt.hwasan