From 40b0b4b6c4c196cfce223163d8a442b43d20d3bc Mon Sep 17 00:00:00 2001 From: TheM14 Date: Fri, 16 Oct 2026 20:26:30 +0800 Subject: [PATCH] Sync the kernel with the single-definition error detail --- kernel/include/joc_version.h | 2 +- kernel/joc_kernel.vcxproj | 1 + kernel/src/foundation/status.cpp | 11 +++++++++++ kernel/src/foundation/status.h | 6 ++++-- 4 files changed, 17 insertions(+), 3 deletions(-) create mode 100644 kernel/src/foundation/status.cpp diff --git a/kernel/include/joc_version.h b/kernel/include/joc_version.h index 0874ca6..722dcb6 100644 --- a/kernel/include/joc_version.h +++ b/kernel/include/joc_version.h @@ -11,6 +11,6 @@ #define JOC_VERSION_MAJOR 0 #define JOC_VERSION_MINOR 1 #define JOC_VERSION_PATCH 0 -#define JOC_VERSION_STRING "0.1.0" +#define JOC_VERSION_STRING "1.0.0" #endif /* JOC_VERSION_H */ diff --git a/kernel/joc_kernel.vcxproj b/kernel/joc_kernel.vcxproj index 0ecb6be..c0caa6c 100644 --- a/kernel/joc_kernel.vcxproj +++ b/kernel/joc_kernel.vcxproj @@ -158,6 +158,7 @@ + diff --git a/kernel/src/foundation/status.cpp b/kernel/src/foundation/status.cpp new file mode 100644 index 0000000..a70fe4b --- /dev/null +++ b/kernel/src/foundation/status.cpp @@ -0,0 +1,11 @@ +#include "foundation/status.h" + +namespace joc { + +// The single definition of the per-thread detail string. It cannot live in the +// header: a thread_local with dynamic initialisation that is included by several +// translation units makes each of them emit its own TLS initialisation routine, +// and ld64 rejects those as duplicate symbols (GNU ld and MSVC fold them). +thread_local std::string last_error_detail; + +} // namespace joc diff --git a/kernel/src/foundation/status.h b/kernel/src/foundation/status.h index 3abe932..20ffe69 100644 --- a/kernel/src/foundation/status.h +++ b/kernel/src/foundation/status.h @@ -36,8 +36,10 @@ private: // Structured detail of the most recent failing call, as returned by // joc_last_error_detail(). It is one instance per thread across the whole // library, so every C entry point -- the task API and the streaming API alike -- -// reports through the same string. -inline thread_local std::string last_error_detail; +// reports through the same string. Defined in status.cpp: a thread_local with +// dynamic initialisation defined in a header emits a TLS initialisation routine +// in every including unit, and ld64 rejects those duplicates. +extern thread_local std::string last_error_detail; inline void record_error_detail(const Status& status) { if (status.ok()) {