Merge pull request #1649 from Doridian/fix/build-arm32

Make NEON build detection a bit more robust and work on 32-bit ARM
This commit is contained in:
Iceman 2022-04-01 07:29:57 +02:00 committed by GitHub
commit abcc061251
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 31 additions and 1 deletions

View file

@ -17,6 +17,7 @@ target_compile_definitions(pm3rrg_rdv4_hardnested_nosimd PRIVATE NOSIMD_BUILD)
## Mingw platforms: AMD64
set(X86_CPUS x86 x86_64 i686 AMD64)
set(ARM64_CPUS arm64 aarch64)
set(ARM32_CPUS armel armhf)
message(STATUS "CMAKE_SYSTEM_PROCESSOR := ${CMAKE_SYSTEM_PROCESSOR}")
@ -118,6 +119,26 @@ elseif ("${CMAKE_SYSTEM_PROCESSOR}" IN_LIST ARM64_CPUS)
target_compile_options(pm3rrg_rdv4_hardnested_neon PRIVATE -Wall -Werror -O3)
set_property(TARGET pm3rrg_rdv4_hardnested_neon PROPERTY POSITION_INDEPENDENT_CODE ON)
target_include_directories(pm3rrg_rdv4_hardnested_neon PRIVATE
../../common
../../include
../src)
set(SIMD_TARGETS
$<TARGET_OBJECTS:pm3rrg_rdv4_hardnested_neon>)
elseif ("${CMAKE_SYSTEM_PROCESSOR}" IN_LIST ARM32_CPUS)
message(STATUS "Building optimised arm binaries")
## arm64 / NEON
add_library(pm3rrg_rdv4_hardnested_neon OBJECT
hardnested/hardnested_bf_core.c
hardnested/hardnested_bitarray_core.c)
target_compile_options(pm3rrg_rdv4_hardnested_neon PRIVATE -Wall -Werror -O3)
target_compile_options(pm3rrg_rdv4_hardnested_neon BEFORE PRIVATE
-mfpu=neon)
set_property(TARGET pm3rrg_rdv4_hardnested_neon PROPERTY POSITION_INDEPENDENT_CODE ON)
target_include_directories(pm3rrg_rdv4_hardnested_neon PRIVATE
../../common
../../include

View file

@ -13,6 +13,9 @@ endif
ifneq ($(findstring amd64, $(cpu_arch)), )
IS_SIMD_ARCH=x86
endif
ifneq ($(findstring arm, $(cpu_arch)), )
IS_SIMD_ARCH=arm
endif
ifneq ($(findstring arm64, $(cpu_arch)), )
IS_SIMD_ARCH=arm64
endif
@ -24,13 +27,14 @@ ifneq ($(IS_SIMD_ARCH), )
MULTIARCHSRCS = hardnested_bf_core.c hardnested_bitarray_core.c
endif
ifeq ($(MULTIARCHSRCS), )
MYCFLAGS += -DNOSIMD_BUILD
MYSRCS += hardnested_bf_core.c hardnested_bitarray_core.c
endif
LIB_A = libhardnested.a
MYOBJS = $(MYSRCS:%.c=$(OBJDIR)/%.o)
ifeq ($(IS_SIMD_ARCH), arm64)
ifneq ($(findstring arm, $(IS_SIMD_ARCH)), )
MYOBJS += $(MULTIARCHSRCS:%.c=$(OBJDIR)/%_NOSIMD.o) \
$(MULTIARCHSRCS:%.c=$(OBJDIR)/%_NEON.o)
else
@ -54,6 +58,11 @@ ifeq ($(IS_SIMD_ARCH), arm64)
SUPPORTS_AVX512=False
HARD_SWITCH_NOSIMD = -DNOSIMD_BUILD
endif
ifeq ($(IS_SIMD_ARCH), arm)
SUPPORTS_AVX512=False
HARD_SWITCH_NEON = -mfpu=neon
HARD_SWITCH_NOSIMD = -DNOSIMD_BUILD
endif
ifeq "$(SUPPORTS_AVX512)" "True"
HARD_SWITCH_NOSIMD += -mno-avx512f
HARD_SWITCH_MMX += -mno-avx512f