Skip to contentSkip to conversation

package/alsa-lib: fix i386 dmix build with -Os and AVX512BW

PATCH New Yegor Yefremov via buildroot 1 participant 1 message Oct 23

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 package/alsa-lib: fix i386 dmix build with -Os and AVX512BW

When building alsa-lib for i386 with BR2_OPTIMIZE_S and a CPU that supports AVX512BW (e.g. BR2_x86_cannonlake), the dmix plugin fails to build:

pcm_dmix_i386.h:52:9: error: 'asm' operand has impossible constraints or there are not enough registers

The i386 mix_areas_*() assembly clobbers esi, edi, edx, ecx, eax and ebx, and at -Os gcc uses ebp as frame pointer, so no general purpose register is left. Since upstream commit abc9f32cf45c ("pcm: dmix:
assembly: give more freedom over the constraints"), the size operand is "+&rm", and with AVX512BW enabled, gcc 15 and gcc 16 then fail to fall back to memory.

Add a patch, submitted upstream, restoring the "+m" constraint for size, as used before that commit.

This issue has been present since commit dfb3ac81e484 ("package/alsa-lib: bump version to 1.2.3"), as alsa-lib 1.2.3 is the first release with the relaxed constraint. It therefore affects 2020.08 and later, including all maintained branches, when building with a toolchain that hits it (verified with gcc 15 and gcc 16).

Fixes:
https://autobuild.buildroot.org/results/ff613c2d94c35a38a5886b70d72aa37b58440b5d

Fixes dfb3ac81e48485a3ab8c018854725cfe30631e3a ("package/alsa-lib: bump version to 1.2.3")
Assisted-by Claude:claude-opus-5-5
---
 ...i386-keep-the-size-operand-in-memory.patch | 82 +++++++++++++++++++
 1 file changed, 82 insertions(+)
 create mode 100644 package/alsa-lib/0002-pcm-dmix-i386-keep-the-size-operand-in-memory.patch
package/alsa-lib/0002-pcm-dmix-i386-keep-the-size-operand-in-memory.patch new file +82 -0
new file mode 100644
index 0000000000..f57e93efce
@@ -0,0 +1,82 @@
+From 5729c2cd216bf3fe8564ab720e25e143660c089a Mon Sep 17 00:00:00 2001
+From: Yegor Yefremov <[email protected]>
+Date: Sat, 24 Oct 2026 01:18:15 +0200
+Subject: [PATCH] pcm: dmix: i386: keep the size operand in memory
+
+The i386 mix_areas_*() assembly clobbers esi, edi, edx, ecx, eax and
+(since gcc 5, even in PIC mode) ebx. When gcc also needs ebp as frame
+pointer, which it does at -Os, no general purpose register is left.
+
+Commit abc9f32cf45c ("pcm: dmix: assembly: give more freedom over the
+constraints") relaxed the size operand from "+m" to "+&rm". With
+AVX512BW enabled (e.g. -march=skylake-avx512, cannonlake, icelake or
+x86-64-v4) and -Os or -Oz, gcc 15 and gcc 16 then fail to pick the
+memory alternative and abort:
+
+  pcm_dmix_i386.h:52:9: error: 'asm' operand has impossible constraints or there are not enough registers
+
+As the asm already uses all registers, restore the "+m" constraint for
+size, as used before that commit. The loop decrementing it in memory
+also does read-modify-write operations on dst and sum, so the extra
+memory access has a negligible cost.
+
+Upstream: https://github.com/alsa-project/alsa-lib/pull/537
+Fixes: abc9f32cf45c ("pcm: dmix: assembly: give more freedom over the constraints")
+Assisted-by: Claude:claude-opus-5-5
+Signed-off-by: Yegor Yefremov <[email protected]>
+---
+ src/pcm/pcm_dmix_i386.h | 10 +++++-----
+ 1 file changed, 5 insertions(+), 5 deletions(-)
+
+diff --git a/src/pcm/pcm_dmix_i386.h b/src/pcm/pcm_dmix_i386.h
+index 0a56e8c6..7c9c9dcf 100644
+--- a/src/pcm/pcm_dmix_i386.h
++++ b/src/pcm/pcm_dmix_i386.h
+@@ -149,7 +149,7 @@ static void MIX_AREAS_16(unsigned int size,
+ #ifdef BOUNDED_EBX
+ 		"\tmovl %[old_ebx], %%ebx\n"	/* ebx is GOT pointer (-fPIC) */
+ #endif
+-		: [size] "+&rm" (size)
++		: [size] "+m" (size)
+ #ifdef BOUNDED_EBX
+ 		  , [old_ebx] "=m" (old_ebx)
+ #endif
+@@ -248,7 +248,7 @@ static void MIX_AREAS_16_MMX(unsigned int size,
+ #ifdef BOUNDED_EBX
+ 		"\tmovl %[old_ebx], %%ebx\n"	/* ebx is GOT pointer (-fPIC) */
+ #endif
+-		: [size] "+&rm" (size)
++		: [size] "+m" (size)
+ #ifdef BOUNDED_EBX
+ 		  , [old_ebx] "=m" (old_ebx)
+ #endif
+@@ -376,7 +376,7 @@ static void MIX_AREAS_32(unsigned int size,
+ #ifdef BOUNDED_EBX
+ 		"\tmovl %[old_ebx], %%ebx\n"	/* ebx is GOT pointer (-fPIC) */
+ #endif
+-		: [size] "+&rm" (size)
++		: [size] "+m" (size)
+ #ifdef BOUNDED_EBX
+ 		  , [old_ebx] "=m" (old_ebx)
+ #endif
+@@ -491,7 +491,7 @@ static void MIX_AREAS_24(unsigned int size,
+ #ifdef BOUNDED_EBX
+ 		"\tmovl %[old_ebx], %%ebx\n"	/* ebx is GOT pointer (-fPIC) */
+ #endif
+-		: [size] "+&rm" (size)
++		: [size] "+m" (size)
+ #ifdef BOUNDED_EBX
+ 		  , [old_ebx] "=m" (old_ebx)
+ #endif
+@@ -599,7 +599,7 @@ static void MIX_AREAS_24_CMOV(unsigned int size,
+ #ifdef BOUNDED_EBX
+ 		"\tmovl %[old_ebx], %%ebx\n"	/* ebx is GOT pointer (-fPIC) */
+ #endif
+-		: [size] "+&rm" (size)
++		: [size] "+m" (size)
+ #ifdef BOUNDED_EBX
+ 		  , [old_ebx] "=m" (old_ebx)
+ #endif
+-- 
+2.34.1
+
Signature · 6 lines
2.34.1

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot