Skip to content

Commit 3e02bd9

Browse files
authored
Merge pull request #15 from steinwurf/fix-aarch64-neon-detection
Fix NEON detection on AArch64
2 parents 85c6e18 + d502977 commit 3e02bd9

3 files changed

Lines changed: 29 additions & 17 deletions

File tree

.github/workflows/cpp-internal.yml

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -84,25 +84,26 @@ jobs:
8484
container:
8585
image: ghcr.io/steinwurf/build-images/zig-cpp
8686
options: --user 0:0
87-
volumes:
88-
- /root/.ssh:/root/.ssh
8987
steps:
9088
- name: Checkout source code
9189
uses: actions/checkout@v4
92-
- name: Install dependencies
90+
with:
91+
persist-credentials: false
92+
- name: Configure Github Authentication
9393
run: |
94-
apk add --no-cache \
95-
python3 \
96-
py3-pip \
97-
git \
98-
cmake \
99-
build-base
100-
- name: Waf Clean
101-
run: python3 waf clean --no_resolve
94+
git config --global credential.helper 'store'
95+
git credential approve <<EOF
96+
protocol=https
97+
host=github.com
98+
username=x-access-token
99+
password=${{ secrets.GH_ACCESS_TOKEN }}
100+
EOF
102101
- name: Waf Configure with Zig Toolchain
103-
run: python3 waf configure --git_protocol=git@ --cmake_toolchain=./resolve_symlinks/toolchains/zig-toolchain-x86_64-linux-musl.cmake --cmake_verbose
102+
run: python3 waf configure --git_protocol=https:// --cmake_toolchain=./resolve_symlinks/toolchains/zig-toolchain-x86_64-linux-musl.cmake --cmake_verbose
104103
- name: Waf Build with Zig Toolchain
105-
run: python3 waf build --run_tests
104+
run: python3 waf build
105+
- name: Waf Run Tests
106+
run: python3 waf --run_tests
106107

107108
macos_cmake:
108109
timeout-minutes: 45

CMakeLists.txt

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ target_link_libraries(aybabtu PRIVATE steinwurf::platform)
6060

6161
# Check Accelerations
6262
include(CheckCXXCompilerFlag)
63+
include(CheckCXXSourceCompiles)
6364

6465
if(CMAKE_C_COMPILER_ID MATCHES "GNU|AppleClang|Clang")
6566
# # SSE2 check_cxx_compiler_flag("-Werror -msse2" HAS_SSE2)
@@ -89,12 +90,21 @@ if(CMAKE_C_COMPILER_ID MATCHES "GNU|AppleClang|Clang")
8990
set_source_files_properties(${avx2} PROPERTIES COMPILE_FLAGS -mavx2)
9091
endif()
9192

93+
9294
# NEON
93-
check_cxx_compiler_flag("-Werror -mfpu=neon" HAS_NEON)
95+
if(CMAKE_SYSTEM_PROCESSOR MATCHES "^(aarch64|AARCH64|arm64|ARM64)$")
96+
check_cxx_source_compiles(
97+
"int main()\n{\n#if defined(__ARM_NEON) || defined(__ARM_NEON__) || defined(__aarch64__)\n return 0;\n#else\n#error NEON is required\n#endif\n}\n"
98+
HAS_NEON)
99+
else()
100+
check_cxx_compiler_flag("-Werror -mfpu=neon" HAS_NEON)
101+
endif()
94102

95103
if(HAS_NEON)
96104
file(GLOB_RECURSE neon ./src/*neon.cpp)
97-
set_source_files_properties(${neon} PROPERTIES COMPILE_FLAGS -mfpu=neon)
105+
if(NOT CMAKE_SYSTEM_PROCESSOR MATCHES "^(aarch64|AARCH64|arm64|ARM64)$")
106+
set_source_files_properties(${neon} PROPERTIES COMPILE_FLAGS -mfpu=neon)
107+
endif()
98108
endif()
99109
elseif(CMAKE_C_COMPILER_ID MATCHES "MSVC")
100110
# AVX2
@@ -129,7 +139,7 @@ if(${CMAKE_PROJECT_NAME} STREQUAL ${PROJECT_NAME})
129139
# Build test executable
130140
file(GLOB_RECURSE aybabtu_tests_sources ./test/*.cpp)
131141
add_executable(aybabtu_tests ${aybabtu_tests_sources})
132-
target_link_libraries(aybabtu_tests
142+
target_link_libraries(aybabtu_tests
133143
gtest_main
134144
steinwurf::aybabtu
135145
steinwurf::cpuid

NEWS.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ every change, see the Git log.
66

77
Latest
88
------
9-
* tbd
9+
* Patch: Fixed NEON detection on AArch64 by checking for compiler intrinsics instead of
10+
relying on the unavailable -mfpu=neon flag.
1011

1112
5.0.0
1213
-----

0 commit comments

Comments
 (0)