Compare commits

...

2 Commits

Author SHA1 Message Date
Milot Mirdita
e44092c9ab
Merge 3453401cfe into c05e8c9934 2025-01-11 13:25:01 +01:00
Milot Mirdita
3453401cfe Fix GGML not compiling on macOS with GCC 2025-01-11 17:41:56 +09:00
3 changed files with 16 additions and 0 deletions

View File

@ -73,6 +73,10 @@ if (BLAS_FOUND)
message(STATUS "BLAS found, Includes: ${BLAS_INCLUDE_DIRS}") message(STATUS "BLAS found, Includes: ${BLAS_INCLUDE_DIRS}")
target_compile_options(ggml-blas PRIVATE ${BLAS_LINKER_FLAGS}) target_compile_options(ggml-blas PRIVATE ${BLAS_LINKER_FLAGS})
# GCC on apple complains about vector conversions
if (APPLE AND CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
target_compile_options(ggml-blas PRIVATE -flax-vector-conversions)
endif ()
if (${BLAS_INCLUDE_DIRS} MATCHES "mkl" AND (${GGML_BLAS_VENDOR} MATCHES "Generic" OR ${GGML_BLAS_VENDOR} MATCHES "Intel")) if (${BLAS_INCLUDE_DIRS} MATCHES "mkl" AND (${GGML_BLAS_VENDOR} MATCHES "Generic" OR ${GGML_BLAS_VENDOR} MATCHES "Intel"))
add_compile_definitions(GGML_BLAS_USE_MKL) add_compile_definitions(GGML_BLAS_USE_MKL)

View File

@ -319,6 +319,10 @@ function(ggml_add_cpu_backend_variant_impl tag_name)
message(STATUS "Adding CPU backend variant ${GGML_CPU_NAME}: ${ARCH_FLAGS} ${ARCH_DEFINITIONS}") message(STATUS "Adding CPU backend variant ${GGML_CPU_NAME}: ${ARCH_FLAGS} ${ARCH_DEFINITIONS}")
target_sources(${GGML_CPU_NAME} PRIVATE ${GGML_CPU_SOURCES}) target_sources(${GGML_CPU_NAME} PRIVATE ${GGML_CPU_SOURCES})
target_compile_options(${GGML_CPU_NAME} PRIVATE ${ARCH_FLAGS}) target_compile_options(${GGML_CPU_NAME} PRIVATE ${ARCH_FLAGS})
# GCC on apple complains about vector conversions
if (APPLE AND CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
target_compile_options(${GGML_CPU_NAME} PRIVATE -flax-vector-conversions)
endif ()
target_compile_definitions(${GGML_CPU_NAME} PRIVATE ${ARCH_DEFINITIONS}) target_compile_definitions(${GGML_CPU_NAME} PRIVATE ${ARCH_DEFINITIONS})
if (GGML_BACKEND_DL) if (GGML_BACKEND_DL)

View File

@ -206,6 +206,14 @@ static int sched_yield (void) {
} }
#else #else
// GCC fails to compile ggml on macos
#if defined(__APPLE__) && !defined(__clang__)
#undef __restrict
#define __restrict
#define _Nullable
#define _Nonnull
#endif
#include <pthread.h> #include <pthread.h>
#include <stdatomic.h> #include <stdatomic.h>
#include <sched.h> #include <sched.h>