Work around MinGW bug

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.
This commit is contained in:
Mosè Giordano 2024-01-03 21:33:59 +00:00 committed by GitHub
parent cb1e2818e0
commit e3698b5f87
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

3
ggml.c
View file

@ -1,6 +1,8 @@
#define _CRT_SECURE_NO_DEPRECATE // Disables ridiculous "unsafe" warnings on Windows #define _CRT_SECURE_NO_DEPRECATE // Disables ridiculous "unsafe" warnings on Windows
#define _USE_MATH_DEFINES // For M_PI on MSVC #define _USE_MATH_DEFINES // For M_PI on MSVC
// Load `stdlib.h` before other headers to work around MinGW bug: <https://sourceforge.net/p/mingw-w64/bugs/192/>.
#include <stdlib.h>
#include "ggml-impl.h" #include "ggml-impl.h"
#include "ggml-quants.h" #include "ggml-quants.h"
@ -14,7 +16,6 @@
#include <errno.h> #include <errno.h>
#include <time.h> #include <time.h>
#include <math.h> #include <math.h>
#include <stdlib.h>
#include <string.h> #include <string.h>
#include <stdint.h> #include <stdint.h>
#include <inttypes.h> #include <inttypes.h>