PR #24639 opened by Kacper Michajłow (kasper93)
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/24639
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/24639.patch

Clang targeting MSVC compiles __int128, but nothing links the compiler-rt
builtins that implement 128-bit division. The clang driver defaults to
the libgcc runtime, which adds nothing on MSVC, and link.exe or lld-link
invoked directly do not know the library either. Since b2b37802a9 the
check therefore fails for these toolchains and libswscale falls back to
AVInteger.

Ask the driver for the library name and retry the check with it. The
driver and lld-link search the clang runtime directory on their own, so
this covers linking through clang as well as calling lld-link directly.
link.exe only finds the library through LIB, where the copy shipped with
MSVC is built with cl and lacks the 128-bit routines, so the check keeps
failing there and nothing changes for such setups.

The library is recorded in int128_extralibs and pulled in by libswscale,
the only user of av_int128, the same way libatomic is handled.


From 3bbbf0e50562894e65d0feb21a3aee40d7c3f0d1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Kacper=20Michaj=C5=82ow?= <[email protected]>
Date: Tue, 22 Sep 2026 23:33:13 +0200
Subject: [PATCH] configure: link compiler-rt builtins for __int128 on Clang
 targeting MSVC
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Clang targeting MSVC compiles __int128, but nothing links the compiler-rt
builtins that implement 128-bit division. The clang driver defaults to
the libgcc runtime, which adds nothing on MSVC, and link.exe or lld-link
invoked directly do not know the library either. Since b2b37802a9 the
check therefore fails for these toolchains and libswscale falls back to
AVInteger.

Ask the driver for the library name and retry the check with it. The
driver and lld-link search the clang runtime directory on their own, so
this covers linking through clang as well as calling lld-link directly.
link.exe only finds the library through LIB, where the copy shipped with
MSVC is built with cl and lacks the 128-bit routines, so the check keeps
failing there and nothing changes for such setups.

The library is recorded in int128_extralibs and pulled in by libswscale,
the only user of av_int128, the same way libatomic is handled.

Signed-off-by: Kacper Michajłow <[email protected]>
---
 configure | 20 ++++++++++++++++++--
 1 file changed, 18 insertions(+), 2 deletions(-)

diff --git a/configure b/configure
index 84ab8beb4b..566a9a7e37 100755
--- a/configure
+++ b/configure
@@ -4353,7 +4353,7 @@ avutil_suggest="amf clock_gettime ffnvcodec gcrypt libm 
zlib libdrm libmfx openc
 swresample_deps="avutil"
 swresample_suggest="libm libsoxr stdatomic"
 swscale_deps="avutil"
-swscale_suggest="libm stdatomic"
+swscale_suggest="libm stdatomic int128"
 shader_compression_suggest="zlib"
 
 avcodec_extralibs="pthreads_extralibs iconv_extralibs dxva2_extralibs 
liblcevc_dec_extralibs lcms2_extralibs"
@@ -6829,7 +6829,23 @@ fi
 check_builtin MemoryBarrier windows.h "MemoryBarrier()"
 check_builtin gmtime_r time.h "time_t *time; struct tm *tm; gmtime_r(time, tm)"
 check_builtin localtime_r time.h "time_t *time; struct tm *tm; 
localtime_r(time, tm)"
-check_builtin int128 "" "volatile __int128 i128var = 1; i128var /= 100;"
+check_int128(){
+    check_builtin int128 "" "volatile __int128 i128var = 1; i128var /= 100;" 
"$@" &&
+        int128_extralibs="$*"
+}
+
+# Clang targeting MSVC compiles __int128 but does not link the compiler-rt
+# builtins providing the 128-bit division helpers. Ask the driver for the
+# library name and link it explicitly.
+check_int128 ||
+    case "$cc_type" in
+        clang|msvc)
+            rtlib=$($cc -print-libgcc-file-name --rtlib=compiler-rt 
2>/dev/null)
+            case $rtlib in
+                *.lib) check_int128 -l$(basename "$rtlib" .lib) ;;
+            esac
+        ;;
+    esac
 
 check_builtin float16 "" "_Float16 f16var"
 if enabled float16; then
-- 
2.52.0

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

Reply via email to