[libcxx-commits] [libcxx] ab41129 - [libc++] Proper fix for libc++'s modulemap after D68480

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Tue Feb 25 08:41:49 PST 2020


Author: Louis Dionne
Date: 2020-02-25T11:31:10-05:00
New Revision: ab41129b1ee1f20d772f9eed346c10edcd70396a

URL: https://github.com/llvm/llvm-project/commit/ab41129b1ee1f20d772f9eed346c10edcd70396a
DIFF: https://github.com/llvm/llvm-project/commit/ab41129b1ee1f20d772f9eed346c10edcd70396a.diff

LOG: [libc++] Proper fix for libc++'s modulemap after D68480

Summary:
In libc++, we normally #ifdef out header content instead of #erroring
out when the Standard in use is insufficient for the requirements of
the header.

Reviewers: EricWF

Subscribers: jkorous, dexonsmith, libcxx-commits, teemperor

Tags: #libc

Differential Revision: https://reviews.llvm.org/D75074

Added: 
    libcxx/test/libcxx/modules/stds_include.sh.cpp

Modified: 
    libcxx/include/barrier
    libcxx/include/latch
    libcxx/include/semaphore

Removed: 
    


################################################################################
diff  --git a/libcxx/include/barrier b/libcxx/include/barrier
index e6dc0a19a5c3..5ef8b78e83c4 100644
--- a/libcxx/include/barrier
+++ b/libcxx/include/barrier
@@ -57,9 +57,7 @@ namespace std
 # error <barrier> is not supported on this single threaded system
 #endif
 
-#if _LIBCPP_STD_VER < 14
-# error <barrier> requires C++14 or later
-#endif
+#if _LIBCPP_STD_VER >= 14
 
 _LIBCPP_BEGIN_NAMESPACE_STD
 
@@ -319,4 +317,6 @@ public:
 
 _LIBCPP_END_NAMESPACE_STD
 
+#endif // _LIBCPP_STD_VER >= 14
+
 #endif //_LIBCPP_BARRIER

diff  --git a/libcxx/include/latch b/libcxx/include/latch
index 7c8b2f52205b..c83f6bf41368 100644
--- a/libcxx/include/latch
+++ b/libcxx/include/latch
@@ -49,9 +49,7 @@ namespace std
 # error <latch> is not supported on this single threaded system
 #endif
 
-#if _LIBCPP_STD_VER < 14
-# error <latch> requires C++14 or later
-#endif
+#if _LIBCPP_STD_VER >= 14
 
 _LIBCPP_BEGIN_NAMESPACE_STD
 
@@ -101,4 +99,6 @@ public:
 
 _LIBCPP_END_NAMESPACE_STD
 
+#endif // _LIBCPP_STD_VER >= 14
+
 #endif //_LIBCPP_LATCH

diff  --git a/libcxx/include/semaphore b/libcxx/include/semaphore
index 77e3797f7ac6..cd27534d3e85 100644
--- a/libcxx/include/semaphore
+++ b/libcxx/include/semaphore
@@ -58,9 +58,7 @@ using binary_semaphore = counting_semaphore<1>;
 # error <semaphore> is not supported on this single threaded system
 #endif
 
-#if _LIBCPP_STD_VER < 14
-# error <semaphore> is requires C++14 or later
-#endif
+#if _LIBCPP_STD_VER >= 14
 
 _LIBCPP_BEGIN_NAMESPACE_STD
 
@@ -230,4 +228,6 @@ using binary_semaphore = counting_semaphore<1>;
 
 _LIBCPP_END_NAMESPACE_STD
 
+#endif // _LIBCPP_STD_VER >= 14
+
 #endif //_LIBCPP_SEMAPHORE

diff  --git a/libcxx/test/libcxx/modules/stds_include.sh.cpp b/libcxx/test/libcxx/modules/stds_include.sh.cpp
new file mode 100644
index 000000000000..ce5bfb2a8eef
--- /dev/null
+++ b/libcxx/test/libcxx/modules/stds_include.sh.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// Test that we can include libc++ headers when building with modules
+// enabled in various Standard modes. This is a common source of breakage
+// since the 'std' module will include all headers, so if something in a
+// header fails under a standard mode, importing anything will fail.
+
+// This test fails on Windows because the underlying libc headers on Windows
+// are not modular
+// XFAIL: LIBCXX-WINDOWS-FIXME
+
+// FIXME: The <atomic> header is not supported for single-threaded systems,
+// but still gets built as part of the 'std' module, which breaks the build.
+// XFAIL: libcpp-has-no-threads
+
+// REQUIRES: modules-support
+
+// NOTE: The -std=XXX flag is present in %flags, so we overwrite it by passing it after %flags.
+// RUN: %cxx %flags %compile_flags -fmodules -fcxx-modules -fsyntax-only -std=c++98 %s
+// RUN: %cxx %flags %compile_flags -fmodules -fcxx-modules -fsyntax-only -std=c++03 %s
+// RUN: %cxx %flags %compile_flags -fmodules -fcxx-modules -fsyntax-only -std=c++11 %s
+// RUN: %cxx %flags %compile_flags -fmodules -fcxx-modules -fsyntax-only -std=c++14 %s
+// RUN: %cxx %flags %compile_flags -fmodules -fcxx-modules -fsyntax-only -std=c++17 %s
+// RUN: %cxx %flags %compile_flags -fmodules -fcxx-modules -fsyntax-only -std=c++2a %s
+
+#include <vector>
+
+int main(int, char**) {
+  return 0;
+}


        


More information about the libcxx-commits mailing list