Skip to content

Commit 6f79699

Browse files
authored
build: add armv{6,7,8} support to cmake (#1251)
- flags copied from Makefile - updated comments in both CMakeLists.txt and Makefile to match reality
1 parent a5d30b1 commit 6f79699

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

CMakeLists.txt

+14-1
Original file line numberDiff line numberDiff line change
@@ -258,9 +258,22 @@ if (${CMAKE_SYSTEM_PROCESSOR} MATCHES "arm" OR ${CMAKE_SYSTEM_PROCESSOR} MATCHES
258258
# TODO: arm msvc?
259259
else()
260260
if (${CMAKE_SYSTEM_PROCESSOR} MATCHES "aarch64")
261+
# Apple M1, M2, etc.
262+
# Raspberry Pi 3, 4, Zero 2 (64-bit)
261263
add_compile_options(-mcpu=native)
262264
endif()
263-
# TODO: armv6,7,8 version specific flags
265+
if (${CMAKE_SYSTEM_PROCESSOR} MATCHES "armv6")
266+
# Raspberry Pi 1, Zero
267+
add_compile_options(-mfpu=neon-fp-armv8 -mfp16-format=ieee -mno-unaligned-access)
268+
endif()
269+
if (${CMAKE_SYSTEM_PROCESSOR} MATCHES "armv7")
270+
# Raspberry Pi 2
271+
add_compile_options(-mfpu=neon-fp-armv8 -mfp16-format=ieee -mno-unaligned-access -funsafe-math-optimizations)
272+
endif()
273+
if (${CMAKE_SYSTEM_PROCESSOR} MATCHES "armv8")
274+
# Raspberry Pi 3, 4, Zero 2 (32-bit)
275+
add_compile_options(-mfp16-format=ieee -mno-unaligned-access)
276+
endif()
264277
endif()
265278
elseif (${CMAKE_SYSTEM_PROCESSOR} MATCHES "^(x86_64|i686|AMD64)$")
266279
message(STATUS "x86 detected")

Makefile

+5-3
Original file line numberDiff line numberDiff line change
@@ -135,19 +135,21 @@ ifdef LLAMA_PERF
135135
CXXFLAGS += -DGGML_PERF
136136
endif
137137
ifneq ($(filter aarch64%,$(UNAME_M)),)
138+
# Apple M1, M2, etc.
139+
# Raspberry Pi 3, 4, Zero 2 (64-bit)
138140
CFLAGS += -mcpu=native
139141
CXXFLAGS += -mcpu=native
140142
endif
141143
ifneq ($(filter armv6%,$(UNAME_M)),)
142-
# Raspberry Pi 1, 2, 3
144+
# Raspberry Pi 1, Zero
143145
CFLAGS += -mfpu=neon-fp-armv8 -mfp16-format=ieee -mno-unaligned-access
144146
endif
145147
ifneq ($(filter armv7%,$(UNAME_M)),)
146-
# Raspberry Pi 4
148+
# Raspberry Pi 2
147149
CFLAGS += -mfpu=neon-fp-armv8 -mfp16-format=ieee -mno-unaligned-access -funsafe-math-optimizations
148150
endif
149151
ifneq ($(filter armv8%,$(UNAME_M)),)
150-
# Raspberry Pi 4
152+
# Raspberry Pi 3, 4, Zero 2 (32-bit)
151153
CFLAGS += -mfp16-format=ieee -mno-unaligned-access
152154
endif
153155

0 commit comments

Comments
 (0)