diff options
author | 2018-09-11 18:18:58 +0000 | |
---|---|---|
committer | 2018-09-11 18:18:58 +0000 | |
commit | 820e1f31efc1d6ed04795ba2e79f3044e1907492 (patch) | |
tree | 815cebb3734784074b661935c33f00bd5eb4d862 /lib/libcxx/docs | |
parent | Nuke unused LIST() ieee80211com_head. (diff) | |
download | wireguard-openbsd-820e1f31efc1d6ed04795ba2e79f3044e1907492.tar.xz wireguard-openbsd-820e1f31efc1d6ed04795ba2e79f3044e1907492.zip |
import of libc++ 6.0.0
Diffstat (limited to 'lib/libcxx/docs')
-rw-r--r-- | lib/libcxx/docs/BuildingLibcxx.rst | 113 | ||||
-rw-r--r-- | lib/libcxx/docs/CMakeLists.txt | 4 | ||||
-rw-r--r-- | lib/libcxx/docs/DesignDocs/AvailabilityMarkup.rst | 114 | ||||
-rw-r--r-- | lib/libcxx/docs/DesignDocs/DebugMode.rst | 100 | ||||
-rw-r--r-- | lib/libcxx/docs/DesignDocs/ThreadingSupportAPI.rst | 79 | ||||
-rw-r--r-- | lib/libcxx/docs/DesignDocs/VisibilityMacros.rst | 163 | ||||
-rw-r--r-- | lib/libcxx/docs/Makefile.sphinx | 2 | ||||
-rw-r--r-- | lib/libcxx/docs/TestingLibcxx.rst | 104 | ||||
-rw-r--r-- | lib/libcxx/docs/UsingLibcxx.rst | 94 | ||||
-rw-r--r-- | lib/libcxx/docs/conf.py | 6 | ||||
-rw-r--r-- | lib/libcxx/docs/index.rst | 15 |
11 files changed, 753 insertions, 41 deletions
diff --git a/lib/libcxx/docs/BuildingLibcxx.rst b/lib/libcxx/docs/BuildingLibcxx.rst index 36866b13ef7..3dae2f41c27 100644 --- a/lib/libcxx/docs/BuildingLibcxx.rst +++ b/lib/libcxx/docs/BuildingLibcxx.rst @@ -49,7 +49,7 @@ The basic steps needed to build libc++ are: For more information about configuring libc++ see :ref:`CMake Options`. * ``make cxx`` --- will build libc++ and libc++abi. - * ``make check-libcxx check-libcxxabi`` --- will run the test suites. + * ``make check-cxx check-cxxabi`` --- will run the test suites. Shared libraries for libc++ and libc++ abi should now be present in llvm/build/lib. See :ref:`using an alternate libc++ installation <alternate libcxx>` @@ -60,7 +60,7 @@ The basic steps needed to build libc++ are: careful not to replace it. Remember Use the CMake option ``CMAKE_INSTALL_PREFIX`` to select a safe place to install libc++. - * ``make install-libcxx install-libcxxabi`` --- Will install the libraries and the headers + * ``make install-cxx install-cxxabi`` --- Will install the libraries and the headers .. warning:: * Replacing your systems libc++ installation could render the system non-functional. @@ -92,6 +92,57 @@ build would look like this: $ make check-libcxx # optional +Experimental Support for Windows +-------------------------------- + +The Windows support requires building with clang-cl as cl does not support one +required extension: `#include_next`. Furthermore, VS 2015 or newer (19.00) is +required. In the case of clang-cl, we need to specify the "MS Compatibility +Version" as it defaults to 2014 (18.00). + +CMake + Visual Studio +~~~~~~~~~~~~~~~~~~~~~ + +Building with Visual Studio currently does not permit running tests. However, +it is the simplest way to build. + +.. code-block:: batch + + > cmake -G "Visual Studio 14 2015" ^ + -T "LLVM-vs2014" ^ + -DLIBCXX_ENABLE_SHARED=YES ^ + -DLIBCXX_ENABLE_STATIC=NO ^ + -DLIBCXX_ENABLE_EXPERIMENTAL_LIBRARY=NO ^ + \path\to\libcxx + > cmake --build . + +CMake + ninja +~~~~~~~~~~~~~ + +Building with ninja is required for development to enable tests. +Unfortunately, doing so requires additional configuration as we cannot +just specify a toolset. + +.. code-block:: batch + + > cmake -G Ninja ^ + -DCMAKE_MAKE_PROGRAM=/path/to/ninja ^ + -DCMAKE_SYSTEM_NAME=Windows ^ + -DCMAKE_C_COMPILER=clang-cl ^ + -DCMAKE_C_FLAGS="-fms-compatibility-version=19.00 --target=i686--windows" ^ + -DCMAKE_CXX_COMPILER=clang-cl ^ + -DCMAKE_CXX_FLAGS="-fms-compatibility-version=19.00 --target=i686--windows" ^ + -DLLVM_PATH=/path/to/llvm/tree ^ + -DLIBCXX_ENABLE_SHARED=YES ^ + -DLIBCXX_ENABLE_STATIC=NO ^ + -DLIBCXX_ENABLE_EXPERIMENTAL_LIBRARY=NO ^ + \path\to\libcxx + > /path/to/ninja cxx + > /path/to/ninja check-cxx + +Note that the paths specified with backward slashes must use the `\\` as the +directory separator as clang-cl may otherwise parse the path as an argument. + .. _`libc++abi`: http://libcxxabi.llvm.org/ @@ -144,20 +195,32 @@ libc++ specific options **Default**: ``OFF`` - Build libc++ as a 32 bit library. Also see :option:`LLVM_BUILD_32_BITS`. + Build libc++ as a 32 bit library. Also see `LLVM_BUILD_32_BITS`. .. option:: LIBCXX_ENABLE_SHARED:BOOL **Default**: ``ON`` - Build libc++ as a shared library. If ``OFF`` is specified then libc++ is - built as a static library. + Build libc++ as a shared library. Either `LIBCXX_ENABLE_SHARED` or + `LIBCXX_ENABLE_STATIC` has to be enabled. + +.. option:: LIBCXX_ENABLE_STATIC:BOOL + + **Default**: ``ON`` + + Build libc++ as a static library. Either `LIBCXX_ENABLE_SHARED` or + `LIBCXX_ENABLE_STATIC` has to be enabled. .. option:: LIBCXX_LIBDIR_SUFFIX:STRING Extra suffix to append to the directory where libraries are to be installed. - This option overrides :option:`LLVM_LIBDIR_SUFFIX`. + This option overrides `LLVM_LIBDIR_SUFFIX`. + +.. option:: LIBCXX_INSTALL_PREFIX:STRING + **Default**: ``""`` + + Define libc++ destination prefix. .. _libc++experimental options: @@ -172,7 +235,7 @@ libc++experimental Specific Options .. option:: LIBCXX_INSTALL_EXPERIMENTAL_LIBRARY:BOOL - **Default**: ``OFF`` + **Default**: ``LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY AND LIBCXX_INSTALL_LIBRARY`` Install libc++experimental.a alongside libc++. @@ -227,7 +290,7 @@ ABI Library Specific Options libc++abi is the C++ ABI library used. -libc++ Feature options +libc++ Feature Options ---------------------- .. option:: LIBCXX_ENABLE_EXCEPTIONS:BOOL @@ -242,9 +305,32 @@ libc++ Feature options Build libc++ with run time type information. +.. option:: LIBCXX_INCLUDE_BENCHMARKS:BOOL -libc++ Feature options ----------------------- + **Default**: ``ON`` + + Build the libc++ benchmark tests and the Google Benchmark library needed + to support them. + +.. option:: LIBCXX_BENCHMARK_NATIVE_STDLIB:STRING + + **Default**:: ``""`` + + **Values**:: ``libc++``, ``libstdc++`` + + Build the libc++ benchmark tests and Google Benchmark library against the + specified standard library on the platform. On linux this can be used to + compare libc++ to libstdc++ by building the benchmark tests against both + standard libraries. + +.. option:: LIBCXX_BENCHMARK_NATIVE_GCC_TOOLCHAIN:STRING + + Use the specified GCC toolchain and standard library when building the native + stdlib benchmark tests. + + +libc++ ABI Feature Options +-------------------------- The following options allow building libc++ for a different ABI version. @@ -261,6 +347,13 @@ The following options allow building libc++ for a different ABI version. Build the "unstable" ABI version of libc++. Includes all ABI changing features on top of the current stable version. +.. option:: LIBCXX_ABI_DEFINES:STRING + + **Default**: ``""`` + + A semicolon-separated list of ABI macros to persist in the site config header. + See ``include/__config`` for the list of ABI macros. + .. _LLVM-specific variables: LLVM-specific options diff --git a/lib/libcxx/docs/CMakeLists.txt b/lib/libcxx/docs/CMakeLists.txt index f63ee00a5a0..d679761a5ad 100644 --- a/lib/libcxx/docs/CMakeLists.txt +++ b/lib/libcxx/docs/CMakeLists.txt @@ -1,9 +1,9 @@ if (LLVM_ENABLE_SPHINX) + include(AddSphinxTarget) if (SPHINX_FOUND) - include(AddSphinxTarget) if (${SPHINX_OUTPUT_HTML}) add_sphinx_target(html libcxx) endif() endif() -endif()
\ No newline at end of file +endif() diff --git a/lib/libcxx/docs/DesignDocs/AvailabilityMarkup.rst b/lib/libcxx/docs/DesignDocs/AvailabilityMarkup.rst new file mode 100644 index 00000000000..4a85c698f23 --- /dev/null +++ b/lib/libcxx/docs/DesignDocs/AvailabilityMarkup.rst @@ -0,0 +1,114 @@ +=================== +Availability Markup +=================== + +.. contents:: + :local: + +Overview +======== + +Libc++ is used as a system library on macOS and iOS (amongst others). In order +for users to be able to compile a binary that is intended to be deployed to an +older version of the platform, clang provides the +`availability attribute <https://clang.llvm.org/docs/AttributeReference.html#availability>`_ +that can be placed on declarations to describe the lifecycle of a symbol in the +library. + +Design +====== + +When a new feature is introduced that requires dylib support, a macro should be +created in include/__config to mark this feature as unavailable for all the +systems. For example:: + + // Define availability macros. + #if defined(_LIBCPP_USE_AVAILABILITY_APPLE) + #define _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS __attribute__((unavailable)) + #else if defined(_LIBCPP_USE_AVAILABILITY_SOME_OTHER_VENDOR) + #define _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS __attribute__((unavailable)) + #else + #define _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS + #endif + +When the library is updated by the platform vendor, the markup can be updated. +For example:: + + #define _LIBCPP_AVAILABILITY_SHARED_MUTEX \ + __attribute__((availability(macosx,strict,introduced=10.12))) \ + __attribute__((availability(ios,strict,introduced=10.0))) \ + __attribute__((availability(tvos,strict,introduced=10.0))) \ + __attribute__((availability(watchos,strict,introduced=3.0))) + +In the source code, the macro can be added on a class if the full class requires +type info from the library for example:: + + _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL + class _LIBCPP_EXCEPTION_ABI _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS bad_optional_access + : public std::logic_error { + +or on a particular symbol: + + _LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_AVAILABILITY_SIZED_NEW_DELETE void operator delete(void* __p, std::size_t __sz) _NOEXCEPT; + + +Testing +======= + +Some parameters can be passed to lit to run the test-suite and exercising the +availability. + +* The `platform` parameter controls the deployement target. For example lit can + be invoked with `--param=platform=macosx10.8`. Default is the current host. +* The `use_system_cxx_lib` parameter indicates to use another library than the + just built one. Invoking lit with `--param=use_system_cxx_lib=true` will run + the test-suite against the host system library. Alternatively a path to the + directory containing a specific prebuilt libc++ can be used, for example: + `--param=use_system_cxx_lib=/path/to/macOS/10.8/`. +* The `with_availability` boolean parameter enables the availability markup. + +Tests can be marked as XFAIL based on multiple features made available by lit: + + +* if either `use_system_cxx_lib` or `with_availability` is passed to lit, + assuming `--param=platform=macosx10.8` is passed as well the following + features will be available: + + - availability + - availability=x86_64 + - availability=macosx + - availability=x86_64-macosx + - availability=x86_64-apple-macosx10.8 + - availability=macosx10.8 + + This feature is used to XFAIL a test that *is* using a class of a method marked + as unavailable *and* that is expected to *fail* if deployed on an older system. + +* if `use_system_cxx_lib` is passed to lit, the following features will also + be available: + + - with_system_cxx_lib + - with_system_cxx_lib=x86_64 + - with_system_cxx_lib=macosx + - with_system_cxx_lib=x86_64-macosx + - with_system_cxx_lib=x86_64-apple-macosx10.8 + - with_system_cxx_lib=macosx10.8 + + This feature is used to XFAIL a test that is *not* using a class of a method + marked as unavailable *but* that is expected to fail if deployed on an older + system. For example if we know that it exhibits a but in the libc on a + particular system version. + +* if `with_availability` is passed to lit, the following features will also + be available: + + - availability_markup + - availability_markup=x86_64 + - availability_markup=macosx + - availability_markup=x86_64-macosx + - availability_markup=x86_64-apple-macosx10.8 + - availability_markup=macosx10.8 + + This feature is used to XFAIL a test that *is* using a class of a method + marked as unavailable *but* that is expected to *pass* if deployed on an older + system. For example if it is using a symbol in a statically evaluated context. diff --git a/lib/libcxx/docs/DesignDocs/DebugMode.rst b/lib/libcxx/docs/DesignDocs/DebugMode.rst new file mode 100644 index 00000000000..3b997d44607 --- /dev/null +++ b/lib/libcxx/docs/DesignDocs/DebugMode.rst @@ -0,0 +1,100 @@ +========== +Debug Mode +========== + +.. contents:: + :local: + +.. _using-debug-mode: + +Using Debug Mode +================ + +Libc++ provides a debug mode that enables assertions meant to detect incorrect +usage of the standard library. By default these assertions are disabled but +they can be enabled using the ``_LIBCPP_DEBUG`` macro. + +**_LIBCPP_DEBUG** Macro +----------------------- + +**_LIBCPP_DEBUG**: + This macro is used to enable assertions and iterator debugging checks within + libc++. By default it is undefined. + + **Values**: ``0``, ``1`` + + Defining ``_LIBCPP_DEBUG`` to ``0`` or greater enables most of libc++'s + assertions. Defining ``_LIBCPP_DEBUG`` to ``1`` enables "iterator debugging" + which provides additional assertions about the validity of iterators used by + the program. + + Note that this option has no effect on libc++'s ABI + +**_LIBCPP_DEBUG_USE_EXCEPTIONS**: + When this macro is defined ``_LIBCPP_ASSERT`` failures throw + ``__libcpp_debug_exception`` instead of aborting. Additionally this macro + disables exception specifications on functions containing ``_LIBCPP_ASSERT`` + checks. This allows assertion failures to correctly throw through these + functions. + +Handling Assertion Failures +--------------------------- + +When a debug assertion fails the assertion handler is called via the +``std::__libcpp_debug_function`` function pointer. It is possible to override +this function pointer using a different handler function. Libc++ provides two +different assertion handlers, the default handler +``std::__libcpp_abort_debug_handler`` which aborts the program, and +``std::__libcpp_throw_debug_handler`` which throws an instance of +``std::__libcpp_debug_exception``. Libc++ can be changed to use the throwing +assertion handler as follows: + +.. code-block:: cpp + + #define _LIBCPP_DEBUG 1 + #include <string> + int main() { + std::__libcpp_debug_function = std::__libcpp_throw_debug_function; + try { + std::string::iterator bad_it; + std::string str("hello world"); + str.insert(bad_it, '!'); // causes debug assertion + } catch (std::__libcpp_debug_exception const&) { + return EXIT_SUCCESS; + } + return EXIT_FAILURE; + } + +Debug Mode Checks +================= + +Libc++'s debug mode offers two levels of checking. The first enables various +precondition checks throughout libc++. The second additionally enables +"iterator debugging" which checks the validity of iterators used by the program. + +Basic Checks +============ + +These checks are enabled when ``_LIBCPP_DEBUG`` is defined to either 0 or 1. + +The following checks are enabled by ``_LIBCPP_DEBUG``: + + * FIXME: Update this list + +Iterator Debugging Checks +========================= + +These checks are enabled when ``_LIBCPP_DEBUG`` is defined to 1. + +The following containers and STL classes support iterator debugging: + + * ``std::string`` + * ``std::vector<T>`` (``T != bool``) + * ``std::list`` + * ``std::unordered_map`` + * ``std::unordered_multimap`` + * ``std::unordered_set`` + * ``std::unordered_multiset`` + +The remaining containers do not currently support iterator debugging. +Patches welcome. diff --git a/lib/libcxx/docs/DesignDocs/ThreadingSupportAPI.rst b/lib/libcxx/docs/DesignDocs/ThreadingSupportAPI.rst new file mode 100644 index 00000000000..556c45b7e1f --- /dev/null +++ b/lib/libcxx/docs/DesignDocs/ThreadingSupportAPI.rst @@ -0,0 +1,79 @@ +===================== +Threading Support API +===================== + +.. contents:: + :local: + +Overview +======== + +Libc++ supports using multiple different threading models and configurations +to implement the threading parts of libc++, including ``<thread>`` and ``<mutex>``. +These different models provide entirely different interfaces from each +other. To address this libc++ wraps the underlying threading API in a new and +consistent API, which it uses internally to implement threading primitives. + +The ``<__threading_support>`` header is where libc++ defines its internal +threading interface. It contains forward declarations of the internal threading +interface as well as definitions for the interface. + +External Threading API and the ``<__external_threading>`` header +================================================================ + +In order to support vendors with custom threading API's libc++ allows the +entire internal threading interface to be provided by an external, +vendor provided, header. + +When ``_LIBCPP_HAS_THREAD_API_EXTERNAL`` is defined the ``<__threading_support>`` +header simply forwards to the ``<__external_threading>`` header (which must exist). +It is expected that the ``<__external_threading>`` header provide the exact +interface normally provided by ``<__threading_support>``. + +External Threading Library +========================== + +libc++ can be compiled with its internal threading API delegating to an external +library. Such a configuration is useful for library vendors who wish to +distribute a thread-agnostic libc++ library, where the users of the library are +expected to provide the implementation of the libc++ internal threading API. + +On a production setting, this would be achieved through a custom +``<__external_threading>`` header, which declares the libc++ internal threading +API but leaves out the implementation. + +The ``-DLIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY`` option allows building libc++ in +such a configuration while allowing it to be tested on a platform that supports +any of the threading systems (e.g. pthread) supported in ``__threading_support`` +header. Therefore, the main purpose of this option is to allow testing of this +particular configuration of the library without being tied to a vendor-specific +threading system. This option is only meant to be used by libc++ library +developers. + +Threading Configuration Macros +============================== + +**_LIBCPP_HAS_NO_THREADS** + This macro is defined when libc++ is built without threading support. It + should not be manually defined by the user. + +**_LIBCPP_HAS_THREAD_API_EXTERNAL** + This macro is defined when libc++ should use the ``<__external_threading>`` + header to provide the internal threading API. This macro overrides + ``_LIBCPP_HAS_THREAD_API_PTHREAD``. + +**_LIBCPP_HAS_THREAD_API_PTHREAD** + This macro is defined when libc++ should use POSIX threads to implement the + internal threading API. + +**_LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL** + This macro is defined when libc++ expects the definitions of the internal + threading API to be provided by an external library. When defined + ``<__threading_support>`` will only provide the forward declarations and + typedefs for the internal threading API. + +**_LIBCPP_BUILDING_THREAD_LIBRARY_EXTERNAL** + This macro is used to build an external threading library using the + ``<__threading_support>``. Specifically it exposes the threading API + definitions in ``<__threading_support>`` as non-inline definitions meant to + be compiled into a library. diff --git a/lib/libcxx/docs/DesignDocs/VisibilityMacros.rst b/lib/libcxx/docs/DesignDocs/VisibilityMacros.rst new file mode 100644 index 00000000000..993ce2cca5f --- /dev/null +++ b/lib/libcxx/docs/DesignDocs/VisibilityMacros.rst @@ -0,0 +1,163 @@ +======================== +Symbol Visibility Macros +======================== + +.. contents:: + :local: + +Overview +======== + +Libc++ uses various "visibility" macros in order to provide a stable ABI in +both the library and the headers. These macros work by changing the +visibility and inlining characteristics of the symbols they are applied to. + +Visibility Macros +================= + +**_LIBCPP_HIDDEN** + Mark a symbol as hidden so it will not be exported from shared libraries. + +**_LIBCPP_FUNC_VIS** + Mark a symbol as being exported by the libc++ library. This attribute must + be applied to the declaration of all functions exported by the libc++ dylib. + +**_LIBCPP_EXTERN_VIS** + Mark a symbol as being exported by the libc++ library. This attribute may + only be applied to objects defined in the libc++ library. On Windows this + macro applies `dllimport`/`dllexport` to the symbol. On all other platforms + this macro has no effect. + +**_LIBCPP_OVERRIDABLE_FUNC_VIS** + Mark a symbol as being exported by the libc++ library, but allow it to be + overridden locally. On non-Windows, this is equivalent to `_LIBCPP_FUNC_VIS`. + This macro is applied to all `operator new` and `operator delete` overloads. + + **Windows Behavior**: Any symbol marked `dllimport` cannot be overridden + locally, since `dllimport` indicates the symbol should be bound to a separate + DLL. All `operator new` and `operator delete` overloads are required to be + locally overridable, and therefore must not be marked `dllimport`. On Windows, + this macro therefore expands to `__declspec(dllexport)` when building the + library and has an empty definition otherwise. + +**_LIBCPP_INLINE_VISIBILITY** + Mark a function as hidden and force inlining whenever possible. + +**_LIBCPP_ALWAYS_INLINE** + A synonym for `_LIBCPP_INLINE_VISIBILITY` + +**_LIBCPP_TYPE_VIS** + Mark a type's typeinfo, vtable and members as having default visibility. + This attribute cannot be used on class templates. + +**_LIBCPP_TEMPLATE_VIS** + Mark a type's typeinfo and vtable as having default visibility. + This macro has no effect on the visibility of the type's member functions. + + **GCC Behavior**: GCC does not support Clang's `type_visibility(...)` + attribute. With GCC the `visibility(...)` attribute is used and member + functions are affected. + + **Windows Behavior**: DLLs do not support dllimport/export on class templates. + The macro has an empty definition on this platform. + + +**_LIBCPP_ENUM_VIS** + Mark the typeinfo of an enum as having default visibility. This attribute + should be applied to all enum declarations. + + **Windows Behavior**: DLLs do not support importing or exporting enumeration + typeinfo. The macro has an empty definition on this platform. + + **GCC Behavior**: GCC un-hides the typeinfo for enumerations by default, even + if `-fvisibility=hidden` is specified. Additionally applying a visibility + attribute to an enum class results in a warning. The macro has an empty + definition with GCC. + +**_LIBCPP_EXTERN_TEMPLATE_TYPE_VIS** + Mark the member functions, typeinfo, and vtable of the type named in + a `_LIBCPP_EXTERN_TEMPLATE` declaration as being exported by the libc++ library. + This attribute must be specified on all extern class template declarations. + + This macro is used to override the `_LIBCPP_TEMPLATE_VIS` attribute + specified on the primary template and to export the member functions produced + by the explicit instantiation in the dylib. + + **GCC Behavior**: GCC ignores visibility attributes applied the type in + extern template declarations and applying an attribute results in a warning. + However since `_LIBCPP_TEMPLATE_VIS` is the same as + `__attribute__((visibility("default"))` the visibility is already correct. + The macro has an empty definition with GCC. + + **Windows Behavior**: `extern template` and `dllexport` are fundamentally + incompatible *on a class template* on Windows; the former suppresses + instantiation, while the latter forces it. Specifying both on the same + declaration makes the class template be instantiated, which is not desirable + inside headers. This macro therefore expands to `dllimport` outside of libc++ + but nothing inside of it (rather than expanding to `dllexport`); instead, the + explicit instantiations themselves are marked as exported. Note that this + applies *only* to extern *class* templates. Extern *function* templates obey + regular import/export semantics, and applying `dllexport` directly to the + extern template declaration (i.e. using `_LIBCPP_FUNC_VIS`) is the correct + thing to do for them. + +**_LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS** + Mark the member functions, typeinfo, and vtable of an explicit instantiation + of a class template as being exported by the libc++ library. This attribute + must be specified on all class template explicit instantiations. + + It is only necessary to mark the explicit instantiation itself (as opposed to + the extern template declaration) as exported on Windows, as discussed above. + On all other platforms, this macro has an empty definition. + +**_LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS** + Mark a symbol as hidden so it will not be exported from shared libraries. This + is intended specifically for method templates of either classes marked with + `_LIBCPP_TYPE_VIS` or classes with an extern template instantiation + declaration marked with `_LIBCPP_EXTERN_TEMPLATE_TYPE_VIS`. + + When building libc++ with hidden visibility, we want explicit template + instantiations to export members, which is consistent with existing Windows + behavior. We also want classes annotated with `_LIBCPP_TYPE_VIS` to export + their members, which is again consistent with existing Windows behavior. + Both these changes are necessary for clients to be able to link against a + libc++ DSO built with hidden visibility without encountering missing symbols. + + An unfortunate side effect, however, is that method templates of classes + either marked `_LIBCPP_TYPE_VIS` or with extern template instantiation + declarations marked with `_LIBCPP_EXTERN_TEMPLATE_TYPE_VIS` also get default + visibility when instantiated. These methods are often implicitly instantiated + inside other libraries which use the libc++ headers, and will therefore end up + being exported from those libraries, since those implicit instantiations will + receive default visibility. This is not acceptable for libraries that wish to + control their visibility, and led to PR30642. + + Consequently, all such problematic method templates are explicitly marked + either hidden (via this macro) or inline, so that they don't leak into client + libraries. The problematic methods were found by running + `bad-visibility-finder <https://github.com/smeenai/bad-visibility-finder>`_ + against the libc++ headers after making `_LIBCPP_TYPE_VIS` and + `_LIBCPP_EXTERN_TEMPLATE_TYPE_VIS` expand to default visibility. + +**_LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY** + Mark a member function of a class template as visible and always inline. This + macro should only be applied to member functions of class templates that are + externally instantiated. It is important that these symbols are not marked + as hidden as that will prevent the dylib definition from being found. + + This macro is used to maintain ABI compatibility for symbols that have been + historically exported by the libc++ library but are now marked inline. + +**_LIBCPP_EXCEPTION_ABI** + Mark the member functions, typeinfo, and vtable of the type as being exported + by the libc++ library. This macro must be applied to all *exception types*. + Exception types should be defined directly in namespace `std` and not the + versioning namespace. This allows throwing and catching some exception types + between libc++ and libstdc++. + +Links +===== + +* `[cfe-dev] Visibility in libc++ - 1 <http://lists.llvm.org/pipermail/cfe-dev/2013-July/030610.html>`_ +* `[cfe-dev] Visibility in libc++ - 2 <http://lists.llvm.org/pipermail/cfe-dev/2013-August/031195.html>`_ +* `[libcxx] Visibility fixes for Windows <http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20130805/085461.html>`_ diff --git a/lib/libcxx/docs/Makefile.sphinx b/lib/libcxx/docs/Makefile.sphinx index 2ca1e4d3faf..ae37a34b54e 100644 --- a/lib/libcxx/docs/Makefile.sphinx +++ b/lib/libcxx/docs/Makefile.sphinx @@ -5,7 +5,7 @@ # out-of-tree builds. # You can set these variables from the command line. -SPHINXOPTS = +SPHINXOPTS = -n -W SPHINXBUILD = sphinx-build PAPER = BUILDDIR = _build diff --git a/lib/libcxx/docs/TestingLibcxx.rst b/lib/libcxx/docs/TestingLibcxx.rst index 9226ae17023..43c0684dc7d 100644 --- a/lib/libcxx/docs/TestingLibcxx.rst +++ b/lib/libcxx/docs/TestingLibcxx.rst @@ -98,56 +98,64 @@ configuration. Passing the option on the command line will override the default. .. program:: lit -.. option:: --cxx_under_test=<path/to/compiler> +.. option:: cxx_under_test=<path/to/compiler> Specify the compiler used to build the tests. +.. option:: cxx_stdlib_under_test=<stdlib name> + + **Values**: libc++, libstdc++ + + Specify the C++ standard library being tested. Unless otherwise specified + libc++ is used. This option is intended to allow running the libc++ test + suite against other standard library implementations. + .. option:: std=<standard version> - **Values**: c++98, c++03, c++11, c++14, c++1z + **Values**: c++98, c++03, c++11, c++14, c++17, c++2a Change the standard version used when building the tests. -.. option:: --libcxx_site_config=<path/to/lit.site.cfg> +.. option:: libcxx_site_config=<path/to/lit.site.cfg> Specify the site configuration to use when running the tests. This option - overrides the enviroment variable LIBCXX_SITE_CONFIG. + overrides the environment variable LIBCXX_SITE_CONFIG. -.. option:: --libcxx_headers=<path/to/headers> +.. option:: cxx_headers=<path/to/headers> - Specify the libc++ headers that are tested. By default the headers in the - source tree are used. + Specify the c++ standard library headers that are tested. By default the + headers in the source tree are used. -.. option:: --cxx_library_root=<path/to/lib/> +.. option:: cxx_library_root=<path/to/lib/> Specify the directory of the libc++ library to be tested. By default the library folder of the build directory is used. This option cannot be used - when use_system_lib is provided. + when use_system_cxx_lib is provided. -.. option:: --cxx_runtime_root=<path/to/lib/> +.. option:: cxx_runtime_root=<path/to/lib/> Specify the directory of the libc++ library to use at runtime. This directory is not added to the linkers search path. This can be used to compile tests against one version of libc++ and run them using another. The default value for this option is `cxx_library_root`. This option cannot be used - when use_system_lib is provided. + when use_system_cxx_lib is provided. -.. option:: --use_system_lib=<bool> +.. option:: use_system_cxx_lib=<bool> **Default**: False Enable or disable testing against the installed version of libc++ library. Note: This does not use the installed headers. -.. option:: --use_lit_shell=<bool> +.. option:: use_lit_shell=<bool> Enable or disable the use of LIT's internal shell in ShTests. If the environment variable LIT_USE_INTERNAL_SHELL is present then that is used as the default value. Otherwise the default value is True on Windows and False on every other platform. -.. option:: --no_default_flags=<bool> +.. option:: no_default_flags=<bool> **Default**: False @@ -155,16 +163,16 @@ configuration. Passing the option on the command line will override the default. option is used only flags specified using the compile_flags and link_flags will be used. -.. option:: --compile_flags="<list-of-args>" +.. option:: compile_flags="<list-of-args>" Specify additional compile flags as a space delimited string. Note: This options should not be used to change the standard version used. -.. option:: --link_flags="<list-of-args>" +.. option:: link_flags="<list-of-args>" Specify additional link flags as a space delimited string. -.. option:: --debug_level=<level> +.. option:: debug_level=<level> **Values**: 0, 1 @@ -191,10 +199,68 @@ Environment Variables .. envvar:: LIBCXX_SITE_CONFIG=<path/to/lit.site.cfg> Specify the site configuration to use when running the tests. - Also see :option:`libcxx_site_config`. + Also see `libcxx_site_config`. .. envvar:: LIBCXX_COLOR_DIAGNOSTICS If ``LIBCXX_COLOR_DIAGNOSTICS`` is defined then the test suite will attempt to use color diagnostic outputs from the compiler. - Also see :option:`color_diagnostics`. + Also see `color_diagnostics`. + +Benchmarks +========== + +Libc++ contains benchmark tests separately from the test of the test suite. +The benchmarks are written using the `Google Benchmark`_ library, a copy of which +is stored in the libc++ repository. + +For more information about using the Google Benchmark library see the +`official documentation <https://github.com/google/benchmark>`_. + +.. _`Google Benchmark`: https://github.com/google/benchmark + +Building Benchmarks +------------------- + +The benchmark tests are not built by default. The benchmarks can be built using +the ``cxx-benchmarks`` target. + +An example build would look like: + +.. code-block:: bash + + $ cd build + $ cmake [options] <path to libcxx sources> + $ make cxx-benchmarks + +This will build all of the benchmarks under ``<libcxx-src>/benchmarks`` to be +built against the just-built libc++. The compiled tests are output into +``build/benchmarks``. + +The benchmarks can also be built against the platforms native standard library +using the ``-DLIBCXX_BUILD_BENCHMARKS_NATIVE_STDLIB=ON`` CMake option. This +is useful for comparing the performance of libc++ to other standard libraries. +The compiled benchmarks are named ``<test>.libcxx.out`` if they test libc++ and +``<test>.native.out`` otherwise. + +Also See: + + * :ref:`Building Libc++ <build instructions>` + * :ref:`CMake Options` + +Running Benchmarks +------------------ + +The benchmarks must be run manually by the user. Currently there is no way +to run them as part of the build. + +For example: + +.. code-block:: bash + + $ cd build/benchmarks + $ make cxx-benchmarks + $ ./algorithms.libcxx.out # Runs all the benchmarks + $ ./algorithms.libcxx.out --benchmark_filter=BM_Sort.* # Only runs the sort benchmarks + +For more information about running benchmarks see `Google Benchmark`_. diff --git a/lib/libcxx/docs/UsingLibcxx.rst b/lib/libcxx/docs/UsingLibcxx.rst index 514ed14b746..f54234d6aa3 100644 --- a/lib/libcxx/docs/UsingLibcxx.rst +++ b/lib/libcxx/docs/UsingLibcxx.rst @@ -123,3 +123,97 @@ supported by libc++ they may be useful to users. Known 3rd Party Implementations Include: * `Koutheir's libc++ pretty-printers <https://github.com/koutheir/libcxx-pretty-printers>`_. + + +Libc++ Configuration Macros +=========================== + +Libc++ provides a number of configuration macros which can be used to enable +or disable extended libc++ behavior, including enabling "debug mode" or +thread safety annotations. + +**_LIBCPP_DEBUG**: + See :ref:`using-debug-mode` for more information. + +**_LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS**: + This macro is used to enable -Wthread-safety annotations on libc++'s + ``std::mutex`` and ``std::lock_guard``. By default these annotations are + disabled and must be manually enabled by the user. + +**_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS**: + This macro is used to disable all visibility annotations inside libc++. + Defining this macro and then building libc++ with hidden visibility gives a + build of libc++ which does not export any symbols, which can be useful when + building statically for inclusion into another library. + +**_LIBCPP_DISABLE_EXTERN_TEMPLATE**: + This macro is used to disable extern template declarations in the libc++ + headers. The intended use case is for clients who wish to use the libc++ + headers without taking a dependency on the libc++ library itself. + +**_LIBCPP_ENABLE_TUPLE_IMPLICIT_REDUCED_ARITY_EXTENSION**: + This macro is used to re-enable an extension in `std::tuple` which allowed + it to be implicitly constructed from fewer initializers than contained + elements. Elements without an initializer are default constructed. For example: + + .. code-block:: cpp + + std::tuple<std::string, int, std::error_code> foo() { + return {"hello world", 42}; // default constructs error_code + } + + + Since libc++ 4.0 this extension has been disabled by default. This macro + may be defined to re-enable it in order to support existing code that depends + on the extension. New use of this extension should be discouraged. + See `PR 27374 <http://llvm.org/PR27374>`_ for more information. + + Note: The "reduced-arity-initialization" extension is still offered but only + for explicit conversions. Example: + + .. code-block:: cpp + + auto foo() { + using Tup = std::tuple<std::string, int, std::error_code>; + return Tup{"hello world", 42}; // explicit constructor called. OK. + } + +**_LIBCPP_DISABLE_ADDITIONAL_DIAGNOSTICS**: + This macro disables the additional diagnostics generated by libc++ using the + `diagnose_if` attribute. These additional diagnostics include checks for: + + * Giving `set`, `map`, `multiset`, `multimap` a comparator which is not + const callable. + +**_LIBCPP_NO_VCRUNTIME**: + Microsoft's C and C++ headers are fairly entangled, and some of their C++ + headers are fairly hard to avoid. In particular, `vcruntime_new.h` gets pulled + in from a lot of other headers and provides definitions which clash with + libc++ headers, such as `nothrow_t` (note that `nothrow_t` is a struct, so + there's no way for libc++ to provide a compatible definition, since you can't + have multiple definitions). + + By default, libc++ solves this problem by deferring to Microsoft's vcruntime + headers where needed. However, it may be undesirable to depend on vcruntime + headers, since they may not always be available in cross-compilation setups, + or they may clash with other headers. The `_LIBCPP_NO_VCRUNTIME` macro + prevents libc++ from depending on vcruntime headers. Consequently, it also + prevents libc++ headers from being interoperable with vcruntime headers (from + the aforementioned clashes), so users of this macro are promising to not + attempt to combine libc++ headers with the problematic vcruntime headers. This + macro also currently prevents certain `operator new`/`operator delete` + replacement scenarios from working, e.g. replacing `operator new` and + expecting a non-replaced `operator new[]` to call the replaced `operator new`. + +C++17 Specific Configuration Macros +----------------------------------- +**_LIBCPP_ENABLE_CXX17_REMOVED_FEATURES**: + This macro is used to re-enable all the features removed in C++17. The effect + is equivalent to manually defining each macro listed below. + +**_LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS**: + This macro is used to re-enable the `set_unexpected`, `get_unexpected`, and + `unexpected` functions, which were removed in C++17. + +**_LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR**: + This macro is used to re-enable `std::auto_ptr` in C++17. diff --git a/lib/libcxx/docs/conf.py b/lib/libcxx/docs/conf.py index e385406b992..bb231ac3e35 100644 --- a/lib/libcxx/docs/conf.py +++ b/lib/libcxx/docs/conf.py @@ -40,16 +40,16 @@ master_doc = 'index' # General information about the project. project = u'libc++' -copyright = u'2011-2016, LLVM Project' +copyright = u'2011-2017, LLVM Project' # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the # built documents. # # The short X.Y version. -version = '3.9' +version = '6.0' # The full version, including alpha/beta/rc tags. -release = '3.9' +release = '6.0' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff --git a/lib/libcxx/docs/index.rst b/lib/libcxx/docs/index.rst index b0c8b813f57..3526b47210f 100644 --- a/lib/libcxx/docs/index.rst +++ b/lib/libcxx/docs/index.rst @@ -7,7 +7,8 @@ Overview ======== -libc++ is a new implementation of the C++ standard library, targeting C++11. +libc++ is a new implementation of the C++ standard library, targeting C++11 and +above. * Features and Goals @@ -119,7 +120,7 @@ This list contains known issues with libc++ A full list of currently open libc++ bugs can be `found here`__. -.. __: https://llvm.org/bugs/buglist.cgi?component=All%20Bugs&product=libc%2B%2B&query_format=advanced&resolution=---&order=changeddate%20DESC%2Cassigned_to%20DESC%2Cbug_status%2Cpriority%2Cbug_id&list_id=74184 +.. __: https://bugs.llvm.org/buglist.cgi?component=All%20Bugs&product=libc%2B%2B&query_format=advanced&resolution=---&order=changeddate%20DESC%2Cassigned_to%20DESC%2Cbug_status%2Cpriority%2Cbug_id&list_id=74184 Design Documents ---------------- @@ -127,13 +128,15 @@ Design Documents .. toctree:: :maxdepth: 1 + DesignDocs/AvailabilityMarkup + DesignDocs/DebugMode DesignDocs/CapturingConfigInfo DesignDocs/ABIVersioning - + DesignDocs/VisibilityMacros + DesignDocs/ThreadingSupportAPI * `<atomic> design <http://libcxx.llvm.org/atomic_design.html>`_ * `<type_traits> design <http://libcxx.llvm.org/type_traits_design.html>`_ -* `Status of debug mode <http://libcxx.llvm.org/debug_mode.html>`_ * `Notes by Marshall Clow`__ .. __: https://cplusplusmusings.wordpress.com/2012/07/05/clang-and-standard-libraries-on-mac-os-x/ @@ -143,7 +146,7 @@ Build Bots and Test Coverage * `LLVM Buildbot Builders <http://lab.llvm.org:8011/console>`_ * `Apple Jenkins Builders <http://lab.llvm.org:8080/green/view/Libcxx/>`_ -* `EricWF's Nightly Builders <http://ds2.efcs.ca:8080/console>`_ +* `Windows Appveyor Builders <https://ci.appveyor.com/project/llvm-mirror/libcxx>`_ * `Code Coverage Results <http://efcs.ca/libcxx-coverage>`_ Getting Involved @@ -178,7 +181,7 @@ Quick Links =========== * `LLVM Homepage <http://llvm.org/>`_ * `libc++abi Homepage <http://libcxxabi.llvm.org/>`_ -* `LLVM Bugzilla <http://llvm.org/bugs/>`_ +* `LLVM Bugzilla <https://bugs.llvm.org/>`_ * `cfe-commits Mailing List`_ * `cfe-dev Mailing List`_ * `Browse libc++ -- SVN <http://llvm.org/svn/llvm-project/libcxx/trunk/>`_ |