build(wasm): liblogging now builds for wasm

Further, due to limitations of file system access on wasm, liblogging now outputs all logs to the console syncronously
This commit is contained in:
2025-12-03 10:46:29 -05:00
parent 03bbaf1a9e
commit 888d44cec1
12 changed files with 185 additions and 27 deletions

View File

@@ -0,0 +1,20 @@
--- quill/include/quill/core/Rdtsc.h.orig 2025-12-03 09:43:26.530875697 -0500
+++ quill/include/quill/core/Rdtsc.h 2025-12-03 09:42:49.852913743 -0500
@@ -16,7 +16,7 @@
#elif defined(__ARM_ARCH)
#include <chrono>
#include <cstdint>
-#elif (defined(_M_ARM) || defined(_M_ARM64))
+#elif (defined(_M_ARM) || defined(_M_ARM64) || defined(__wasm__))
#include <chrono>
#include <cstdint>
#elif (defined(__PPC64__))
@@ -72,7 +72,7 @@
// soft failover
return static_cast<uint64_t>(std::chrono::system_clock::now().time_since_epoch().count());
}
-#elif (defined(_M_ARM) || defined(_M_ARM64) || defined(__PPC64__))
+#elif (defined(_M_ARM) || defined(_M_ARM64) || defined(__PPC64__) || defined(__wasm__))
QUILL_NODISCARD QUILL_ATTRIBUTE_HOT inline uint64_t rdtsc() noexcept
{
// soft failover

View File

@@ -0,0 +1,36 @@
--- quill/inlcude/quill/backend/BackendUtilities.h.orig 2025-12-03 10:02:26.861779737 -0500
+++ quill/include/quill/backend/BackendUtilities.h 2025-12-03 10:09:04.509482559 -0500
@@ -35,7 +35,7 @@
#elif defined(__CYGWIN__)
#include <sched.h>
#include <unistd.h>
-#elif defined(__linux__)
+#elif (defined(__linux__) || defined(__EMSCRIPTEN__))
#include <pthread.h>
#include <sched.h>
#include <unistd.h>
@@ -84,6 +84,8 @@
thread_port_t mach_thread = pthread_mach_thread_np(pthread_self());
thread_policy_set(mach_thread, THREAD_AFFINITY_POLICY, (thread_policy_t)&policy, 1);
+#elif defined(__EMSCRIPTEN__)
+ (void)cpu_id;
#else
cpu_set_t cpuset;
CPU_ZERO(&cpuset);
@@ -102,7 +104,7 @@
/***/
QUILL_ATTRIBUTE_COLD inline void set_thread_name(char const* name)
{
-#if defined(__CYGWIN__) || defined(__MINGW32__) || defined(__MINGW64__) || defined(QUILL_NO_THREAD_NAME_SUPPORT)
+#if defined(__CYGWIN__) || defined(__MINGW32__) || defined(__MINGW64__) || defined(QUILL_NO_THREAD_NAME_SUPPORT) || defined(__EMSCRIPTEN__)
// Disabled on MINGW / Cygwin.
(void)name;
#elif defined(_WIN32)
@@ -154,4 +156,4 @@
}
} // namespace detail
-QUILL_END_NAMESPACE
\ No newline at end of file
+QUILL_END_NAMESPACE

View File

@@ -1,5 +1,6 @@
[wrap-git]
url = https://github.com/odygrd/quill
revision = v8.1.1
diff_files = quill/add_wasm_rdtsc_fallback_support.patch, quill/enable_pthread_header_emscripted.patch
[cmake]
[cmake]