From 7252e2a8bd4e0f08d94d6ee26a08c4299b9f3fa6 Mon Sep 17 00:00:00 2001 From: Petr Hosek Date: Wed, 13 Jun 2018 07:08:28 +0000 Subject: [PATCH] [XRay] Set an explicit dependency on libc++ when needed When XRay is being built as part of the just built compiler together with libc++ as part of the runtimes build, we need an explicit dependency from XRay to libc++ to make sure that the library is available by the time we start building XRay. Differential Revision: https://reviews.llvm.org/D48113 llvm-svn: 334575 --- compiler-rt/cmake/Modules/AddCompilerRT.cmake | 8 ++++-- compiler-rt/lib/xray/CMakeLists.txt | 28 +++++++++++++------ 2 files changed, 26 insertions(+), 10 deletions(-) diff --git a/compiler-rt/cmake/Modules/AddCompilerRT.cmake b/compiler-rt/cmake/Modules/AddCompilerRT.cmake index 95432e298076..be5b81f0512d 100644 --- a/compiler-rt/cmake/Modules/AddCompilerRT.cmake +++ b/compiler-rt/cmake/Modules/AddCompilerRT.cmake @@ -31,9 +31,10 @@ endfunction() # ARCHS # SOURCES # CFLAGS -# DEFS ) +# DEFS +# DEPS ) function(add_compiler_rt_object_libraries name) - cmake_parse_arguments(LIB "" "" "OS;ARCHS;SOURCES;CFLAGS;DEFS" ${ARGN}) + cmake_parse_arguments(LIB "" "" "OS;ARCHS;SOURCES;CFLAGS;DEFS;DEPS" ${ARGN}) set(libnames) if(APPLE) foreach(os ${LIB_OS}) @@ -56,6 +57,9 @@ function(add_compiler_rt_object_libraries name) foreach(libname ${libnames}) add_library(${libname} OBJECT ${LIB_SOURCES}) + if(LIB_DEPS) + add_dependencies(${libname} ${LIB_DEPS}) + endif() # Strip out -msse3 if this isn't macOS. set(target_flags ${LIB_CFLAGS}) diff --git a/compiler-rt/lib/xray/CMakeLists.txt b/compiler-rt/lib/xray/CMakeLists.txt index baac739d4079..dab2511e225f 100644 --- a/compiler-rt/lib/xray/CMakeLists.txt +++ b/compiler-rt/lib/xray/CMakeLists.txt @@ -81,6 +81,10 @@ set(XRAY_COMMON_RUNTIME_OBJECT_LIBS RTSanitizerCommon RTSanitizerCommonLibc) +if (CLANG_DEFAULT_CXX_STDLIB STREQUAL "libc++" AND (TARGET cxx OR HAVE_LIBCXX)) + set(XRAY_DEPS cxx) +endif() + if (APPLE) set(XRAY_LINK_LIBS ${SANITIZER_COMMON_LINK_LIBS}) add_asm_sources(XRAY_ASM_SOURCES xray_trampoline_x86_64.S) @@ -93,25 +97,29 @@ if (APPLE) ARCHS ${XRAY_SUPPORTED_ARCH} SOURCES ${x86_64_SOURCES} CFLAGS ${XRAY_CFLAGS} - DEFS ${XRAY_COMMON_DEFINITIONS}) + DEFS ${XRAY_COMMON_DEFINITIONS} + DEPS ${XRAY_DEPS}) add_compiler_rt_object_libraries(RTXrayFDR OS ${XRAY_SUPPORTED_OS} ARCHS ${XRAY_SUPPORTED_ARCH} SOURCES ${XRAY_FDR_MODE_SOURCES} CFLAGS ${XRAY_CFLAGS} - DEFS ${XRAY_COMMON_DEFINITIONS}) + DEFS ${XRAY_COMMON_DEFINITIONS} + DEPS ${XRAY_DEPS}) add_compiler_rt_object_libraries(RTXrayBASIC OS ${XRAY_SUPPORTED_OS} ARCHS ${XRAY_SUPPORTED_ARCH} SOURCES ${XRAY_BASIC_MODE_SOURCES} CFLAGS ${XRAY_CFLAGS} - DEFS ${XRAY_COMMON_DEFINITIONS}) + DEFS ${XRAY_COMMON_DEFINITIONS} + DEPS ${XRAY_DEPS}) add_compiler_rt_object_libraries(RTXrayPROFILING OS ${XRAY_SUPPORTED_OS} ARCHS ${XRAY_SUPPORTED_ARCH} SOURCES ${XRAY_PROFILING_MODE_SOURCES} CFLAGS ${XRAY_CFLAGS} - DEFS ${XRAY_COMMON_DEFINITIONS}) + DEFS ${XRAY_COMMON_DEFINITIONS} + DEPS ${XRAY_DEPS}) # We only support running on osx for now. add_compiler_rt_runtime(clang_rt.xray @@ -164,19 +172,23 @@ else() # not Apple add_compiler_rt_object_libraries(RTXray ARCHS ${arch} SOURCES ${XRAY_SOURCES} ${${arch}_SOURCES} CFLAGS ${XRAY_CFLAGS} - DEFS ${XRAY_COMMON_DEFINITIONS}) + DEFS ${XRAY_COMMON_DEFINITIONS} + DEPS ${XRAY_DEPS}) add_compiler_rt_object_libraries(RTXrayFDR ARCHS ${arch} SOURCES ${XRAY_FDR_MODE_SOURCES} CFLAGS ${XRAY_CFLAGS} - DEFS ${XRAY_COMMON_DEFINITIONS}) + DEFS ${XRAY_COMMON_DEFINITIONS} + DEPS ${XRAY_DEPS}) add_compiler_rt_object_libraries(RTXrayBASIC ARCHS ${arch} SOURCES ${XRAY_BASIC_MODE_SOURCES} CFLAGS ${XRAY_CFLAGS} - DEFS ${XRAY_COMMON_DEFINITIONS}) + DEFS ${XRAY_COMMON_DEFINITIONS} + DEPS ${XRAY_DEPS}) add_compiler_rt_object_libraries(RTXrayPROFILING ARCHS ${arch} SOURCES ${XRAY_PROFILING_MODE_SOURCES} CFLAGS ${XRAY_CFLAGS} - DEFS ${XRAY_COMMON_DEFINITIONS}) + DEFS ${XRAY_COMMON_DEFINITIONS} + DEPS ${XRAY_DEPS}) # Common XRay archive for instrumented binaries. add_compiler_rt_runtime(clang_rt.xray -- GitLab