From e3698b5f87eb890362755f0c41d4cccf007a9fd7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mos=C3=A8=20Giordano?= Date: Wed, 3 Jan 2024 21:33:59 +0000 Subject: [PATCH] Work around MinGW bug MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Without this patch, compiling llama.cpp with MinGW results in ``` /workspace/srcdir/llama.cpp/ggml.c: In function ‘ggml_init’: /workspace/srcdir/llama.cpp/ggml.c:193:35: error: implicit declaration of function ‘_aligned_malloc’; did you mean ‘_aligned_realloc’? [-Werror=implicit-function-declaration] 193 | #define GGML_ALIGNED_MALLOC(size) _aligned_malloc(size, GGML_MEM_ALIGN) | ^~~~~~~~~~~~~~~ ``` This is an upstream bug: https://sourceforge.net/p/mingw-w64/bugs/192/, this change is to work around it. --- ggml.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ggml.c b/ggml.c index b124f14cc..64edc1175 100644 --- a/ggml.c +++ b/ggml.c @@ -1,6 +1,8 @@ #define _CRT_SECURE_NO_DEPRECATE // Disables ridiculous "unsafe" warnings on Windows #define _USE_MATH_DEFINES // For M_PI on MSVC +// Load `stdlib.h` before other headers to work around MinGW bug: . +#include #include "ggml-impl.h" #include "ggml-quants.h" @@ -14,7 +16,6 @@ #include #include #include -#include #include #include #include