[PATCH] D12392: Use libc++ headers from the correct build tree for sanitizer tests

Evgeniy Stepanov via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 26 17:46:35 PDT 2015


eugenis created this revision.
eugenis added reviewers: samsonov, EricWF, mclow.lists.
eugenis added a subscriber: llvm-commits.
eugenis set the repository for this revision to rL LLVM.

This is needed for http://reviews.llvm.org/D11740. With that change, libc++ headers can no longer be included directly from libc++ source.

Repository:
  rL LLVM

http://reviews.llvm.org/D12392

Files:
  cmake/Modules/AddCompilerRT.cmake
  lib/msan/tests/CMakeLists.txt
  test/tsan/CMakeLists.txt
  test/tsan/lit.cfg
  test/tsan/lit.site.cfg.in

Index: test/tsan/lit.site.cfg.in
===================================================================
--- test/tsan/lit.site.cfg.in
+++ test/tsan/lit.site.cfg.in
@@ -2,6 +2,8 @@
 # Do not edit!
 
 config.has_libcxx = @TSAN_HAS_LIBCXX@
+config.libcxx_incdir = "@TSAN_LIBCXX_INCDIR@"
+config.libcxx_libdir = "@TSAN_LIBCXX_LIBDIR@"
 
 # Load common config for all compiler-rt lit tests.
 lit_config.load_config(config, "@COMPILER_RT_BINARY_DIR@/test/lit.common.configured")
Index: test/tsan/lit.cfg
===================================================================
--- test/tsan/lit.cfg
+++ test/tsan/lit.cfg
@@ -35,16 +35,11 @@
 clang_tsan_cxxflags = config.cxx_mode_flags + clang_tsan_cflags
 # Add additional flags if we're using instrumented libc++.
 if config.has_libcxx:
-  # FIXME: Dehardcode this path somehow.
-  libcxx_path = os.path.join(config.compiler_rt_obj_root, "lib",
-                             "tsan", "libcxx_tsan")
-  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")
+  libcxx_so = os.path.join(config.libcxx_libdir, "libc++.so")
   clang_tsan_cxxflags += ["-std=c++11",
-                          "-I%s" % libcxx_incdir,
+                          "-I%s" % config.libcxx_incdir,
                           libcxx_so,
-                          "-Wl,-rpath=%s" % libcxx_libdir]
+                          "-Wl,-rpath=%s" % config.libcxx_libdir]
 
 def build_invocation(compile_flags):
   return " " + " ".join([config.clang] + compile_flags) + " "
Index: test/tsan/CMakeLists.txt
===================================================================
--- test/tsan/CMakeLists.txt
+++ test/tsan/CMakeLists.txt
@@ -9,6 +9,8 @@
    COMPILER_RT_TEST_COMPILER_ID STREQUAL "Clang")
   list(APPEND TSAN_TEST_DEPS libcxx_tsan)
   set(TSAN_HAS_LIBCXX True)
+  set(TSAN_LIBCXX_INCDIR ${CMAKE_CURRENT_BINARY_DIR}/../../lib/tsan/libcxx_tsan/include/c++/v${LIBCXX_ABI_MAJOR_VERSION})
+  set(TSAN_LIBCXX_LIBDIR ${CMAKE_CURRENT_BINARY_DIR}/../../lib/tsan/libcxx_tsan/lib)
 else()
   set(TSAN_HAS_LIBCXX False)
 endif()
Index: lib/msan/tests/CMakeLists.txt
===================================================================
--- lib/msan/tests/CMakeLists.txt
+++ lib/msan/tests/CMakeLists.txt
@@ -92,20 +92,21 @@
 macro(add_msan_tests_for_arch arch kind)
   # Build gtest instrumented with MSan.
   set(MSAN_INST_GTEST)
+  set(LIBCXX_CFLAGS "-I${LIBCXX_PREFIX}/include/c++/v${LIBCXX_ABI_MAJOR_VERSION}")
   msan_compile(MSAN_INST_GTEST ${COMPILER_RT_GTEST_SOURCE} ${arch} "${kind}"
-                               ${MSAN_UNITTEST_INSTRUMENTED_CFLAGS} ${ARGN})
+               ${LIBCXX_CFLAGS} ${MSAN_UNITTEST_INSTRUMENTED_CFLAGS} ${ARGN})
 
   # Instrumented tests.
   set(MSAN_INST_TEST_OBJECTS)
   foreach (SOURCE ${MSAN_UNITTEST_SOURCES})
     msan_compile(MSAN_INST_TEST_OBJECTS ${SOURCE} ${arch} "${kind}"
-                 ${MSAN_UNITTEST_INSTRUMENTED_CFLAGS} ${ARGN})
+                 ${LIBCXX_CFLAGS} ${MSAN_UNITTEST_INSTRUMENTED_CFLAGS} ${ARGN})
   endforeach(SOURCE)
 
   # Instrumented loadable module objects.
   set(MSAN_INST_LOADABLE_OBJECTS)
   msan_compile(MSAN_INST_LOADABLE_OBJECTS ${MSAN_LOADABLE_SOURCE} ${arch} "${kind}"
-               ${MSAN_UNITTEST_INSTRUMENTED_CFLAGS} ${ARGN})
+               ${LIBCXX_CFLAGS} ${MSAN_UNITTEST_INSTRUMENTED_CFLAGS} ${ARGN})
 
   # Instrumented loadable library tests.
   set(MSAN_LOADABLE_SO)
Index: cmake/Modules/AddCompilerRT.cmake
===================================================================
--- cmake/Modules/AddCompilerRT.cmake
+++ cmake/Modules/AddCompilerRT.cmake
@@ -276,6 +276,8 @@
                -DCMAKE_CXX_FLAGS=${LIBCXX_CFLAGS}
                -DCMAKE_BUILD_TYPE=Release
                -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>
+               -DLIBCXX_ABI_MAJOR_VERSION=${LIBCXX_ABI_MAJOR_VERSION}
+               -DLIBCXX_ABI_MINOR_VERSION=${LIBCXX_ABI_MINOR_VERSION}
     LOG_BUILD 1
     LOG_CONFIGURE 1
     LOG_INSTALL 1


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D12392.33284.patch
Type: text/x-patch
Size: 4036 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150827/326766bd/attachment.bin>


More information about the llvm-commits mailing list