[PATCH] D28725: [libc++][CMake] Use debug MSVC runtimes when libc++ is built in debug mode

Eric Fiselier via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Jan 13 22:59:41 PST 2017


EricWF updated this revision to Diff 84433.

https://reviews.llvm.org/D28725

Files:
  CMakeLists.txt
  lib/CMakeLists.txt
  test/CMakeLists.txt
  test/libcxx/test/config.py
  test/lit.site.cfg.in


Index: test/lit.site.cfg.in
===================================================================
--- test/lit.site.cfg.in
+++ test/lit.site.cfg.in
@@ -26,7 +26,7 @@
 config.llvm_unwinder            = "@LIBCXXABI_USE_LLVM_UNWINDER@"
 config.has_libatomic            = "@LIBCXX_HAS_ATOMIC_LIB@"
 config.use_libatomic            = "@LIBCXX_HAVE_CXX_ATOMICS_WITH_LIB@"
-
+config.debug_build              = "@LIBCXX_DEBUG_BUILD@"
 config.libcxxabi_shared         = "@LIBCXXABI_ENABLE_SHARED@"
 config.cxx_ext_threads          = "@LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY@"
 
Index: test/libcxx/test/config.py
===================================================================
--- test/libcxx/test/config.py
+++ test/libcxx/test/config.py
@@ -148,6 +148,7 @@
         self.lit_config.note('Using available_features: %s' %
                              list(self.config.available_features))
         self.lit_config.note('Using environment: %r' % self.exec_env)
+        sys.stderr.flush()  # Force flushing to avoid broken output on Windows
 
     def get_test_format(self):
         return LibcxxTestFormat(
@@ -667,7 +668,9 @@
             self.cxx.link_flags += ['-lcxxrt']
         elif cxx_abi == 'none' or cxx_abi == 'default':
             if self.is_windows:
-                self.cxx.link_flags += ['-lmsvcrt']
+                debug_suffix = 'd' \
+                    if self.get_lit_bool('debug_build', default=False) else ''
+                self.cxx.link_flags += ['-lmsvcrt%s' % debug_suffix]
         else:
             self.lit_config.fatal(
                 'C++ ABI setting %s unsupported for tests' % cxx_abi)
Index: test/CMakeLists.txt
===================================================================
--- test/CMakeLists.txt
+++ test/CMakeLists.txt
@@ -35,6 +35,7 @@
 pythonize_bool(LIBCXX_HAS_ATOMIC_LIB)
 pythonize_bool(LIBCXX_HAVE_CXX_ATOMICS_WITH_LIB)
 pythonize_bool(LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY)
+pythonize_bool(LIBCXX_DEBUG_BUILD)
 
 # By default, for non-standalone builds, libcxx and libcxxabi share a library
 # directory.
Index: lib/CMakeLists.txt
===================================================================
--- lib/CMakeLists.txt
+++ lib/CMakeLists.txt
@@ -102,14 +102,21 @@
 if (NOT WIN32)
   add_flags_if_supported(-fPIC)
 endif()
+
 add_link_flags_if_supported(-nodefaultlibs)
 
 if (LIBCXX_TARGETING_MSVC)
+  if (LIBCXX_DEBUG_BUILD)
+    set(LIB_SUFFIX "d")
+  else()
+    set(LIB_SUFFIX "")
+  endif()
   add_compile_flags(/Zl)
   add_link_flags(/nodefaultlib)
-  add_library_flags(ucrt) # Universal C runtime
-  add_library_flags(vcruntime) # C++ runtime
-  add_library_flags(msvcrt) # C runtime startup files
+
+  add_library_flags(ucrt${LIB_SUFFIX}) # Universal C runtime
+  add_library_flags(vcruntime${LIB_SUFFIX}) # C++ runtime
+  add_library_flags(msvcrt${LIB_SUFFIX}) # C runtime startup files
   # Required for standards-complaint wide character formatting functions
   # (e.g. `printfw`/`scanfw`)
   add_library_flags(iso_stdio_wide_specifiers)
Index: CMakeLists.txt
===================================================================
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -369,6 +369,11 @@
 endif()
 
 string(TOUPPER "${CMAKE_BUILD_TYPE}" uppercase_CMAKE_BUILD_TYPE)
+if (uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG")
+  set(LIBCXX_DEBUG_BUILD ON)
+else()
+  set(LIBCXX_DEBUG_BUILD OFF)
+endif()
 
 #===============================================================================
 # Setup Compiler Flags


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D28725.84433.patch
Type: text/x-patch
Size: 3464 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170114/20fdd212/attachment.bin>


More information about the cfe-commits mailing list