PR #21211 opened by Martin Storsjö (mstorsjo)
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/21211
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/21211.patch


From 5cf19ec30ae98254dc7656c3f0dacc857933c2b7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Martin=20Storsj=C3=B6?= <[email protected]>
Date: Tue, 16 Dec 2025 00:39:51 +0200
Subject: [PATCH 1/2] doc: Document our stance on Windows ARM64EC

Explicitly spell it out that we are not going to modify the
individual libraries for the purposes of improving conformance
to ARM64EC.

We may (or may not) accept build system patches for making such
a build succeed, provided that it does not require changes to
the actual library code.
---
 doc/platform.texi | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/doc/platform.texi b/doc/platform.texi
index d9ee436a9f..b767971aa9 100644
--- a/doc/platform.texi
+++ b/doc/platform.texi
@@ -330,4 +330,14 @@ and for a build with shared libraries
 ./configure --target-os=mingw32 --enable-shared --disable-static 
--extra-cflags=-mno-cygwin --extra-libs=-mno-cygwin
 @end example
 
+@section ARM64EC
+
+FFmpeg does not intend to support the Windows ARM64EC build configuration;
+patches for changing the individual libraries for the purposes of ARM64EC will
+not be accepted.
+
+It may still be possible to build FFmpeg in this build configuration;
+such a build may seem to work to some extent. Such a build may have some
+amounts of ABI inconsistencies though - which we are not willing to fix.
+
 @bye
-- 
2.49.1


From 24ece7a089e2c5dd880e25761c242ce0930206b7 Mon Sep 17 00:00:00 2001
From: Harishmcw <[email protected]>
Date: Fri, 17 Oct 2025 18:03:44 +0530
Subject: [PATCH 2/2] compat: Fix .def file generation for ARM64EC builds on
 Windows
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

When building DLLs on ARM64EC, the default use of `dumpbin
-linkermember:1` fails because ARM64EC static libraries use a
different linker member format. Use `-linkermember:32` for ARM64EC
to correctly extract symbols.

Additionally, MSVC inserts $exit_thunk and $entry_thunk symbols
for ARM64EC to handle x64 ↔ ARM64 transitions. These are internal
thunks and must not be exported. Filter them out when generating
the .def file to avoid unresolved symbols or invalid exports.

Trim out the leading '#' on ARM64EC function symbols. This is only
relevant on ARM64EC, but it is benign to do that filtering on
all architectures (such symbols aren't expected on other
architectures).

Simplify the sed command by removing the symbol address with a
sed expression instead of a later "cut" command.

This ensures correct symbol extraction and stable DLL generation
on ARM64EC targets, while keeping behavior unchanged for other
Windows architectures.
---
 compat/windows/makedef | 25 ++++++++++++++++++++-----
 configure              |  2 +-
 2 files changed, 21 insertions(+), 6 deletions(-)

diff --git a/compat/windows/makedef b/compat/windows/makedef
index add8222d13..af42f08fd5 100755
--- a/compat/windows/makedef
+++ b/compat/windows/makedef
@@ -48,7 +48,13 @@ trap 'rm -f -- $libname' EXIT
 if [ -n "$AR" ]; then
     $AR rcs ${libname} $@ >/dev/null
 else
-    lib.exe -out:${libname} $@ >/dev/null
+    machine_flag=""
+    case "$LDFLAGS" in
+    *"machine:arm64ec"*)
+        machine_flag="-machine:arm64ec"
+        ;;
+    esac
+    lib.exe ${machine_flag} -out:${libname} $@ >/dev/null
 fi
 if [ $? != 0 ]; then
     echo "Could not create temporary library." >&2
@@ -106,12 +112,21 @@ if [ -n "$NM" ]; then
               grep -v : |
               grep -v ^$ |
               cut -d' ' -f3 |
-              sed -e "s/^${prefix}//")
+              sed -e "s/^${prefix}//" -e "s/^#//" |
+              grep -v '\$entry_thunk' |
+              grep -v '\$exit_thunk')
 else
-    dump=$(dumpbin.exe -linkermember:1 ${libname} |
-              sed -e '/public symbols/,$!d' -e '/^ \{1,\}Summary/,$d' -e "s/ 
\{1,\}${prefix}/ /" -e 's/ \{1,\}/ /g' |
+    member=1
+    case "$LDFLAGS" in
+    *"machine:arm64ec"*)
+        member=32
+        ;;
+    esac
+    dump=$(dumpbin.exe -linkermember:${member} ${libname} |
+              sed -e '/public symbols/,$!d' -e '/^ \{1,\}Summary/,$d' -e 
's/^[[:space:]]*[0-9A-Fa-f]\{1,\}[[:space:]]\{1,\}//' -e "s/^${prefix}//" -e 
's/^#//' |
               tail -n +2 |
-              cut -d' ' -f3)
+              grep -v '\$entry_thunk' |
+              grep -v '\$exit_thunk')
 fi
 
 rm ${libname}
diff --git a/configure b/configure
index 083a30972a..9458a1d964 100755
--- a/configure
+++ b/configure
@@ -6096,7 +6096,7 @@ case $target_os in
         SLIBSUF=".dll"
         SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME)-$(LIBVERSION)$(SLIBSUF)'
         SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME)-$(LIBMAJOR)$(SLIBSUF)'
-        SLIB_CREATE_DEF_CMD='EXTERN_PREFIX="$(EXTERN_PREFIX)" 
$(SRC_PATH)/compat/windows/makedef $(SUBDIR)lib$(NAME).ver $(OBJS) > 
$$(@:$(SLIBSUF)=.def)'
+        SLIB_CREATE_DEF_CMD='LDFLAGS="$(LDFLAGS)" 
EXTERN_PREFIX="$(EXTERN_PREFIX)" $(SRC_PATH)/compat/windows/makedef 
$(SUBDIR)lib$(NAME).ver $(OBJS) > $$(@:$(SLIBSUF)=.def)'
         SLIB_INSTALL_NAME='$(SLIBNAME_WITH_MAJOR)'
         SLIB_INSTALL_LINKS=
         SLIB_INSTALL_EXTRA_SHLIB='$(SLIBNAME:$(SLIBSUF)=.lib)'
-- 
2.49.1

_______________________________________________
ffmpeg-devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to