Skip to content

Commit 09cebfb

Browse files
committed
Revert "[libc++] Always build c++experimental.a"
This caused build failures when building Clang and libc++ together on Mac: fatal error: 'experimental/memory_resource' file not found See the code review for details. Reverting until the problem and how to solve it is better understood. (Updates to some test files were not reverted, since they seemed unrelated and were later updated by 340b48b.) > 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 This reverts commit bb93993.
1 parent 24ec521 commit 09cebfb

33 files changed

+86
-143
lines changed

clang/cmake/caches/Fuchsia-stage2.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ if(WIN32)
8080
set(RUNTIMES_${target}_CMAKE_SYSTEM_NAME Windows CACHE STRING "")
8181
set(RUNTIMES_${target}_CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "")
8282
set(RUNTIMES_${target}_LIBCXX_ABI_VERSION 2 CACHE STRING "")
83+
set(RUNTIMES_${target}_LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY OFF CACHE BOOL "")
8384
set(RUNTIMES_${target}_LIBCXX_ENABLE_FILESYSTEM OFF CACHE BOOL "")
8485
set(RUNTIMES_${target}_LIBCXX_ENABLE_ABI_LINKER_SCRIPT OFF CACHE BOOL "")
8586
set(RUNTIMES_${target}_LIBCXX_ENABLE_SHARED OFF CACHE BOOL "")

clang/cmake/caches/Fuchsia.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ endif()
5151

5252
if(WIN32)
5353
set(LIBCXX_ABI_VERSION 2 CACHE STRING "")
54+
set(LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY OFF CACHE BOOL "")
5455
set(LIBCXX_ENABLE_FILESYSTEM OFF CACHE BOOL "")
5556
set(LIBCXX_ENABLE_ABI_LINKER_SCRIPT OFF CACHE BOOL "")
5657
set(LIBCXX_ENABLE_SHARED OFF CACHE BOOL "")

compiler-rt/cmake/Modules/AddCompilerRT.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -685,6 +685,7 @@ 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
688689
-DLIBCXX_ENABLE_SHARED=OFF
689690
-DLIBCXX_HERMETIC_STATIC_LIBRARY=ON
690691
-DLIBCXX_INCLUDE_BENCHMARKS=OFF

libcxx/CMakeLists.txt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ 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)
5859
set(ENABLE_FILESYSTEM_DEFAULT ON)
5960
if (WIN32 AND NOT MINGW)
6061
# Filesystem is buildable for windows, but it requires __int128 helper
@@ -166,6 +167,9 @@ cmake_dependent_option(LIBCXX_INSTALL_STATIC_LIBRARY
166167
cmake_dependent_option(LIBCXX_INSTALL_SHARED_LIBRARY
167168
"Install the shared libc++ library." ON
168169
"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)
169173

170174
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)
171175
if (LIBCXX_ABI_UNSTABLE)
@@ -926,7 +930,11 @@ add_subdirectory(include)
926930
add_subdirectory(src)
927931
add_subdirectory(utils)
928932

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

931939
if (LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY)
932940
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"
48+
"-DLLVM_PATH=C:\projects\deps\llvm" -DLIBCXX_ENABLE_EXPERIMENTAL_LIBRARY=OFF
4949
-DLLVM_LIT_ARGS="-sv --show-xfail --show-unsupported"
5050
%APPVEYOR_BUILD_FOLDER%
5151

libcxx/cmake/caches/AIX.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ 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 "")
1213
set(LIBCXX_ENABLE_SHARED ON CACHE BOOL "")
1314
set(LIBCXX_ENABLE_STATIC OFF CACHE BOOL "")
1415
set(LIBCXXABI_ENABLE_SHARED ON CACHE BOOL "")

libcxx/cmake/caches/Apple.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ 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 "")
78
set(LIBCXX_ENABLE_STATIC ON CACHE BOOL "")
89
set(LIBCXX_ENABLE_SHARED ON CACHE BOOL "")
910
set(LIBCXX_CXX_ABI libcxxabi CACHE STRING "")
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
1-
set(LIBCXX_TEST_PARAMS "enable_experimental=False" CACHE STRING "")
2-
set(LIBCXXABI_TEST_PARAMS "${LIBCXX_TEST_PARAMS}" CACHE STRING "")
1+
set(LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY OFF CACHE BOOL "")
32
set(LIBCXX_ENABLE_INCOMPLETE_FEATURES OFF CACHE BOOL "")

libcxx/docs/BuildingLibcxx.rst

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,8 @@ 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
102+
-DLIBCXX_ENABLE_STATIC=NO ^
103+
-DLIBCXX_ENABLE_EXPERIMENTAL_LIBRARY=NO
103104
> cmake --build build
104105
105106
CMake + ninja (MSVC)
@@ -130,7 +131,8 @@ In either case, then run:
130131
> cmake -G Ninja -S runtimes -B build ^
131132
-DCMAKE_C_COMPILER=clang-cl ^
132133
-DCMAKE_CXX_COMPILER=clang-cl ^
133-
-DLLVM_ENABLE_RUNTIMES=libcxx
134+
-DLLVM_ENABLE_RUNTIMES=libcxx ^
135+
-DLIBCXX_ENABLE_EXPERIMENTAL_LIBRARY=NO
134136
> ninja -C build cxx
135137
> ninja -C build check-cxx
136138
@@ -296,6 +298,23 @@ libc++ specific options
296298
Path where target-specific libc++ headers should be installed. If a relative
297299
path, relative to ``CMAKE_INSTALL_PREFIX``.
298300

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+
299318

300319
.. _ABI Library Specific Options:
301320

libcxx/docs/UsingLibcxx.rst

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

3636

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

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.
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
4749
4850
.. warning::
4951
Experimental libraries are Experimental.
50-
* The contents of the ``<experimental/...>`` headers and the associated static
52+
* The contents of the ``<experimental/...>`` headers and ``libc++experimental.a``
5153
library will not remain compatible between versions.
5254
* No guarantees of API or ABI stability are provided.
5355
* When the standardized version of an experimental feature is implemented,

0 commit comments

Comments
 (0)