From 88c254f7fb28dbf721c2d870d50e233cce4d50e8 Mon Sep 17 00:00:00 2001 From: yomaytk Date: Tue, 6 Jan 2026 00:37:03 +0900 Subject: [PATCH 1/2] Fix GGML_MEM_ALIGN to 8 for emscripten. --- ggml/include/ggml.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ggml/include/ggml.h b/ggml/include/ggml.h index 20c912d0e9b..b4d3718ed51 100644 --- a/ggml/include/ggml.h +++ b/ggml/include/ggml.h @@ -234,6 +234,8 @@ #if UINTPTR_MAX == 0xFFFFFFFF #define GGML_MEM_ALIGN 4 +#elif defined(__EMSCRIPTEN__) + #define GGML_MEM_ALIGN 8 #else #define GGML_MEM_ALIGN 16 #endif From 8dde886d5d4a80241c09ebf57c766b8baf36bafd Mon Sep 17 00:00:00 2001 From: yomaytk Date: Thu, 8 Jan 2026 12:11:26 +0900 Subject: [PATCH 2/2] Add a comment explaining the need for GGML_MEM_ALIGN == 8 in 64-bit wasm with emscripten --- ggml/include/ggml.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ggml/include/ggml.h b/ggml/include/ggml.h index b4d3718ed51..b69583dd3fd 100644 --- a/ggml/include/ggml.h +++ b/ggml/include/ggml.h @@ -235,6 +235,9 @@ #if UINTPTR_MAX == 0xFFFFFFFF #define GGML_MEM_ALIGN 4 #elif defined(__EMSCRIPTEN__) +// emscripten uses max_align_t == 8, so we need GGML_MEM_ALIGN == 8 for 64-bit wasm. +// (for 32-bit wasm, the first conditional is true and GGML_MEM_ALIGN stays 4.) +// ref: https://github.com/ggml-org/llama.cpp/pull/18628 #define GGML_MEM_ALIGN 8 #else #define GGML_MEM_ALIGN 16