Skip to content

Commit bb93993

Browse files
committed
[libc++] Always build c++experimental.a
This is the first part of a plan to ship experimental features by default while guarding them behind a compiler flag to avoid users accidentally depending on them. Subsequent patches will also encompass incomplete features (such as <format> and <ranges>) in that categorization. Basically, the idea is that we always build and ship the c++experimental library, however users can't use what's in it unless they pass the `-funstable` flag to Clang. Note that this patch intentionally does not start guarding existing <experimental/FOO> content behind the flag, because that would merely break users that might be relying on such content being in the headers unconditionally. Instead, we should start guarding new TSes behind the flag, and get rid of the existing TSes we have by shipping their Standard counterpart. Also, this patch must jump through a few hoops like defining _LIBCPP_ENABLE_EXPERIMENTAL because we still support compilers that do not implement -funstable yet. Differential Revision: https://reviews.llvm.org/D128927
1 parent c945bd0 commit bb93993

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+198
-86
lines changed

clang/cmake/caches/Fuchsia-stage2.cmake

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ if(WIN32)
7979
set(RUNTIMES_${target}_CMAKE_SYSTEM_NAME Windows CACHE STRING "")
8080
set(RUNTIMES_${target}_CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "")
8181
set(RUNTIMES_${target}_LIBCXX_ABI_VERSION 2 CACHE STRING "")
82-
set(RUNTIMES_${target}_LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY OFF CACHE BOOL "")
8382
set(RUNTIMES_${target}_LIBCXX_ENABLE_FILESYSTEM OFF CACHE BOOL "")
8483
set(RUNTIMES_${target}_LIBCXX_ENABLE_ABI_LINKER_SCRIPT OFF CACHE BOOL "")
8584
set(RUNTIMES_${target}_LIBCXX_ENABLE_SHARED OFF CACHE BOOL "")

clang/cmake/caches/Fuchsia.cmake

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ endif()
5050

5151
if(WIN32)
5252
set(LIBCXX_ABI_VERSION 2 CACHE STRING "")
53-
set(LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY OFF CACHE BOOL "")
5453
set(LIBCXX_ENABLE_FILESYSTEM OFF CACHE BOOL "")
5554
set(LIBCXX_ENABLE_ABI_LINKER_SCRIPT OFF CACHE BOOL "")
5655
set(LIBCXX_ENABLE_SHARED OFF CACHE BOOL "")

compiler-rt/cmake/Modules/AddCompilerRT.cmake

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -685,7 +685,6 @@ macro(add_custom_libcxx name prefix)
685685
-DLIBCXXABI_HERMETIC_STATIC_LIBRARY=ON
686686
-DLIBCXXABI_INCLUDE_TESTS=OFF
687687
-DLIBCXX_CXX_ABI=libcxxabi
688-
-DLIBCXX_ENABLE_EXPERIMENTAL_LIBRARY=OFF
689688
-DLIBCXX_ENABLE_SHARED=OFF
690689
-DLIBCXX_HERMETIC_STATIC_LIBRARY=ON
691690
-DLIBCXX_INCLUDE_BENCHMARKS=OFF

libcxx/CMakeLists.txt

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ option(LIBCXX_ENABLE_ASSERTIONS
5555
by users in their own code regardless of this option." OFF)
5656
option(LIBCXX_ENABLE_SHARED "Build libc++ as a shared library." ON)
5757
option(LIBCXX_ENABLE_STATIC "Build libc++ as a static library." ON)
58-
option(LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY "Build libc++experimental.a" ON)
5958
set(ENABLE_FILESYSTEM_DEFAULT ON)
6059
if (WIN32 AND NOT MINGW)
6160
# Filesystem is buildable for windows, but it requires __int128 helper
@@ -167,9 +166,6 @@ cmake_dependent_option(LIBCXX_INSTALL_STATIC_LIBRARY
167166
cmake_dependent_option(LIBCXX_INSTALL_SHARED_LIBRARY
168167
"Install the shared libc++ library." ON
169168
"LIBCXX_ENABLE_SHARED;LIBCXX_INSTALL_LIBRARY" OFF)
170-
cmake_dependent_option(LIBCXX_INSTALL_EXPERIMENTAL_LIBRARY
171-
"Install libc++experimental.a" ON
172-
"LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY;LIBCXX_INSTALL_LIBRARY" OFF)
173169

174170
option(LIBCXX_ABI_UNSTABLE "Use the unstable ABI of libc++. This is equivalent to specifying LIBCXX_ABI_VERSION=n, where n is the not-yet-stable version." OFF)
175171
if (LIBCXX_ABI_UNSTABLE)
@@ -930,11 +926,7 @@ add_subdirectory(include)
930926
add_subdirectory(src)
931927
add_subdirectory(utils)
932928

933-
set(LIBCXX_TEST_DEPS "")
934-
935-
if (LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY)
936-
list(APPEND LIBCXX_TEST_DEPS cxx_experimental)
937-
endif()
929+
set(LIBCXX_TEST_DEPS "cxx_experimental")
938930

939931
if (LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY)
940932
list(APPEND LIBCXX_TEST_DEPS cxx_external_threads)

libcxx/appveyor.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ build_script:
4545
#############################################################################
4646
- cmake -G "%GENERATOR%" %CMAKE_OPTIONS%
4747
"-DCMAKE_BUILD_TYPE=%configuration%"
48-
"-DLLVM_PATH=C:\projects\deps\llvm" -DLIBCXX_ENABLE_EXPERIMENTAL_LIBRARY=OFF
48+
"-DLLVM_PATH=C:\projects\deps\llvm"
4949
-DLLVM_LIT_ARGS="-sv --show-xfail --show-unsupported"
5050
%APPVEYOR_BUILD_FOLDER%
5151

libcxx/cmake/caches/AIX.cmake

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ set(LIBCXX_USE_COMPILER_RT ON CACHE BOOL "")
99
set(LIBCXX_ENABLE_ASSERTIONS OFF CACHE BOOL "")
1010
set(LIBCXX_ABI_VERSION "1" CACHE STRING "")
1111
set(LIBCXX_ENABLE_ABI_LINKER_SCRIPT OFF CACHE BOOL "")
12-
set(LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY OFF CACHE BOOL "")
1312
set(LIBCXX_ENABLE_SHARED ON CACHE BOOL "")
1413
set(LIBCXX_ENABLE_STATIC OFF CACHE BOOL "")
1514
set(LIBCXXABI_ENABLE_SHARED ON CACHE BOOL "")

libcxx/cmake/caches/Apple.cmake

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ set(CMAKE_POSITION_INDEPENDENT_CODE OFF CACHE BOOL "")
44
set(LIBCXX_USE_COMPILER_RT ON CACHE BOOL "")
55
set(LIBCXX_ENABLE_ASSERTIONS OFF CACHE BOOL "")
66
set(LIBCXX_ABI_VERSION "1" CACHE STRING "")
7-
set(LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY OFF CACHE BOOL "")
87
set(LIBCXX_ENABLE_STATIC ON CACHE BOOL "")
98
set(LIBCXX_ENABLE_SHARED ON CACHE BOOL "")
109
set(LIBCXX_CXX_ABI libcxxabi CACHE STRING "")
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1-
set(LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY OFF CACHE BOOL "")
1+
set(LIBCXX_TEST_PARAMS "enable_experimental=False" CACHE STRING "")
2+
set(LIBCXXABI_TEST_PARAMS "${LIBCXX_TEST_PARAMS}" CACHE STRING "")
23
set(LIBCXX_ENABLE_INCOMPLETE_FEATURES OFF CACHE BOOL "")

libcxx/docs/BuildingLibcxx.rst

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,7 @@ it is the simplest way to build.
9999
-T "ClangCL" ^
100100
-DLLVM_ENABLE_RUNTIMES=libcxx ^
101101
-DLIBCXX_ENABLE_SHARED=YES ^
102-
-DLIBCXX_ENABLE_STATIC=NO ^
103-
-DLIBCXX_ENABLE_EXPERIMENTAL_LIBRARY=NO
102+
-DLIBCXX_ENABLE_STATIC=NO
104103
> cmake --build build
105104
106105
CMake + ninja (MSVC)
@@ -131,8 +130,7 @@ In either case, then run:
131130
> cmake -G Ninja -S runtimes -B build ^
132131
-DCMAKE_C_COMPILER=clang-cl ^
133132
-DCMAKE_CXX_COMPILER=clang-cl ^
134-
-DLLVM_ENABLE_RUNTIMES=libcxx ^
135-
-DLIBCXX_ENABLE_EXPERIMENTAL_LIBRARY=NO
133+
-DLLVM_ENABLE_RUNTIMES=libcxx
136134
> ninja -C build cxx
137135
> ninja -C build check-cxx
138136
@@ -298,23 +296,6 @@ libc++ specific options
298296
Path where target-specific libc++ headers should be installed. If a relative
299297
path, relative to ``CMAKE_INSTALL_PREFIX``.
300298

301-
.. _libc++experimental options:
302-
303-
libc++experimental Specific Options
304-
------------------------------------
305-
306-
.. option:: LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY:BOOL
307-
308-
**Default**: ``ON``
309-
310-
Build and test libc++experimental.a.
311-
312-
.. option:: LIBCXX_INSTALL_EXPERIMENTAL_LIBRARY:BOOL
313-
314-
**Default**: ``LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY AND LIBCXX_INSTALL_LIBRARY``
315-
316-
Install libc++experimental.a alongside libc++.
317-
318299

319300
.. _ABI Library Specific Options:
320301

libcxx/docs/UsingLibcxx.rst

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,22 +34,20 @@ matches that Standard in the library.
3434
library until the standard has been ratified.
3535

3636

37-
Using libc++experimental and ``<experimental/...>``
38-
===================================================
37+
Enabling experimental C++ Library features
38+
==========================================
3939

40-
Libc++ provides implementations of experimental technical specifications
41-
in a separate library, ``libc++experimental.a``. Users of ``<experimental/...>``
42-
headers may be required to link ``-lc++experimental``. Note that not all
43-
vendors ship ``libc++experimental.a``, and as a result, you may not be
44-
able to use those experimental features.
45-
46-
.. code-block:: bash
47-
48-
$ clang++ test.cpp -lc++experimental
40+
Libc++ provides implementations of some experimental features. Experimental features
41+
are either Technical Specifications (TSes) or official features that were voted to
42+
the Standard but whose implementation is not complete or stable yet in libc++. Those
43+
are disabled by default because they are neither API nor ABI stable. However, the
44+
``_LIBCPP_ENABLE_EXPERIMENTAL`` macro can be defined to turn those features on. Note
45+
that you will also need to link to the appropriate ``libc++experimental.a`` static
46+
archive.
4947

5048
.. warning::
5149
Experimental libraries are Experimental.
52-
* The contents of the ``<experimental/...>`` headers and ``libc++experimental.a``
50+
* The contents of the ``<experimental/...>`` headers and the associated static
5351
library will not remain compatible between versions.
5452
* No guarantees of API or ABI stability are provided.
5553
* When the standardized version of an experimental feature is implemented,

0 commit comments

Comments
 (0)