[compiler-rt] r201656 - [CMake] Add the way to run tests in standalone build.
Alexey Samsonov
samsonov at google.com
Wed Feb 19 02:04:30 PST 2014
Author: samsonov
Date: Wed Feb 19 04:04:29 2014
New Revision: 201656
URL: http://llvm.org/viewvc/llvm-project?rev=201656&view=rev
Log:
[CMake] Add the way to run tests in standalone build.
1) Depend on llvm-config (configured in LLVM_CONFIG_PATH) to
get necessary LLVM source/binary directories.
2) Add basic support for running lit tests (check-xsan commands).
For now this "support" is far from what we want:
* unit tests are not built currently.
* lit tests use Clang/compiler-rt from LLVM build directory,
not the host compiler or just-built compiler-rt libraries.
We should make a choice on the way we intend ti run compiler-rt lit testsuite:
a) use either Clang from LLVM build tree, or the host compiler.
b) use either just-built runtimes, or the runtimes shipped with the
host compiler.
Using just-built runtimes is tricky - we have to know where to put them, so that
Clang/GCC driver would pick them up (and not overwrite the existing runtimes).
Using a host compiler instead of Clang from LLVM build tree will give us a chance to
run lit tests under GCC (which already has support for several sanitizers).
That is, I tend to make the following choice: if we're in a standalone compiler-rt
build, use host compiler with its set of runtime libraries to run lit tests.
This will effectively decouple "make compiler-rt" and "make check-compiler-rt" in
a standalone build - the latter wouldn't invoke the former. Note that if we decide
to fix LLVM/Clang/compiler-rt build system so that it would configure/build
compiler-rt with just-built Clang (as we do in Makefile-based build), this will not
be a problem - we can add a dependency to ensure that clang/compiler-rt are rebuilt
before running compiler-rt tests.
Modified:
compiler-rt/trunk/CMakeLists.txt
compiler-rt/trunk/test/CMakeLists.txt
Modified: compiler-rt/trunk/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/CMakeLists.txt?rev=201656&r1=201655&r2=201656&view=diff
==============================================================================
--- compiler-rt/trunk/CMakeLists.txt (original)
+++ compiler-rt/trunk/CMakeLists.txt Wed Feb 19 04:04:29 2014
@@ -44,23 +44,50 @@ else()
"Path where built compiler-rt libraries should be stored.")
set(COMPILER_RT_INSTALL_PATH ${CMAKE_INSTALL_PREFIX} CACHE PATH
"Path where built compiler-rt libraries should be installed.")
- # FIXME: Rely on llvm-config instead.
- set(LLVM_BUILD_DIR "" CACHE PATH "Path to LLVM build tree.")
- if (NOT LLVM_BUILD_DIR)
- message(FATAL_ERROR "LLVM_BUILD_DIR must be specified.")
+
+ set(LLVM_CONFIG_PATH "" CACHE PATH "Path to llvm-config binary")
+ if (NOT LLVM_CONFIG_PATH)
+ find_program(LLVM_CONFIG_PATH "llvm-config")
+ if (NOT LLVM_CONFIG_PATH)
+ message(FATAL_ERROR "llvm-config not found: specify LLVM_CONFIG_PATH")
+ endif()
+ endif()
+ execute_process(
+ COMMAND ${LLVM_CONFIG_PATH} "--obj-root" "--bindir" "--libdir" "--src-root"
+ RESULT_VARIABLE HAD_ERROR
+ OUTPUT_VARIABLE CONFIG_OUTPUT)
+ if (HAD_ERROR)
+ message(FATAL_ERROR "llvm-config failed with status ${HAD_ERROR}")
endif()
+ string(REGEX REPLACE "[ \t]*[\r\n]+[ \t]*" ";" CONFIG_OUTPUT ${CONFIG_OUTPUT})
+ list(GET CONFIG_OUTPUT 0 LLVM_BINARY_DIR)
+ list(GET CONFIG_OUTPUT 1 LLVM_TOOLS_BINARY_DIR)
+ list(GET CONFIG_OUTPUT 2 LLVM_LIBRARY_DIR)
+ list(GET CONFIG_OUTPUT 3 LLVM_MAIN_SRC_DIR)
+
# Make use of LLVM CMake modules.
- set(LLVM_CMAKE_PATH "${LLVM_BUILD_DIR}/share/llvm/cmake")
+ set(LLVM_CMAKE_PATH "${LLVM_BINARY_DIR}/share/llvm/cmake")
list(APPEND CMAKE_MODULE_PATH "${LLVM_CMAKE_PATH}")
# Get some LLVM variables from LLVMConfig.
include("${LLVM_CMAKE_PATH}/LLVMConfig.cmake")
- # Setup another LLVM variables.
- # FIXME: get the following paths from llvm-config instead.
- set(LLVM_TOOLS_BINARY_DIR "${LLVM_BUILD_DIR}/bin")
- set(LLVM_LIBRARY_DIR "${LLVM_BUILD_DIR}/lib")
-
set(LLVM_LIBRARY_OUTPUT_INTDIR ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/lib)
+
+ # Find Python interpreter.
+ set(Python_ADDITIONAL_VERSIONS 2.7 2.6 2.5)
+ include(FindPythonInterp)
+ if(NOT PYTHONINTERP_FOUND)
+ message(FATAL_ERROR "
+ Unable to find Python interpreter required testing. Please install Python
+ or specify the PYTHON_EXECUTABLE CMake variable.")
+ endif()
+
+ # Define default arguments to lit.
+ set(LIT_ARGS_DEFAULT "-sv")
+ if (MSVC OR XCODE)
+ set(LIT_ARGS_DEFAULT "${LIT_ARGS_DEFAULT} --no-progress-bar")
+ endif()
+ set(LLVM_LIT_ARGS "${LIT_ARGS_DEFAULT}" CACHE STRING "Default options for lit")
endif()
string(TOLOWER ${CMAKE_SYSTEM_NAME} COMPILER_RT_OS_DIR)
Modified: compiler-rt/trunk/test/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/CMakeLists.txt?rev=201656&r1=201655&r2=201656&view=diff
==============================================================================
--- compiler-rt/trunk/test/CMakeLists.txt (original)
+++ compiler-rt/trunk/test/CMakeLists.txt Wed Feb 19 04:04:29 2014
@@ -6,12 +6,16 @@ configure_lit_site_cfg(
# add_subdirectory(BlocksRuntime)
# add_subdirectory(builtins)
+set(SANITIZER_COMMON_LIT_TEST_DEPS)
# When ANDROID, we build tests with the host compiler (i.e. CMAKE_C_COMPILER),
# and run tests with tools from the host toolchain.
-if (NOT ANDROID)
- set(SANITIZER_COMMON_LIT_TEST_DEPS
- clang clang-headers FileCheck count not llvm-nm llvm-symbolizer
- compiler-rt-headers)
+if(NOT ANDROID)
+ if(NOT COMPILER_RT_STANDALONE_BUILD)
+ # Use LLVM utils and Clang from the same build tree.
+ list(APPEND SANITIZER_COMMON_LIT_TEST_DEPS
+ clang clang-headers FileCheck count not llvm-nm llvm-symbolizer
+ compiler-rt-headers)
+ endif()
if(UNIX)
list(APPEND SANITIZER_COMMON_LIT_TEST_DEPS SanitizerLintCheck)
endif()
More information about the llvm-commits
mailing list