Al Hoang commited on
Commit
5d3218a
·
1 Parent(s): 91f208e

fix compilation on haiku

Browse files
Files changed (2) hide show
  1. Makefile +21 -0
  2. ggml.c +4 -0
Makefile CHANGED
@@ -45,6 +45,10 @@ ifeq ($(UNAME_S),FreeBSD)
45
  CFLAGS += -pthread
46
  CXXFLAGS += -pthread
47
  endif
 
 
 
 
48
 
49
  # Architecture specific
50
  # TODO: probably these flags need to be tweaked on some architectures
@@ -77,6 +81,23 @@ ifeq ($(UNAME_M),x86_64)
77
  ifneq (,$(findstring f16c,$(F16C_M)))
78
  CFLAGS += -mf16c
79
  endif
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
80
  else
81
  CFLAGS += -mfma -mf16c -mavx -mavx2
82
  endif
 
45
  CFLAGS += -pthread
46
  CXXFLAGS += -pthread
47
  endif
48
+ ifeq ($(UNAME_S),Haiku)
49
+ CFLAGS += -pthread
50
+ CXXFLAGS += -pthread
51
+ endif
52
 
53
  # Architecture specific
54
  # TODO: probably these flags need to be tweaked on some architectures
 
81
  ifneq (,$(findstring f16c,$(F16C_M)))
82
  CFLAGS += -mf16c
83
  endif
84
+ else ifeq ($(UNAME_S),Haiku)
85
+ AVX1_M := $(shell sysinfo -cpu | grep "AVX ")
86
+ ifneq (,$(findstring avx,$(AVX1_M)))
87
+ CFLAGS += -mavx
88
+ endif
89
+ AVX2_M := $(shell sysinfo -cpu | grep "AVX2 ")
90
+ ifneq (,$(findstring avx2,$(AVX2_M)))
91
+ CFLAGS += -mavx2
92
+ endif
93
+ FMA_M := $(shell sysinfo -cpu | grep "FMA ")
94
+ ifneq (,$(findstring fma,$(FMA_M)))
95
+ CFLAGS += -mfma
96
+ endif
97
+ F16C_M := $(shell sysinfo -cpu | grep "F16C ")
98
+ ifneq (,$(findstring f16c,$(F16C_M)))
99
+ CFLAGS += -mf16c
100
+ endif
101
  else
102
  CFLAGS += -mfma -mf16c -mavx -mavx2
103
  endif
ggml.c CHANGED
@@ -69,6 +69,10 @@ static int sched_yield (void) {
69
  typedef void* thread_ret_t;
70
  #endif
71
 
 
 
 
 
72
  #define GGML_DEBUG 0
73
  #define GGML_GELU_FP16
74
 
 
69
  typedef void* thread_ret_t;
70
  #endif
71
 
72
+ #ifdef __HAIKU__
73
+ #define static_assert(cond, msg) _Static_assert(cond, msg)
74
+ #endif
75
+
76
  #define GGML_DEBUG 0
77
  #define GGML_GELU_FP16
78