On Tue, 30 Sep 2025, Harish Raja Selvan wrote:

Thank you for your feedback and questions about the ARM64EC patch.
I’m sharing the build system patch for enabling ARM64EC support in FFmpeg.
This patch addresses .def file generation for ARM64EC builds on Windows.

In-Lined patch:

diff --git a/compat/windows/makedef b/compat/windows/makedef
index add8222d13..59e300ab61 100755
--- a/compat/windows/makedef
+++ b/compat/windows/makedef
@@ -108,7 +108,12 @@ if [ -n "$NM" ]; then
               cut -d' ' -f3 |
               sed -e "s/^${prefix}//")
 else
-    dump=$(dumpbin.exe -linkermember:1 ${libname} |
+    member=1
+    arch=$VSCMD_ARG_TGT_ARCH
+    if [ "${arch^^}" = "ARM64EC" ]; then
+        member=32
+    fi

We shouldn't inspect any VSCMD_* env variables here in order to deduce the target architecture. (Also, how do you initialize the environment in order to get such a variable set? If you just open a regular arm64 VS command prompt, which AFAIK is the default environment for arm64ec compilation, I wouldn't expect such a variable to be set?)

Instead we need to deduce the architecture from something else here - potentially by passing some parameter from configure.

+        dump=$(dumpbin.exe -linkermember:${member} ${libname} |
               sed -e '/public symbols/,$!d' -e '/^ \{1,\}Summary/,$d' -e
"s/ \{1,\}${prefix}/ /" -e 's/ \{1,\}/ /g' |
               tail -n +2 |
               cut -d' ' -f3)
@@ -121,7 +126,7 @@ list=""
 for exp in ${regex}; do
     list="${list}"'
 '$(echo "${dump}" |
-          grep "^${exp}" |
+          grep "^${exp}" | awk '!/\$exit_thunk/{print}' |

I presume the added awk expression here is just to filter out any line that doesn't match '$exit_thunk'? Why not just a "grep -v '$exit_thunk'"? And that can be in the dump expression as well, in order not to need to do that filtering for each expression. (If we add it to the dump expression, we do need to include it in both variants of the dump expression though; it's possible to build arm64ec with mingw style tools as well.)

For me, this doesn't really end up matching any symbols - I only get the data symbols. What does EXTERN_PREFIX end up being set to in your configurations; for me it's an empty string. Does it get set to "#" in your case?


For reference, here is the configuration used to build FFmpeg with MSVC for
ARM64EC:
I've also attached the same configuration in ffmpeg-arm64ec-msvc.config for
convenience.

# find_ar_lib resolves to /usr/share/automake-1.16/ar-lib
AR_LIB="$(find_ar_lib)"
AR_CMD="${AR_LIB} lib.exe -machine:arm64ec"

Why do you need any extra ar-lib here? This works fine for me with just AR_CMD="lib.exe -machine:arm64ec".

ARCH="arm64"

"${SRC_DIR}/configure" \
    --toolchain=msvc \
    --target-os=win64 \
    --cc=cl.exe \
    --cxx=cl.exe \
    --extra-cxxflags="-arm64EC" \
    --extra-cflags="-arm64EC" \
    --extra-ldflags="/machine:arm64ec" \
    --as="armasm64.exe -machine ARM64EC" \
    --ld=link.exe \
    --ar="${AR_CMD}" \
    --arch="${ARCH}"

In my setup, this configuration requires the gas-preprocessor.pl patch, as
the build otherwise ends with a “GNU assembler not found” error.

Thanks - with this context, it's easier to review your gas-preprocessor patch.

As far as I can see, this builds fine without any extra modifications of ffmpeg, as long as gas-preprocessor is patched. Building with --enable-shared would require the suggested changes to makedef, but those changes aren't entirely right in order to work for me in my tests.

I have an alternative suggestion on how to do the gas-preprocessor patch - I'll send those patches and CC you on them.

Another alternative for gas-preprocessor would be to just look for the -arm64EC option, and inject the "-machine arm64ec" options implicitly in that case (it turns out I actually had such a patch lying around since experiments in 2021), but it's perhaps more transparent to force the caller of gas-preprocessor to provide the option.

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

Reply via email to