Index: libcxx/trunk/CMakeLists.txt =================================================================== --- libcxx/trunk/CMakeLists.txt +++ libcxx/trunk/CMakeLists.txt @@ -73,6 +73,12 @@ 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 ON) +if (WIN32) + set(ENABLE_FILESYSTEM_DEFAULT OFF) +endif() +option(LIBCXX_ENABLE_FILESYSTEM "Build filesystem as part of the main libc++ library" + ${ENABLE_FILESYSTEM_DEFAULT}) option(LIBCXX_INCLUDE_TESTS "Build the libc++ tests." ${LLVM_INCLUDE_TESTS}) # Benchmark options ----------------------------------------------------------- Index: libcxx/trunk/docs/BuildingLibcxx.rst =================================================================== --- libcxx/trunk/docs/BuildingLibcxx.rst +++ libcxx/trunk/docs/BuildingLibcxx.rst @@ -206,6 +206,13 @@ libraries that may be used in with other shared libraries that use different C++ library. We want to avoid avoid exporting any libc++ symbols in that case. +.. option:: LIBCXX_ENABLE_FILESYSTEM:BOOL + + **Default**: ``ON`` except on Windows. + + This option can be used to enable or disable the filesystem components on + platforms that may not support them. For example on Windows. + .. _libc++experimental options: libc++experimental Specific Options Index: libcxx/trunk/lib/CMakeLists.txt =================================================================== --- libcxx/trunk/lib/CMakeLists.txt +++ libcxx/trunk/lib/CMakeLists.txt @@ -3,8 +3,6 @@ # 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}) @@ -13,12 +11,16 @@ 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) +if (LIBCXX_ENABLE_FILESYSTEM) + list(APPEND LIBCXX_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_SOURCES ../src/filesystem/int128_builtins.cpp) + endif() endif() # Add all the headers to the project for IDEs. Index: libcxx/trunk/test/CMakeLists.txt =================================================================== --- libcxx/trunk/test/CMakeLists.txt +++ libcxx/trunk/test/CMakeLists.txt @@ -30,6 +30,7 @@ pythonize_bool(LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY) pythonize_bool(LIBCXX_ENABLE_RTTI) pythonize_bool(LIBCXX_ENABLE_SHARED) +pythonize_bool(LIBCXX_ENABLE_FILESYSTEM) pythonize_bool(LIBCXX_BUILD_32_BITS) pythonize_bool(LIBCXX_GENERATE_COVERAGE) pythonize_bool(LIBCXXABI_ENABLE_SHARED) Index: libcxx/trunk/test/libcxx/input.output/filesystems/lit.local.cfg =================================================================== --- libcxx/trunk/test/libcxx/input.output/filesystems/lit.local.cfg +++ libcxx/trunk/test/libcxx/input.output/filesystems/lit.local.cfg @@ -1,3 +1,5 @@ # Disable all of the filesystem tests if the dylib under test doesn't support them. if 'dylib-has-no-filesystem' in config.available_features: config.unsupported = True +if 'c++filesystem-disabled' in config.available_features: + config.unsupported = True Index: libcxx/trunk/test/lit.site.cfg.in =================================================================== --- libcxx/trunk/test/lit.site.cfg.in +++ libcxx/trunk/test/lit.site.cfg.in @@ -6,6 +6,7 @@ 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@ Index: libcxx/trunk/test/std/input.output/filesystems/lit.local.cfg =================================================================== --- libcxx/trunk/test/std/input.output/filesystems/lit.local.cfg +++ libcxx/trunk/test/std/input.output/filesystems/lit.local.cfg @@ -1,3 +1,6 @@ # Disable all of the filesystem tests if the dylib under test doesn't support them. if 'dylib-has-no-filesystem' in config.available_features: config.unsupported = True +if 'c++filesystem-disabled' in config.available_features: + config.unsupported = True + Index: libcxx/trunk/utils/libcxx/test/config.py =================================================================== --- libcxx/trunk/utils/libcxx/test/config.py +++ libcxx/trunk/utils/libcxx/test/config.py @@ -435,6 +435,9 @@ if self.long_tests: self.config.available_features.add('long_tests') + if not self.get_lit_bool('enable_filesystem', default=True): + self.config.available_features.add('c++filesystem-disabled') + # Run a compile test for the -fsized-deallocation flag. This is needed # in test/std/language.support/support.dynamic/new.delete if self.cxx.hasCompileFlag('-fsized-deallocation'):