<div dir="ltr">I reverted this commit in r298868, because it broke GreenDragon:<div><a href="http://lab.llvm.org:8080/green/job/clang-stage1-configure-RA_check/29505/consoleFull">http://lab.llvm.org:8080/green/job/clang-stage1-configure-RA_check/29505/consoleFull</a><br></div><div><br></div><div>Cheers,</div><div>Juergen</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Mar 24, 2017 at 10:06 AM, Weiming Zhao via llvm-commits <span dir="ltr"><<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: weimingz<br>
Date: Fri Mar 24 12:06:05 2017<br>
New Revision: 298714<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=298714&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project?rev=298714&view=rev</a><br>
Log:<br>
[Compiler-rt][Builtins] Implement lit-test support (part 2 of 2)<br>
<br>
Summary:<br>
Original r297566 (<a href="https://reviews.llvm.org/D30802" rel="noreferrer" target="_blank">https://reviews.llvm.org/<wbr>D30802</a>) is splitted into two parts.<br>
This part adds CMakefile/lit.cfg support.<br>
<br>
Reviewers: rengolin, compnerd, jroelofs, erik.pilkington<br>
<br>
Subscribers: srhines, dberris, mgorny<br>
<br>
Differential Revision: <a href="https://reviews.llvm.org/D31259" rel="noreferrer" target="_blank">https://reviews.llvm.org/<wbr>D31259</a><br>
<br>
Added:<br>
    compiler-rt/trunk/test/<wbr>builtins/Unit/lit.cfg<br>
    compiler-rt/trunk/test/<wbr>builtins/Unit/<a href="http://lit.site.cfg.in" rel="noreferrer" target="_blank">lit.site.cfg.in</a><br>
Modified:<br>
    compiler-rt/trunk/test/<wbr>builtins/CMakeLists.txt<br>
<br>
Modified: compiler-rt/trunk/test/<wbr>builtins/CMakeLists.txt<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/builtins/CMakeLists.txt?rev=298714&r1=298713&r2=298714&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/compiler-rt/trunk/<wbr>test/builtins/CMakeLists.txt?<wbr>rev=298714&r1=298713&r2=<wbr>298714&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- compiler-rt/trunk/test/<wbr>builtins/CMakeLists.txt (original)<br>
+++ compiler-rt/trunk/test/<wbr>builtins/CMakeLists.txt Fri Mar 24 12:06:05 2017<br>
@@ -9,6 +9,23 @@ configure_lit_site_cfg(<br>
   ${CMAKE_CURRENT_BINARY_DIR}/<wbr>lit.site.cfg<br>
 )<br>
<br>
+#Unit tests.<br>
+<br>
+include(builtin-config-ix)<br>
+<br>
+foreach(arch ${BUILTIN_SUPPORTED_ARCH})<br>
+  set(BUILTINS_TEST_TARGET_ARCH ${arch})<br>
+  string(TOLOWER "-${arch}-${OS_NAME}" BUILTINS_TEST_CONFIG_SUFFIX)<br>
+  get_test_cc_for_arch(${arch} BUILTINS_TEST_TARGET_CC BUILTINS_TEST_TARGET_CFLAGS)<br>
+  string(TOUPPER ${arch} ARCH_UPPER_CASE)<br>
+  set(CONFIG_NAME ${ARCH_UPPER_CASE}${OS_NAME}<wbr>Config)<br>
+  configure_lit_site_cfg(<br>
+    ${CMAKE_CURRENT_SOURCE_DIR}/<wbr>Unit/<a href="http://lit.site.cfg.in" rel="noreferrer" target="_blank">lit.site.cfg.in</a><br>
+    ${CMAKE_CURRENT_BINARY_DIR}/<wbr>Unit/${CONFIG_NAME}/lit.site.<wbr>cfg<br>
+    )<br>
+  list(APPEND BUILTINS_TESTSUITES ${CMAKE_CURRENT_BINARY_DIR}/<wbr>Unit/${CONFIG_NAME})<br>
+endforeach()<br>
+<br>
 add_lit_testsuite(check-<wbr>builtins "Running the Builtins tests"<br>
   ${BUILTINS_TESTSUITES}<br>
   DEPENDS ${BUILTINS_TEST_DEPS})<br>
<br>
Added: compiler-rt/trunk/test/<wbr>builtins/Unit/lit.cfg<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/builtins/Unit/lit.cfg?rev=298714&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/compiler-rt/trunk/<wbr>test/builtins/Unit/lit.cfg?<wbr>rev=298714&view=auto</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- compiler-rt/trunk/test/<wbr>builtins/Unit/lit.cfg (added)<br>
+++ compiler-rt/trunk/test/<wbr>builtins/Unit/lit.cfg Fri Mar 24 12:06:05 2017<br>
@@ -0,0 +1,80 @@<br>
+# -*- Python -*-<br>
+<br>
+import os<br>
+import platform<br>
+<br>
+import lit.formats<br>
+<br>
+def get_required_attr(config, attr_name):<br>
+  attr_value = getattr(config, attr_name, None)<br>
+  if attr_value == None:<br>
+    lit_config.fatal(<br>
+      "No attribute %r in test configuration! You may need to run "<br>
+      "tests from your build directory or add this attribute "<br>
+      "to lit.site.cfg " % attr_name)<br>
+  return attr_value<br>
+<br>
+# Setup config name.<br>
+<a href="http://config.name" rel="noreferrer" target="_blank">config.name</a> = 'Builtins' + config.name_suffix<br>
+<br>
+# Platform-specific default Builtins_OPTIONS for lit tests.<br>
+default_builtins_opts = ''<br>
+<br>
+# Setup source root.<br>
+config.test_source_root = os.path.dirname(__file__)<br>
+<br>
+# Path to the static library<br>
+base_lib = os.path.join(config.compiler_<wbr>rt_libdir, "libclang_rt.builtins-%s.a "<br>
+    % config.target_arch)<br>
+<br>
+builtins_source_dir = os.path.join(<br>
+  get_required_attr(config, "compiler_rt_src_root"), "lib", "builtins")<br>
+builtins_lit_source_dir = get_required_attr(config, "builtins_lit_source_dir")<br>
+<br>
+extra_link_flags = ["-nodefaultlibs"]<br>
+config.substitutions.append( ("%librt ", base_lib + ' -lc -lm ') )<br>
+<br>
+target_cflags = [get_required_attr(config, "target_cflags")]<br>
+target_cflags += ['-fno-builtin', '-I', builtins_source_dir]<br>
+target_cflags += extra_link_flags<br>
+target_cxxflags = config.cxx_mode_flags + target_cflags<br>
+clang_builtins_static_cflags = ([""] +<br>
+                            config.debug_info_flags + target_cflags)<br>
+clang_builtins_static_<wbr>cxxflags = config.cxx_mode_flags + \<br>
+                                 clang_builtins_static_cflags<br>
+<br>
+clang_builtins_cflags = clang_builtins_static_cflags<br>
+clang_builtins_cxxflags = clang_builtins_static_cxxflags<br>
+<br>
+<br>
+config.available_features.<wbr>add('not-android')<br>
+clang_wrapper = ""<br>
+<br>
+def build_invocation(compile_<wbr>flags):<br>
+  return " " + " ".join([clang_wrapper, config.clang] + compile_flags) + " "<br>
+<br>
+<br>
+target_arch = config.target_arch<br>
+if (target_arch == "arm"):<br>
+  target_arch = "armv7"<br>
+<br>
+config.substitutions.append( ("%clang ", build_invocation(target_<wbr>cflags)) )<br>
+config.substitutions.append( ("%clangxx ", build_invocation(target_<wbr>cxxflags)) )<br>
+config.substitutions.append( ("%clang_builtins ", \<br>
+                              build_invocation(clang_<wbr>builtins_cflags)))<br>
+config.substitutions.append( ("%clangxx_builtins ", \<br>
+                              build_invocation(clang_<wbr>builtins_cxxflags)))<br>
+<br>
+# FIXME: move the call_apsr.s into call_apsr.h as inline-asm.<br>
+# some ARM tests needs call_apsr.s<br>
+call_apsr_source = os.path.join(builtins_lit_<wbr>source_dir, 'arm', 'call_apsr.S')<br>
+march_flag = '-march=' + target_arch<br>
+call_apsr_flags = ['-c', march_flag, call_apsr_source]<br>
+config.substitutions.append( ("%arm_call_apsr ", \<br>
+                              build_invocation(call_apsr_<wbr>flags)) )<br>
+<br>
+# Default test suffixes.<br>
+config.suffixes = ['.c', '.cc', '.cpp']<br>
+<br>
+if not config.emulator:<br>
+  config.available_features.add(<wbr>'native-run')<br>
<br>
Added: compiler-rt/trunk/test/<wbr>builtins/Unit/<a href="http://lit.site.cfg.in" rel="noreferrer" target="_blank">lit.site.cfg.in</a><br>
URL: <a href="http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/builtins/Unit/lit.site.cfg.in?rev=298714&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/compiler-rt/trunk/<wbr>test/builtins/Unit/lit.site.<wbr>cfg.in?rev=298714&view=auto</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- compiler-rt/trunk/test/<wbr>builtins/Unit/<a href="http://lit.site.cfg.in" rel="noreferrer" target="_blank">lit.site.cfg.in</a> (added)<br>
+++ compiler-rt/trunk/test/<wbr>builtins/Unit/<a href="http://lit.site.cfg.in" rel="noreferrer" target="_blank">lit.site.cfg.in</a> Fri Mar 24 12:06:05 2017<br>
@@ -0,0 +1,12 @@<br>
+@LIT_SITE_CFG_IN_HEADER@<br>
+<br>
+config.name_suffix = "@BUILTINS_TEST_CONFIG_SUFFIX@<wbr>"<br>
+config.builtins_lit_source_<wbr>dir = "@BUILTINS_LIT_SOURCE_DIR@/<wbr>Unit"<br>
+config.target_cflags = "@BUILTINS_TEST_TARGET_CFLAGS@<wbr>"<br>
+config.target_arch = "@BUILTINS_TEST_TARGET_ARCH@"<br>
+<br>
+# Load common config for all compiler-rt lit tests.<br>
+lit_config.load_config(<wbr>config, "@COMPILER_RT_BINARY_DIR@/<wbr>test/lit.common.configured")<br>
+<br>
+# Load tool-specific config that would do the real work.<br>
+lit_config.load_config(<wbr>config, "@BUILTINS_LIT_SOURCE_DIR@/<wbr>Unit/lit.cfg")<br>
<br>
<br>
______________________________<wbr>_________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-commits</a><br>
</blockquote></div><br></div>