[compiler-rt] r298892 - Reland "[Compiler-rt][Builtins] Implement lit-test support (part 2 of 2)"

Weiming Zhao via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 27 16:57:45 PDT 2017


Author: weimingz
Date: Mon Mar 27 18:57:44 2017
New Revision: 298892

URL: http://llvm.org/viewvc/llvm-project?rev=298892&view=rev
Log:
Reland "[Compiler-rt][Builtins] Implement lit-test support (part 2 of 2)"

Re-land of r298714 which got reverted in r298868.
It looks like the current lit tests won't run for Apple.
Possible reason is the libname is different. (need to update
the base_lib variable of lit.cfg)

Added:
    compiler-rt/trunk/test/builtins/Unit/lit.cfg
    compiler-rt/trunk/test/builtins/Unit/lit.site.cfg.in
Modified:
    compiler-rt/trunk/test/builtins/CMakeLists.txt

Modified: compiler-rt/trunk/test/builtins/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/builtins/CMakeLists.txt?rev=298892&r1=298891&r2=298892&view=diff
==============================================================================
--- compiler-rt/trunk/test/builtins/CMakeLists.txt (original)
+++ compiler-rt/trunk/test/builtins/CMakeLists.txt Mon Mar 27 18:57:44 2017
@@ -9,6 +9,26 @@ configure_lit_site_cfg(
   ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg
 )
 
+#Unit tests.
+
+include(builtin-config-ix)
+
+#TODO: Add support for Apple.
+if (NOT APPLE)
+foreach(arch ${BUILTIN_SUPPORTED_ARCH})
+  set(BUILTINS_TEST_TARGET_ARCH ${arch})
+  string(TOLOWER "-${arch}-${OS_NAME}" BUILTINS_TEST_CONFIG_SUFFIX)
+  get_test_cc_for_arch(${arch} BUILTINS_TEST_TARGET_CC BUILTINS_TEST_TARGET_CFLAGS)
+  string(TOUPPER ${arch} ARCH_UPPER_CASE)
+  set(CONFIG_NAME ${ARCH_UPPER_CASE}${OS_NAME}Config)
+  configure_lit_site_cfg(
+    ${CMAKE_CURRENT_SOURCE_DIR}/Unit/lit.site.cfg.in
+    ${CMAKE_CURRENT_BINARY_DIR}/Unit/${CONFIG_NAME}/lit.site.cfg
+    )
+  list(APPEND BUILTINS_TESTSUITES ${CMAKE_CURRENT_BINARY_DIR}/Unit/${CONFIG_NAME})
+endforeach()
+endif()
+
 add_lit_testsuite(check-builtins "Running the Builtins tests"
   ${BUILTINS_TESTSUITES}
   DEPENDS ${BUILTINS_TEST_DEPS})

Added: compiler-rt/trunk/test/builtins/Unit/lit.cfg
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/builtins/Unit/lit.cfg?rev=298892&view=auto
==============================================================================
--- compiler-rt/trunk/test/builtins/Unit/lit.cfg (added)
+++ compiler-rt/trunk/test/builtins/Unit/lit.cfg Mon Mar 27 18:57:44 2017
@@ -0,0 +1,80 @@
+# -*- Python -*-
+
+import os
+import platform
+
+import lit.formats
+
+def get_required_attr(config, attr_name):
+  attr_value = getattr(config, attr_name, None)
+  if attr_value == None:
+    lit_config.fatal(
+      "No attribute %r in test configuration! You may need to run "
+      "tests from your build directory or add this attribute "
+      "to lit.site.cfg " % attr_name)
+  return attr_value
+
+# Setup config name.
+config.name = 'Builtins' + config.name_suffix
+
+# Platform-specific default Builtins_OPTIONS for lit tests.
+default_builtins_opts = ''
+
+# Setup source root.
+config.test_source_root = os.path.dirname(__file__)
+
+# Path to the static library
+base_lib = os.path.join(config.compiler_rt_libdir, "libclang_rt.builtins-%s.a "
+    % config.target_arch)
+
+builtins_source_dir = os.path.join(
+  get_required_attr(config, "compiler_rt_src_root"), "lib", "builtins")
+builtins_lit_source_dir = get_required_attr(config, "builtins_lit_source_dir")
+
+extra_link_flags = ["-nodefaultlibs"]
+config.substitutions.append( ("%librt ", base_lib + ' -lc -lm ') )
+
+target_cflags = [get_required_attr(config, "target_cflags")]
+target_cflags += ['-fno-builtin', '-I', builtins_source_dir]
+target_cflags += extra_link_flags
+target_cxxflags = config.cxx_mode_flags + target_cflags
+clang_builtins_static_cflags = ([""] +
+                            config.debug_info_flags + target_cflags)
+clang_builtins_static_cxxflags = config.cxx_mode_flags + \
+                                 clang_builtins_static_cflags
+
+clang_builtins_cflags = clang_builtins_static_cflags
+clang_builtins_cxxflags = clang_builtins_static_cxxflags
+
+
+config.available_features.add('not-android')
+clang_wrapper = ""
+
+def build_invocation(compile_flags):
+  return " " + " ".join([clang_wrapper, config.clang] + compile_flags) + " "
+
+
+target_arch = config.target_arch
+if (target_arch == "arm"):
+  target_arch = "armv7"
+
+config.substitutions.append( ("%clang ", build_invocation(target_cflags)) )
+config.substitutions.append( ("%clangxx ", build_invocation(target_cxxflags)) )
+config.substitutions.append( ("%clang_builtins ", \
+                              build_invocation(clang_builtins_cflags)))
+config.substitutions.append( ("%clangxx_builtins ", \
+                              build_invocation(clang_builtins_cxxflags)))
+
+# FIXME: move the call_apsr.s into call_apsr.h as inline-asm.
+# some ARM tests needs call_apsr.s
+call_apsr_source = os.path.join(builtins_lit_source_dir, 'arm', 'call_apsr.S')
+march_flag = '-march=' + target_arch
+call_apsr_flags = ['-c', march_flag, call_apsr_source]
+config.substitutions.append( ("%arm_call_apsr ", \
+                              build_invocation(call_apsr_flags)) )
+
+# Default test suffixes.
+config.suffixes = ['.c', '.cc', '.cpp']
+
+if not config.emulator:
+  config.available_features.add('native-run')

Added: compiler-rt/trunk/test/builtins/Unit/lit.site.cfg.in
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/builtins/Unit/lit.site.cfg.in?rev=298892&view=auto
==============================================================================
--- compiler-rt/trunk/test/builtins/Unit/lit.site.cfg.in (added)
+++ compiler-rt/trunk/test/builtins/Unit/lit.site.cfg.in Mon Mar 27 18:57:44 2017
@@ -0,0 +1,12 @@
+ at LIT_SITE_CFG_IN_HEADER@
+
+config.name_suffix = "@BUILTINS_TEST_CONFIG_SUFFIX@"
+config.builtins_lit_source_dir = "@BUILTINS_LIT_SOURCE_DIR@/Unit"
+config.target_cflags = "@BUILTINS_TEST_TARGET_CFLAGS@"
+config.target_arch = "@BUILTINS_TEST_TARGET_ARCH@"
+
+# Load common config for all compiler-rt lit tests.
+lit_config.load_config(config, "@COMPILER_RT_BINARY_DIR@/test/lit.common.configured")
+
+# Load tool-specific config that would do the real work.
+lit_config.load_config(config, "@BUILTINS_LIT_SOURCE_DIR@/Unit/lit.cfg")




More information about the llvm-commits mailing list