Skip to content
This repository has been archived by the owner on Apr 23, 2020. It is now read-only.

Commit

Permalink
Implement <filesystem>
Browse files Browse the repository at this point in the history
This patch implements the <filesystem> header and uses that
to provide <experimental/filesystem>.

Unlike other standard headers, the symbols needed for <filesystem>
have not yet been placed in libc++.so. Instead they live in the
new libc++fs.a library. Users of filesystem are required to link this
library. (Also note that libc++experimental no longer contains the
definition of <experimental/filesystem>, which now requires linking libc++fs).

The reason for keeping <filesystem> out of the dylib for now is that
it's still somewhat experimental, and the possibility of requiring an
ABI breaking change is very real. In the future the symbols will likely
be moved into the dylib, or the dylib will be made to link libc++fs automagically).

Note that moving the symbols out of libc++experimental may break user builds
until they update to -lc++fs. This should be OK, because the experimental
library provides no stability guarantees. However, I plan on looking into
ways we can force libc++experimental to automagically link libc++fs.

In order to use a single implementation and set of tests for <filesystem>, it
has been placed in a special `__fs` namespace. This namespace is inline in
C++17 onward, but not before that. As such implementation is available
in C++11 onward, but no filesystem namespace is present "directly", and
as such name conflicts shouldn't occur in C++11 or C++14.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@338093 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
EricWF committed Jul 27, 2018
1 parent 47d2a98 commit a0866c5
Show file tree
Hide file tree
Showing 178 changed files with 3,980 additions and 3,163 deletions.
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,10 @@ option(LIBCXX_INSTALL_SUPPORT_HEADERS "Install libc++ support headers." ON)
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_LIBRARY;LIBCXX_INSTALL_LIBRARY" OFF)

if (FUCHSIA)
set(DEFAULT_ABI_VERSION 2)
else()
Expand Down
10 changes: 7 additions & 3 deletions docs/BuildingLibcxx.rst
Original file line number Diff line number Diff line change
Expand Up @@ -242,11 +242,15 @@ libc++experimental Specific Options

.. option:: LIBCXX_ENABLE_FILESYSTEM:BOOL

**Default**: ``LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY``
**Default**: ``ON``

Build filesystem as a standalone library libc++fs.a.

.. option:: LIBCXX_INSTALL_FILESYSTEM_LIBRARY:BOOL

Build filesystem as part of libc++experimental.a. This allows filesystem
to be disabled without turning off the entire experimental library.
**Default**: ``LIBCXX_ENABLE_FILESYSTEM AND LIBCXX_INSTALL_LIBRARY``

Install libc++fs.a alongside libc++.

.. _ABI Library Specific Options:

Expand Down
21 changes: 21 additions & 0 deletions docs/UsingLibcxx.rst
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,24 @@ An example of using ``LD_LIBRARY_PATH``:
$ export LD_LIBRARY_PATH=<libcxx-install-prefix>/lib
$ ./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/...>``
=====================================================

Expand All @@ -65,6 +83,9 @@ installed. For information on building libc++experimental from source see
: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.

Expand Down
37 changes: 25 additions & 12 deletions include/__config
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,18 @@
# endif
#endif

#ifndef _LIBCPP_STD_VER
# if __cplusplus <= 201103L
# define _LIBCPP_STD_VER 11
# elif __cplusplus <= 201402L
# define _LIBCPP_STD_VER 14
# elif __cplusplus <= 201703L
# define _LIBCPP_STD_VER 17
# else
# define _LIBCPP_STD_VER 18 // current year, or date of c++2a ratification
# endif
#endif // _LIBCPP_STD_VER

#if defined(__ELF__)
# define _LIBCPP_OBJECT_FORMAT_ELF 1
#elif defined(__MACH__)
Expand Down Expand Up @@ -462,6 +474,19 @@ namespace std {
}
}

#if _LIBCPP_STD_VER >= 17
#define _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM \
_LIBCPP_BEGIN_NAMESPACE_STD inline namespace __fs { namespace filesystem {
#else
#define _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM \
_LIBCPP_BEGIN_NAMESPACE_STD namespace __fs { namespace filesystem {
#endif

#define _LIBCPP_END_NAMESPACE_FILESYSTEM \
_LIBCPP_END_NAMESPACE_STD } }

#define _VSTD_FS _VSTD::__fs::filesystem

#if !defined(_LIBCPP_HAS_NO_ASAN) && !__has_feature(address_sanitizer)
#define _LIBCPP_HAS_NO_ASAN
#endif
Expand Down Expand Up @@ -959,18 +984,6 @@ template <unsigned> struct __static_assert_check {};
#define _LIBCPP_WCTYPE_IS_MASK
#endif

#ifndef _LIBCPP_STD_VER
# if __cplusplus <= 201103L
# define _LIBCPP_STD_VER 11
# elif __cplusplus <= 201402L
# define _LIBCPP_STD_VER 14
# elif __cplusplus <= 201703L
# define _LIBCPP_STD_VER 17
# else
# define _LIBCPP_STD_VER 18 // current year, or date of c++2a ratification
# endif
#endif // _LIBCPP_STD_VER

#if _LIBCPP_STD_VER > 11
# define _LIBCPP_DEPRECATED [[deprecated]]
#else
Expand Down
2 changes: 0 additions & 2 deletions include/experimental/__config
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@

#define _VSTD_CORO _VSTD_EXPERIMENTAL::coroutines_v1

#define _VSTD_FS ::std::experimental::filesystem::v1

#define _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL_SIMD \
_LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL inline namespace parallelism_v2 {

Expand Down
Loading

0 comments on commit a0866c5

Please sign in to comment.