[llvm-branch-commits] [compiler-rt-branch] r259664 - Merging r259542:

Daniel Sanders via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Wed Feb 3 09:11:51 PST 2016


Author: dsanders
Date: Wed Feb  3 11:11:50 2016
New Revision: 259664

URL: http://llvm.org/viewvc/llvm-project?rev=259664&view=rev
Log:
Merging r259542:
------------------------------------------------------------------------
r259542 | dsanders | 2016-02-02 18:43:53 +0000 (Tue, 02 Feb 2016) | 24 lines

Re-commit r259512: [tsan] Add a libc++ and lit testsuite for each ${TSAN_SUPPORTED_ARCH}.

Summary:
This is a workaround to a problem in the 3.8 release that affects MIPS and
possibly other targets where the default is not supported but a sibling is
supported.

When TSAN_SUPPORTED_ARCH is not empty, cmake currently attempts to build a
tsan'd libcxx as well as test tsan for the default target regardless of whether
the default target is supported or not. This causes problems on MIPS32 since
tsan is supported for MIPS64 but not MIPS32.

This patch causes cmake to only build the libcxx and run the lit test-suite for
archictures in ${TSAN_SUPPORTED_ARCH}

This re-commit fixes an issue where 'check-tsan' continued to look for the
tsan'd libc++ in the directory it used to be built in.

Reviewers: hans, samsonov

Subscribers: tberghammer, llvm-commits, danalbert, srhines, dvyukov

Differential Revision: http://reviews.llvm.org/D16685

------------------------------------------------------------------------

Modified:
    compiler-rt/branches/release_38/lib/tsan/CMakeLists.txt
    compiler-rt/branches/release_38/test/tsan/CMakeLists.txt
    compiler-rt/branches/release_38/test/tsan/lit.cfg
    compiler-rt/branches/release_38/test/tsan/lit.site.cfg.in

Modified: compiler-rt/branches/release_38/lib/tsan/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/branches/release_38/lib/tsan/CMakeLists.txt?rev=259664&r1=259663&r2=259664&view=diff
==============================================================================
--- compiler-rt/branches/release_38/lib/tsan/CMakeLists.txt (original)
+++ compiler-rt/branches/release_38/lib/tsan/CMakeLists.txt Wed Feb  3 11:11:50 2016
@@ -204,10 +204,17 @@ endif()
 # Build libcxx instrumented with TSan.
 if(COMPILER_RT_HAS_LIBCXX_SOURCES AND
    COMPILER_RT_TEST_COMPILER_ID STREQUAL "Clang")
-  set(LIBCXX_PREFIX ${CMAKE_CURRENT_BINARY_DIR}/libcxx_tsan)
-  add_custom_libcxx(libcxx_tsan ${LIBCXX_PREFIX}
-    DEPS ${TSAN_RUNTIME_LIBRARIES}
-    CFLAGS -fsanitize=thread)
+  set(libcxx_tsan_deps)
+  foreach(arch ${TSAN_SUPPORTED_ARCH})
+    get_target_flags_for_arch(${arch} TARGET_CFLAGS)
+    set(LIBCXX_PREFIX ${CMAKE_CURRENT_BINARY_DIR}/libcxx_tsan_${arch})
+    add_custom_libcxx(libcxx_tsan_${arch} ${LIBCXX_PREFIX}
+      DEPS ${TSAN_RUNTIME_LIBRARIES}
+      CFLAGS ${TARGET_CFLAGS} -fsanitize=thread)
+    list(APPEND libcxx_tsan_deps libcxx_tsan_${arch})
+  endforeach()
+
+  add_custom_target(libcxx_tsan DEPENDS ${libcxx_tsan_deps})
 endif()
 
 if(COMPILER_RT_INCLUDE_TESTS)

Modified: compiler-rt/branches/release_38/test/tsan/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/branches/release_38/test/tsan/CMakeLists.txt?rev=259664&r1=259663&r2=259664&view=diff
==============================================================================
--- compiler-rt/branches/release_38/test/tsan/CMakeLists.txt (original)
+++ compiler-rt/branches/release_38/test/tsan/CMakeLists.txt Wed Feb  3 11:11:50 2016
@@ -14,9 +14,28 @@ else()
   set(TSAN_HAS_LIBCXX False)
 endif()
 
-configure_lit_site_cfg(
-  ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in
-  ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg)
+set(TSAN_TESTSUITES)
+
+foreach(arch ${TSAN_SUPPORTED_ARCH})
+  string(TOLOWER "-${arch}" TSAN_TEST_CONFIG_SUFFIX)
+  if(ANDROID OR ${arch} MATCHES "arm|aarch64")
+    # This is only true if we are cross-compiling.
+    # Build all tests with host compiler and use host tools.
+    set(TSAN_TEST_TARGET_CC ${COMPILER_RT_TEST_COMPILER})
+    set(TSAN_TEST_TARGET_CFLAGS ${COMPILER_RT_TEST_COMPILER_CFLAGS})
+  else()
+    get_target_flags_for_arch(${arch} TSAN_TEST_TARGET_CFLAGS)
+    string(REPLACE ";" " " TSAN_TEST_TARGET_CFLAGS "${TSAN_TEST_TARGET_CFLAGS}")
+  endif()
+
+  string(TOUPPER ${arch} ARCH_UPPER_CASE)
+  set(CONFIG_NAME ${ARCH_UPPER_CASE}Config)
+
+  configure_lit_site_cfg(
+    ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in
+    ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/lit.site.cfg)
+  list(APPEND TSAN_TESTSUITES ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME})
+endforeach()
 
 if(COMPILER_RT_INCLUDE_TESTS)
   configure_lit_site_cfg(
@@ -26,6 +45,6 @@ if(COMPILER_RT_INCLUDE_TESTS)
 endif()
 
 add_lit_testsuite(check-tsan "Running ThreadSanitizer tests"
-  ${CMAKE_CURRENT_BINARY_DIR}
+  ${TSAN_TESTSUITES}
   DEPENDS ${TSAN_TEST_DEPS})
 set_target_properties(check-tsan PROPERTIES FOLDER "TSan tests")

Modified: compiler-rt/branches/release_38/test/tsan/lit.cfg
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/branches/release_38/test/tsan/lit.cfg?rev=259664&r1=259663&r2=259664&view=diff
==============================================================================
--- compiler-rt/branches/release_38/test/tsan/lit.cfg (original)
+++ compiler-rt/branches/release_38/test/tsan/lit.cfg Wed Feb  3 11:11:50 2016
@@ -12,7 +12,7 @@ def get_required_attr(config, attr_name)
   return attr_value
 
 # Setup config name.
-config.name = 'ThreadSanitizer'
+config.name = 'ThreadSanitizer' + config.name_suffix
 
 # Setup source root.
 config.test_source_root = os.path.dirname(__file__)
@@ -39,16 +39,18 @@ else:
   extra_cflags = []
 
 # Setup default compiler flags used with -fsanitize=thread option.
-clang_tsan_cflags = ["-fsanitize=thread",
-                     "-Wall",
-                     "-m64"] + config.debug_info_flags + extra_cflags
+clang_tsan_cflags = (["-fsanitize=thread",
+                      "-Wall"] +
+                      [config.target_cflags] +
+                      config.debug_info_flags +
+                      extra_cflags)
 clang_tsan_cxxflags = config.cxx_mode_flags + clang_tsan_cflags
 # Add additional flags if we're using instrumented libc++.
 # Instrumented libcxx currently not supported on Darwin.
 if config.has_libcxx and config.host_os != 'Darwin':
   # FIXME: Dehardcode this path somehow.
   libcxx_path = os.path.join(config.compiler_rt_obj_root, "lib",
-                             "tsan", "libcxx_tsan")
+                             "tsan", "libcxx_tsan_" + config.arch)
   libcxx_incdir = os.path.join(libcxx_path, "include", "c++", "v1")
   libcxx_libdir = os.path.join(libcxx_path, "lib")
   libcxx_so = os.path.join(libcxx_libdir, "libc++.so")

Modified: compiler-rt/branches/release_38/test/tsan/lit.site.cfg.in
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/branches/release_38/test/tsan/lit.site.cfg.in?rev=259664&r1=259663&r2=259664&view=diff
==============================================================================
--- compiler-rt/branches/release_38/test/tsan/lit.site.cfg.in (original)
+++ compiler-rt/branches/release_38/test/tsan/lit.site.cfg.in Wed Feb  3 11:11:50 2016
@@ -1,7 +1,10 @@
 ## Autogenerated by LLVM/Clang configuration.
 # Do not edit!
 
+config.name_suffix = "@TSAN_TEST_CONFIG_SUFFIX@"
+config.arch = "@arch@"
 config.has_libcxx = @TSAN_HAS_LIBCXX@
+config.target_cflags = "@TSAN_TEST_TARGET_CFLAGS@"
 
 # Load common config for all compiler-rt lit tests.
 lit_config.load_config(config, "@COMPILER_RT_BINARY_DIR@/test/lit.common.configured")




More information about the llvm-branch-commits mailing list