summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPetr Hosek <phosek@chromium.org>2018-11-07 18:35:44 +0000
committerPetr Hosek <phosek@chromium.org>2018-11-07 18:35:44 +0000
commit5dc0fba2e38a63f861462e7e57a346afffc786d6 (patch)
tree888afe83ebff56a5570400a1ad675373cce8da1b
parent3b12b7e702b2647593f234e8b06757ba19fec663 (diff)
downloadbcm5719-llvm-5dc0fba2e38a63f861462e7e57a346afffc786d6.tar.gz
bcm5719-llvm-5dc0fba2e38a63f861462e7e57a346afffc786d6.zip
[CMake][ASan][HWASan] Set an explicit dependency on libc++ headers
We have seen failing builds due to a race condition between RTAsan_dynamic and libc++ headers builds, specifically libc++ headers depend on __config and if this header hasn't been copied into the final location, including other headers will typically result in failure. To avoid this race, we add an explicit dependency on libc++ headers which ensures that they've been copied into place before the sanitizer object library build starts. Differential Revision: https://reviews.llvm.org/D54198 llvm-svn: 346339
-rw-r--r--compiler-rt/lib/asan/CMakeLists.txt28
-rw-r--r--compiler-rt/lib/hwasan/CMakeLists.txt16
2 files changed, 32 insertions, 12 deletions
diff --git a/compiler-rt/lib/asan/CMakeLists.txt b/compiler-rt/lib/asan/CMakeLists.txt
index 4afc8c9449c..726da27d052 100644
--- a/compiler-rt/lib/asan/CMakeLists.txt
+++ b/compiler-rt/lib/asan/CMakeLists.txt
@@ -101,6 +101,10 @@ append_list_if(COMPILER_RT_HAS_LIBPTHREAD pthread ASAN_DYNAMIC_LIBS)
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 @@ add_compiler_rt_object_libraries(RTAsan_dynamic
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 @@ if(NOT APPLE)
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 @@ else()
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 @@ else()
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 @@ else()
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
diff --git a/compiler-rt/lib/hwasan/CMakeLists.txt b/compiler-rt/lib/hwasan/CMakeLists.txt
index 552133e8d06..0f81a4ea98f 100644
--- a/compiler-rt/lib/hwasan/CMakeLists.txt
+++ b/compiler-rt/lib/hwasan/CMakeLists.txt
@@ -61,6 +61,10 @@ append_list_if(COMPILER_RT_HAS_LIBRT rt HWASAN_DYNAMIC_LIBS)
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 @@ add_compiler_rt_object_libraries(RTHwasan
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
OpenPOWER on IntegriCloud