[vlc-commits] [Git][videolan/vlc][master] contrib: mpg123: Backport upstream patches for building on Windows on ARM

Felix Paul Kühne (@fkuehne) gitlab at videolan.org
Sun Jun 28 20:58:46 UTC 2026



Felix Paul Kühne pushed to branch master at VideoLAN / VLC


Commits:
28db1318 by Martin Storsjö at 2026-06-28T22:29:46+02:00
contrib: mpg123: Backport upstream patches for building on Windows on ARM

The first of these commits fixes building for Windows on aarch64,
with a Clang built with asserts enabled. With asserts disabled,
it built successfully before, but it did hit a codepath that
is supposed to be unreachable (this is technically an LLVM bug,
as it can be hit with faulty input), so it is unclear what it
really did in that case.

The second of these commits correspond to the two patches we
already had, for building for 32 bit ARM.

These are backports from
https://github.com/madebr/mpg123/commit/1c35a3eb9d0dd8bc93472aa15946d08b047adb6c
https://github.com/madebr/mpg123/commit/5f147713802f92454ac7c9cb2a673cb95a54ab84

- - - - -


4 changed files:

- + contrib/src/mpg123/0001-ports-cmake-Fix-detecting-asm-align-directives-in-cm.patch
- contrib/src/mpg123/win_arm_asm.patch → contrib/src/mpg123/0002-ports-cmake-Fix-building-ARM-assembly-for-Windows-fo.patch
- − contrib/src/mpg123/getcpuflags_arm.c.patch
- contrib/src/mpg123/rules.mak


Changes:

=====================================
contrib/src/mpg123/0001-ports-cmake-Fix-detecting-asm-align-directives-in-cm.patch
=====================================
@@ -0,0 +1,75 @@
+From 1c35a3eb9d0dd8bc93472aa15946d08b047adb6c Mon Sep 17 00:00:00 2001
+From: thor <thor at 35dc7657-300d-0410-a2e5-dc2837fedb53>
+Date: Fri, 26 Jun 2026 20:33:00 +0000
+Subject: [PATCH 1/2] ports/cmake: Fix detecting asm align directives in cmake
+ on Windows
+
+(https://github.com/madebr/mpg123/pull/25 by mstorsjo)
+
+The mpg123 build system attempts to detect which kind of alignment
+directives the target assembler has.
+
+The autoconf build system attempts detecting this through assembling
+these directives as a .s file, containing only the directive.
+However the cmake build system checks for the same through a
+.c file, with the assembler directives stuck within main() { .. }.
+
+This causes Clang to fail assembling that for Windows ARM/AArch64
+targets, with errors like these:
+
+    fatal error: error in backend: Failed to evaluate function length in SEH unwind info
+
+On Windows on ARM/AArch64, we can't do variable length constructs
+like .align within a function, as it breaks the SEH unwind info
+generation.
+
+These failed tests cause CMake to incorrectly conclude that
+".balign" isn't available, and that ".align" isn't using powers
+of two.
+
+This leads to the assembly attempting to do ".align 16", which
+is interpreted as aligning the sections to 2^16 bytes. In a
+release build of Clang, this gets built successfully, even if it
+might be invalid - but in a Clang build with asserts enabled, it
+fails asserts like this:
+
+    unsupported section alignment
+    UNREACHABLE executed at ../lib/MC/WinCOFFObjectWriter.cpp:322!
+
+(Ideally this wouldn't be an assert but a proper error at some
+level though.)
+
+By placing the __asm__() directive outside of main(), we can
+still test the features of the assembler through a .c file in
+cmake. (CMake has no corresponding "check_asm_source_compiles"
+unfortunately.)
+
+This fixes building for Windows on AArch64 with Clang.
+
+
+
+git-svn-id: svn://scm.orgis.org/mpg123/trunk@5579 35dc7657-300d-0410-a2e5-dc2837fedb53
+---
+ ports/cmake/src/CMakeLists.txt | 4 ++--
+ 3 files changed, 7 insertions(+), 4 deletions(-)
+
+diff --git a/ports/cmake/src/CMakeLists.txt b/ports/cmake/src/CMakeLists.txt
+index f6a77b97..23b2ff57 100644
+--- a/ports/cmake/src/CMakeLists.txt
++++ b/ports/cmake/src/CMakeLists.txt
+@@ -98,10 +98,10 @@ search_libs(socket SOCKET_LIB socket)
+ test_big_endian(WORDS_BIGENDIAN)
+ 
+ check_c_source_compiles(
+-    "int main() { __asm__(\".balign 4\"); return 0; }"
++    "__asm__(\".balign 4\"); int main() { return 0; }"
+     ASMALIGN_BALIGN)
+ check_c_source_compiles(
+-    "int main() { __asm__(\".align 3\"); return 0; }"
++    "__asm__(\".align 3\"); int main() { return 0; }"
+     ASMALIGN_EXP)
+ if(NOT ASMALIGN_EXP)
+     set(ASMALIGN_BYTE ON)
+-- 
+2.43.0
+


=====================================
contrib/src/mpg123/win_arm_asm.patch → contrib/src/mpg123/0002-ports-cmake-Fix-building-ARM-assembly-for-Windows-fo.patch
=====================================
@@ -1,6 +1,54 @@
-diff -urN mpg123-orig/src/libmpg123/check_neon.S mpg123/src/libmpg123/check_neon.S
---- mpg123-orig/src/libmpg123/check_neon.S	2026-06-06 11:39:41.000000000 +0300
-+++ mpg123/src/libmpg123/check_neon.S	2026-06-14 15:52:42.872593755 +0300
+From 5f147713802f92454ac7c9cb2a673cb95a54ab84 Mon Sep 17 00:00:00 2001
+From: thor <thor at 35dc7657-300d-0410-a2e5-dc2837fedb53>
+Date: Fri, 26 Jun 2026 20:59:56 +0000
+Subject: [PATCH 2/2] ports/cmake: Fix building ARM assembly for Windows for
+ mingw targets
+
+This code was attempted to be fixed to support building for
+Windows on ARM with MSVC before - by adding ifdefs for _M_ARM.
+
+The MSVC compilers predefine _M_ARM when targeting ARM - but
+mingw compilers don't define this (they predefine __arm__
+instead).
+
+However, within ARM specific files, we don't specifically need
+to check for an _M_ARM at all - we can just check for _WIN32
+which is predefined by all compilers targeting Windows.
+
+Secondly, add "#ifdef __ELF__" around ".fpu neon" instead of
+"#ifndef __APPLE__"; the .fpu directive can only be assembled on
+ELF targets.
+
+Thirdly, use a separate codepath for Windows in the
+synth*_neon_accurate.S files. Windows on ARM is Thumb only, and in
+Thumb mode, not all instructions are allowed. In this case, we can't
+align the stack pointer with one single instruction, but need to
+use a scratch register inbetween.
+
+This fixes building for Windows on ARM in mingw environments,
+such as with llvm-mingw toolchains.
+
+
+
+git-svn-id: svn://scm.orgis.org/mpg123/trunk@5580 35dc7657-300d-0410-a2e5-dc2837fedb53
+---
+ src/libmpg123/check_neon.S                 |  4 ++--
+ src/libmpg123/dct36_neon.S                 |  4 ++--
+ src/libmpg123/dct64_neon_float.S           |  4 ++--
+ src/libmpg123/getcpuflags_arm.c            |  6 +++---
+ src/libmpg123/synth_neon_accurate.S        | 10 +++++++++-
+ src/libmpg123/synth_neon_float.S           |  4 ++--
+ src/libmpg123/synth_neon_s32.S             |  4 ++--
+ src/libmpg123/synth_stereo_neon.S          |  4 ++--
+ src/libmpg123/synth_stereo_neon_accurate.S | 10 +++++++++-
+ src/libmpg123/synth_stereo_neon_float.S    |  4 ++--
+ src/libmpg123/synth_stereo_neon_s32.S      |  4 ++--
+ 12 files changed, 38 insertions(+), 21 deletions(-)
+
+diff --git a/src/libmpg123/check_neon.S b/src/libmpg123/check_neon.S
+index 87f5f226..6ba6171a 100644
+--- a/src/libmpg123/check_neon.S
++++ b/src/libmpg123/check_neon.S
 @@ -10,10 +10,10 @@
  #include "mangle.h"
  
@@ -14,9 +62,10 @@ diff -urN mpg123-orig/src/libmpg123/check_neon.S mpg123/src/libmpg123/check_neon
  	.fpu neon
  #endif
  #endif
-diff -urN mpg123-orig/src/libmpg123/dct36_neon.S mpg123/src/libmpg123/dct36_neon.S
---- mpg123-orig/src/libmpg123/dct36_neon.S	2026-06-06 11:39:41.000000000 +0300
-+++ mpg123/src/libmpg123/dct36_neon.S	2026-06-14 15:42:56.392916805 +0300
+diff --git a/src/libmpg123/dct36_neon.S b/src/libmpg123/dct36_neon.S
+index b1ea973f..e45ffbde 100644
+--- a/src/libmpg123/dct36_neon.S
++++ b/src/libmpg123/dct36_neon.S
 @@ -9,10 +9,10 @@
  
  #include "mangle.h"
@@ -30,9 +79,10 @@ diff -urN mpg123-orig/src/libmpg123/dct36_neon.S mpg123/src/libmpg123/dct36_neon
  	.fpu neon
  #endif
  	
-diff -urN mpg123-orig/src/libmpg123/dct64_neon_float.S mpg123/src/libmpg123/dct64_neon_float.S
---- mpg123-orig/src/libmpg123/dct64_neon_float.S	2026-06-06 11:39:41.000000000 +0300
-+++ mpg123/src/libmpg123/dct64_neon_float.S	2026-06-14 15:43:43.392972217 +0300
+diff --git a/src/libmpg123/dct64_neon_float.S b/src/libmpg123/dct64_neon_float.S
+index 9ee8a259..b6660e2a 100644
+--- a/src/libmpg123/dct64_neon_float.S
++++ b/src/libmpg123/dct64_neon_float.S
 @@ -8,10 +8,10 @@
  
  #include "mangle.h"
@@ -46,9 +96,41 @@ diff -urN mpg123-orig/src/libmpg123/dct64_neon_float.S mpg123/src/libmpg123/dct6
  	.fpu neon
  #endif
  
-diff -urN mpg123-orig/src/libmpg123/synth_neon_accurate.S mpg123/src/libmpg123/synth_neon_accurate.S
---- mpg123-orig/src/libmpg123/synth_neon_accurate.S	2026-06-06 11:39:41.000000000 +0300
-+++ mpg123/src/libmpg123/synth_neon_accurate.S	2026-06-14 15:51:51.252535246 +0300
+diff --git a/src/libmpg123/getcpuflags_arm.c b/src/libmpg123/getcpuflags_arm.c
+index 8d0249a1..d5c9c1e6 100644
+--- a/src/libmpg123/getcpuflags_arm.c
++++ b/src/libmpg123/getcpuflags_arm.c
+@@ -19,7 +19,7 @@
+ 
+ extern void INT123_check_neon(void);
+ 
+-#ifndef _M_ARM
++#ifndef _WIN32
+ static sigjmp_buf jmpbuf;
+ #else
+ static jmp_buf jmpbuf;
+@@ -27,7 +27,7 @@ static jmp_buf jmpbuf;
+ 
+ static void mpg123_arm_catch_sigill(int sig)
+ {
+-#ifndef _M_ARM
++#ifndef _WIN32
+ 	siglongjmp(jmpbuf, 1);
+ #else
+ 	longjmp(jmpbuf, 1);
+@@ -36,7 +36,7 @@ static void mpg123_arm_catch_sigill(int sig)
+ 
+ unsigned int INT123_getcpuflags(struct cpuflags* cf)
+ {
+-#ifndef _M_ARM
++#ifndef _WIN32
+ 	struct sigaction act, act_old;
+ 	act.sa_handler = mpg123_arm_catch_sigill;
+ 	act.sa_flags = SA_RESTART;
+diff --git a/src/libmpg123/synth_neon_accurate.S b/src/libmpg123/synth_neon_accurate.S
+index df60685e..fbc4c5f7 100644
+--- a/src/libmpg123/synth_neon_accurate.S
++++ b/src/libmpg123/synth_neon_accurate.S
 @@ -17,8 +17,10 @@
  	return value: number of clipped samples (0)
  */
@@ -61,7 +143,7 @@ diff -urN mpg123-orig/src/libmpg123/synth_neon_accurate.S mpg123/src/libmpg123/s
  	.fpu neon
  #endif
  
-@@ -32,7 +34,13 @@
+@@ -32,7 +34,13 @@ ASM_NAME(INT123_synth_1to1_neon_accurate_asm):
  	vpush		{q4-q7}
  	mov			r6, sp
  	sub			sp, sp, #16
@@ -75,9 +157,10 @@ diff -urN mpg123-orig/src/libmpg123/synth_neon_accurate.S mpg123/src/libmpg123/s
  	
  	add			WINDOW, WINDOW, #64
  	sub			WINDOW, WINDOW, r3, lsl #2
-diff -urN mpg123-orig/src/libmpg123/synth_neon_float.S mpg123/src/libmpg123/synth_neon_float.S
---- mpg123-orig/src/libmpg123/synth_neon_float.S	2026-06-06 11:39:41.000000000 +0300
-+++ mpg123/src/libmpg123/synth_neon_float.S	2026-06-14 15:44:00.843992734 +0300
+diff --git a/src/libmpg123/synth_neon_float.S b/src/libmpg123/synth_neon_float.S
+index 99a5d21f..d8c018b5 100644
+--- a/src/libmpg123/synth_neon_float.S
++++ b/src/libmpg123/synth_neon_float.S
 @@ -17,10 +17,10 @@
  	return value: number of clipped samples (0)
  */
@@ -91,9 +174,10 @@ diff -urN mpg123-orig/src/libmpg123/synth_neon_float.S mpg123/src/libmpg123/synt
  	.fpu neon
  #endif
  
-diff -urN mpg123-orig/src/libmpg123/synth_neon_s32.S mpg123/src/libmpg123/synth_neon_s32.S
---- mpg123-orig/src/libmpg123/synth_neon_s32.S	2026-06-06 11:39:41.000000000 +0300
-+++ mpg123/src/libmpg123/synth_neon_s32.S	2026-06-14 15:41:45.642832738 +0300
+diff --git a/src/libmpg123/synth_neon_s32.S b/src/libmpg123/synth_neon_s32.S
+index 334a1375..665f47bc 100644
+--- a/src/libmpg123/synth_neon_s32.S
++++ b/src/libmpg123/synth_neon_s32.S
 @@ -17,10 +17,10 @@
  	return value: number of clipped samples (0)
  */
@@ -107,9 +191,27 @@ diff -urN mpg123-orig/src/libmpg123/synth_neon_s32.S mpg123/src/libmpg123/synth_
  	.fpu neon
  #endif
  
-diff -urN mpg123-orig/src/libmpg123/synth_stereo_neon_accurate.S mpg123/src/libmpg123/synth_stereo_neon_accurate.S
---- mpg123-orig/src/libmpg123/synth_stereo_neon_accurate.S	2026-06-06 11:39:41.000000000 +0300
-+++ mpg123/src/libmpg123/synth_stereo_neon_accurate.S	2026-06-14 15:52:13.003559926 +0300
+diff --git a/src/libmpg123/synth_stereo_neon.S b/src/libmpg123/synth_stereo_neon.S
+index 5abc8b74..791c766b 100644
+--- a/src/libmpg123/synth_stereo_neon.S
++++ b/src/libmpg123/synth_stereo_neon.S
+@@ -18,10 +18,10 @@
+ 	return value: number of clipped samples
+ */
+ 
+-#ifndef _M_ARM
++#ifndef _WIN32
+ 	.code 32
+ #endif
+-#ifndef __APPLE__
++#ifdef __ELF__
+ 	.fpu neon
+ #endif
+ 
+diff --git a/src/libmpg123/synth_stereo_neon_accurate.S b/src/libmpg123/synth_stereo_neon_accurate.S
+index 3107a74b..5bdc1427 100644
+--- a/src/libmpg123/synth_stereo_neon_accurate.S
++++ b/src/libmpg123/synth_stereo_neon_accurate.S
 @@ -18,8 +18,10 @@
  	return value: number of clipped samples
  */
@@ -122,7 +224,7 @@ diff -urN mpg123-orig/src/libmpg123/synth_stereo_neon_accurate.S mpg123/src/libm
  	.fpu neon
  #endif
  
-@@ -34,7 +36,13 @@
+@@ -34,7 +36,13 @@ ASM_NAME(INT123_synth_1to1_s_neon_accurate_asm):
  	ldr			r4, [sp, #84]
  	mov			r7, sp
  	sub			sp, sp, #16
@@ -136,9 +238,10 @@ diff -urN mpg123-orig/src/libmpg123/synth_stereo_neon_accurate.S mpg123/src/libm
  	
  	add			WINDOW, WINDOW, #64
  	sub			WINDOW, WINDOW, r4, lsl #2
-diff -urN mpg123-orig/src/libmpg123/synth_stereo_neon_float.S mpg123/src/libmpg123/synth_stereo_neon_float.S
---- mpg123-orig/src/libmpg123/synth_stereo_neon_float.S	2026-06-06 11:39:41.000000000 +0300
-+++ mpg123/src/libmpg123/synth_stereo_neon_float.S	2026-06-14 15:43:22.472947600 +0300
+diff --git a/src/libmpg123/synth_stereo_neon_float.S b/src/libmpg123/synth_stereo_neon_float.S
+index e626f2e1..0a5b5c54 100644
+--- a/src/libmpg123/synth_stereo_neon_float.S
++++ b/src/libmpg123/synth_stereo_neon_float.S
 @@ -18,10 +18,10 @@
  	return value: number of clipped samples (0)
  */
@@ -152,25 +255,10 @@ diff -urN mpg123-orig/src/libmpg123/synth_stereo_neon_float.S mpg123/src/libmpg1
  	.fpu neon
  #endif
  
-diff -urN mpg123-orig/src/libmpg123/synth_stereo_neon.S mpg123/src/libmpg123/synth_stereo_neon.S
---- mpg123-orig/src/libmpg123/synth_stereo_neon.S	2026-06-06 11:39:41.000000000 +0300
-+++ mpg123/src/libmpg123/synth_stereo_neon.S	2026-06-14 15:42:10.402862256 +0300
-@@ -18,10 +18,10 @@
- 	return value: number of clipped samples
- */
- 
--#ifndef _M_ARM
-+#ifndef _WIN32
- 	.code 32
- #endif
--#ifndef __APPLE__
-+#ifdef __ELF__
- 	.fpu neon
- #endif
- 
-diff -urN mpg123-orig/src/libmpg123/synth_stereo_neon_s32.S mpg123/src/libmpg123/synth_stereo_neon_s32.S
---- mpg123-orig/src/libmpg123/synth_stereo_neon_s32.S	2026-06-06 11:39:41.000000000 +0300
-+++ mpg123/src/libmpg123/synth_stereo_neon_s32.S	2026-06-14 15:42:32.055887983 +0300
+diff --git a/src/libmpg123/synth_stereo_neon_s32.S b/src/libmpg123/synth_stereo_neon_s32.S
+index 505e76bd..66f7b942 100644
+--- a/src/libmpg123/synth_stereo_neon_s32.S
++++ b/src/libmpg123/synth_stereo_neon_s32.S
 @@ -18,10 +18,10 @@
  	return value: number of clipped samples
  */
@@ -184,3 +272,6 @@ diff -urN mpg123-orig/src/libmpg123/synth_stereo_neon_s32.S mpg123/src/libmpg123
  	.fpu neon
  #endif
  
+-- 
+2.43.0
+


=====================================
contrib/src/mpg123/getcpuflags_arm.c.patch deleted
=====================================
@@ -1,36 +0,0 @@
-fix LLVM-mingw ARM build
-
-src/libmpg123/getcpuflags_arm.c:23:8: error: unknown type name 'sigjmp_buf'; did you mean 'jmp_buf'?
-   23 | static sigjmp_buf jmpbuf;
-      |        ^~~~~~~~~~
-      |        jmp_buf
-===================================================================
---- orig/src/libmpg123/getcpuflags_arm.c	(revision 5569)
-+++ new/src/libmpg123/getcpuflags_arm.c	(working copy)
-@@ -19,7 +19,7 @@
- 
- extern void INT123_check_neon(void);
- 
--#ifndef _M_ARM
-+#if !defined(_M_ARM) && !defined(_WIN32)
- static sigjmp_buf jmpbuf;
- #else
- static jmp_buf jmpbuf;
-@@ -27,7 +27,7 @@
- 
- static void mpg123_arm_catch_sigill(int sig)
- {
--#ifndef _M_ARM
-+#if !defined(_M_ARM) && !defined(_WIN32)
- 	siglongjmp(jmpbuf, 1);
- #else
- 	longjmp(jmpbuf, 1);
-@@ -36,7 +36,7 @@
- 
- unsigned int INT123_getcpuflags(struct cpuflags* cf)
- {
--#ifndef _M_ARM
-+#if !defined(_M_ARM) && !defined(_WIN32)
- 	struct sigaction act, act_old;
- 	act.sa_handler = mpg123_arm_catch_sigill;
- 	act.sa_flags = SA_RESTART;


=====================================
contrib/src/mpg123/rules.mak
=====================================
@@ -18,9 +18,9 @@ mpg123: mpg123-$(MPG123_VERSION).tar.bz2 .sum-mpg123
 	$(UNPACK)
 	$(call pkg_static,"libmpg123.pc.in")
 	$(call pkg_static,"libsyn123.pc.in")
-	# fix llvm-mingw ARM build
-	$(APPLY) $(SRC)/mpg123/getcpuflags_arm.c.patch
-	$(APPLY) $(SRC)/mpg123/win_arm_asm.patch
+	# fix llvm-mingw ARM/AArch64 build
+	$(APPLY) $(SRC)/mpg123/0001-ports-cmake-Fix-detecting-asm-align-directives-in-cm.patch
+	$(APPLY) $(SRC)/mpg123/0002-ports-cmake-Fix-building-ARM-assembly-for-Windows-fo.patch
 	$(MOVE)
 
 .mpg123: mpg123 toolchain.cmake



View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/28db1318cced314ae0d0016c8ab28d59d4be852d

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/28db1318cced314ae0d0016c8ab28d59d4be852d
You're receiving this email because of your account on code.videolan.org. Manage all notifications: https://code.videolan.org/-/profile/notifications | Help: https://code.videolan.org/help




More information about the vlc-commits mailing list