This is an archive of the discontinued LLVM Phabricator instance.

Include lib/Testing/ only if LLVM_INCLUDE_TESTS is enabled
Needs ReviewPublic

Authored by jiangyi on Jan 27 2019, 3:25 AM.

Details

Reviewers
zturner
chandlerc
Summary

lib/Testing contains functionalities only used by test code. If the users disable LLVM_INCLUDE_TESTS we can shorten the llvm build time.

Diff Detail

Repository
rL LLVM

Event Timeline

jiangyi created this revision.Jan 27 2019, 3:25 AM

This will probably break XRay when building with -DLLVM_INCLUDE_TESTS=OFF -DCOMPILER_RT_INCLUDE_TESTS=ON.

@mgorny compiler-rt includes those tests depending on llvm/lib/Testing/ only if COMPILER_RT_INCLUDE_TESTS is enabled and one of the following cmake conditions is true:

  1. NOT COMPILER_RT_STANDALONE_BUILD
  2. COMPILER_RT_HAS_LLVMTESTINGSUPPORT (true if llvm/lib/Testing/ is built)

So compiler-rt can still build with test if we do not assume in-tree llvm + compiler-rt build always provides llvm/lib/Testing/ and let compiler-rt/cmake/Modules/CompilerRTUtils.cmake probes if the dependent library (libLLVMTestingSupport) exists regardless of in-tree or out-of-tree build.

The compiler-rt patch is as follow:

diff --git a/lib/xray/tests/unit/CMakeLists.txt b/lib/xray/tests/unit/CMakeLists.txt
index d10524b8d..fc083a9e4 100644
--- a/lib/xray/tests/unit/CMakeLists.txt
+++ b/lib/xray/tests/unit/CMakeLists.txt
@@ -1,16 +1,16 @@
 set(TEST_SOURCES
   allocator_test.cc
   buffer_queue_test.cc
   function_call_trie_test.cc
   profile_collector_test.cc
   segmented_array_test.cc
   test_helpers.cc
   xray_unit_test_main.cc)
 
-if (NOT COMPILER_RT_STANDALONE_BUILD OR COMPILER_RT_HAS_LLVMTESTINGSUPPORT)
+if (COMPILER_RT_HAS_LLVMTESTINGSUPPORT)
   list(APPEND TEST_SOURCES
     fdr_controller_test.cc
     fdr_log_writer_test.cc)
 endif()
 
 add_xray_unittest(XRayTest SOURCES ${TEST_SOURCES})