Allow disabling of filesystem library.

Summary: Filesystem doesn't work on Windows, so we need a mechanism to turn it off for the time being.

Reviewers: ldionne, serge-sans-paille, EricWF

Reviewed By: EricWF

Subscribers: mstorsjo, mgorny, christof, jdoerfert, libcxx-commits

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

llvm-svn: 356633
This commit is contained in:
Eric Fiselier 2019-03-21 00:04:31 +00:00
parent 49fc265581
commit f1d87f8b4c
8 changed files with 33 additions and 8 deletions

View File

@ -73,6 +73,12 @@ option(LIBCXX_ENABLE_ASSERTIONS "Enable assertions independent of build mode." O
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 -----------------------------------------------------------

View File

@ -206,6 +206,13 @@ libc++ specific options
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

View File

@ -3,8 +3,6 @@ set(LIBCXX_LIB_CMAKEFILES_DIR "${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTOR
# 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 @@ elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "SunOS")
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.

View File

@ -30,6 +30,7 @@ pythonize_bool(LIBCXX_ENABLE_EXCEPTIONS)
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)

View File

@ -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

View File

@ -6,6 +6,7 @@ config.libcxx_obj_root = "@LIBCXX_BINARY_DIR@"
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@

View File

@ -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

View File

@ -435,6 +435,9 @@ class Configuration(object):
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'):