Skip to content

Commit 5214ee9

Browse files
JoeMattclaude
andcommitted
Fix SIMD auto-detection for cross-compilation and native builds
- Remove plain 'arm' from NEON ARCH filter (armv5/armv6 lack NEON) - Don't initialize BLITTER_SIMD_SRC to scalar — let auto-detection run by keeping it empty until a match is found - Add -msse2 flag for 32-bit x86 targets - Add scalar fallback for exotic platforms with no SIMD support - uname -m fallback now only fires when no prior rule matched Co-Authored-By: Claude Opus 4.6 <[email protected]>
1 parent 5514b46 commit 5214ee9

1 file changed

Lines changed: 18 additions & 4 deletions

File tree

Makefile.common

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ SOURCES_C := \
5050

5151
# SIMD-accelerated blitter operations: select arch-specific implementation.
5252
# BLITTER_SIMD may be set explicitly to one of: scalar, sse2, neon.
53-
BLITTER_SIMD_SRC := $(CORE_DIR)/src/blitter_simd_scalar.c
53+
BLITTER_SIMD_SRC :=
5454

5555
ifneq ($(BLITTER_SIMD),)
5656
ifeq (,$(filter scalar sse2 neon,$(BLITTER_SIMD)))
@@ -72,16 +72,21 @@ endif
7272
ifneq (,$(filter ios-arm64 tvos-arm64,$(platform)))
7373
BLITTER_SIMD_SRC := $(CORE_DIR)/src/blitter_simd_neon.c
7474
endif
75-
ifneq (,$(filter aarch64 arm64 arm,$(ARCH)))
75+
# Only aarch64/arm64 guaranteed to have NEON; plain 'arm' may lack it
76+
ifneq (,$(filter aarch64 arm64,$(ARCH)))
7677
BLITTER_SIMD_SRC := $(CORE_DIR)/src/blitter_simd_neon.c
7778
endif
78-
ifneq (,$(filter arm64 armv8% armv7% armhf arm,$(platform)))
79+
ifneq (,$(filter arm64 armv8% armv7% armhf,$(platform)))
7980
BLITTER_SIMD_SRC := $(CORE_DIR)/src/blitter_simd_neon.c
8081
endif
8182

8283
# x86/x64 targets: use SSE2.
8384
ifneq (,$(filter x86_64 x86 i686 i386,$(ARCH)))
8485
BLITTER_SIMD_SRC := $(CORE_DIR)/src/blitter_simd_sse2.c
86+
# 32-bit x86 may need explicit SSE2 enable
87+
ifneq (,$(filter i686 i386 x86,$(ARCH)))
88+
CFLAGS += -msse2
89+
endif
8590
endif
8691
ifneq (,$(filter x86_64 x86 i686 i386 win-x64 win32,$(platform)))
8792
BLITTER_SIMD_SRC := $(CORE_DIR)/src/blitter_simd_sse2.c
@@ -91,14 +96,23 @@ ifneq (,$(filter MINGW64%,$(MSYSTEM)))
9196
BLITTER_SIMD_SRC := $(CORE_DIR)/src/blitter_simd_sse2.c
9297
endif
9398

94-
# Native build fallback: auto-detect from host architecture
99+
# Native build fallback: auto-detect from host when no SIMD was selected above.
100+
ifeq ($(BLITTER_SIMD_SRC),)
95101
ifneq (,$(filter x86_64 x86 i686 i386,$(shell uname -m 2>/dev/null)))
96102
BLITTER_SIMD_SRC := $(CORE_DIR)/src/blitter_simd_sse2.c
97103
endif
104+
endif
105+
ifeq ($(BLITTER_SIMD_SRC),)
98106
ifneq (,$(filter aarch64 arm64,$(shell uname -m 2>/dev/null)))
99107
BLITTER_SIMD_SRC := $(CORE_DIR)/src/blitter_simd_neon.c
100108
endif
101109
endif
110+
endif
111+
112+
# Fall back to scalar if no SIMD was selected (e.g., exotic platforms)
113+
ifeq ($(BLITTER_SIMD_SRC),)
114+
BLITTER_SIMD_SRC := $(CORE_DIR)/src/blitter_simd_scalar.c
115+
endif
102116

103117
SOURCES_C += $(BLITTER_SIMD_SRC)
104118

0 commit comments

Comments
 (0)