From 02677596a1c5da6b117f53bbc38a0ceee928f43e Mon Sep 17 00:00:00 2001 From: MaidOpi Date: Mon, 11 May 2026 13:32:11 +0800 Subject: [PATCH] memory hash workaround --- CMakeLists.txt | 1 + src/leanclr_wasm_libcxx_shim.cpp | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 src/leanclr_wasm_libcxx_shim.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 13c8935..ea4261b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -85,6 +85,7 @@ add_library(leanclr_godot SHARED src/leanclr_script_language.cpp src/leanclr_script_loader.cpp src/leanclr_script_saver.cpp + src/leanclr_wasm_libcxx_shim.cpp src/register_types.cpp ) diff --git a/src/leanclr_wasm_libcxx_shim.cpp b/src/leanclr_wasm_libcxx_shim.cpp new file mode 100644 index 0000000..974802d --- /dev/null +++ b/src/leanclr_wasm_libcxx_shim.cpp @@ -0,0 +1,18 @@ +#include + +#if defined(__EMSCRIPTEN__) +extern "C" std::size_t leanclr_godot_libcxx_hash_memory(const void* p_data, std::size_t p_size) noexcept + __asm__("_ZNSt3__213__hash_memoryEPKvm"); + +extern "C" std::size_t leanclr_godot_libcxx_hash_memory(const void* p_data, std::size_t p_size) noexcept +{ + const unsigned char* bytes = static_cast(p_data); + std::size_t hash = 1469598103934665603ull; + for (std::size_t i = 0; i < p_size; ++i) + { + hash ^= bytes[i]; + hash *= 1099511628211ull; + } + return hash; +} +#endif