[compiler-rt] 692131f - [compiler-rt] Explicitly set dependency on libcxx for MemProfUnitTest

Haowei Wu via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 22 12:47:20 PST 2021


Author: Haowei Wu
Date: 2021-11-22T12:47:12-08:00
New Revision: 692131f41aa1a8b4e1f7606546d206201ae2e55c

URL: https://github.com/llvm/llvm-project/commit/692131f41aa1a8b4e1f7606546d206201ae2e55c
DIFF: https://github.com/llvm/llvm-project/commit/692131f41aa1a8b4e1f7606546d206201ae2e55c.diff

LOG: [compiler-rt] Explicitly set dependency on libcxx for MemProfUnitTest

MemProfUnitTest now depends on libcxx but the dependency is not
explicitly expressed in build system, causing build races. This patch
addresses this issue.

Differential Revision: https://reviews.llvm.org/D114267

Added: 
    

Modified: 
    compiler-rt/lib/memprof/tests/CMakeLists.txt

Removed: 
    


################################################################################
diff  --git a/compiler-rt/lib/memprof/tests/CMakeLists.txt b/compiler-rt/lib/memprof/tests/CMakeLists.txt
index 4c12c1ad45235..1dfd78399e5c6 100644
--- a/compiler-rt/lib/memprof/tests/CMakeLists.txt
+++ b/compiler-rt/lib/memprof/tests/CMakeLists.txt
@@ -30,6 +30,10 @@ if(NOT WIN32)
   list(APPEND MEMPROF_UNITTEST_LINK_FLAGS -pthread)
 endif()
 
+foreach(lib ${SANITIZER_TEST_CXX_LIBRARIES})
+  list(APPEND MEMPROF_UNITTEST_LINK_FLAGS -l${lib})
+endforeach()
+
 if(COMPILER_RT_DEFAULT_TARGET_ARCH IN_LIST MEMPROF_SUPPORTED_ARCH)
   # MemProf unit tests are only run on the host machine.
   set(arch ${COMPILER_RT_DEFAULT_TARGET_ARCH})
@@ -45,7 +49,11 @@ if(COMPILER_RT_DEFAULT_TARGET_ARCH IN_LIST MEMPROF_SUPPORTED_ARCH)
     $<TARGET_OBJECTS:RTSanitizerCommonSymbolizer.${arch}>)
   set_target_compile_flags(MemProfUnitTests ${MEMPROF_UNITTEST_CFLAGS})
   set_target_link_flags(MemProfUnitTests ${MEMPROF_UNITTEST_LINK_FLAGS})
-  target_link_libraries(MemProfUnitTests dl) 
+  target_link_libraries(MemProfUnitTests dl)
+
+  if (TARGET cxx-headers OR HAVE_LIBCXX)
+    add_dependencies(MemProfUnitTests cxx-headers)
+  endif()
 
   set_target_properties(MemProfUnitTests PROPERTIES
     RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})


        


More information about the llvm-commits mailing list