hamzasood updated this revision to Diff 166124.
hamzasood added a comment.
Herald added a subscriber: christof.

I've added a fix for another related issue: the tests would fail to link if 
libc++ is built only as a DLL.

The auto-linking doesn't look for a dynamic library unless `_DLL` is defined 
(which I think is done by passing `/MD` to CL), but the test runner doesn't use 
CL-style commands. This could either be solved by either manually defining that 
macro or just disabling auto-linking. The test runner already configures the 
linker correctly so disabling auto-linking seemed like the simplest option.


https://reviews.llvm.org/D51868

Files:
  CMakeLists.txt
  include/filesystem
  test/std/strings/c.strings/cuchar.pass.cpp
  test/support/test_macros.h
  test/support/verbose_assert.h
  utils/libcxx/test/config.py

Index: utils/libcxx/test/config.py
===================================================================
--- utils/libcxx/test/config.py
+++ utils/libcxx/test/config.py
@@ -515,6 +515,10 @@
             # and so that those tests don't have to be changed to tolerate
             # this insanity.
             self.cxx.compile_flags += ['-DNOMINMAX']
+            # Disable auto-linking; the library is linked manually when
+            # configuring the linker flags.
+            if self.cxx_stdlib_under_test == 'libc++':
+                self.cxx.compile_flags += ['-D_LIBCPP_NO_AUTO_LINK']
         additional_flags = self.get_lit_conf('test_compiler_flags')
         if additional_flags:
             self.cxx.compile_flags += shlex.split(additional_flags)
Index: test/support/verbose_assert.h
===================================================================
--- test/support/verbose_assert.h
+++ test/support/verbose_assert.h
@@ -21,18 +21,18 @@
 
 template <class Tp, int ST = (IsStreamable<decltype(std::cerr), Tp>::value ? 1
         : (IsStreamable<decltype(std::wcerr), Tp>::value ? 2 : -1))>
-struct SelectStream {
+struct SelectErrStream {
   static_assert(ST == -1, "specialization required for ST != -1");
   static void Print(Tp const&) { std::clog << "Value Not Streamable!\n"; }
 };
 
 template <class Tp>
-struct SelectStream<Tp, 1> {
+struct SelectErrStream<Tp, 1> {
   static void Print(Tp const& val) { std::cerr << val; }
 };
 
 template <class Tp>
-struct SelectStream<Tp, 2> {
+struct SelectErrStream<Tp, 2> {
   static void Print(Tp const& val) { std::wcerr << val; }
 };
 
@@ -86,14 +86,14 @@
     template <class Tp>
     friend LogType& operator<<(LogType& log, Tp const& value) {
       if (!log.is_disabled) {
-        SelectStream<Tp>::Print(value);
+        SelectErrStream<Tp>::Print(value);
       }
       return log;
     }
 
     friend LogType& operator<<(LogType& log, EndLType* m) {
       if (!log.is_disabled) {
-        SelectStream<EndLType*>::Print(m);
+        std::cerr << m;
       }
       return log;
     }
Index: test/support/test_macros.h
===================================================================
--- test/support/test_macros.h
+++ test/support/test_macros.h
@@ -143,11 +143,6 @@
 #      define TEST_HAS_C11_FEATURES
 #      define TEST_HAS_TIMESPEC_GET
 #    endif
-#  elif defined(_WIN32)
-#    if defined(_MSC_VER) && !defined(__MINGW32__)
-#      define TEST_HAS_C11_FEATURES // Using Microsoft's C Runtime library
-#      define TEST_HAS_TIMESPEC_GET
-#    endif
 #  endif
 #endif
 
Index: test/std/strings/c.strings/cuchar.pass.cpp
===================================================================
--- test/std/strings/c.strings/cuchar.pass.cpp
+++ test/std/strings/c.strings/cuchar.pass.cpp
@@ -8,6 +8,9 @@
 //===----------------------------------------------------------------------===//
 //
 // XFAIL: *
+//
+// The MSVC stdlib has cuchar, which causes this test to pass unexpectedly.
+// UNSUPPORTED: windows
 
 // <cuchar>
 
Index: include/filesystem
===================================================================
--- include/filesystem
+++ include/filesystem
@@ -1390,7 +1390,6 @@
     return __storage_->__what_.c_str();
   }
 
-  _LIBCPP_FUNC_VIS
   void __create_what(int __num_paths);
 
 private:
Index: CMakeLists.txt
===================================================================
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -67,7 +67,7 @@
 option(LIBCXX_ENABLE_ASSERTIONS "Enable assertions independent of build mode." OFF)
 option(LIBCXX_ENABLE_SHARED "Build libc++ as a shared library." ON)
 option(LIBCXX_ENABLE_STATIC "Build libc++ as a static library." ON)
-option(LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY "Build libc++experimental.a" ON)
+option(LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY "Build libc++experimental.a" $<NOT:WIN32>)
 set(ENABLE_FILESYSTEM_DEFAULT ${LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY})
 if (WIN32)
   set(ENABLE_FILESYSTEM_DEFAULT OFF)
@@ -542,8 +542,13 @@
 
 # Warning flags ===============================================================
 add_definitions(-D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+if (MSVC)
+    add_compile_flags(/W4)
+else()
+    add_compile_flags_if_supported(-Wall)
+endif()
 add_compile_flags_if_supported(
-    -Wall -Wextra -W -Wwrite-strings
+    -Wextra -W -Wwrite-strings
     -Wno-unused-parameter -Wno-long-long
     -Werror=return-type)
 if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to