diff --git a/.github/workflows/07-linux-riscv-build.yml b/.github/workflows/07-linux-riscv-build.yml index b0fed6f..3c2a27d 100644 --- a/.github/workflows/07-linux-riscv-build.yml +++ b/.github/workflows/07-linux-riscv-build.yml @@ -22,7 +22,6 @@ jobs: - name: Checkout code uses: actions/checkout@v6 with: - ref: main submodules: recursive - name: Install build dependencies diff --git a/thirdparty/FastPFOR/CMakeLists.txt b/thirdparty/FastPFOR/CMakeLists.txt index 77a8dfb..4d19289 100644 --- a/thirdparty/FastPFOR/CMakeLists.txt +++ b/thirdparty/FastPFOR/CMakeLists.txt @@ -1,17 +1,25 @@ include(${CMAKE_SOURCE_DIR}/cmake/bazel.cmake) -# On ARM platforms, FastPFOR uses SIMDe to emulate SSE intrinsics. -# Detection covers native ARM builds AND cross-compilation (e.g. iOS/Android). -set(_FASTPFOR_IS_ARM FALSE) +# On non-x86 platforms, FastPFOR uses SIMDe to emulate SSE intrinsics. +# Detection covers native ARM/RISC-V builds AND cross-compilation (e.g. iOS/Android). +set(_FASTPFOR_NEEDS_SIMDE FALSE) if(CMAKE_SYSTEM_PROCESSOR MATCHES "arm|aarch64|ARM64|arm64") - set(_FASTPFOR_IS_ARM TRUE) + set(_FASTPFOR_NEEDS_SIMDE TRUE) +elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "riscv64|riscv32") + set(_FASTPFOR_NEEDS_SIMDE TRUE) elseif(CMAKE_OSX_ARCHITECTURES MATCHES "arm64") - set(_FASTPFOR_IS_ARM TRUE) + set(_FASTPFOR_NEEDS_SIMDE TRUE) elseif(CMAKE_SYSTEM_NAME STREQUAL "iOS") - set(_FASTPFOR_IS_ARM TRUE) + set(_FASTPFOR_NEEDS_SIMDE TRUE) endif() -if(_FASTPFOR_IS_ARM) +# RISC-V: patch FastPFOR common.h to include SIMDe header for __riscv +if(CMAKE_SYSTEM_PROCESSOR MATCHES "riscv64|riscv32") + set(FASTPFOR_RISCV_PATCH ${CMAKE_CURRENT_SOURCE_DIR}/fastpfor.riscv.patch) + apply_patch_once("fastpfor_riscv_fix" "${CMAKE_CURRENT_SOURCE_DIR}/FastPFOR-0.4.0" "${FASTPFOR_RISCV_PATCH}") +endif() + +if(_FASTPFOR_NEEDS_SIMDE) include(FetchContent) FetchContent_Declare( simde diff --git a/thirdparty/FastPFOR/fastpfor.riscv.patch b/thirdparty/FastPFOR/fastpfor.riscv.patch new file mode 100644 index 0000000..d48cfc5 --- /dev/null +++ b/thirdparty/FastPFOR/fastpfor.riscv.patch @@ -0,0 +1,13 @@ +diff --git a/headers/common.h b/headers/common.h +index 1234567..abcdefg 100644 +--- a/headers/common.h ++++ b/headers/common.h +@@ -12,7 +12,7 @@ + #include + #if defined(__GNUC__) && (defined(__x86_64__) || defined(__i386__)) + #include +-#elif defined(__GNUC__) && defined(__aarch64__) ++#elif defined(__GNUC__) && (defined(__aarch64__) || defined(__riscv)) + #include + #endif +