[libc++] Roll up fstream support into filesystem support

LIBCXX_ENABLE_FILESYSTEM should represent whether the platform has
support for a filesystem, not just whether we support <filesystem>.
This patch slightly generalizes the setting to also encompass whether
we provide <fstream>, since that only makes sense when a filesystem is
supported.

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

GitOrigin-RevId: 66a562d22e708ba40b8443b58e504ac3f983ba59
diff --git a/CMakeLists.txt b/CMakeLists.txt
index d3b7f6f..0152232 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -57,7 +57,10 @@
    by users in their own code regardless of this option." 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_FILESYSTEM "Build filesystem as part of the main libc++ library" ON)
+option(LIBCXX_ENABLE_FILESYSTEM
+  "Whether to include support for parts of the library that rely on a filesystem being
+   available on the platform. This includes things like most parts of <filesystem> and
+   others like <fstream>" ON)
 option(LIBCXX_INCLUDE_TESTS "Build the libc++ tests." ${LLVM_INCLUDE_TESTS})
 option(LIBCXX_ENABLE_DEBUG_MODE
   "Whether to build libc++ with the debug mode enabled.
@@ -76,8 +79,6 @@
    the C locale API (e.g. embedded). When localization is not supported,
    several parts of the library will be disabled: <iostream>, <regex>, <locale>
    will be completely unusable, and other parts may be only partly available." ON)
-option(LIBCXX_ENABLE_FSTREAM
-   "Whether to include support for <fstream>." ON) # TODO: Consider rolling that into LIBCXX_ENABLE_FILESYSTEM
 option(LIBCXX_ENABLE_UNICODE
   "Whether to include support for Unicode in the library. Disabling Unicode can
    be useful when porting to platforms that don't support UTF-8 encoding (e.g.
@@ -779,10 +780,9 @@
 config_define_if(LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY _LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL)
 config_define_if(LIBCXX_HAS_MUSL_LIBC _LIBCPP_HAS_MUSL_LIBC)
 config_define_if(LIBCXX_NO_VCRUNTIME _LIBCPP_NO_VCRUNTIME)
-config_define_if_not(LIBCXX_ENABLE_FILESYSTEM _LIBCPP_HAS_NO_FILESYSTEM_LIBRARY)
+config_define_if_not(LIBCXX_ENABLE_FILESYSTEM _LIBCPP_HAS_NO_FILESYSTEM)
 config_define_if_not(LIBCXX_ENABLE_RANDOM_DEVICE _LIBCPP_HAS_NO_RANDOM_DEVICE)
 config_define_if_not(LIBCXX_ENABLE_LOCALIZATION _LIBCPP_HAS_NO_LOCALIZATION)
-config_define_if_not(LIBCXX_ENABLE_FSTREAM _LIBCPP_HAS_NO_FSTREAM)
 config_define_if_not(LIBCXX_ENABLE_UNICODE _LIBCPP_HAS_NO_UNICODE)
 config_define_if_not(LIBCXX_ENABLE_WIDE_CHARACTERS _LIBCPP_HAS_NO_WIDE_CHARACTERS)
 config_define_if_not(LIBCXX_ENABLE_VENDOR_AVAILABILITY_ANNOTATIONS _LIBCPP_HAS_NO_VENDOR_AVAILABILITY_ANNOTATIONS)
diff --git a/cmake/caches/Generic-no-fstream.cmake b/cmake/caches/Generic-no-fstream.cmake
deleted file mode 100644
index 000d300..0000000
--- a/cmake/caches/Generic-no-fstream.cmake
+++ /dev/null
@@ -1 +0,0 @@
-set(LIBCXX_ENABLE_FSTREAM OFF CACHE BOOL "")
diff --git a/docs/ReleaseNotes.rst b/docs/ReleaseNotes.rst
index 2f040ed..9e477b2 100644
--- a/docs/ReleaseNotes.rst
+++ b/docs/ReleaseNotes.rst
@@ -153,3 +153,11 @@
 - Building libc++ and libc++abi for Apple platforms now requires targeting macOS 10.13 and later.
   This is relevant for vendors building the libc++ shared library and for folks statically linking
   libc++ into an application that has back-deployment requirements on Apple platforms.
+
+- ``LIBCXX_ENABLE_FILESYSTEM`` now represents whether a filesystem is supported on the platform instead
+  of representing merely whether ``<filesystem>`` should be provided. This means that vendors building
+  with ``LIBCXX_ENABLE_FILESYSTEM=OFF`` will now also get ``<fstream>`` excluded from their configuration
+  of the library.
+
+- ``LIBCXX_ENABLE_FSTREAM`` is not supported anymore, please use ``LIBCXX_ENABLE_FILESYSTEM=OFF`` if your
+  platform does not have support for a filesystem.
diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt
index 89b7995..f676805 100644
--- a/include/CMakeLists.txt
+++ b/include/CMakeLists.txt
@@ -990,7 +990,7 @@
   wctype.h
   )
 
-foreach(feature LIBCXX_ENABLE_FILESYSTEM LIBCXX_ENABLE_LOCALIZATION LIBCXX_ENABLE_FSTREAM LIBCXX_ENABLE_THREADS LIBCXX_ENABLE_WIDE_CHARACTERS)
+foreach(feature LIBCXX_ENABLE_FILESYSTEM LIBCXX_ENABLE_LOCALIZATION LIBCXX_ENABLE_THREADS LIBCXX_ENABLE_WIDE_CHARACTERS)
   if (NOT ${${feature}})
     set(requires_${feature} "requires LIBCXX_CONFIGURED_WITHOUT_SUPPORT_FOR_THIS_HEADER")
   endif()
diff --git a/include/__config_site.in b/include/__config_site.in
index 88f7383..6949ae8 100644
--- a/include/__config_site.in
+++ b/include/__config_site.in
@@ -24,10 +24,9 @@
 #cmakedefine _LIBCPP_HAS_NO_VENDOR_AVAILABILITY_ANNOTATIONS
 #cmakedefine _LIBCPP_NO_VCRUNTIME
 #cmakedefine _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION @_LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION@
-#cmakedefine _LIBCPP_HAS_NO_FILESYSTEM_LIBRARY
+#cmakedefine _LIBCPP_HAS_NO_FILESYSTEM
 #cmakedefine _LIBCPP_HAS_NO_RANDOM_DEVICE
 #cmakedefine _LIBCPP_HAS_NO_LOCALIZATION
-#cmakedefine _LIBCPP_HAS_NO_FSTREAM
 #cmakedefine _LIBCPP_HAS_NO_WIDE_CHARACTERS
 #cmakedefine01 _LIBCPP_ENABLE_ASSERTIONS_DEFAULT
 #cmakedefine _LIBCPP_ENABLE_DEBUG_MODE
diff --git a/include/filesystem b/include/filesystem
index b10555d..addf28a 100644
--- a/include/filesystem
+++ b/include/filesystem
@@ -457,7 +457,7 @@
 // [fs.filesystem.syn]
 #include <compare>
 
-#if defined(_LIBCPP_HAS_NO_FILESYSTEM_LIBRARY)
+#if defined(_LIBCPP_HAS_NO_FILESYSTEM)
 # error "The <filesystem> library is not supported since libc++ has been configured without support for a filesystem."
 #endif
 
diff --git a/include/fstream b/include/fstream
index 1aa5414..3c358a9 100644
--- a/include/fstream
+++ b/include/fstream
@@ -194,7 +194,7 @@
 #include <typeinfo>
 #include <version>
 
-#if !defined(_LIBCPP_HAS_NO_FILESYSTEM_LIBRARY)
+#if !defined(_LIBCPP_HAS_NO_FILESYSTEM)
 #   include <filesystem>
 #endif
 
@@ -209,7 +209,7 @@
 #  define _LIBCPP_HAS_NO_OFF_T_FUNCTIONS
 #endif
 
-#if !defined(_LIBCPP_HAS_NO_FSTREAM)
+#if !defined(_LIBCPP_HAS_NO_FILESYSTEM)
 
 _LIBCPP_BEGIN_NAMESPACE_STD
 
@@ -245,7 +245,7 @@
     _LIBCPP_INLINE_VISIBILITY
     basic_filebuf* open(const string& __s, ios_base::openmode __mode);
 
-#if _LIBCPP_STD_VER >= 17 && !defined(_LIBCPP_HAS_NO_FILESYSTEM_LIBRARY)
+#if _LIBCPP_STD_VER >= 17
     _LIBCPP_AVAILABILITY_FILESYSTEM _LIBCPP_INLINE_VISIBILITY
     basic_filebuf* open(const _VSTD_FS::path& __p, ios_base::openmode __mode) {
       return open(__p.c_str(), __mode);
@@ -1168,7 +1168,7 @@
 #endif
     _LIBCPP_INLINE_VISIBILITY
     explicit basic_ifstream(const string& __s, ios_base::openmode __mode = ios_base::in);
-#if _LIBCPP_STD_VER >= 17 && !defined(_LIBCPP_HAS_NO_FILESYSTEM_LIBRARY)
+#if _LIBCPP_STD_VER >= 17
     _LIBCPP_AVAILABILITY_FILESYSTEM _LIBCPP_INLINE_VISIBILITY
     explicit basic_ifstream(const filesystem::path& __p, ios_base::openmode __mode = ios_base::in)
       : basic_ifstream(__p.c_str(), __mode) {}
@@ -1189,7 +1189,7 @@
     void open(const wchar_t* __s, ios_base::openmode __mode = ios_base::in);
 #endif
     void open(const string& __s, ios_base::openmode __mode = ios_base::in);
-#if _LIBCPP_STD_VER >= 17 && !defined(_LIBCPP_HAS_NO_FILESYSTEM_LIBRARY)
+#if _LIBCPP_STD_VER >= 17
     _LIBCPP_AVAILABILITY_FILESYSTEM _LIBCPP_INLINE_VISIBILITY
     void open(const filesystem::path& __p,
               ios_base::openmode __mode = ios_base::in) {
@@ -1369,7 +1369,7 @@
     _LIBCPP_INLINE_VISIBILITY
     explicit basic_ofstream(const string& __s, ios_base::openmode __mode = ios_base::out);
 
-#if _LIBCPP_STD_VER >= 17 && !defined(_LIBCPP_HAS_NO_FILESYSTEM_LIBRARY)
+#if _LIBCPP_STD_VER >= 17
     _LIBCPP_AVAILABILITY_FILESYSTEM _LIBCPP_INLINE_VISIBILITY
     explicit basic_ofstream(const filesystem::path& __p, ios_base::openmode __mode = ios_base::out)
       : basic_ofstream(__p.c_str(), __mode) {}
@@ -1392,7 +1392,7 @@
 #endif
     void open(const string& __s, ios_base::openmode __mode = ios_base::out);
 
-#if _LIBCPP_STD_VER >= 17 && !defined(_LIBCPP_HAS_NO_FILESYSTEM_LIBRARY)
+#if _LIBCPP_STD_VER >= 17
     _LIBCPP_AVAILABILITY_FILESYSTEM _LIBCPP_INLINE_VISIBILITY
     void open(const filesystem::path& __p, ios_base::openmode __mode = ios_base::out)
     { return open(__p.c_str(), __mode); }
@@ -1570,7 +1570,7 @@
     _LIBCPP_INLINE_VISIBILITY
     explicit basic_fstream(const string& __s, ios_base::openmode __mode = ios_base::in | ios_base::out);
 
-#if _LIBCPP_STD_VER >= 17 && !defined(_LIBCPP_HAS_NO_FILESYSTEM_LIBRARY)
+#if _LIBCPP_STD_VER >= 17
     _LIBCPP_AVAILABILITY_FILESYSTEM _LIBCPP_INLINE_VISIBILITY
     explicit basic_fstream(const filesystem::path& __p, ios_base::openmode __mode = ios_base::in | ios_base::out)
       : basic_fstream(__p.c_str(), __mode) {}
@@ -1595,7 +1595,7 @@
 #endif
     _LIBCPP_HIDE_FROM_ABI void open(const string& __s, ios_base::openmode __mode = ios_base::in | ios_base::out);
 
-#if _LIBCPP_STD_VER >= 17 && !defined(_LIBCPP_HAS_NO_FILESYSTEM_LIBRARY)
+#if _LIBCPP_STD_VER >= 17
     _LIBCPP_AVAILABILITY_FILESYSTEM _LIBCPP_INLINE_VISIBILITY
     void open(const filesystem::path& __p, ios_base::openmode __mode = ios_base::in|ios_base::out)
     { return open(__p.c_str(), __mode); }
@@ -1745,7 +1745,7 @@
 
 _LIBCPP_END_NAMESPACE_STD
 
-#endif // _LIBCPP_HAS_NO_FSTREAM
+#endif // _LIBCPP_HAS_NO_FILESYSTEM
 
 _LIBCPP_POP_MACROS
 
diff --git a/include/module.modulemap.in b/include/module.modulemap.in
index 5e390d6..d9948a7 100644
--- a/include/module.modulemap.in
+++ b/include/module.modulemap.in
@@ -976,7 +976,7 @@
   }
   module fstream {
     @requires_LIBCXX_ENABLE_LOCALIZATION@
-    @requires_LIBCXX_ENABLE_FSTREAM@
+    @requires_LIBCXX_ENABLE_FILESYSTEM@
     header "fstream"
     export *
   }
diff --git a/src/ios.instantiations.cpp b/src/ios.instantiations.cpp
index ca77ce1..01fe199 100644
--- a/src/ios.instantiations.cpp
+++ b/src/ios.instantiations.cpp
@@ -37,7 +37,7 @@
 template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS basic_ostringstream<char>;
 template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS basic_istringstream<char>;
 
-#ifndef _LIBCPP_HAS_NO_FSTREAM
+#ifndef _LIBCPP_HAS_NO_FILESYSTEM
 template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS basic_ifstream<char>;
 template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS basic_ofstream<char>;
 template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS basic_filebuf<char>;
diff --git a/test/libcxx/iterators/iterator.requirements/iterator.assoc.types/iterator.traits/legacy_bidirectional_iterator.compile.pass.cpp b/test/libcxx/iterators/iterator.requirements/iterator.assoc.types/iterator.traits/legacy_bidirectional_iterator.compile.pass.cpp
index 5d7097c..e8b5a0c 100644
--- a/test/libcxx/iterators/iterator.requirements/iterator.assoc.types/iterator.traits/legacy_bidirectional_iterator.compile.pass.cpp
+++ b/test/libcxx/iterators/iterator.requirements/iterator.assoc.types/iterator.traits/legacy_bidirectional_iterator.compile.pass.cpp
@@ -20,7 +20,7 @@
 
 #include <array>
 #include <deque>
-#ifndef TEST_HAS_NO_FILESYSTEM_LIBRARY
+#ifndef TEST_HAS_NO_FILESYSTEM
 #include <filesystem>
 #endif
 #include <forward_list>
@@ -61,7 +61,7 @@
 static_assert(std::__iterator_traits_detail::__cpp17_bidirectional_iterator<std::deque<int>::const_reverse_iterator>);
 
 // <filesystem>
-#ifndef TEST_HAS_NO_FILESYSTEM_LIBRARY
+#ifndef TEST_HAS_NO_FILESYSTEM
 static_assert(!std::__iterator_traits_detail::__cpp17_bidirectional_iterator<std::filesystem::directory_iterator>);
 static_assert(!std::__iterator_traits_detail::__cpp17_bidirectional_iterator<std::filesystem::recursive_directory_iterator>);
 #endif
diff --git a/test/libcxx/iterators/iterator.requirements/iterator.assoc.types/iterator.traits/legacy_forward_iterator.compile.pass.cpp b/test/libcxx/iterators/iterator.requirements/iterator.assoc.types/iterator.traits/legacy_forward_iterator.compile.pass.cpp
index 8f36323..9e36cfa 100644
--- a/test/libcxx/iterators/iterator.requirements/iterator.assoc.types/iterator.traits/legacy_forward_iterator.compile.pass.cpp
+++ b/test/libcxx/iterators/iterator.requirements/iterator.assoc.types/iterator.traits/legacy_forward_iterator.compile.pass.cpp
@@ -20,7 +20,7 @@
 
 #include <array>
 #include <deque>
-#ifndef TEST_HAS_NO_FILESYSTEM_LIBRARY
+#ifndef TEST_HAS_NO_FILESYSTEM
 #include <filesystem>
 #endif
 #include <forward_list>
@@ -61,7 +61,7 @@
 static_assert(std::__iterator_traits_detail::__cpp17_forward_iterator<std::deque<int>::const_reverse_iterator>);
 
 // <filesystem>
-#ifndef TEST_HAS_NO_FILESYSTEM_LIBRARY
+#ifndef TEST_HAS_NO_FILESYSTEM
 static_assert(!std::__iterator_traits_detail::__cpp17_forward_iterator<std::filesystem::directory_iterator>);
 static_assert(!std::__iterator_traits_detail::__cpp17_forward_iterator<std::filesystem::recursive_directory_iterator>);
 #endif
diff --git a/test/libcxx/iterators/iterator.requirements/iterator.assoc.types/iterator.traits/legacy_input_iterator.compile.pass.cpp b/test/libcxx/iterators/iterator.requirements/iterator.assoc.types/iterator.traits/legacy_input_iterator.compile.pass.cpp
index 43f22c6..69a6391 100644
--- a/test/libcxx/iterators/iterator.requirements/iterator.assoc.types/iterator.traits/legacy_input_iterator.compile.pass.cpp
+++ b/test/libcxx/iterators/iterator.requirements/iterator.assoc.types/iterator.traits/legacy_input_iterator.compile.pass.cpp
@@ -20,7 +20,7 @@
 
 #include <array>
 #include <deque>
-#ifndef TEST_HAS_NO_FILESYSTEM_LIBRARY
+#ifndef TEST_HAS_NO_FILESYSTEM
 #include <filesystem>
 #endif
 #include <forward_list>
@@ -61,7 +61,7 @@
 static_assert(std::__iterator_traits_detail::__cpp17_input_iterator<std::deque<int>::const_reverse_iterator>);
 
 // <filesystem>
-#ifndef TEST_HAS_NO_FILESYSTEM_LIBRARY
+#ifndef TEST_HAS_NO_FILESYSTEM
 static_assert(std::__iterator_traits_detail::__cpp17_input_iterator<std::filesystem::directory_iterator>);
 static_assert(std::__iterator_traits_detail::__cpp17_input_iterator<std::filesystem::recursive_directory_iterator>);
 #endif
diff --git a/test/libcxx/iterators/iterator.requirements/iterator.assoc.types/iterator.traits/legacy_iterator.compile.pass.cpp b/test/libcxx/iterators/iterator.requirements/iterator.assoc.types/iterator.traits/legacy_iterator.compile.pass.cpp
index 32f4022..54e9d7b 100644
--- a/test/libcxx/iterators/iterator.requirements/iterator.assoc.types/iterator.traits/legacy_iterator.compile.pass.cpp
+++ b/test/libcxx/iterators/iterator.requirements/iterator.assoc.types/iterator.traits/legacy_iterator.compile.pass.cpp
@@ -20,7 +20,7 @@
 
 #include <array>
 #include <deque>
-#ifndef TEST_HAS_NO_FILESYSTEM_LIBRARY
+#ifndef TEST_HAS_NO_FILESYSTEM
 #include <filesystem>
 #endif
 #include <forward_list>
@@ -61,7 +61,7 @@
 static_assert(std::__iterator_traits_detail::__cpp17_iterator<std::deque<int>::const_reverse_iterator>);
 
 // <filesystem>
-#ifndef TEST_HAS_NO_FILESYSTEM_LIBRARY
+#ifndef TEST_HAS_NO_FILESYSTEM
 static_assert(std::__iterator_traits_detail::__cpp17_iterator<std::filesystem::directory_iterator>);
 static_assert(std::__iterator_traits_detail::__cpp17_iterator<std::filesystem::recursive_directory_iterator>);
 #endif
diff --git a/test/libcxx/iterators/iterator.requirements/iterator.assoc.types/iterator.traits/legacy_random_access_iterator.compile.pass.cpp b/test/libcxx/iterators/iterator.requirements/iterator.assoc.types/iterator.traits/legacy_random_access_iterator.compile.pass.cpp
index 7e311e1..0532151 100644
--- a/test/libcxx/iterators/iterator.requirements/iterator.assoc.types/iterator.traits/legacy_random_access_iterator.compile.pass.cpp
+++ b/test/libcxx/iterators/iterator.requirements/iterator.assoc.types/iterator.traits/legacy_random_access_iterator.compile.pass.cpp
@@ -20,7 +20,7 @@
 
 #include <array>
 #include <deque>
-#ifndef TEST_HAS_NO_FILESYSTEM_LIBRARY
+#ifndef TEST_HAS_NO_FILESYSTEM
 #include <filesystem>
 #endif
 #include <forward_list>
@@ -61,7 +61,7 @@
 static_assert(std::__iterator_traits_detail::__cpp17_random_access_iterator<std::deque<int>::const_reverse_iterator>);
 
 // <filesystem>
-#ifndef TEST_HAS_NO_FILESYSTEM_LIBRARY
+#ifndef TEST_HAS_NO_FILESYSTEM
 static_assert(!std::__iterator_traits_detail::__cpp17_random_access_iterator<std::filesystem::directory_iterator>);
 static_assert(!std::__iterator_traits_detail::__cpp17_random_access_iterator<std::filesystem::recursive_directory_iterator>);
 #endif
diff --git a/test/std/input.output/file.streams/lit.local.cfg b/test/std/input.output/file.streams/lit.local.cfg
index 0abfd8b..3fe886f 100644
--- a/test/std/input.output/file.streams/lit.local.cfg
+++ b/test/std/input.output/file.streams/lit.local.cfg
@@ -2,5 +2,5 @@
 if "no-localization" in config.available_features:
     config.unsupported = True
 
-if "no-fstream" in config.available_features:
+if "no-filesystem" in config.available_features:
     config.unsupported = True
diff --git a/test/std/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.put/xsputn.PR14074.pass.cpp b/test/std/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.put/xsputn.PR14074.pass.cpp
index 84c7263..021c656 100644
--- a/test/std/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.put/xsputn.PR14074.pass.cpp
+++ b/test/std/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.put/xsputn.PR14074.pass.cpp
@@ -17,7 +17,7 @@
 // basic_streambuf, but I can't seem to reproduce without going through one
 // of its derived classes.
 
-// UNSUPPORTED: no-fstream
+// UNSUPPORTED: no-filesystem
 
 #include <cassert>
 #include <cstddef>
diff --git a/test/std/iterators/iterator.primitives/iterator.traits/cxx20_iterator_traits.compile.pass.cpp b/test/std/iterators/iterator.primitives/iterator.traits/cxx20_iterator_traits.compile.pass.cpp
index 18fc2fb..f6b7f6f 100644
--- a/test/std/iterators/iterator.primitives/iterator.traits/cxx20_iterator_traits.compile.pass.cpp
+++ b/test/std/iterators/iterator.primitives/iterator.traits/cxx20_iterator_traits.compile.pass.cpp
@@ -40,7 +40,7 @@
 #  include <istream>
 #endif
 
-#ifndef TEST_HAS_NO_FILESYSTEM_LIBRARY
+#ifndef TEST_HAS_NO_FILESYSTEM
 #  include <filesystem>
 #endif
 
@@ -156,7 +156,7 @@
 static_assert(testConst<std::cregex_token_iterator, std::forward_iterator_tag, std::csub_match>());
 #endif // !TEST_HAS_NO_LOCALIZATION
 
-#ifndef TEST_HAS_NO_FILESYSTEM_LIBRARY
+#ifndef TEST_HAS_NO_FILESYSTEM
 static_assert(test<std::filesystem::directory_iterator, std::input_iterator_tag, std::filesystem::directory_entry,
                    std::ptrdiff_t, const std::filesystem::directory_entry&, const std::filesystem::directory_entry*>());
 static_assert(test<std::filesystem::recursive_directory_iterator, std::input_iterator_tag,
diff --git a/test/std/localization/locales/locale.convenience/conversions/conversions.buffer/overflow.pass.cpp b/test/std/localization/locales/locale.convenience/conversions/conversions.buffer/overflow.pass.cpp
index e033304..198007e 100644
--- a/test/std/localization/locales/locale.convenience/conversions/conversions.buffer/overflow.pass.cpp
+++ b/test/std/localization/locales/locale.convenience/conversions/conversions.buffer/overflow.pass.cpp
@@ -88,7 +88,7 @@
         }
     }
     // TODO: Move this to std::stringstream once https://llvm.org/PR59083 has been resolved
-#ifndef TEST_HAS_NO_FSTREAM
+#ifndef TEST_HAS_NO_FILESYSTEM
     {
         {
             std::ofstream bs("overflow.dat");
@@ -113,7 +113,7 @@
         }
         std::remove("overflow.dat");
     }
-#endif // TEST_HAS_NO_FSTREAM
+#endif // TEST_HAS_NO_FILESYSTEM
 
     return 0;
 }
diff --git a/test/std/localization/locales/locale.convenience/conversions/conversions.buffer/seekoff.pass.cpp b/test/std/localization/locales/locale.convenience/conversions/conversions.buffer/seekoff.pass.cpp
index a6f58e9..87d9061 100644
--- a/test/std/localization/locales/locale.convenience/conversions/conversions.buffer/seekoff.pass.cpp
+++ b/test/std/localization/locales/locale.convenience/conversions/conversions.buffer/seekoff.pass.cpp
@@ -22,7 +22,7 @@
 // XFAIL: no-wide-characters
 
 // TODO: Avoid using <fstream> in this test.
-// XFAIL: no-fstream
+// XFAIL: no-filesystem
 
 #include <locale>
 #include <codecvt>
diff --git a/test/std/utilities/format/format.formattable/concept.formattable.compile.pass.cpp b/test/std/utilities/format/format.formattable/concept.formattable.compile.pass.cpp
index 604d384..71faa82 100644
--- a/test/std/utilities/format/format.formattable/concept.formattable.compile.pass.cpp
+++ b/test/std/utilities/format/format.formattable/concept.formattable.compile.pass.cpp
@@ -42,7 +42,7 @@
 #include "test_macros.h"
 #include "min_allocator.h"
 
-#ifndef TEST_HAS_NO_FILESYSTEM_LIBRARY
+#ifndef TEST_HAS_NO_FILESYSTEM
 #  include <filesystem>
 #endif
 #ifndef TEST_HAS_NO_LOCALIZATION
@@ -182,7 +182,7 @@
   assert_is_not_formattable<std::bitset<42>, CharT>();
   assert_is_not_formattable<std::complex<double>, CharT>();
   assert_is_not_formattable<std::error_code, CharT>();
-#ifndef TEST_HAS_NO_FILESYSTEM_LIBRARY
+#ifndef TEST_HAS_NO_FILESYSTEM
   assert_is_not_formattable<std::filesystem::path, CharT>();
 #endif
   assert_is_not_formattable<std::shared_ptr<int>, CharT>();
diff --git a/test/std/utilities/format/format.range/format.range.fmtkind/format_kind.compile.pass.cpp b/test/std/utilities/format/format.range/format.range.fmtkind/format_kind.compile.pass.cpp
index ba47997..acb1046 100644
--- a/test/std/utilities/format/format.range/format.range.fmtkind/format_kind.compile.pass.cpp
+++ b/test/std/utilities/format/format.range/format.range.fmtkind/format_kind.compile.pass.cpp
@@ -35,7 +35,7 @@
 
 #include "test_macros.h"
 
-#ifndef TEST_HAS_NO_FILESYSTEM_LIBRARY
+#ifndef TEST_HAS_NO_FILESYSTEM
 #  include <filesystem>
 #endif
 
@@ -67,7 +67,7 @@
 static_assert(std::ranges::input_range<recursive_range>, "format_kind requires an input range");
 static_assert(std::format_kind<recursive_range> == std::range_format::disabled);
 
-#ifndef TEST_HAS_NO_FILESYSTEM_LIBRARY
+#ifndef TEST_HAS_NO_FILESYSTEM
 static_assert(std::format_kind<std::filesystem::path> == std::range_format::disabled);
 #endif
 
diff --git a/test/support/test_macros.h b/test/support/test_macros.h
index 624caf3..55234fa 100644
--- a/test/support/test_macros.h
+++ b/test/support/test_macros.h
@@ -386,12 +386,8 @@
 #  define TEST_HAS_NO_THREADS
 #endif
 
-#if defined(_LIBCPP_HAS_NO_FILESYSTEM_LIBRARY)
-#  define TEST_HAS_NO_FILESYSTEM_LIBRARY
-#endif
-
-#if defined(_LIBCPP_HAS_NO_FSTREAM)
-#  define TEST_HAS_NO_FSTREAM
+#if defined(_LIBCPP_HAS_NO_FILESYSTEM)
+#  define TEST_HAS_NO_FILESYSTEM
 #endif
 
 #if defined(_LIBCPP_HAS_NO_FGETPOS_FSETPOS)
diff --git a/utils/ci/buildkite-pipeline.yml b/utils/ci/buildkite-pipeline.yml
index bc570cc..e1c6f91 100644
--- a/utils/ci/buildkite-pipeline.yml
+++ b/utils/ci/buildkite-pipeline.yml
@@ -575,24 +575,6 @@
             limit: 2
       timeout_in_minutes: 120
 
-    - label: "No fstream"
-      command: "libcxx/utils/ci/run-buildbot generic-no-fstream"
-      artifact_paths:
-        - "**/test-results.xml"
-        - "**/*.abilist"
-      env:
-          CC: "clang-${LLVM_HEAD_VERSION}"
-          CXX: "clang++-${LLVM_HEAD_VERSION}"
-          ENABLE_CLANG_TIDY: "On"
-      agents:
-        queue: "libcxx-builders"
-        os: "linux"
-      retry:
-        automatic:
-          - exit_status: -1  # Agent was lost
-            limit: 2
-      timeout_in_minutes: 120
-
     - label: "No locale"
       command: "libcxx/utils/ci/run-buildbot generic-no-localization"
       artifact_paths:
diff --git a/utils/ci/run-buildbot b/utils/ci/run-buildbot
index 411e3f7..59f66a8 100755
--- a/utils/ci/run-buildbot
+++ b/utils/ci/run-buildbot
@@ -409,11 +409,6 @@
     generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-no-random_device.cmake"
     check-runtimes
 ;;
-generic-no-fstream)
-    clean
-    generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-no-fstream.cmake"
-    check-runtimes
-;;
 generic-no-localization)
     clean
     generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-no-localization.cmake"
diff --git a/utils/libcxx/test/features.py b/utils/libcxx/test/features.py
index fc1680c..9afe3d2 100644
--- a/utils/libcxx/test/features.py
+++ b/utils/libcxx/test/features.py
@@ -333,10 +333,9 @@
     "_LIBCPP_HAS_THREAD_API_PTHREAD": "libcpp-has-thread-api-pthread",
     "_LIBCPP_NO_VCRUNTIME": "libcpp-no-vcruntime",
     "_LIBCPP_ABI_VERSION": "libcpp-abi-version",
-    "_LIBCPP_HAS_NO_FILESYSTEM_LIBRARY": "no-filesystem",
+    "_LIBCPP_HAS_NO_FILESYSTEM": "no-filesystem",
     "_LIBCPP_HAS_NO_RANDOM_DEVICE": "no-random-device",
     "_LIBCPP_HAS_NO_LOCALIZATION": "no-localization",
-    "_LIBCPP_HAS_NO_FSTREAM": "no-fstream",
     "_LIBCPP_HAS_NO_WIDE_CHARACTERS": "no-wide-characters",
     "_LIBCPP_HAS_NO_UNICODE": "libcpp-has-no-unicode",
     "_LIBCPP_ENABLE_DEBUG_MODE": "libcpp-has-debug-mode",
diff --git a/utils/libcxx/test/header_information.py b/utils/libcxx/test/header_information.py
index 6ebfbb8..7f15571 100644
--- a/utils/libcxx/test/header_information.py
+++ b/utils/libcxx/test/header_information.py
@@ -36,7 +36,7 @@
     "experimental/utility": "// UNSUPPORTED: c++03",
     "experimental/vector": "// UNSUPPORTED: c++03",
     "filesystem": "// UNSUPPORTED: no-filesystem, c++03, c++11, c++14",
-    "fstream": "// UNSUPPORTED: no-localization, no-fstream",
+    "fstream": "// UNSUPPORTED: no-localization, no-filesystem",
     "future": "// UNSUPPORTED: no-threads, c++03",
     "iomanip": "// UNSUPPORTED: no-localization",
     "ios": "// UNSUPPORTED: no-localization",