Skip to content

Commit

Permalink
[libc++][C++20 modules] Tests no threading build.
Browse files Browse the repository at this point in the history
Depends on D158330

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D158331
  • Loading branch information
mordante committed Aug 22, 2023
1 parent 7e8c80f commit ef3a391
Show file tree
Hide file tree
Showing 15 changed files with 31 additions and 9 deletions.
1 change: 1 addition & 0 deletions libcxx/cmake/caches/Generic-no-threads.cmake
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
set(LIBCXX_ENABLE_STD_MODULES ON CACHE BOOL "") # TODO MODULES Remove when enabled automatically.
set(LIBCXX_ENABLE_THREADS OFF CACHE BOOL "")
set(LIBCXXABI_ENABLE_THREADS OFF CACHE BOOL "")
set(LIBCXX_ENABLE_MONOTONIC_CLOCK OFF CACHE BOOL "")
1 change: 1 addition & 0 deletions libcxx/docs/Modules.rst
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ What works

* ``LIBCXX_ENABLE_LOCALIZATION``
* ``LIBCXX_ENABLE_WIDE_CHARACTERS``
* ``LIBCXX_ENABLE_THREADS``

Some of the current limitations
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down
3 changes: 0 additions & 3 deletions libcxx/modules/CMakeLists.txt.in
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@ macro(compile_define_if condition def)
endif()
endmacro()

if(NOT @LIBCXX_ENABLE_THREADS@ OR NOT @LIBCXXABI_ENABLE_THREADS@ OR NOT @LIBCXX_ENABLE_MONOTONIC_CLOCK@)
message(FATAL_ERROR "Modules without thread support is not yet implemented.")
endif()
if(NOT @LIBCXX_ENABLE_FILESYSTEM@)
message(FATAL_ERROR "Modules without filesystem support is not yet implemented.")
endif()
Expand Down
2 changes: 2 additions & 0 deletions libcxx/modules/std/barrier.inc
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,7 @@
//===----------------------------------------------------------------------===//

export namespace std {
#ifndef _LIBCPP_HAS_NO_THREADS
using std::barrier;
#endif // _LIBCPP_HAS_NO_THREADS
} // namespace std
2 changes: 2 additions & 0 deletions libcxx/modules/std/chrono.inc
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,10 @@ export namespace std {

using std::chrono::file_time;

#ifndef _LIBCPP_HAS_NO_MONOTONIC_CLOCK
// [time.clock.steady], class steady_clock
using std::chrono::steady_clock;
#endif

// [time.clock.hires], class high_resolution_clock
using std::chrono::high_resolution_clock;
Expand Down
4 changes: 2 additions & 2 deletions libcxx/modules/std/condition_variable.inc
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
//===----------------------------------------------------------------------===//

export namespace std {

#ifndef _LIBCPP_HAS_NO_THREADS
// [thread.condition.condvar], class condition_variable
using std::condition_variable;
// [thread.condition.condvarany], class condition_variable_any
Expand All @@ -18,5 +18,5 @@ export namespace std {
using std::notify_all_at_thread_exit;

using std::cv_status;

#endif // _LIBCPP_HAS_NO_THREADS
} // namespace std
2 changes: 2 additions & 0 deletions libcxx/modules/std/future.inc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
//===----------------------------------------------------------------------===//

export namespace std {
#ifndef _LIBCPP_HAS_NO_THREADS
using std::future_errc;
using std::future_status;
using std::launch;
Expand Down Expand Up @@ -50,4 +51,5 @@ export namespace std {

// [futures.async], function template async
using std::async;
#endif // _LIBCPP_HAS_NO_THREADS
} // namespace std
2 changes: 2 additions & 0 deletions libcxx/modules/std/latch.inc
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,7 @@
//===----------------------------------------------------------------------===//

export namespace std {
#ifndef _LIBCPP_HAS_NO_THREADS
using std::latch;
#endif // _LIBCPP_HAS_NO_THREADS
} // namespace std
2 changes: 2 additions & 0 deletions libcxx/modules/std/memory.inc
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ export namespace std {
// [inout.ptr], function template inout_ptr
// using std::inout_ptr;

#ifndef _LIBCPP_HAS_NO_THREADS
// [depr.util.smartptr.shared.atomic]
using std::atomic_is_lock_free;

Expand All @@ -203,4 +204,5 @@ export namespace std {
using std::atomic_compare_exchange_strong_explicit;
using std::atomic_compare_exchange_weak;
using std::atomic_compare_exchange_weak_explicit;
#endif // _LIBCPP_HAS_NO_THREADS
} // namespace std
2 changes: 2 additions & 0 deletions libcxx/modules/std/mutex.inc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
//===----------------------------------------------------------------------===//

export namespace std {
#ifndef _LIBCPP_HAS_NO_THREADS
// [thread.mutex.class], class mutex
using std::mutex;
// [thread.mutex.recursive], class recursive_mutex
Expand Down Expand Up @@ -35,6 +36,7 @@ export namespace std {
// [thread.lock.algorithm], generic locking algorithms
using std::lock;
using std::try_lock;
#endif // _LIBCPP_HAS_NO_THREADS

using std::once_flag;

Expand Down
2 changes: 2 additions & 0 deletions libcxx/modules/std/semaphore.inc
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@
//===----------------------------------------------------------------------===//

export namespace std {
#ifndef _LIBCPP_HAS_NO_THREADS
// [thread.sema.cnt], class template counting_semaphore
using std::counting_semaphore;

using std::binary_semaphore;
#endif // _LIBCPP_HAS_NO_THREADS
} // namespace std
2 changes: 2 additions & 0 deletions libcxx/modules/std/shared_mutex.inc
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@
//===----------------------------------------------------------------------===//

export namespace std {
#ifndef _LIBCPP_HAS_NO_THREADS
// [thread.sharedmutex.class], class shared_­mutex
using std::shared_mutex;
// [thread.sharedtimedmutex.class], class shared_­timed_­mutex
using std::shared_timed_mutex;
// [thread.lock.shared], class template shared_­lock
using std::shared_lock;
using std::swap;
#endif // _LIBCPP_HAS_NO_THREADS
} // namespace std
2 changes: 2 additions & 0 deletions libcxx/modules/std/stop_token.inc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
//===----------------------------------------------------------------------===//

export namespace std {
#ifndef _LIBCPP_HAS_NO_THREADS
// [stoptoken], class stop_­token
using std::stop_token;

Expand All @@ -20,4 +21,5 @@ export namespace std {

// [stopcallback], class template stop_­callback
using std::stop_callback;
#endif // _LIBCPP_HAS_NO_THREADS
} // namespace std
6 changes: 4 additions & 2 deletions libcxx/modules/std/thread.inc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
//===----------------------------------------------------------------------===//

export namespace std {
#ifndef _LIBCPP_HAS_NO_THREADS
// [thread.thread.class], class thread
using std::thread;

Expand All @@ -28,11 +29,12 @@ export namespace std {
// [thread.thread.id]
using std::operator==;
using std::operator<=>;
#ifndef _LIBCPP_HAS_NO_LOCALIZATION
# ifndef _LIBCPP_HAS_NO_LOCALIZATION
using std::operator<<;
#endif // _LIBCPP_HAS_NO_LOCALIZATION
# endif // _LIBCPP_HAS_NO_LOCALIZATION

using std::formatter;

using std::hash;
#endif // _LIBCPP_HAS_NO_THREADS
} // namespace std
7 changes: 5 additions & 2 deletions libcxx/utils/ci/buildkite-pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -569,8 +569,11 @@ steps:
- "**/test-results.xml"
- "**/*.abilist"
env:
CC: "clang-${LLVM_HEAD_VERSION}"
CXX: "clang++-${LLVM_HEAD_VERSION}"
# Note: Modules require and absolute path for clang-scan-deps
# https://github.com/llvm/llvm-project/issues/61006
CC: "/usr/lib/llvm-${LLVM_HEAD_VERSION}/bin/clang"
CXX: "/usr/lib/llvm-${LLVM_HEAD_VERSION}/bin/clang++"
CMAKE: "/opt/bin/cmake"
ENABLE_CLANG_TIDY: "On"
agents:
queue: "libcxx-builders"
Expand Down

0 comments on commit ef3a391

Please sign in to comment.