]> git.djapps.eu Git - pkg/ggml/sources/whisper.cpp/commitdiff
fix compilation on haiku
authorAl Hoang <redacted>
Thu, 8 Dec 2022 05:34:19 +0000 (05:34 +0000)
committerGeorgi Gerganov <redacted>
Thu, 8 Dec 2022 07:20:57 +0000 (09:20 +0200)
Makefile
ggml.c

index 991f65065f27f683b6a2197c45475ffe14b4cc0d..57693b2428f7b75e67d54fc373b9f90b8d7a6cb3 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -45,6 +45,10 @@ ifeq ($(UNAME_S),FreeBSD)
        CFLAGS   += -pthread
        CXXFLAGS += -pthread
 endif
+ifeq ($(UNAME_S),Haiku)
+       CFLAGS   += -pthread
+       CXXFLAGS += -pthread
+endif
 
 # Architecture specific
 # TODO: probably these flags need to be tweaked on some architectures
@@ -77,6 +81,23 @@ ifeq ($(UNAME_M),x86_64)
                ifneq (,$(findstring f16c,$(F16C_M)))
                        CFLAGS += -mf16c
                endif
+       else ifeq ($(UNAME_S),Haiku)
+               AVX1_M := $(shell sysinfo -cpu | grep "AVX ")
+               ifneq (,$(findstring avx,$(AVX1_M)))
+                       CFLAGS += -mavx
+               endif
+               AVX2_M := $(shell sysinfo -cpu | grep "AVX2 ")
+               ifneq (,$(findstring avx2,$(AVX2_M)))
+                       CFLAGS += -mavx2
+               endif
+               FMA_M := $(shell sysinfo -cpu | grep "FMA ")
+               ifneq (,$(findstring fma,$(FMA_M)))
+                       CFLAGS += -mfma
+               endif
+               F16C_M := $(shell sysinfo -cpu | grep "F16C ")
+               ifneq (,$(findstring f16c,$(F16C_M)))
+                       CFLAGS += -mf16c
+               endif
        else
                CFLAGS += -mfma -mf16c -mavx -mavx2
        endif
diff --git a/ggml.c b/ggml.c
index f38b367d5ecb07aab581302c1114ea7ddef28ff1..f379f5525392f11c9618d74581d1129b227a395a 100644 (file)
--- a/ggml.c
+++ b/ggml.c
@@ -69,6 +69,10 @@ static int sched_yield (void) {
 typedef void* thread_ret_t;
 #endif
 
+#ifdef __HAIKU__
+#define static_assert(cond, msg) _Static_assert(cond, msg)
+#endif
+
 #define GGML_DEBUG 0
 #define GGML_GELU_FP16