|
| 1 | +From: RISE Project <info@riseproject.dev> |
| 2 | +Subject: [PATCH] cmake: don't assume x86 when the target isn't ARM |
| 3 | + |
| 4 | +The Linux branch of CMakeLists.txt has two if/else pairs that treat |
| 5 | +"not ARM" as "x86": one adds -march=native (or -mavx) and defines |
| 6 | +HAVE_AVX, the other keeps FFTW's AVX/SSE codelets and drops only the |
| 7 | +NEON ones. On any other architecture the build fails at |
| 8 | +simd-support/simd-avx.h with "compiling simd-avx.h without -mavx". |
| 9 | + |
| 10 | +Make both conditions test for x86 explicitly, so architectures without a |
| 11 | +vendored SIMD backend (riscv64, ppc64le, s390x) build the scalar FFTW |
| 12 | +codelets and get no architecture-specific compiler flags. JUCE already |
| 13 | +falls back to its scalar path when JUCE_USE_SIMD is 0. |
| 14 | + |
| 15 | +Upstream-Status: To upstream [not yet submitted; upstream builds no riscv64 wheels] |
| 16 | +diff --git a/CMakeLists.txt b/CMakeLists.txt |
| 17 | +index 89de0fa..f697bfc 100644 |
| 18 | +--- a/CMakeLists.txt |
| 19 | ++++ b/CMakeLists.txt |
| 20 | +@@ -203,7 +203,7 @@ elseif(UNIX AND NOT APPLE) |
| 21 | + # Processor-specific optimizations (x86 vs ARM) |
| 22 | + if(CMAKE_SYSTEM_PROCESSOR MATCHES "arm|aarch64") |
| 23 | + add_compile_definitions(HAVE_NEON=1) |
| 24 | +- else() |
| 25 | ++ elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64|amd64|AMD64|i[3-6]86") |
| 26 | + # Use -march=native for local builds to optimize for the current CPU, |
| 27 | + # but use a portable baseline for CI builds to avoid "Illegal instruction" errors |
| 28 | + # when ccache restores objects built on different runner hardware. |
| 29 | +@@ -214,6 +214,7 @@ elseif(UNIX AND NOT APPLE) |
| 30 | + endif() |
| 31 | + add_compile_definitions(HAVE_AVX) |
| 32 | + endif() |
| 33 | ++ # Any other architecture (riscv64, ppc64le, s390x, ...) builds without SIMD. |
| 34 | + |
| 35 | + # Additional Linux flags |
| 36 | + list(APPEND ALL_INCLUDES "vendors/fftw3/api/" "vendors/fftw3/") |
| 37 | +@@ -317,8 +318,10 @@ function(collect_sources) |
| 38 | + # Exclude files depending on architecture |
| 39 | + if(CMAKE_SYSTEM_PROCESSOR MATCHES "arm|aarch64") |
| 40 | + list(FILTER FFTW_SOURCES EXCLUDE REGEX ".*(avx|/sse).*") |
| 41 | +- else() |
| 42 | ++ elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64|amd64|AMD64|i[3-6]86") |
| 43 | + list(FILTER FFTW_SOURCES EXCLUDE REGEX ".*neon.*") |
| 44 | ++ else() |
| 45 | ++ list(FILTER FFTW_SOURCES EXCLUDE REGEX ".*(avx|/sse|neon).*") |
| 46 | + endif() |
| 47 | + |
| 48 | + # Exclude unused FFTW components |
0 commit comments