From 913732c2898bc66c03073abb767f5941cfe88abe Mon Sep 17 00:00:00 2001 From: Indy Ray Date: Tue, 30 Sep 2025 21:53:53 -0700 Subject: [PATCH 1/4] Fix for building SquidTasks on linux. * std::nullptr_t in SquidTasks --- include/FunctionGuard.h | 4 ++-- include/Task.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/FunctionGuard.h b/include/FunctionGuard.h index 6b15f69..da19b5a 100644 --- a/include/FunctionGuard.h +++ b/include/FunctionGuard.h @@ -58,7 +58,7 @@ class FunctionGuard { public: FunctionGuard() = default; /// Default constructor - FunctionGuard(nullptr_t) /// Null-pointer constructor + FunctionGuard(std::nullptr_t) /// Null-pointer constructor { } FunctionGuard(tFn in_fn) /// Functor constructor @@ -80,7 +80,7 @@ class FunctionGuard in_other.Forget(); return *this; } - FunctionGuard& operator=(nullptr_t) noexcept /// Null-pointer assignment operator (calls Forget() to clear the functor) + FunctionGuard& operator=(std::nullptr_t) noexcept /// Null-pointer assignment operator (calls Forget() to clear the functor) { Forget(); return *this; diff --git a/include/Task.h b/include/Task.h index 321097e..581f709 100644 --- a/include/Task.h +++ b/include/Task.h @@ -216,7 +216,7 @@ class Task Task() /// Default constructor (constructs an invalid handle) { } - Task(nullptr_t) /// Null-pointer constructor (constructs an invalid handle) + Task(std::nullptr_t) /// Null-pointer constructor (constructs an invalid handle) { } Task(std::shared_ptr in_taskInternal) /// @private @@ -240,7 +240,7 @@ class Task { // NOTE: No need to alter logical reference here (this is a move) } - Task& operator=(nullptr_t) noexcept /// Null-pointer assignment operator (makes the handle invalid) + Task& operator=(std::nullptr_t) noexcept /// Null-pointer assignment operator (makes the handle invalid) { RemoveRef(); // Remove logical reference from old internal task m_taskInternal = nullptr; From ec50b0c7a162730897cbb95b2c1dcd1a198e967d Mon Sep 17 00:00:00 2001 From: Indy Ray Date: Mon, 6 Oct 2025 15:14:19 -0700 Subject: [PATCH 2/4] Adding missing algorithm for linux build. --- include/Task.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/Task.h b/include/Task.h index 581f709..ee9f4f2 100644 --- a/include/Task.h +++ b/include/Task.h @@ -10,6 +10,7 @@ /// @defgroup Awaiters Awaiters /// @brief Versatile task awaiters that offer utility to most projects +#include #include #include #include From 9272bb27e6c137fa1e375d5e94ad987c6abf96fa Mon Sep 17 00:00:00 2001 From: Indy Ray Date: Wed, 8 Oct 2025 13:40:32 -0700 Subject: [PATCH 3/4] Fix for crash on clang with -O2 or above. It appears that coroutine elision was causing a crash in clang 20, by using force noinline we are able to prevent elision, fixing the crash. This may be a more fundamental bug, that appears potentially fixed in clang 21, so we may want to disable it there. --- include/Private/TasksCommonPrivate.h | 6 ++++++ include/Task.h | 2 ++ 2 files changed, 8 insertions(+) diff --git a/include/Private/TasksCommonPrivate.h b/include/Private/TasksCommonPrivate.h index 984f867..c57d440 100644 --- a/include/Private/TasksCommonPrivate.h +++ b/include/Private/TasksCommonPrivate.h @@ -54,6 +54,12 @@ NAMESPACE_SQUID_END #define COROUTINE_OPTIMIZE_ON _Pragma("clang optimize on") #endif +#if defined(__clang__) +#define SQUID_FORCENOINLINE __attribute__((noinline)) +#else +#define SQUID_FORCENOINLINE __attribute__((noinline)) +#endif + // False type for use in static_assert() [static_assert(false, ...) -> static_assert(static_false, ...)] #include template diff --git a/include/Task.h b/include/Task.h index ee9f4f2..5d4fca7 100644 --- a/include/Task.h +++ b/include/Task.h @@ -225,6 +225,8 @@ class Task { AddRef(); } + // Heap elision crash on clang https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0981r0.html + SQUID_FORCENOINLINE Task(std::coroutine_handle in_coroHandle) /// @private : m_taskInternal(std::make_shared(in_coroHandle)) { From 97e086a4ed8480867cdc59682aff1b1242032a85 Mon Sep 17 00:00:00 2001 From: Indy Ray Date: Wed, 8 Oct 2025 18:11:30 -0700 Subject: [PATCH 4/4] Remove noinline attribute for non-clang. Only clang is experiencing the issue with coroutine elision so far. --- include/Private/TasksCommonPrivate.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/Private/TasksCommonPrivate.h b/include/Private/TasksCommonPrivate.h index c57d440..8629ced 100644 --- a/include/Private/TasksCommonPrivate.h +++ b/include/Private/TasksCommonPrivate.h @@ -57,7 +57,7 @@ NAMESPACE_SQUID_END #if defined(__clang__) #define SQUID_FORCENOINLINE __attribute__((noinline)) #else -#define SQUID_FORCENOINLINE __attribute__((noinline)) +#define SQUID_FORCENOINLINE #endif // False type for use in static_assert() [static_assert(false, ...) -> static_assert(static_false, ...)]