Skip to content

Commit 8ac71b0

Browse files
committed
[libc++] Remove internal "build-with-external-thread-library" configuration
Our threading support layer is currently a huge mess. There are too many configurations with too many confusing names, and none of them are tested in the usual CI. Here's a list of names related to these configurations: LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY _LIBCPP_BUILDING_THREAD_LIBRARY_EXTERNAL LIBCXXABI_BUILD_EXTERNAL_THREAD_LIBRARY _LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL LIBCXX_HAS_EXTERNAL_THREAD_API _LIBCPP_HAS_THREAD_API_EXTERNAL This patch cleans this up by removing the ability to build libc++ with an "external" threading library for testing purposes, removing 4 out of 6 "names" above. That setting was meant to be used by libc++ developers, but we don't use it in-tree and it's not part of our CI. I know the ability to use an external threading API is used by some folks out-of-tree, and this patch doesn't change that. This only changes the way they will have to test their external threading support. After this patch, the intent would be for them to set `-DLIBCXX_HAS_EXTERNAL_THREAD_API=ON` when building the library, and to provide their usual `<__external_threading>` header when they are testing the library. This can be done easily now that we support custom lit configuration files in test suites. The motivation for this patch is that our threading support layer is basically unmaintainable -- anything beyond adding a new "backend" in the slot designed for it requires incredible attention. The complexity added by this setting just doesn't pull its weigh considering the available alternatives. Concretely, this will also allow future patches to clean up `<__threading_support>` significantly. Differential Revision: https://reviews.llvm.org/D154466
1 parent 062fce6 commit 8ac71b0

File tree

8 files changed

+2
-111
lines changed

8 files changed

+2
-111
lines changed

libcxx/CMakeLists.txt

-28
Original file line numberDiff line numberDiff line change
@@ -272,9 +272,6 @@ option(LIBCXX_HAS_WIN32_THREAD_API "Ignore auto-detection and force use of win32
272272
option(LIBCXX_HAS_EXTERNAL_THREAD_API
273273
"Build libc++ with an externalized threading API.
274274
This option may only be set to ON when LIBCXX_ENABLE_THREADS=ON." OFF)
275-
option(LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY
276-
"Build libc++ with an externalized threading library.
277-
This option may only be set to ON when LIBCXX_ENABLE_THREADS=ON" OFF)
278275

279276
if (LIBCXX_ENABLE_THREADS)
280277
set(LIBCXX_PSTL_CPU_BACKEND "std_thread" CACHE STRING "Which PSTL CPU backend to use")
@@ -327,10 +324,6 @@ if(NOT LIBCXX_ENABLE_THREADS)
327324
message(FATAL_ERROR "LIBCXX_HAS_EXTERNAL_THREAD_API can only be set to ON"
328325
" when LIBCXX_ENABLE_THREADS is also set to ON.")
329326
endif()
330-
if (LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY)
331-
message(FATAL_ERROR "LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY can only be set "
332-
"to ON when LIBCXX_ENABLE_THREADS is also set to ON.")
333-
endif()
334327
if (LIBCXX_HAS_WIN32_THREAD_API)
335328
message(FATAL_ERROR "LIBCXX_HAS_WIN32_THREAD_API can only be set to ON"
336329
" when LIBCXX_ENABLE_THREADS is also set to ON.")
@@ -339,11 +332,6 @@ if(NOT LIBCXX_ENABLE_THREADS)
339332
endif()
340333

341334
if (LIBCXX_HAS_EXTERNAL_THREAD_API)
342-
if (LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY)
343-
message(FATAL_ERROR "The options LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY and "
344-
"LIBCXX_HAS_EXTERNAL_THREAD_API cannot both be ON at "
345-
"the same time")
346-
endif()
347335
if (LIBCXX_HAS_PTHREAD_API)
348336
message(FATAL_ERROR "The options LIBCXX_HAS_EXTERNAL_THREAD_API"
349337
"and LIBCXX_HAS_PTHREAD_API cannot be both"
@@ -573,17 +561,6 @@ function(cxx_add_rtti_flags target)
573561
endif()
574562
endfunction()
575563

576-
# Threading flags =============================================================
577-
if (LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY AND LIBCXX_ENABLE_SHARED)
578-
# Need to allow unresolved symbols if this is to work with shared library builds
579-
if (APPLE)
580-
add_link_flags("-undefined dynamic_lookup")
581-
else()
582-
# Relax this restriction from HandleLLVMOptions
583-
string(REPLACE "-Wl,-z,defs" "" CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS}")
584-
endif()
585-
endif()
586-
587564
# Modules flags ===============================================================
588565
# FIXME The libc++ sources are fundamentally non-modular. They need special
589566
# versions of the headers in order to provide C++03 and legacy ABI definitions.
@@ -764,7 +741,6 @@ endif()
764741
config_define_if(LIBCXX_HAS_PTHREAD_API _LIBCPP_HAS_THREAD_API_PTHREAD)
765742
config_define_if(LIBCXX_HAS_EXTERNAL_THREAD_API _LIBCPP_HAS_THREAD_API_EXTERNAL)
766743
config_define_if(LIBCXX_HAS_WIN32_THREAD_API _LIBCPP_HAS_THREAD_API_WIN32)
767-
config_define_if(LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY _LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL)
768744
config_define_if(LIBCXX_HAS_MUSL_LIBC _LIBCPP_HAS_MUSL_LIBC)
769745
config_define_if(LIBCXX_NO_VCRUNTIME _LIBCPP_NO_VCRUNTIME)
770746
config_define_if_not(LIBCXX_ENABLE_FILESYSTEM _LIBCPP_HAS_NO_FILESYSTEM)
@@ -860,10 +836,6 @@ endif()
860836

861837
set(LIBCXX_TEST_DEPS "cxx_experimental")
862838

863-
if (LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY)
864-
list(APPEND LIBCXX_TEST_DEPS cxx_external_threads)
865-
endif()
866-
867839
if (LIBCXX_ENABLE_CLANG_TIDY)
868840
list(APPEND LIBCXX_TEST_DEPS cxx-tidy)
869841
endif()

libcxx/docs/DesignDocs/ThreadingSupportAPI.rst

-20
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,6 @@ On a production setting, this would be achieved through a custom
4242
``<__external_threading>`` header, which declares the libc++ internal threading
4343
API but leaves out the implementation.
4444

45-
The ``-DLIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY`` option allows building libc++ in
46-
such a configuration while allowing it to be tested on a platform that supports
47-
any of the threading systems (e.g. pthread) supported in ``__threading_support``
48-
header. Therefore, the main purpose of this option is to allow testing of this
49-
particular configuration of the library without being tied to a vendor-specific
50-
threading system. This option is only meant to be used by libc++ library
51-
developers.
52-
5345
Threading Configuration Macros
5446
==============================
5547

@@ -69,15 +61,3 @@ Threading Configuration Macros
6961
**_LIBCPP_HAS_THREAD_API_WIN32**
7062
This macro is defined when libc++ should use Win32 threads to implement the
7163
internal threading API.
72-
73-
**_LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL**
74-
This macro is defined when libc++ expects the definitions of the internal
75-
threading API to be provided by an external library. When defined
76-
``<__threading_support>`` will only provide the forward declarations and
77-
typedefs for the internal threading API.
78-
79-
**_LIBCPP_BUILDING_THREAD_LIBRARY_EXTERNAL**
80-
This macro is used to build an external threading library using the
81-
``<__threading_support>``. Specifically it exposes the threading API
82-
definitions in ``<__threading_support>`` as non-inline definitions meant to
83-
be compiled into a library.

libcxx/include/__config_site.in

-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
#cmakedefine _LIBCPP_HAS_THREAD_API_PTHREAD
2020
#cmakedefine _LIBCPP_HAS_THREAD_API_EXTERNAL
2121
#cmakedefine _LIBCPP_HAS_THREAD_API_WIN32
22-
#cmakedefine _LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL
2322
#cmakedefine _LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS
2423
#cmakedefine _LIBCPP_HAS_NO_VENDOR_AVAILABILITY_ANNOTATIONS
2524
#cmakedefine _LIBCPP_NO_VCRUNTIME

libcxx/include/__threading_support

+1-8
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,7 @@
3636
# include <threads.h>
3737
#endif
3838

39-
#if defined(_LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL) || \
40-
defined(_LIBCPP_BUILDING_THREAD_LIBRARY_EXTERNAL) || \
41-
defined(_LIBCPP_HAS_THREAD_API_WIN32)
39+
#if defined(_LIBCPP_HAS_THREAD_API_WIN32)
4240
#define _LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_EXPORTED_FROM_ABI
4341
#else
4442
#define _LIBCPP_THREAD_ABI_VISIBILITY inline _LIBCPP_INLINE_VISIBILITY
@@ -248,9 +246,6 @@ int __libcpp_tls_set(__libcpp_tls_key __key, void *__p);
248246

249247
#endif // !defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)
250248

251-
#if (!defined(_LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL) || \
252-
defined(_LIBCPP_BUILDING_THREAD_LIBRARY_EXTERNAL))
253-
254249
#if defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
255250

256251
int __libcpp_recursive_mutex_init(__libcpp_recursive_mutex_t *__m)
@@ -585,8 +580,6 @@ int __libcpp_tls_set(__libcpp_tls_key __key, void *__p)
585580

586581
#endif
587582

588-
#endif // !_LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL || _LIBCPP_BUILDING_THREAD_LIBRARY_EXTERNAL
589-
590583
#endif // !_LIBCPP_HAS_NO_THREADS
591584

592585
_LIBCPP_END_NAMESPACE_STD

libcxx/src/CMakeLists.txt

-21
Original file line numberDiff line numberDiff line change
@@ -346,27 +346,6 @@ set_target_properties(cxx_experimental
346346
cxx_add_common_build_flags(cxx_experimental)
347347
target_compile_options(cxx_experimental PUBLIC -D_LIBCPP_ENABLE_EXPERIMENTAL)
348348

349-
350-
if (LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY)
351-
set(LIBCXX_EXTERNAL_THREADING_SUPPORT_SOURCES
352-
"${CMAKE_CURRENT_SOURCE_DIR}/../test/support/external_threads.cpp")
353-
354-
if (LIBCXX_ENABLE_SHARED)
355-
add_library(cxx_external_threads SHARED ${LIBCXX_EXTERNAL_THREADING_SUPPORT_SOURCES})
356-
else()
357-
add_library(cxx_external_threads STATIC ${LIBCXX_EXTERNAL_THREADING_SUPPORT_SOURCES})
358-
endif()
359-
360-
set_target_properties(cxx_external_threads
361-
PROPERTIES
362-
LINK_FLAGS "${LIBCXX_LINK_FLAGS}"
363-
COMPILE_FLAGS "${LIBCXX_COMPILE_FLAGS}"
364-
OUTPUT_NAME "c++external_threads"
365-
)
366-
367-
target_link_libraries(cxx_external_threads PRIVATE cxx-headers)
368-
endif()
369-
370349
if (LIBCXX_INSTALL_SHARED_LIBRARY)
371350
install(TARGETS cxx_shared
372351
ARCHIVE DESTINATION ${LIBCXX_INSTALL_LIBRARY_DIR} COMPONENT cxx

libcxx/test/support/external_threads.cpp

-9
This file was deleted.

libcxxabi/CMakeLists.txt

+1-20
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,6 @@ option(LIBCXXABI_HAS_WIN32_THREAD_API "Ignore auto-detection and force use of wi
5555
option(LIBCXXABI_HAS_EXTERNAL_THREAD_API
5656
"Build libc++abi with an externalized threading API.
5757
This option may only be set to ON when LIBCXXABI_ENABLE_THREADS=ON." OFF)
58-
option(LIBCXXABI_BUILD_EXTERNAL_THREAD_LIBRARY
59-
"Build libc++abi with an externalized threading library.
60-
This option may only be set to ON when LIBCXXABI_ENABLE_THREADS=ON" OFF)
6158
option(LIBCXXABI_ENABLE_FORGIVING_DYNAMIC_CAST
6259
"Make dynamic_cast more forgiving when type_info's mistakenly have hidden \
6360
visibility, and thus multiple type_infos can exist for a single type. \
@@ -330,11 +327,6 @@ if (NOT LIBCXXABI_ENABLE_THREADS)
330327
" be set to ON when LIBCXXABI_ENABLE_THREADS"
331328
" is also set to ON.")
332329
endif()
333-
if (LIBCXXABI_BUILD_EXTERNAL_THREAD_LIBRARY)
334-
message(FATAL_ERROR "LIBCXXABI_BUILD_EXTERNAL_THREAD_LIBRARY can only"
335-
" be set to ON when LIBCXXABI_ENABLE_THREADS"
336-
" is also set to ON.")
337-
endif()
338330
add_definitions(-D_LIBCXXABI_HAS_NO_THREADS)
339331
endif()
340332

@@ -349,11 +341,6 @@ if (LIBCXXABI_HAS_EXTERNAL_THREAD_API)
349341
" and LIBCXXABI_HAS_WIN32_THREAD_API cannot be both"
350342
" set to ON at the same time.")
351343
endif()
352-
if (LIBCXXABI_BUILD_EXTERNAL_THREAD_LIBRARY)
353-
message(FATAL_ERROR "The options LIBCXXABI_BUILD_EXTERNAL_THREAD_LIBRARY"
354-
" and LIBCXXABI_HAS_EXTERNAL_THREAD_API cannot be both"
355-
" set to ON at the same time.")
356-
endif()
357344
endif()
358345

359346
if (LIBCXXABI_HAS_PTHREAD_API)
@@ -371,9 +358,7 @@ if (LLVM_ENABLE_MODULES)
371358
endif()
372359

373360
set(LIBCXXABI_HAS_UNDEFINED_SYMBOLS OFF)
374-
if ((NOT LIBCXXABI_ENABLE_NEW_DELETE_DEFINITIONS)
375-
OR (LIBCXXABI_BUILD_EXTERNAL_THREAD_LIBRARY AND LIBCXXABI_ENABLE_SHARED)
376-
OR MINGW)
361+
if ((NOT LIBCXXABI_ENABLE_NEW_DELETE_DEFINITIONS) OR MINGW)
377362
set(LIBCXXABI_HAS_UNDEFINED_SYMBOLS ON)
378363
endif()
379364

@@ -399,10 +384,6 @@ if (LIBCXXABI_HAS_EXTERNAL_THREAD_API)
399384
add_definitions(-D_LIBCPP_HAS_THREAD_API_EXTERNAL)
400385
endif()
401386

402-
if (LIBCXXABI_BUILD_EXTERNAL_THREAD_LIBRARY)
403-
add_definitions(-D_LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL)
404-
endif()
405-
406387
if (MSVC)
407388
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
408389
endif()

libcxxabi/test/CMakeLists.txt

-4
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,6 @@ else()
1717
set(LIBCXXABI_TEST_DEPS cxxabi_static)
1818
endif()
1919

20-
if (LIBCXXABI_BUILD_EXTERNAL_THREAD_LIBRARY)
21-
list(APPEND LIBCXXABI_TEST_DEPS cxx_external_threads)
22-
endif()
23-
2420
list(APPEND LIBCXXABI_TEST_DEPS cxx)
2521
if (LIBCXXABI_USE_LLVM_UNWINDER AND TARGET unwind)
2622
list(APPEND LIBCXXABI_TEST_DEPS unwind)

0 commit comments

Comments
 (0)