[libcxx] Fix compile for BUILD_EXTERNAL_THREAD_LIBRARY
Fix compilation with -DLIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY when using clang. Now linking target 'cxx_external_threads' with 'cxx-headers'. Fix mismatching visibility for `libcpp_timed_backoff_policy` function in file <__threading_support>.
Reviewed By: #libc, ldionne
Differential Revision: https://reviews.llvm.org/D86598
GitOrigin-RevId: 3b71f91558ff8b569199547efe800cb501c3cf94
diff --git a/include/__threading_support b/include/__threading_support
index 072c4c7..f8add05 100644
--- a/include/__threading_support
+++ b/include/__threading_support
@@ -282,7 +282,7 @@
bool operator()(chrono::nanoseconds __elapsed) const;
};
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_THREAD_ABI_VISIBILITY
bool __libcpp_timed_backoff_policy::operator()(chrono::nanoseconds __elapsed) const
{
if(__elapsed > chrono::milliseconds(128))
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 2001c09..dcd53c8 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -323,7 +323,8 @@
if (LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY)
- file(GLOB LIBCXX_EXTERNAL_THREADING_SUPPORT_SOURCES ../test/support/external_threads.cpp)
+ set(LIBCXX_EXTERNAL_THREADING_SUPPORT_SOURCES
+ "${CMAKE_CURRENT_SOURCE_DIR}/../test/support/external_threads.cpp")
if (LIBCXX_ENABLE_SHARED)
add_library(cxx_external_threads SHARED ${LIBCXX_EXTERNAL_THREADING_SUPPORT_SOURCES})
@@ -337,6 +338,8 @@
COMPILE_FLAGS "${LIBCXX_COMPILE_FLAGS}"
OUTPUT_NAME "c++external_threads"
)
+
+ target_link_libraries(cxx_external_threads PRIVATE cxx-headers)
endif()
if (LIBCXX_INSTALL_LIBRARY)