[libc++] Fix modules and benchmarks CI builds when incomplete features are disabled
Differential Revision: https://reviews.llvm.org/D119036
NOKEYCHECK=True
GitOrigin-RevId: 506cf6dc048835c598b654e43ed8f723a42e39ba
diff --git a/benchmarks/CMakeLists.txt b/benchmarks/CMakeLists.txt
index 8c8c9e4..95e2861 100644
--- a/benchmarks/CMakeLists.txt
+++ b/benchmarks/CMakeLists.txt
@@ -166,6 +166,11 @@
# Register Benchmark tests
#==============================================================================
file(GLOB BENCHMARK_TESTS "*.bench.cpp")
+
+if (NOT LIBCXX_ENABLE_INCOMPLETE_FEATURES)
+ list(FILTER BENCHMARK_TESTS EXCLUDE REGEX "(format_to_n|format_to|format|formatted_size|formatter_float|std_format_spec_string_unicode).bench.cpp")
+endif()
+
foreach(test_path ${BENCHMARK_TESTS})
get_filename_component(test_file "${test_path}" NAME)
string(REPLACE ".bench.cpp" "" test_name "${test_file}")
diff --git a/include/__debug b/include/__debug
index 43554de..5d0b5bf 100644
--- a/include/__debug
+++ b/include/__debug
@@ -29,10 +29,10 @@
# define _LIBCPP_ASSERT_IMPL(x, m) ((void)0)
#elif _LIBCPP_DEBUG_LEVEL == 1
# define _LIBCPP_DEBUG_ASSERT(x, m) ((void)0)
-# define _LIBCPP_ASSERT_IMPL(x, m) ((x) ? (void)0 : _VSTD::__libcpp_debug_function(_VSTD::__libcpp_debug_info(__FILE__, __LINE__, #x, m)))
+# define _LIBCPP_ASSERT_IMPL(x, m) ((x) ? (void)0 : ::std::__libcpp_debug_function(::std::__libcpp_debug_info(__FILE__, __LINE__, #x, m)))
#elif _LIBCPP_DEBUG_LEVEL == 2
-# define _LIBCPP_DEBUG_ASSERT(x, m) _LIBCPP_ASSERT(__libcpp_is_constant_evaluated() || (x), m)
-# define _LIBCPP_ASSERT_IMPL(x, m) ((x) ? (void)0 : _VSTD::__libcpp_debug_function(_VSTD::__libcpp_debug_info(__FILE__, __LINE__, #x, m)))
+# define _LIBCPP_DEBUG_ASSERT(x, m) _LIBCPP_ASSERT(::std::__libcpp_is_constant_evaluated() || (x), m)
+# define _LIBCPP_ASSERT_IMPL(x, m) ((x) ? (void)0 : ::std::__libcpp_debug_function(::std::__libcpp_debug_info(__FILE__, __LINE__, #x, m)))
#else
# error _LIBCPP_DEBUG_LEVEL must be one of 0, 1, 2
#endif
diff --git a/include/module.modulemap b/include/module.modulemap
index a182ded..442958b 100644
--- a/include/module.modulemap
+++ b/include/module.modulemap
@@ -2,7 +2,8 @@
// since __config may be included from C headers which may create an
// include cycle.
module std_config [system] [extern_c] {
- header "__config"
+ textual header "__config"
+ textual header "__config_site"
}
module std [system] {
diff --git a/test/configs/llvm-libc++-shared-clangcl.cfg.in b/test/configs/llvm-libc++-shared-clangcl.cfg.in
index dcb2b07..b779ded 100644
--- a/test/configs/llvm-libc++-shared-clangcl.cfg.in
+++ b/test/configs/llvm-libc++-shared-clangcl.cfg.in
@@ -5,7 +5,7 @@
config.substitutions.append(('%{flags}', '--driver-mode=g++'))
config.substitutions.append(('%{compile_flags}',
- '-nostdinc++ -isystem %{include} -isystem %{target-include} -I %{libcxx}/test/support -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_WARNINGS -D_CRT_STDIO_ISO_WIDE_SPECIFIERS -DNOMINMAX'
+ '-nostdinc++ -isystem %{include} -isystem %{target-include} -I %{libcxx}/test/support -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_WARNINGS -D_CRT_STDIO_ISO_WIDE_SPECIFIERS'
))
config.substitutions.append(('%{link_flags}',
'-nostdlib -L %{lib} -lc++ -lmsvcrt -lmsvcprt -loldnames'
diff --git a/test/configs/llvm-libc++-static-clangcl.cfg.in b/test/configs/llvm-libc++-static-clangcl.cfg.in
index 14812b2..5a578f4 100644
--- a/test/configs/llvm-libc++-static-clangcl.cfg.in
+++ b/test/configs/llvm-libc++-static-clangcl.cfg.in
@@ -5,7 +5,7 @@
config.substitutions.append(('%{flags}', '--driver-mode=g++'))
config.substitutions.append(('%{compile_flags}',
- '-nostdinc++ -isystem %{include} -isystem %{target-include} -I %{libcxx}/test/support -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_WARNINGS -D_CRT_STDIO_ISO_WIDE_SPECIFIERS -DNOMINMAX'
+ '-nostdinc++ -isystem %{include} -isystem %{target-include} -I %{libcxx}/test/support -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_WARNINGS -D_CRT_STDIO_ISO_WIDE_SPECIFIERS'
))
config.substitutions.append(('%{link_flags}',
'-nostdlib -L %{lib} -llibc++ -lmsvcrt -lmsvcprt -loldnames'
diff --git a/test/libcxx/algorithms/debug_less.pass.cpp b/test/libcxx/algorithms/debug_less.pass.cpp
index 6dd5695..7f63749 100644
--- a/test/libcxx/algorithms/debug_less.pass.cpp
+++ b/test/libcxx/algorithms/debug_less.pass.cpp
@@ -16,6 +16,7 @@
struct DebugException {};
+// ADDITIONAL_COMPILE_FLAGS: -Wno-macro-redefined
#define _LIBCPP_DEBUG 0
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : throw ::DebugException())
diff --git a/test/libcxx/debug/debug_abort.pass.cpp b/test/libcxx/debug/debug_abort.pass.cpp
index 8ecb8be..a56c304 100644
--- a/test/libcxx/debug/debug_abort.pass.cpp
+++ b/test/libcxx/debug/debug_abort.pass.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=0
+// ADDITIONAL_COMPILE_FLAGS: -Wno-macro-redefined -D_LIBCPP_DEBUG=0
// UNSUPPORTED: libcxx-no-debug-mode
// Test that the default debug handler aborts the program.
diff --git a/test/libcxx/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.mem/db_deallocate.pass.cpp b/test/libcxx/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.mem/db_deallocate.pass.cpp
index 612451b..35e887d 100644
--- a/test/libcxx/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.mem/db_deallocate.pass.cpp
+++ b/test/libcxx/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.mem/db_deallocate.pass.cpp
@@ -16,6 +16,7 @@
int AssertCount = 0;
+// ADDITIONAL_COMPILE_FLAGS: -Wno-macro-redefined
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : (void)::AssertCount++)
#define _LIBCPP_DEBUG 0
#include <experimental/memory_resource>
diff --git a/test/libcxx/experimental/memory/memory.resource.adaptor/memory.resource.adaptor.mem/db_deallocate.pass.cpp b/test/libcxx/experimental/memory/memory.resource.adaptor/memory.resource.adaptor.mem/db_deallocate.pass.cpp
index cbc1e26..850d5aa 100644
--- a/test/libcxx/experimental/memory/memory.resource.adaptor/memory.resource.adaptor.mem/db_deallocate.pass.cpp
+++ b/test/libcxx/experimental/memory/memory.resource.adaptor/memory.resource.adaptor.mem/db_deallocate.pass.cpp
@@ -16,6 +16,7 @@
int AssertCount = 0;
+// ADDITIONAL_COMPILE_FLAGS: -Wno-macro-redefined
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : (void)::AssertCount++)
#define _LIBCPP_DEBUG 0
#include <experimental/memory_resource>
diff --git a/test/libcxx/input.output/filesystems/class.path/path.itr/iterator_db.pass.cpp b/test/libcxx/input.output/filesystems/class.path/path.itr/iterator_db.pass.cpp
index 8e25ac8..b29c0ca 100644
--- a/test/libcxx/input.output/filesystems/class.path/path.itr/iterator_db.pass.cpp
+++ b/test/libcxx/input.output/filesystems/class.path/path.itr/iterator_db.pass.cpp
@@ -10,7 +10,7 @@
// UNSUPPORTED: windows
// UNSUPPORTED: libcxx-no-debug-mode
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=0
+// ADDITIONAL_COMPILE_FLAGS: -Wno-macro-redefined -D_LIBCPP_DEBUG=0
// <filesystem>
diff --git a/test/libcxx/iterators/advance.debug1.pass.cpp b/test/libcxx/iterators/advance.debug1.pass.cpp
index 3b71f7f..09a4e6a 100644
--- a/test/libcxx/iterators/advance.debug1.pass.cpp
+++ b/test/libcxx/iterators/advance.debug1.pass.cpp
@@ -8,7 +8,7 @@
// UNSUPPORTED: c++03
// UNSUPPORTED: windows
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=0
+// ADDITIONAL_COMPILE_FLAGS: -Wno-macro-redefined -D_LIBCPP_DEBUG=0
// UNSUPPORTED: libcxx-no-debug-mode
// <list>
diff --git a/test/libcxx/iterators/next.debug1.pass.cpp b/test/libcxx/iterators/next.debug1.pass.cpp
index e2eaf58..a7a51f7 100644
--- a/test/libcxx/iterators/next.debug1.pass.cpp
+++ b/test/libcxx/iterators/next.debug1.pass.cpp
@@ -8,7 +8,7 @@
// UNSUPPORTED: c++03
// UNSUPPORTED: windows
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=0
+// ADDITIONAL_COMPILE_FLAGS: -Wno-macro-redefined -D_LIBCPP_DEBUG=0
// UNSUPPORTED: libcxx-no-debug-mode
// <list>
@@ -27,8 +27,8 @@
forward_iterator<int *> it(a+1);
- std::next(it, 1); // should work fine
- std::next(it, 0); // should work fine
+ std::next(it, 1); // should work fine
+ std::next(it, 0); // should work fine
EXPECT_DEATH( std::next(it, -1) ); // can't go backwards on a FwdIter
return 0;
diff --git a/test/libcxx/iterators/prev.debug1.pass.cpp b/test/libcxx/iterators/prev.debug1.pass.cpp
index 35d5449..f236cdc 100644
--- a/test/libcxx/iterators/prev.debug1.pass.cpp
+++ b/test/libcxx/iterators/prev.debug1.pass.cpp
@@ -8,7 +8,7 @@
// UNSUPPORTED: c++03
// UNSUPPORTED: windows
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=0
+// ADDITIONAL_COMPILE_FLAGS: -Wno-macro-redefined -D_LIBCPP_DEBUG=0
// UNSUPPORTED: libcxx-no-debug-mode
// <list>
@@ -26,8 +26,8 @@
int a[] = {1, 2, 3};
bidirectional_iterator<int *> bidi(a+1);
- std::prev(bidi, -1); // should work fine
- std::prev(bidi, 0); // should work fine
+ std::prev(bidi, -1); // should work fine
+ std::prev(bidi, 0); // should work fine
std::prev(bidi, 1); // should work fine
forward_iterator<int *> it(a+1);
diff --git a/test/libcxx/thread/futures/futures.promise/set_exception.pass.cpp b/test/libcxx/thread/futures/futures.promise/set_exception.pass.cpp
index a79fdab..150813d 100644
--- a/test/libcxx/thread/futures/futures.promise/set_exception.pass.cpp
+++ b/test/libcxx/thread/futures/futures.promise/set_exception.pass.cpp
@@ -11,7 +11,7 @@
// UNSUPPORTED: c++03
// UNSUPPORTED: libcxx-no-debug-mode
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=0
+// ADDITIONAL_COMPILE_FLAGS: -Wno-macro-redefined -D_LIBCPP_DEBUG=0
// <future>
diff --git a/test/libcxx/thread/futures/futures.promise/set_exception_at_thread_exit.pass.cpp b/test/libcxx/thread/futures/futures.promise/set_exception_at_thread_exit.pass.cpp
index 407b69f..19b6756 100644
--- a/test/libcxx/thread/futures/futures.promise/set_exception_at_thread_exit.pass.cpp
+++ b/test/libcxx/thread/futures/futures.promise/set_exception_at_thread_exit.pass.cpp
@@ -11,7 +11,7 @@
// UNSUPPORTED: c++03
// UNSUPPORTED: libcxx-no-debug-mode
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=0
+// ADDITIONAL_COMPILE_FLAGS: -Wno-macro-redefined -D_LIBCPP_DEBUG=0
// <future>
diff --git a/test/std/input.output/filesystems/class.directory_entry/directory_entry.obs/last_write_time.pass.cpp b/test/std/input.output/filesystems/class.directory_entry/directory_entry.obs/last_write_time.pass.cpp
index 928248b..6038bfd 100644
--- a/test/std/input.output/filesystems/class.directory_entry/directory_entry.obs/last_write_time.pass.cpp
+++ b/test/std/input.output/filesystems/class.directory_entry/directory_entry.obs/last_write_time.pass.cpp
@@ -19,6 +19,9 @@
// file_time_type last_write_time() const;
// file_time_type last_write_time(error_code const&) const noexcept;
+// Disable min() and max() macros in <windows.h> on Windows.
+// ADDITIONAL_COMPILE_FLAGS: -DNOMINMAX
+
#include "filesystem_include.h"
#include <type_traits>
#include <cassert>
diff --git a/test/std/input.output/filesystems/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp b/test/std/input.output/filesystems/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp
index 4ecf628..3f1a475 100644
--- a/test/std/input.output/filesystems/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp
+++ b/test/std/input.output/filesystems/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp
@@ -22,6 +22,9 @@
// void last_write_time(const path& p, file_time_type new_type,
// std::error_code& ec) noexcept;
+// Disable min() and max() macros in <windows.h> on Windows.
+// ADDITIONAL_COMPILE_FLAGS: -DNOMINMAX
+
#include "filesystem_include.h"
#include <chrono>
#include <cstdio>
diff --git a/test/support/filesystem_test_helper.h b/test/support/filesystem_test_helper.h
index 746cbe6..e8c453c 100644
--- a/test/support/filesystem_test_helper.h
+++ b/test/support/filesystem_test_helper.h
@@ -31,6 +31,9 @@
# include <sys/un.h>
#endif
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
namespace utils {
#ifdef _WIN32
inline int mkdir(const char* path, int mode) { (void)mode; return ::_mkdir(path); }
@@ -733,4 +736,6 @@
return fs::path();
}
-#endif /* FILESYSTEM_TEST_HELPER_HPP */
+_LIBCPP_POP_MACROS
+
+#endif /* FILESYSTEM_TEST_HELPER_H */
diff --git a/utils/libcxx/test/config.py b/utils/libcxx/test/config.py
index fdc1ff4..bc71829 100644
--- a/utils/libcxx/test/config.py
+++ b/utils/libcxx/test/config.py
@@ -245,10 +245,6 @@
# Build the tests in the same configuration as libcxx itself,
# to avoid mismatches if linked statically.
self.cxx.compile_flags += ['-D_CRT_STDIO_ISO_WIDE_SPECIFIERS']
- # Required so that tests using min/max don't fail on Windows,
- # and so that those tests don't have to be changed to tolerate
- # this insanity.
- self.cxx.compile_flags += ['-DNOMINMAX']
additional_flags = self.get_lit_conf('test_compiler_flags')
if additional_flags:
self.cxx.compile_flags += shlex.split(additional_flags)
diff --git a/utils/libcxx/test/features.py b/utils/libcxx/test/features.py
index 429e2d8..54f318e 100644
--- a/utils/libcxx/test/features.py
+++ b/utils/libcxx/test/features.py
@@ -129,22 +129,10 @@
'_LIBCPP_HAS_NO_UNICODE': 'libcpp-has-no-unicode',
}
for macro, feature in macros.items():
- DEFAULT_FEATURES += [
- Feature(name=lambda cfg, m=macro, f=feature: f + (
- '={}'.format(compilerMacros(cfg)[m]) if compilerMacros(cfg)[m] else ''
- ),
- when=lambda cfg, m=macro: m in compilerMacros(cfg),
-
- # FIXME: This is a hack that should be fixed using module maps.
- # If modules are enabled then we have to lift all of the definitions
- # in <__config_site> onto the command line.
- actions=lambda cfg, m=macro: [
- AddCompileFlag('-Wno-macro-redefined -D{}'.format(m) + (
- '={}'.format(compilerMacros(cfg)[m]) if compilerMacros(cfg)[m] else ''
- ))
- ]
- )
- ]
+ DEFAULT_FEATURES.append(
+ Feature(name=lambda cfg, m=macro, f=feature: f + ('={}'.format(compilerMacros(cfg)[m]) if compilerMacros(cfg)[m] else ''),
+ when=lambda cfg, m=macro: m in compilerMacros(cfg))
+ )
# Mapping from canonical locale names (used in the tests) to possible locale