Skip to content

Commit 3453401

Browse files
committed
Fix GGML not compiling on macOS with GCC
1 parent 2739a71 commit 3453401

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

ggml/src/ggml-blas/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,10 @@ if (BLAS_FOUND)
7373
message(STATUS "BLAS found, Includes: ${BLAS_INCLUDE_DIRS}")
7474

7575
target_compile_options(ggml-blas PRIVATE ${BLAS_LINKER_FLAGS})
76+
# GCC on apple complains about vector conversions
77+
if (APPLE AND CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
78+
target_compile_options(ggml-blas PRIVATE -flax-vector-conversions)
79+
endif ()
7680

7781
if (${BLAS_INCLUDE_DIRS} MATCHES "mkl" AND (${GGML_BLAS_VENDOR} MATCHES "Generic" OR ${GGML_BLAS_VENDOR} MATCHES "Intel"))
7882
add_compile_definitions(GGML_BLAS_USE_MKL)

ggml/src/ggml-cpu/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,10 @@ function(ggml_add_cpu_backend_variant_impl tag_name)
319319
message(STATUS "Adding CPU backend variant ${GGML_CPU_NAME}: ${ARCH_FLAGS} ${ARCH_DEFINITIONS}")
320320
target_sources(${GGML_CPU_NAME} PRIVATE ${GGML_CPU_SOURCES})
321321
target_compile_options(${GGML_CPU_NAME} PRIVATE ${ARCH_FLAGS})
322+
# GCC on apple complains about vector conversions
323+
if (APPLE AND CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
324+
target_compile_options(${GGML_CPU_NAME} PRIVATE -flax-vector-conversions)
325+
endif ()
322326
target_compile_definitions(${GGML_CPU_NAME} PRIVATE ${ARCH_DEFINITIONS})
323327

324328
if (GGML_BACKEND_DL)

ggml/src/ggml-cpu/ggml-cpu.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,14 @@ static int sched_yield (void) {
206206
}
207207
#else
208208

209+
// GCC fails to compile ggml on macos
210+
#if defined(__APPLE__) && !defined(__clang__)
211+
#undef __restrict
212+
#define __restrict
213+
#define _Nullable
214+
#define _Nonnull
215+
#endif
216+
209217
#include <pthread.h>
210218
#include <stdatomic.h>
211219
#include <sched.h>

0 commit comments

Comments
 (0)