diff --git a/CMakeLists.txt b/CMakeLists.txt index b8e01207..7be0dc57 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -183,6 +183,30 @@ if(${ASYNC_SIMPLE_BUILD_MODULES}) endif() endif() + if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") + if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS "16.0.0") + string(CONCAT CMAKE_CXX_SCANDEP_SOURCE + "\"${CMAKE_CXX_COMPILER_CLANG_SCAN_DEPS}\"" + " -format=p1689" + " --" + " " + " -x c++ -c -o " + " -MT " + " -MD -MF " + # Write to a temporary file. If the scan fails, we do not want to update + # the actual output file as `ninja` (at least) assumes that failed + # commands either delete or leave output files alone. See Issue#25419. + " > .tmp" + # We cannot use `copy_if_different` as the rule does not have a feature + # analogous to `ninja`'s `restat = 1`. It would also leave behind the + # `.tmp` file. + " && mv .tmp ") + set(CMAKE_CXX_MODULE_MAP_FORMAT "clang") + set(CMAKE_CXX_MODULE_MAP_FLAG "@") + set(CMAKE_CXX_MODULE_BMI_ONLY_FLAG "--precompile") + endif() + endif() + set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED ON) endif() diff --git a/async_simple/Executor.h b/async_simple/Executor.h index cc662d16..74912a7b 100644 --- a/async_simple/Executor.h +++ b/async_simple/Executor.h @@ -179,7 +179,7 @@ class Executor::TimeAwaitable { Executor::TimeAwaitable inline Executor::after(Executor::Duration dur) { return Executor::TimeAwaitable(this, dur); -}; +} } // namespace async_simple diff --git a/async_simple/async_simple.cppm b/async_simple/async_simple.cppm index 20350a23..3d3a9df4 100644 --- a/async_simple/async_simple.cppm +++ b/async_simple/async_simple.cppm @@ -56,7 +56,6 @@ export extern "C++" { #include "IOExecutor.h" #include "coro/SharedMutex.h" #include "uthread/Collect.h" - #include "coro/PromiseAllocator.h" #include "executors/SimpleIOExecutor.h" #include "coro/Mutex.h" #include "Collect.h" @@ -70,5 +69,9 @@ export extern "C++" { #include "coro/SyncAwait.h" #include "executors/SimpleExecutor.h" #include "coro/Semaphore.h" + // There are some bugs in clang lower versions. +#if defined(__clang_major__) && __clang_major__ >= 17 + #include "coro/PromiseAllocator.h" #include "coro/Generator.h" +#endif } diff --git a/async_simple/std.mock.cppm b/async_simple/std.mock.cppm index 85d8cd73..49d14733 100644 --- a/async_simple/std.mock.cppm +++ b/async_simple/std.mock.cppm @@ -38,6 +38,7 @@ module; #include #if defined(__clang__) #pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wunknown-warning-option" #pragma clang diagnostic ignored "-Wreserved-module-identifier" #endif @@ -416,7 +417,6 @@ using std::ranges::destroy_n; } // namespace ranges using std::default_delete; using std::make_unique; -using std::make_unique_for_overwrite; using std::unique_ptr; using std::operator<; using std::operator>; @@ -425,7 +425,6 @@ using std::operator>=; using std::operator<=>; using std::operator<<; using std::allocate_shared; -using std::allocate_shared_for_overwrite; using std::atomic_compare_exchange_strong; using std::atomic_compare_exchange_strong_explicit; using std::atomic_compare_exchange_weak; @@ -444,7 +443,6 @@ using std::enable_shared_from_this; using std::get_deleter; using std::hash; using std::make_shared; -using std::make_shared_for_overwrite; using std::owner_less; using std::reinterpret_pointer_cast; using std::shared_ptr; @@ -892,14 +890,8 @@ using std::atomic_fetch_xor_explicit; using std::atomic_flag; using std::atomic_flag_clear; using std::atomic_flag_clear_explicit; -using std::atomic_flag_notify_all; -using std::atomic_flag_notify_one; -using std::atomic_flag_test; using std::atomic_flag_test_and_set; using std::atomic_flag_test_and_set_explicit; -using std::atomic_flag_test_explicit; -using std::atomic_flag_wait; -using std::atomic_flag_wait_explicit; using std::atomic_init; using std::atomic_int; using std::atomic_int16_t; @@ -928,7 +920,6 @@ using std::atomic_ref; using std::atomic_schar; using std::atomic_short; using std::atomic_signal_fence; -using std::atomic_signed_lock_free; using std::atomic_size_t; using std::atomic_store; using std::atomic_store_explicit; @@ -951,7 +942,6 @@ using std::atomic_uintmax_t; using std::atomic_uintptr_t; using std::atomic_ullong; using std::atomic_ulong; -using std::atomic_unsigned_lock_free; using std::atomic_ushort; using std::atomic_wait; using std::atomic_wait_explicit; @@ -1091,7 +1081,6 @@ using std::ranges::iterator_t; using std::ranges::output_range; using std::ranges::random_access_range; using std::ranges::range; -using std::ranges::range_common_reference_t; using std::ranges::range_difference_t; using std::ranges::range_reference_t; using std::ranges::range_rvalue_reference_t; @@ -1129,16 +1118,11 @@ using std::ranges::views::iota; } using std::ranges::basic_istream_view; using std::ranges::istream_view; -using std::ranges::wistream_view; -namespace views { -using std::ranges::views::istream; -} namespace views { using std::ranges::views::all; using std::ranges::views::all_t; } // namespace views using std::ranges::filter_view; -using std::ranges::owning_view; using std::ranges::ref_view; namespace views { using std::ranges::views::filter; @@ -1328,7 +1312,6 @@ using std::chrono::ceil; using std::chrono::duration_cast; using std::chrono::floor; using std::chrono::round; -using std::chrono::operator<<; using std::chrono::abs; using std::chrono::day; using std::chrono::days; @@ -1375,7 +1358,6 @@ using std::chrono::year_month_weekday; using std::chrono::year_month_weekday_last; using std::chrono::years; } // namespace chrono -using std::formatter; namespace chrono { using std::chrono::April; using std::chrono::August; diff --git a/async_simple/uthread/internal/thread.h b/async_simple/uthread/internal/thread.h index b6622202..8558e41e 100644 --- a/async_simple/uthread/internal/thread.h +++ b/async_simple/uthread/internal/thread.h @@ -36,7 +36,7 @@ namespace async_simple { namespace uthread { namespace internal { -static constexpr size_t default_base_stack_size = 512 * 1024; +inline constexpr size_t default_base_stack_size = 512 * 1024; size_t get_base_stack_size(); class thread_context { diff --git a/async_simple/util/ThreadPool.h b/async_simple/util/ThreadPool.h index 73e56d6f..0a00a10c 100644 --- a/async_simple/util/ThreadPool.h +++ b/async_simple/util/ThreadPool.h @@ -81,7 +81,7 @@ class ThreadPool { }; #ifdef __linux__ -static void getCurrentCpus(std::vector &ids) { +inline void getCurrentCpus(std::vector &ids) { cpu_set_t set; ids.clear(); if (sched_getaffinity(0, sizeof(set), &set) == 0)