[libc++] Build <filesystem> support as part of the dylib

Summary:
This patch treats <filesystem> as a first-class citizen of the dylib,
like all other sub-libraries (e.g. <chrono>). As such, it also removes
all special handling for installing the filesystem library separately
or disabling part of the test suite from the lit command line.

Unlike the previous attempt (r356500), this doesn't remove all the
filesystem tests.

Reviewers: mclow.lists, EricWF, serge-sans-paille

Subscribers: mgorny, christof, jkorous, dexonsmith, jfb, jdoerfert, libcxx-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@356518 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 0c20cc3..9e0d5ed 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -73,12 +73,6 @@
 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)
-set(ENABLE_FILESYSTEM_DEFAULT ${LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY})
-if (WIN32)
-  set(ENABLE_FILESYSTEM_DEFAULT OFF)
-endif()
-option(LIBCXX_ENABLE_FILESYSTEM "Build filesystem as part of libc++fs.a"
-    ${ENABLE_FILESYSTEM_DEFAULT})
 option(LIBCXX_INCLUDE_TESTS "Build the libc++ tests." ${LLVM_INCLUDE_TESTS})
 
 # Benchmark options -----------------------------------------------------------
@@ -117,9 +111,6 @@
 cmake_dependent_option(LIBCXX_INSTALL_EXPERIMENTAL_LIBRARY
         "Install libc++experimental.a" ON
         "LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY;LIBCXX_INSTALL_LIBRARY" OFF)
-cmake_dependent_option(LIBCXX_INSTALL_FILESYSTEM_LIBRARY
-        "Install libc++fs.a" ON
-        "LIBCXX_ENABLE_FILESYSTEM;LIBCXX_INSTALL_LIBRARY" OFF)
 
 set(LIBCXX_ABI_VERSION "1" CACHE STRING "ABI version of libc++. Can be either 1 or 2, where 2 is currently not stable. Defaults to 1.")
 set(LIBCXX_ABI_NAMESPACE "" CACHE STRING "The inline ABI namespace used by libc++. It defaults to __n where `n` is the current ABI version.")
@@ -291,11 +282,6 @@
 # Check option configurations
 #===============================================================================
 
-if (LIBCXX_ENABLE_FILESYSTEM AND NOT LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY)
-  message(FATAL_ERROR
-    "LIBCXX_ENABLE_FILESYSTEM cannot be turned on when LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY=OFF")
-endif()
-
 # Ensure LIBCXX_ENABLE_MONOTONIC_CLOCK is set to ON only when
 # LIBCXX_ENABLE_THREADS is on.
 if(LIBCXX_ENABLE_THREADS AND NOT LIBCXX_ENABLE_MONOTONIC_CLOCK)
@@ -791,9 +777,6 @@
 if (LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY)
   list(APPEND LIBCXX_TEST_DEPS cxx_experimental)
 endif()
-if (LIBCXX_ENABLE_FILESYSTEM)
-  list(APPEND LIBCXX_TEST_DEPS cxx_filesystem)
-endif()
 
 if (LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY)
   list(APPEND LIBCXX_TEST_DEPS cxx_external_threads)
diff --git a/benchmarks/CMakeLists.txt b/benchmarks/CMakeLists.txt
index 637035e..11e3f99 100644
--- a/benchmarks/CMakeLists.txt
+++ b/benchmarks/CMakeLists.txt
@@ -146,9 +146,6 @@
   if (TARGET cxx_experimental)
     target_link_libraries(${libcxx_target} cxx_experimental)
   endif()
-  if (TARGET cxx_filesystem)
-    target_link_libraries(${libcxx_target} cxx_filesystem)
-  endif()
   target_link_libraries(${libcxx_target} -lbenchmark)
   if (LLVM_USE_SANITIZER)
     target_link_libraries(${libcxx_target} -ldl)
diff --git a/docs/BuildingLibcxx.rst b/docs/BuildingLibcxx.rst
index 01f442d..cb00b89 100644
--- a/docs/BuildingLibcxx.rst
+++ b/docs/BuildingLibcxx.rst
@@ -224,18 +224,6 @@
   Install libc++experimental.a alongside libc++.
 
 
-.. option:: LIBCXX_ENABLE_FILESYSTEM:BOOL
-
-  **Default**: ``ON``
-
-  Build filesystem as a standalone library libc++fs.a.
-
-.. option:: LIBCXX_INSTALL_FILESYSTEM_LIBRARY:BOOL
-
-  **Default**: ``LIBCXX_ENABLE_FILESYSTEM AND LIBCXX_INSTALL_LIBRARY``
-
-  Install libc++fs.a alongside libc++.
-
 .. _ABI Library Specific Options:
 
 ABI Library Specific Options
diff --git a/docs/UsingLibcxx.rst b/docs/UsingLibcxx.rst
index 7b06189..2055a5a 100644
--- a/docs/UsingLibcxx.rst
+++ b/docs/UsingLibcxx.rst
@@ -50,23 +50,6 @@
   $ ./a.out # Searches for libc++ along LD_LIBRARY_PATH
 
 
-Using ``<filesystem>`` and libc++fs
-====================================
-
-Libc++ provides the implementation of the filesystem library in a separate
-library. Users of ``<filesystem>`` and ``<experimental/filesystem>`` are
-required to link ``-lc++fs``.
-
-.. note::
-  Prior to libc++ 7.0, users of ``<experimental/filesystem>`` were required
-  to link libc++experimental.
-
-.. warning::
-  The Filesystem library is still experimental in nature. As such normal
-  guarantees about ABI stability and backwards compatibility do not yet apply
-  to it. In the future, this restriction will be removed.
-
-
 Using libc++experimental and ``<experimental/...>``
 =====================================================
 
@@ -83,9 +66,6 @@
 :ref:`Building Libc++ <build instructions>` and
 :ref:`libc++experimental CMake Options <libc++experimental options>`.
 
-Note that as of libc++ 7.0 using the ``<experimental/filesystem>`` requires linking
-libc++fs instead of libc++experimental.
-
 Also see the `Experimental Library Implementation Status <http://libcxx.llvm.org/ts1z_status.html>`__
 page.
 
diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt
index fd493d4..9af75ef 100644
--- a/lib/CMakeLists.txt
+++ b/lib/CMakeLists.txt
@@ -3,6 +3,8 @@
 # Get sources
 # FIXME: Don't use glob here
 file(GLOB LIBCXX_SOURCES ../src/*.cpp)
+list(APPEND LIBCXX_SOURCES ../src/filesystem/operations.cpp
+                           ../src/filesystem/directory_iterator.cpp)
 if(WIN32)
   file(GLOB LIBCXX_WIN32_SOURCES ../src/support/win32/*.cpp)
   list(APPEND LIBCXX_SOURCES ${LIBCXX_WIN32_SOURCES})
@@ -11,6 +13,14 @@
   list(APPEND LIBCXX_SOURCES ${LIBCXX_SOLARIS_SOURCES})
 endif()
 
+# Filesystem uses __int128_t, which requires a definition of __muloi4 when
+# compiled with UBSAN. This definition is not provided by libgcc_s, but is
+# provided by compiler-rt. So we need to disable it to avoid having multiple
+# definitions. See filesystem/int128_builtins.cpp.
+if (NOT LIBCXX_USE_COMPILER_RT)
+  list(APPEND LIBCXX_SOURCES ../src/filesystem/int128_builtins.cpp)
+endif()
+
 # Add all the headers to the project for IDEs.
 if (LIBCXX_CONFIGURE_IDE)
   file(GLOB_RECURSE LIBCXX_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/../include/*)
@@ -278,39 +288,6 @@
 # Add a meta-target for both libraries.
 add_custom_target(cxx DEPENDS cxx-headers ${LIBCXX_BUILD_TARGETS})
 
-if (LIBCXX_ENABLE_FILESYSTEM)
-  set(LIBCXX_FILESYSTEM_SOURCES
-      ../src/filesystem/operations.cpp
-      ../src/filesystem/directory_iterator.cpp)
-
-  # Filesystem uses __int128_t, which requires a definition of __muloi4 when
-  # compiled with UBSAN. This definition is not provided by libgcc_s, but is
-  # provided by compiler-rt. So we need to disable it to avoid having multiple
-  # definitions. See filesystem/int128_builtins.cpp.
-  if (NOT LIBCXX_USE_COMPILER_RT)
-    list(APPEND LIBCXX_FILESYSTEM_SOURCES ../src/filesystem/int128_builtins.cpp)
-  endif()
-
-  add_library(cxx_filesystem STATIC ${LIBCXX_FILESYSTEM_SOURCES})
-  if (LIBCXX_ENABLE_SHARED)
-    target_link_libraries(cxx_filesystem cxx_shared)
-  else()
-    target_link_libraries(cxx_filesystem cxx_static)
-  endif()
-
-  set(filesystem_flags "${LIBCXX_COMPILE_FLAGS}")
-  check_flag_supported(-std=c++14)
-  if (NOT MSVC AND LIBCXX_SUPPORTS_STD_EQ_CXX14_FLAG AND LIBCXX_STANDARD_VER STREQUAL "c++11")
-    string(REPLACE "-std=c++11" "-std=c++14" filesystem_flags "${LIBCXX_COMPILE_FLAGS}")
-  endif()
-  set_target_properties(cxx_filesystem
-    PROPERTIES
-      COMPILE_FLAGS "${filesystem_flags}"
-      OUTPUT_NAME   "c++fs"
-  )
-endif()
-
-
 if (LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY)
   file(GLOB LIBCXX_EXPERIMENTAL_SOURCES ../src/experimental/*.cpp)
   add_library(cxx_experimental STATIC ${LIBCXX_EXPERIMENTAL_SOURCES})
@@ -379,13 +356,10 @@
 endif()
 
 if (LIBCXX_INSTALL_LIBRARY)
-  if (LIBCXX_INSTALL_FILESYSTEM_LIBRARY)
-    set(filesystem_lib cxx_filesystem)
-  endif()
   if (LIBCXX_INSTALL_EXPERIMENTAL_LIBRARY)
     set(experimental_lib cxx_experimental)
   endif()
-  install(TARGETS ${LIBCXX_INSTALL_TARGETS} ${filesystem_lib} ${experimental_lib}
+  install(TARGETS ${LIBCXX_INSTALL_TARGETS} ${experimental_lib}
     LIBRARY DESTINATION ${LIBCXX_INSTALL_PREFIX}lib${LIBCXX_LIBDIR_SUFFIX} COMPONENT cxx
     ARCHIVE DESTINATION ${LIBCXX_INSTALL_PREFIX}lib${LIBCXX_LIBDIR_SUFFIX} COMPONENT cxx
     )
@@ -405,9 +379,6 @@
     if(LIBCXX_INSTALL_LIBRARY)
       set(lib_install_target cxx)
     endif()
-    if (LIBCXX_INSTALL_FILESYSTEM_LIBRARY)
-      set(filesystem_lib_install_target cxx_filesystem)
-    endif()
     if (LIBCXX_INSTALL_EXPERIMENTAL_LIBRARY)
       set(experimental_lib_install_target cxx_experimental)
     endif()
@@ -417,7 +388,6 @@
     add_custom_target(install-cxx
                       DEPENDS ${lib_install_target}
                               ${experimental_lib_install_target}
-                              ${filesystem_lib_install_target}
                               ${header_install_target}
                       COMMAND "${CMAKE_COMMAND}"
                       -DCMAKE_INSTALL_COMPONENT=cxx
@@ -425,7 +395,6 @@
     add_custom_target(install-cxx-stripped
                       DEPENDS ${lib_install_target}
                               ${experimental_lib_install_target}
-                              ${filesystem_lib_install_target}
                               ${header_install_target}
                       COMMAND "${CMAKE_COMMAND}"
                       -DCMAKE_INSTALL_COMPONENT=cxx
diff --git a/lib/abi/CHANGELOG.TXT b/lib/abi/CHANGELOG.TXT
index 2e0e8a6..ae3bc24 100644
--- a/lib/abi/CHANGELOG.TXT
+++ b/lib/abi/CHANGELOG.TXT
@@ -16,6 +16,130 @@
 Version 9.0
 -----------
 
+* rXXXXXX - Integrate <filesystem> support into the shared library
+
+  This patch introduces support for <filesystem> into the shared library,
+  instead of requiring users to manually link against a static archive. As
+  such, new symbols required to implement <filesystem> are exported from
+  the shared library.
+
+  x86_64-unknown-linux-gnu
+  ------------------------
+  TODO
+
+  x86_64-apple-apple-darwin
+  -------------------------
+  Symbol added: __ZNKSt3__14__fs10filesystem18directory_iterator13__dereferenceEv
+  Symbol added: __ZNKSt3__14__fs10filesystem28recursive_directory_iterator13__dereferenceEv
+  Symbol added: __ZNKSt3__14__fs10filesystem28recursive_directory_iterator5depthEv
+  Symbol added: __ZNKSt3__14__fs10filesystem28recursive_directory_iterator7optionsEv
+  Symbol added: __ZNKSt3__14__fs10filesystem4path10__filenameEv
+  Symbol added: __ZNKSt3__14__fs10filesystem4path11__extensionEv
+  Symbol added: __ZNKSt3__14__fs10filesystem4path11__root_nameEv
+  Symbol added: __ZNKSt3__14__fs10filesystem4path13__parent_pathEv
+  Symbol added: __ZNKSt3__14__fs10filesystem4path15__relative_pathEv
+  Symbol added: __ZNKSt3__14__fs10filesystem4path15__root_path_rawEv
+  Symbol added: __ZNKSt3__14__fs10filesystem4path16__root_directoryEv
+  Symbol added: __ZNKSt3__14__fs10filesystem4path16lexically_normalEv
+  Symbol added: __ZNKSt3__14__fs10filesystem4path18lexically_relativeERKS2_
+  Symbol added: __ZNKSt3__14__fs10filesystem4path3endEv
+  Symbol added: __ZNKSt3__14__fs10filesystem4path5beginEv
+  Symbol added: __ZNKSt3__14__fs10filesystem4path6__stemEv
+  Symbol added: __ZNKSt3__14__fs10filesystem4path9__compareENS_17basic_string_viewIcNS_11char_traitsIcEEEE
+  Symbol added: __ZNSt3__14__fs10filesystem10__absoluteERKNS1_4pathEPNS_10error_codeE
+  Symbol added: __ZNSt3__14__fs10filesystem10hash_valueERKNS1_4pathE
+  Symbol added: __ZNSt3__14__fs10filesystem11__canonicalERKNS1_4pathEPNS_10error_codeE
+  Symbol added: __ZNSt3__14__fs10filesystem11__copy_fileERKNS1_4pathES4_NS1_12copy_optionsEPNS_10error_codeE
+  Symbol added: __ZNSt3__14__fs10filesystem11__file_sizeERKNS1_4pathEPNS_10error_codeE
+  Symbol added: __ZNSt3__14__fs10filesystem12__equivalentERKNS1_4pathES4_PNS_10error_codeE
+  Symbol added: __ZNSt3__14__fs10filesystem12__remove_allERKNS1_4pathEPNS_10error_codeE
+  Symbol added: __ZNSt3__14__fs10filesystem13__fs_is_emptyERKNS1_4pathEPNS_10error_codeE
+  Symbol added: __ZNSt3__14__fs10filesystem13__permissionsERKNS1_4pathENS1_5permsENS1_12perm_optionsEPNS_10error_codeE
+  Symbol added: __ZNSt3__14__fs10filesystem13__resize_fileERKNS1_4pathEmPNS_10error_codeE
+  Symbol added: __ZNSt3__14__fs10filesystem14__copy_symlinkERKNS1_4pathES4_PNS_10error_codeE
+  Symbol added: __ZNSt3__14__fs10filesystem14__current_pathEPNS_10error_codeE
+  Symbol added: __ZNSt3__14__fs10filesystem14__current_pathERKNS1_4pathEPNS_10error_codeE
+  Symbol added: __ZNSt3__14__fs10filesystem14__read_symlinkERKNS1_4pathEPNS_10error_codeE
+  Symbol added: __ZNSt3__14__fs10filesystem15directory_entry12__do_refreshEv
+  Symbol added: __ZNSt3__14__fs10filesystem16__create_symlinkERKNS1_4pathES4_PNS_10error_codeE
+  Symbol added: __ZNSt3__14__fs10filesystem16__symlink_statusERKNS1_4pathEPNS_10error_codeE
+  Symbol added: __ZNSt3__14__fs10filesystem16_FilesystemClock3nowEv
+  Symbol added: __ZNSt3__14__fs10filesystem16filesystem_error13__create_whatEi
+  Symbol added: __ZNSt3__14__fs10filesystem16filesystem_errorD0Ev
+  Symbol added: __ZNSt3__14__fs10filesystem16filesystem_errorD1Ev
+  Symbol added: __ZNSt3__14__fs10filesystem16filesystem_errorD2Ev
+  Symbol added: __ZNSt3__14__fs10filesystem17__hard_link_countERKNS1_4pathEPNS_10error_codeE
+  Symbol added: __ZNSt3__14__fs10filesystem17__last_write_timeERKNS1_4pathENS_6chrono10time_pointINS1_16_FilesystemClockENS5_8durationInNS_5ratioILl1ELl1000000000EEEEEEEPNS_10error_codeE
+  Symbol added: __ZNKSt3__14__fs10filesystem28recursive_directory_iterator5depthEv
+  Symbol added: __ZNKSt3__14__fs10filesystem28recursive_directory_iterator7optionsEv
+  Symbol added: __ZNKSt3__14__fs10filesystem4path10__filenameEv
+  Symbol added: __ZNKSt3__14__fs10filesystem4path11__extensionEv
+  Symbol added: __ZNKSt3__14__fs10filesystem4path11__root_nameEv
+  Symbol added: __ZNKSt3__14__fs10filesystem4path13__parent_pathEv
+  Symbol added: __ZNKSt3__14__fs10filesystem4path15__relative_pathEv
+  Symbol added: __ZNKSt3__14__fs10filesystem4path15__root_path_rawEv
+  Symbol added: __ZNKSt3__14__fs10filesystem4path16__root_directoryEv
+  Symbol added: __ZNKSt3__14__fs10filesystem4path16lexically_normalEv
+  Symbol added: __ZNKSt3__14__fs10filesystem4path18lexically_relativeERKS2_
+  Symbol added: __ZNKSt3__14__fs10filesystem4path3endEv
+  Symbol added: __ZNKSt3__14__fs10filesystem4path5beginEv
+  Symbol added: __ZNKSt3__14__fs10filesystem4path6__stemEv
+  Symbol added: __ZNKSt3__14__fs10filesystem4path9__compareENS_17basic_string_viewIcNS_11char_traitsIcEEEE
+  Symbol added: __ZNSt3__14__fs10filesystem10__absoluteERKNS1_4pathEPNS_10error_codeE
+  Symbol added: __ZNSt3__14__fs10filesystem10hash_valueERKNS1_4pathE
+  Symbol added: __ZNSt3__14__fs10filesystem11__canonicalERKNS1_4pathEPNS_10error_codeE
+  Symbol added: __ZNSt3__14__fs10filesystem11__copy_fileERKNS1_4pathES4_NS1_12copy_optionsEPNS_10error_codeE
+  Symbol added: __ZNSt3__14__fs10filesystem11__file_sizeERKNS1_4pathEPNS_10error_codeE
+  Symbol added: __ZNSt3__14__fs10filesystem12__equivalentERKNS1_4pathES4_PNS_10error_codeE
+  Symbol added: __ZNSt3__14__fs10filesystem12__remove_allERKNS1_4pathEPNS_10error_codeE
+  Symbol added: __ZNSt3__14__fs10filesystem13__fs_is_emptyERKNS1_4pathEPNS_10error_codeE
+  Symbol added: __ZNSt3__14__fs10filesystem13__permissionsERKNS1_4pathENS1_5permsENS1_12perm_optionsEPNS_10error_codeE
+  Symbol added: __ZNSt3__14__fs10filesystem13__resize_fileERKNS1_4pathEmPNS_10error_codeE
+  Symbol added: __ZNSt3__14__fs10filesystem14__copy_symlinkERKNS1_4pathES4_PNS_10error_codeE
+  Symbol added: __ZNSt3__14__fs10filesystem14__current_pathEPNS_10error_codeE
+  Symbol added: __ZNSt3__14__fs10filesystem14__current_pathERKNS1_4pathEPNS_10error_codeE
+  Symbol added: __ZNSt3__14__fs10filesystem14__read_symlinkERKNS1_4pathEPNS_10error_codeE
+  Symbol added: __ZNSt3__14__fs10filesystem15directory_entry12__do_refreshEv
+  Symbol added: __ZNSt3__14__fs10filesystem16__create_symlinkERKNS1_4pathES4_PNS_10error_codeE
+  Symbol added: __ZNSt3__14__fs10filesystem16__symlink_statusERKNS1_4pathEPNS_10error_codeE
+  Symbol added: __ZNSt3__14__fs10filesystem16_FilesystemClock3nowEv
+  Symbol added: __ZNSt3__14__fs10filesystem16filesystem_error13__create_whatEi
+  Symbol added: __ZNSt3__14__fs10filesystem16filesystem_errorD0Ev
+  Symbol added: __ZNSt3__14__fs10filesystem16filesystem_errorD1Ev
+  Symbol added: __ZNSt3__14__fs10filesystem16filesystem_errorD2Ev
+  Symbol added: __ZNSt3__14__fs10filesystem17__hard_link_countERKNS1_4pathEPNS_10error_codeE
+  Symbol added: __ZNSt3__14__fs10filesystem17__last_write_timeERKNS1_4pathENS_6chrono10time_pointINS1_16_FilesystemClockENS5_8durationInNS_5ratioILl1ELl1000000000EEEEEEEPNS_10error_codeE
+  Symbol added: __ZNSt3__14__fs10filesystem17__last_write_timeERKNS1_4pathEPNS_10error_codeE
+  Symbol added: __ZNSt3__14__fs10filesystem18__create_directoryERKNS1_4pathEPNS_10error_codeE
+  Symbol added: __ZNSt3__14__fs10filesystem18__create_directoryERKNS1_4pathES4_PNS_10error_codeE
+  Symbol added: __ZNSt3__14__fs10filesystem18__create_hard_linkERKNS1_4pathES4_PNS_10error_codeE
+  Symbol added: __ZNSt3__14__fs10filesystem18__weakly_canonicalERKNS1_4pathEPNS_10error_codeE
+  Symbol added: __ZNSt3__14__fs10filesystem18directory_iterator11__incrementEPNS_10error_codeE
+  Symbol added: __ZNSt3__14__fs10filesystem18directory_iteratorC1ERKNS1_4pathEPNS_10error_codeENS1_17directory_optionsE
+  Symbol added: __ZNSt3__14__fs10filesystem18directory_iteratorC2ERKNS1_4pathEPNS_10error_codeENS1_17directory_optionsE
+  Symbol added: __ZNSt3__14__fs10filesystem20__create_directoriesERKNS1_4pathEPNS_10error_codeE
+  Symbol added: __ZNSt3__14__fs10filesystem21__temp_directory_pathEPNS_10error_codeE
+  Symbol added: __ZNSt3__14__fs10filesystem26__create_directory_symlinkERKNS1_4pathES4_PNS_10error_codeE
+  Symbol added: __ZNSt3__14__fs10filesystem28recursive_directory_iterator11__incrementEPNS_10error_codeE
+  Symbol added: __ZNSt3__14__fs10filesystem28recursive_directory_iterator15__try_recursionEPNS_10error_codeE
+  Symbol added: __ZNSt3__14__fs10filesystem28recursive_directory_iterator5__popEPNS_10error_codeE
+  Symbol added: __ZNSt3__14__fs10filesystem28recursive_directory_iterator9__advanceEPNS_10error_codeE
+  Symbol added: __ZNSt3__14__fs10filesystem28recursive_directory_iteratorC1ERKNS1_4pathENS1_17directory_optionsEPNS_10error_codeE
+  Symbol added: __ZNSt3__14__fs10filesystem28recursive_directory_iteratorC2ERKNS1_4pathENS1_17directory_optionsEPNS_10error_codeE
+  Symbol added: __ZNSt3__14__fs10filesystem4path17replace_extensionERKS2_
+  Symbol added: __ZNSt3__14__fs10filesystem4path8iterator11__decrementEv
+  Symbol added: __ZNSt3__14__fs10filesystem4path8iterator11__incrementEv
+  Symbol added: __ZNSt3__14__fs10filesystem6__copyERKNS1_4pathES4_NS1_12copy_optionsEPNS_10error_codeE
+  Symbol added: __ZNSt3__14__fs10filesystem7__spaceERKNS1_4pathEPNS_10error_codeE
+  Symbol added: __ZNSt3__14__fs10filesystem8__removeERKNS1_4pathEPNS_10error_codeE
+  Symbol added: __ZNSt3__14__fs10filesystem8__renameERKNS1_4pathES4_PNS_10error_codeE
+  Symbol added: __ZNSt3__14__fs10filesystem8__statusERKNS1_4pathEPNS_10error_codeE
+  Symbol added: __ZNSt3__14__fs10filesystem16_FilesystemClock9is_steadyE
+  Symbol added: __ZNSt3__14__fs10filesystem4path19preferred_separatorE
+  Symbol added: __ZTINSt3__14__fs10filesystem16filesystem_errorE
+  Symbol added: __ZTSNSt3__14__fs10filesystem16filesystem_errorE
+  Symbol added: __ZTVNSt3__14__fs10filesystem16filesystem_errorE
+
 * rTBD - Remove exception throwing debug mode handler support.
 
   The reason libc++ implemented a throwing debug mode handler was for ease of testing. Specifically,
diff --git a/lib/abi/x86_64-apple-darwin.v1.abilist b/lib/abi/x86_64-apple-darwin.v1.abilist
index 67c8eb5..bfcc5c5 100644
--- a/lib/abi/x86_64-apple-darwin.v1.abilist
+++ b/lib/abi/x86_64-apple-darwin.v1.abilist
@@ -2346,3 +2346,74 @@
 {'is_defined': True, 'name': '___dynamic_cast', 'type': 'I'}
 {'is_defined': False, 'name': '___gxx_personality_v0', 'type': 'U'}
 {'is_defined': True, 'name': '___gxx_personality_v0', 'type': 'I'}
+{'type': 'FUNC', 'is_defined': True, 'name': '__ZNKSt3__14__fs10filesystem18directory_iterator13__dereferenceEv'}
+{'type': 'FUNC', 'is_defined': True, 'name': '__ZNKSt3__14__fs10filesystem28recursive_directory_iterator13__dereferenceEv'}
+{'type': 'FUNC', 'is_defined': True, 'name': '__ZNKSt3__14__fs10filesystem28recursive_directory_iterator5depthEv'}
+{'type': 'FUNC', 'is_defined': True, 'name': '__ZNKSt3__14__fs10filesystem28recursive_directory_iterator7optionsEv'}
+{'type': 'FUNC', 'is_defined': True, 'name': '__ZNKSt3__14__fs10filesystem4path10__filenameEv'}
+{'type': 'FUNC', 'is_defined': True, 'name': '__ZNKSt3__14__fs10filesystem4path11__extensionEv'}
+{'type': 'FUNC', 'is_defined': True, 'name': '__ZNKSt3__14__fs10filesystem4path11__root_nameEv'}
+{'type': 'FUNC', 'is_defined': True, 'name': '__ZNKSt3__14__fs10filesystem4path13__parent_pathEv'}
+{'type': 'FUNC', 'is_defined': True, 'name': '__ZNKSt3__14__fs10filesystem4path15__relative_pathEv'}
+{'type': 'FUNC', 'is_defined': True, 'name': '__ZNKSt3__14__fs10filesystem4path15__root_path_rawEv'}
+{'type': 'FUNC', 'is_defined': True, 'name': '__ZNKSt3__14__fs10filesystem4path16__root_directoryEv'}
+{'type': 'FUNC', 'is_defined': True, 'name': '__ZNKSt3__14__fs10filesystem4path16lexically_normalEv'}
+{'type': 'FUNC', 'is_defined': True, 'name': '__ZNKSt3__14__fs10filesystem4path18lexically_relativeERKS2_'}
+{'type': 'FUNC', 'is_defined': True, 'name': '__ZNKSt3__14__fs10filesystem4path3endEv'}
+{'type': 'FUNC', 'is_defined': True, 'name': '__ZNKSt3__14__fs10filesystem4path5beginEv'}
+{'type': 'FUNC', 'is_defined': True, 'name': '__ZNKSt3__14__fs10filesystem4path6__stemEv'}
+{'type': 'FUNC', 'is_defined': True, 'name': '__ZNKSt3__14__fs10filesystem4path9__compareENS_17basic_string_viewIcNS_11char_traitsIcEEEE'}
+{'type': 'FUNC', 'is_defined': True, 'name': '__ZNSt3__14__fs10filesystem10__absoluteERKNS1_4pathEPNS_10error_codeE'}
+{'type': 'FUNC', 'is_defined': True, 'name': '__ZNSt3__14__fs10filesystem10hash_valueERKNS1_4pathE'}
+{'type': 'FUNC', 'is_defined': True, 'name': '__ZNSt3__14__fs10filesystem11__canonicalERKNS1_4pathEPNS_10error_codeE'}
+{'type': 'FUNC', 'is_defined': True, 'name': '__ZNSt3__14__fs10filesystem11__copy_fileERKNS1_4pathES4_NS1_12copy_optionsEPNS_10error_codeE'}
+{'type': 'FUNC', 'is_defined': True, 'name': '__ZNSt3__14__fs10filesystem11__file_sizeERKNS1_4pathEPNS_10error_codeE'}
+{'type': 'FUNC', 'is_defined': True, 'name': '__ZNSt3__14__fs10filesystem12__equivalentERKNS1_4pathES4_PNS_10error_codeE'}
+{'type': 'FUNC', 'is_defined': True, 'name': '__ZNSt3__14__fs10filesystem12__remove_allERKNS1_4pathEPNS_10error_codeE'}
+{'type': 'FUNC', 'is_defined': True, 'name': '__ZNSt3__14__fs10filesystem13__fs_is_emptyERKNS1_4pathEPNS_10error_codeE'}
+{'type': 'FUNC', 'is_defined': True, 'name': '__ZNSt3__14__fs10filesystem13__permissionsERKNS1_4pathENS1_5permsENS1_12perm_optionsEPNS_10error_codeE'}
+{'type': 'FUNC', 'is_defined': True, 'name': '__ZNSt3__14__fs10filesystem13__resize_fileERKNS1_4pathEmPNS_10error_codeE'}
+{'type': 'FUNC', 'is_defined': True, 'name': '__ZNSt3__14__fs10filesystem14__copy_symlinkERKNS1_4pathES4_PNS_10error_codeE'}
+{'type': 'FUNC', 'is_defined': True, 'name': '__ZNSt3__14__fs10filesystem14__current_pathEPNS_10error_codeE'}
+{'type': 'FUNC', 'is_defined': True, 'name': '__ZNSt3__14__fs10filesystem14__current_pathERKNS1_4pathEPNS_10error_codeE'}
+{'type': 'FUNC', 'is_defined': True, 'name': '__ZNSt3__14__fs10filesystem14__read_symlinkERKNS1_4pathEPNS_10error_codeE'}
+{'type': 'FUNC', 'is_defined': True, 'name': '__ZNSt3__14__fs10filesystem15directory_entry12__do_refreshEv'}
+{'type': 'FUNC', 'is_defined': True, 'name': '__ZNSt3__14__fs10filesystem16__create_symlinkERKNS1_4pathES4_PNS_10error_codeE'}
+{'type': 'FUNC', 'is_defined': True, 'name': '__ZNSt3__14__fs10filesystem16__symlink_statusERKNS1_4pathEPNS_10error_codeE'}
+{'type': 'FUNC', 'is_defined': True, 'name': '__ZNSt3__14__fs10filesystem16_FilesystemClock3nowEv'}
+{'type': 'FUNC', 'is_defined': True, 'name': '__ZNSt3__14__fs10filesystem16filesystem_error13__create_whatEi'}
+{'type': 'FUNC', 'is_defined': True, 'name': '__ZNSt3__14__fs10filesystem16filesystem_errorD0Ev'}
+{'type': 'FUNC', 'is_defined': True, 'name': '__ZNSt3__14__fs10filesystem16filesystem_errorD1Ev'}
+{'type': 'FUNC', 'is_defined': True, 'name': '__ZNSt3__14__fs10filesystem16filesystem_errorD2Ev'}
+{'type': 'FUNC', 'is_defined': True, 'name': '__ZNSt3__14__fs10filesystem17__hard_link_countERKNS1_4pathEPNS_10error_codeE'}
+{'type': 'FUNC', 'is_defined': True, 'name': '__ZNSt3__14__fs10filesystem17__last_write_timeERKNS1_4pathENS_6chrono10time_pointINS1_16_FilesystemClockENS5_8durationInNS_5ratioILl1ELl1000000000EEEEEEEPNS_10error_codeE'}
+{'type': 'FUNC', 'is_defined': True, 'name': '__ZNSt3__14__fs10filesystem17__last_write_timeERKNS1_4pathEPNS_10error_codeE'}
+{'type': 'FUNC', 'is_defined': True, 'name': '__ZNSt3__14__fs10filesystem18__create_directoryERKNS1_4pathEPNS_10error_codeE'}
+{'type': 'FUNC', 'is_defined': True, 'name': '__ZNSt3__14__fs10filesystem18__create_directoryERKNS1_4pathES4_PNS_10error_codeE'}
+{'type': 'FUNC', 'is_defined': True, 'name': '__ZNSt3__14__fs10filesystem18__create_hard_linkERKNS1_4pathES4_PNS_10error_codeE'}
+{'type': 'FUNC', 'is_defined': True, 'name': '__ZNSt3__14__fs10filesystem18__weakly_canonicalERKNS1_4pathEPNS_10error_codeE'}
+{'type': 'FUNC', 'is_defined': True, 'name': '__ZNSt3__14__fs10filesystem18directory_iterator11__incrementEPNS_10error_codeE'}
+{'type': 'FUNC', 'is_defined': True, 'name': '__ZNSt3__14__fs10filesystem18directory_iteratorC1ERKNS1_4pathEPNS_10error_codeENS1_17directory_optionsE'}
+{'type': 'FUNC', 'is_defined': True, 'name': '__ZNSt3__14__fs10filesystem18directory_iteratorC2ERKNS1_4pathEPNS_10error_codeENS1_17directory_optionsE'}
+{'type': 'FUNC', 'is_defined': True, 'name': '__ZNSt3__14__fs10filesystem20__create_directoriesERKNS1_4pathEPNS_10error_codeE'}
+{'type': 'FUNC', 'is_defined': True, 'name': '__ZNSt3__14__fs10filesystem21__temp_directory_pathEPNS_10error_codeE'}
+{'type': 'FUNC', 'is_defined': True, 'name': '__ZNSt3__14__fs10filesystem26__create_directory_symlinkERKNS1_4pathES4_PNS_10error_codeE'}
+{'type': 'FUNC', 'is_defined': True, 'name': '__ZNSt3__14__fs10filesystem28recursive_directory_iterator11__incrementEPNS_10error_codeE'}
+{'type': 'FUNC', 'is_defined': True, 'name': '__ZNSt3__14__fs10filesystem28recursive_directory_iterator15__try_recursionEPNS_10error_codeE'}
+{'type': 'FUNC', 'is_defined': True, 'name': '__ZNSt3__14__fs10filesystem28recursive_directory_iterator5__popEPNS_10error_codeE'}
+{'type': 'FUNC', 'is_defined': True, 'name': '__ZNSt3__14__fs10filesystem28recursive_directory_iterator9__advanceEPNS_10error_codeE'}
+{'type': 'FUNC', 'is_defined': True, 'name': '__ZNSt3__14__fs10filesystem28recursive_directory_iteratorC1ERKNS1_4pathENS1_17directory_optionsEPNS_10error_codeE'}
+{'type': 'FUNC', 'is_defined': True, 'name': '__ZNSt3__14__fs10filesystem28recursive_directory_iteratorC2ERKNS1_4pathENS1_17directory_optionsEPNS_10error_codeE'}
+{'type': 'FUNC', 'is_defined': True, 'name': '__ZNSt3__14__fs10filesystem4path17replace_extensionERKS2_'}
+{'type': 'FUNC', 'is_defined': True, 'name': '__ZNSt3__14__fs10filesystem4path8iterator11__decrementEv'}
+{'type': 'FUNC', 'is_defined': True, 'name': '__ZNSt3__14__fs10filesystem4path8iterator11__incrementEv'}
+{'type': 'FUNC', 'is_defined': True, 'name': '__ZNSt3__14__fs10filesystem6__copyERKNS1_4pathES4_NS1_12copy_optionsEPNS_10error_codeE'}
+{'type': 'FUNC', 'is_defined': True, 'name': '__ZNSt3__14__fs10filesystem7__spaceERKNS1_4pathEPNS_10error_codeE'}
+{'type': 'FUNC', 'is_defined': True, 'name': '__ZNSt3__14__fs10filesystem8__removeERKNS1_4pathEPNS_10error_codeE'}
+{'type': 'FUNC', 'is_defined': True, 'name': '__ZNSt3__14__fs10filesystem8__renameERKNS1_4pathES4_PNS_10error_codeE'}
+{'type': 'FUNC', 'is_defined': True, 'name': '__ZNSt3__14__fs10filesystem8__statusERKNS1_4pathEPNS_10error_codeE'}
+{'type': 'OBJECT', 'is_defined': True, 'name': '__ZNSt3__14__fs10filesystem16_FilesystemClock9is_steadyE', 'size': 0}
+{'type': 'OBJECT', 'is_defined': True, 'name': '__ZNSt3__14__fs10filesystem4path19preferred_separatorE', 'size': 0}
+{'type': 'OBJECT', 'is_defined': True, 'name': '__ZTINSt3__14__fs10filesystem16filesystem_errorE', 'size': 0}
+{'type': 'OBJECT', 'is_defined': True, 'name': '__ZTSNSt3__14__fs10filesystem16filesystem_errorE', 'size': 0}
+{'type': 'OBJECT', 'is_defined': True, 'name': '__ZTVNSt3__14__fs10filesystem16filesystem_errorE', 'size': 0}
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 9435744..6ea7135 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -28,7 +28,6 @@
 
 pythonize_bool(LIBCXX_ENABLE_EXCEPTIONS)
 pythonize_bool(LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY)
-pythonize_bool(LIBCXX_ENABLE_FILESYSTEM)
 pythonize_bool(LIBCXX_ENABLE_RTTI)
 pythonize_bool(LIBCXX_ENABLE_SHARED)
 pythonize_bool(LIBCXX_BUILD_32_BITS)
diff --git a/test/libcxx/input.output/filesystems/lit.local.cfg b/test/libcxx/input.output/filesystems/lit.local.cfg
deleted file mode 100644
index 3d93604..0000000
--- a/test/libcxx/input.output/filesystems/lit.local.cfg
+++ /dev/null
@@ -1,3 +0,0 @@
-# Disable all of the filesystem tests if the correct feature is not available.
-if 'c++filesystem' not in config.available_features:
-  config.unsupported = True
diff --git a/test/lit.site.cfg.in b/test/lit.site.cfg.in
index ed9a711..de7bffa 100644
--- a/test/lit.site.cfg.in
+++ b/test/lit.site.cfg.in
@@ -6,7 +6,6 @@
 config.cxx_library_root         = "@LIBCXX_LIBRARY_DIR@"
 config.enable_exceptions        = @LIBCXX_ENABLE_EXCEPTIONS@
 config.enable_experimental      = @LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY@
-config.enable_filesystem        = @LIBCXX_ENABLE_FILESYSTEM@
 config.enable_rtti              = @LIBCXX_ENABLE_RTTI@
 config.enable_shared            = @LIBCXX_ENABLE_SHARED@
 config.enable_32bit             = @LIBCXX_BUILD_32_BITS@
diff --git a/test/std/input.output/filesystems/lit.local.cfg b/test/std/input.output/filesystems/lit.local.cfg
deleted file mode 100644
index 3d93604..0000000
--- a/test/std/input.output/filesystems/lit.local.cfg
+++ /dev/null
@@ -1,3 +0,0 @@
-# Disable all of the filesystem tests if the correct feature is not available.
-if 'c++filesystem' not in config.available_features:
-  config.unsupported = True
diff --git a/test/std/utilities/time/time.clock/time.clock.file/consistency.pass.cpp b/test/std/utilities/time/time.clock/time.clock.file/consistency.pass.cpp
index 165bec2..585433a 100644
--- a/test/std/utilities/time/time.clock/time.clock.file/consistency.pass.cpp
+++ b/test/std/utilities/time/time.clock/time.clock.file/consistency.pass.cpp
@@ -7,9 +7,6 @@
 //===----------------------------------------------------------------------===//
 //
 // UNSUPPORTED: c++98, c++03, c++11, c++14, c++17
-//
-// TODO: Remove this when filesystem gets integrated into the dylib
-// REQUIRES: c++filesystem
 
 // <chrono>
 
diff --git a/test/std/utilities/time/time.clock/time.clock.file/now.pass.cpp b/test/std/utilities/time/time.clock/time.clock.file/now.pass.cpp
index 79cdf06..ef61657 100644
--- a/test/std/utilities/time/time.clock/time.clock.file/now.pass.cpp
+++ b/test/std/utilities/time/time.clock/time.clock.file/now.pass.cpp
@@ -8,9 +8,6 @@
 
 // UNSUPPORTED: c++98, c++03, c++11, c++14, c++17
 
-// TODO: Remove this when filesystem gets integrated into the dylib
-// REQUIRES: c++filesystem
-
 // <chrono>
 
 // file_clock
diff --git a/test/std/utilities/time/time.clock/time.clock.file/rep_signed.pass.cpp b/test/std/utilities/time/time.clock/time.clock.file/rep_signed.pass.cpp
index 821072e..c87fad2 100644
--- a/test/std/utilities/time/time.clock/time.clock.file/rep_signed.pass.cpp
+++ b/test/std/utilities/time/time.clock/time.clock.file/rep_signed.pass.cpp
@@ -8,9 +8,6 @@
 
 // UNSUPPORTED: c++98, c++03, c++11, c++14, c++17
 
-// TODO: Remove this when filesystem gets integrated into the dylib
-// REQUIRES: c++filesystem
-
 // <chrono>
 
 // file_clock
diff --git a/utils/ci/macos-backdeployment.sh b/utils/ci/macos-backdeployment.sh
index c3f6376..aaed799 100755
--- a/utils/ci/macos-backdeployment.sh
+++ b/utils/ci/macos-backdeployment.sh
@@ -167,7 +167,6 @@
 echo "@@@ Running tests for libc++ @@@"
 "${LIBCXX_BUILD_DIR}/bin/llvm-lit" -sv "${LIBCXX_ROOT}/test" \
                                    --param=enable_experimental=false \
-                                   --param=enable_filesystem=false \
                                    ${LIT_ARCH_STRING} \
                                    --param=cxx_under_test="${CXX}" \
                                    --param=cxx_headers="${LIBCXX_INSTALL_DIR}/include/c++/v1" \
diff --git a/utils/libcxx/test/config.py b/utils/libcxx/test/config.py
index 999c5ac..2fead3a 100644
--- a/utils/libcxx/test/config.py
+++ b/utils/libcxx/test/config.py
@@ -332,8 +332,6 @@
             # FIXME this is a hack.
             if self.get_lit_conf('enable_experimental') is None:
                 self.config.enable_experimental = 'true'
-            if self.get_lit_conf('enable_filesystem') is None:
-                self.config.enable_filesystem = 'true'
 
     def configure_use_clang_verify(self):
         '''If set, run clang with -verify on failing tests.'''
@@ -707,10 +705,6 @@
           self.cxx.compile_flags += ['-D_LIBCPP_ABI_UNSTABLE']
 
     def configure_filesystem_compile_flags(self):
-        enable_fs = self.get_lit_bool('enable_filesystem', default=False)
-        if not enable_fs:
-            return
-        self.config.available_features.add('c++filesystem')
         static_env = os.path.join(self.libcxx_src_root, 'test', 'std',
                                   'input.output', 'filesystems', 'Inputs', 'static_test_env')
         static_env = os.path.realpath(static_env)
@@ -748,12 +742,8 @@
             self.configure_link_flags_abi_library()
             self.configure_extra_library_flags()
         elif self.cxx_stdlib_under_test == 'libstdc++':
-            enable_fs = self.get_lit_bool('enable_filesystem',
-                                          default=False)
-            if enable_fs:
-                self.config.available_features.add('c++experimental')
-                self.cxx.link_flags += ['-lstdc++fs']
-            self.cxx.link_flags += ['-lm', '-pthread']
+            self.config.available_features.add('c++experimental')
+            self.cxx.link_flags += ['-lstdc++fs', '-lm', '-pthread']
         elif self.cxx_stdlib_under_test == 'msvc':
             # FIXME: Correctly setup debug/release flags here.
             pass
@@ -803,10 +793,6 @@
         if libcxx_experimental:
             self.config.available_features.add('c++experimental')
             self.cxx.link_flags += ['-lc++experimental']
-        libcxx_fs = self.get_lit_bool('enable_filesystem', default=False)
-        if libcxx_fs:
-            self.config.available_features.add('c++fs')
-            self.cxx.link_flags += ['-lc++fs']
         if self.link_shared:
             self.cxx.link_flags += ['-lc++']
         else:
diff --git a/utils/libcxx/test/target_info.py b/utils/libcxx/test/target_info.py
index 2ea24d6..2f2e395 100644
--- a/utils/libcxx/test/target_info.py
+++ b/utils/libcxx/test/target_info.py
@@ -234,18 +234,13 @@
                           self.full_config.config.available_features)
         llvm_unwinder = self.full_config.get_lit_bool('llvm_unwinder', False)
         shared_libcxx = self.full_config.get_lit_bool('enable_shared', True)
-        # FIXME: Remove the need to link -lrt in all the tests, and instead
-        # limit it only to the filesystem tests. This ensures we don't cause an
-        # implicit dependency on librt except when filesystem is needed.
-        enable_fs = self.full_config.get_lit_bool('enable_filesystem',
-                                                  default=False)
         flags += ['-lm']
         if not llvm_unwinder:
             flags += ['-lgcc_s', '-lgcc']
         if enable_threads:
             flags += ['-lpthread']
-            if not shared_libcxx or enable_fs:
-              flags += ['-lrt']
+            if not shared_libcxx:
+                flags += ['-lrt']
         flags += ['-lc']
         if llvm_unwinder:
             flags += ['-lunwind', '-ldl']