Skip to content

Commit

Permalink
Allow compiler-rt test targets to work with multi-config CMake genera…
Browse files Browse the repository at this point in the history
…tors

Multi-config CMake generators need lit to be able to resolve paths of
artifacts from previous build steps at lit time, rather than expect them
to be fully resolved at CMake time as they may contain the build mode.

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

llvm-svn: 318037
  • Loading branch information
gregbedwell committed Nov 13, 2017
1 parent 2aa707b commit d6b0ecb
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 14 deletions.
11 changes: 11 additions & 0 deletions compiler-rt/cmake/Modules/AddCompilerRT.cmake
Expand Up @@ -508,3 +508,14 @@ function(rt_externalize_debuginfo name)
message(FATAL_ERROR "COMPILER_RT_EXTERNALIZE_DEBUGINFO isn't implemented for non-darwin platforms!")
endif()
endfunction()


# Configure lit configuration files, including compiler-rt specific variables.
function(configure_compiler_rt_lit_site_cfg input output)
set_llvm_build_mode()

string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} COMPILER_RT_RESOLVED_TEST_COMPILER ${COMPILER_RT_TEST_COMPILER})
string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} COMPILER_RT_RESOLVED_LIBRARY_OUTPUT_DIR ${COMPILER_RT_LIBRARY_OUTPUT_DIR})

configure_lit_site_cfg(${input} ${output})
endfunction()
4 changes: 2 additions & 2 deletions compiler-rt/test/CMakeLists.txt
@@ -1,7 +1,7 @@
# Needed for lit support
# Needed for lit support in standalone builds.
include(AddLLVM)

configure_lit_site_cfg(
configure_compiler_rt_lit_site_cfg(
${CMAKE_CURRENT_SOURCE_DIR}/lit.common.configured.in
${CMAKE_CURRENT_BINARY_DIR}/lit.common.configured)

Expand Down
5 changes: 0 additions & 5 deletions compiler-rt/test/lit.common.cfg
Expand Up @@ -27,11 +27,6 @@ config.test_format = lit.formats.ShTest(execute_external)
if execute_external:
config.available_features.add('shell')

# Setup clang binary.
compiler_path = getattr(config, 'clang', None)
if (not compiler_path) or (not os.path.exists(compiler_path)):
lit_config.fatal("Can't find compiler on path %r" % compiler_path)

compiler_id = getattr(config, 'compiler_id', None)
if compiler_id == "Clang":
if platform.system() != 'Windows':
Expand Down
11 changes: 8 additions & 3 deletions compiler-rt/test/lit.common.configured.in
Expand Up @@ -16,14 +16,14 @@ set_default("llvm_src_root", "@LLVM_MAIN_SRC_DIR@")
set_default("llvm_obj_root", "@LLVM_BINARY_DIR@")
set_default("compiler_rt_src_root", "@COMPILER_RT_SOURCE_DIR@")
set_default("compiler_rt_obj_root", "@COMPILER_RT_BINARY_DIR@")
set_default("llvm_tools_dir", "@LLVM_TOOLS_BINARY_DIR@")
set_default("llvm_tools_dir", "@LLVM_TOOLS_DIR@")
set_default("llvm_shlib_dir", "@LLVM_LIBRARY_OUTPUT_INTDIR@")
set_default("gold_executable", "@GOLD_EXECUTABLE@")
set_default("clang", "@COMPILER_RT_TEST_COMPILER@")
set_default("clang", "@COMPILER_RT_RESOLVED_TEST_COMPILER@")
set_default("compiler_id", "@COMPILER_RT_TEST_COMPILER_ID@")
set_default("python_executable", "@PYTHON_EXECUTABLE@")
set_default("compiler_rt_debug", @COMPILER_RT_DEBUG_PYBOOL@)
set_default("compiler_rt_libdir", "@COMPILER_RT_LIBRARY_OUTPUT_DIR@")
set_default("compiler_rt_libdir", "@COMPILER_RT_RESOLVED_LIBRARY_OUTPUT_DIR@")
set_default("emulator", "@COMPILER_RT_EMULATOR@")
set_default("ios", False)
set_default("iossim", False)
Expand All @@ -39,9 +39,14 @@ config.available_features.add('target-is-%s' % config.target_arch)
# apply substitution.
try:
config.llvm_tools_dir = config.llvm_tools_dir % lit_config.params
config.clang = config.clang % lit_config.params
config.compiler_rt_libdir = config.compiler_rt_libdir % lit_config.params
except KeyError as e:
key, = e.args
lit_config.fatal("unable to find %r parameter, use '--param=%s=VALUE'" % (key, key))

if not os.path.exists(config.clang):
lit_config.fatal("Can't find compiler on path %r" % config.clang)

# Setup attributes common for all compiler-rt projects.
lit_config.load_config(config, "@COMPILER_RT_SOURCE_DIR@/test/lit.common.cfg")
4 changes: 2 additions & 2 deletions compiler-rt/unittests/CMakeLists.txt
@@ -1,6 +1,6 @@
# Needed for lit support
# Needed for lit support in standalone builds.
include(AddLLVM)

configure_lit_site_cfg(
configure_compiler_rt_lit_site_cfg(
${CMAKE_CURRENT_SOURCE_DIR}/lit.common.unit.configured.in
${CMAKE_CURRENT_BINARY_DIR}/lit.common.unit.configured)
5 changes: 3 additions & 2 deletions compiler-rt/unittests/lit.common.unit.configured.in
Expand Up @@ -4,9 +4,9 @@
config.target_triple = "@TARGET_TRIPLE@"
config.llvm_src_root = "@LLVM_MAIN_SRC_DIR@"
config.llvm_obj_root = "@LLVM_BINARY_DIR@"
config.llvm_tools_dir = "@LLVM_TOOLS_BINARY_DIR@"
config.llvm_tools_dir = "@LLVM_TOOLS_DIR@"
config.compiler_rt_src_root = "@COMPILER_RT_SOURCE_DIR@"
config.compiler_rt_libdir = "@COMPILER_RT_LIBRARY_OUTPUT_DIR@"
config.compiler_rt_libdir = "@COMPILER_RT_RESOLVED_LIBRARY_OUTPUT_DIR@"
config.llvm_build_mode = "@LLVM_BUILD_MODE@"
config.host_arch = "@HOST_ARCH@"
config.host_os = "@HOST_OS@"
Expand All @@ -15,6 +15,7 @@ config.host_os = "@HOST_OS@"
# so try to apply substitution.
try:
config.llvm_tools_dir = config.llvm_tools_dir % lit_config.params
config.compiler_rt_libdir = config.compiler_rt_libdir % lit_config.params
config.llvm_build_mode = config.llvm_build_mode % lit_config.params
except KeyError as e:
key, = e.args
Expand Down

0 comments on commit d6b0ecb

Please sign in to comment.