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


From b174d423cf3b997d879fc7e321ccd1c95c776cb1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Kacper=20Michaj=C5=82ow?= <[email protected]>
Date: Sun, 18 Oct 2026 22:39:49 +0200
Subject: [PATCH 1/2] configure: store probed symbols in a volatile intptr_t
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Cast each probed symbol to intptr_t and store it in a static volatile
object instead of casting it to long in a wrapper function whose address
main() masks. The volatile stores keep the references under LTO and
intptr_t avoids the pointer truncation warnings on LLP64 targets
(-Wpointer-to-int-cast). Also deduplicate it with check_host_lib.

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

diff --git a/configure b/configure
index b724e10929..f3c8a1468e 100755
--- a/configure
+++ b/configure
@@ -1469,26 +1469,28 @@ int main(void){ $func(); }
 EOF
 }
 
+print_func_headers_test(){
+    headers=$1
+    funcs=$2
+    for hdr in $headers; do
+        print_include $hdr
+    done
+    echo "#include <stdint.h>"
+    echo "static volatile intptr_t ref;"
+    echo "int main(void) {"
+    for func in $funcs; do
+        echo " ref = (intptr_t) $func;"
+    done
+    echo "return 0; }"
+}
+
 check_func_headers(){
     log check_func_headers "$@"
     headers=$1
     funcs=$2
     shift 2
-    {
-        for hdr in $headers; do
-            print_include $hdr
-        done
-        echo "#include <stdint.h>"
-        for func in $funcs; do
-            echo "long check_$func(void) { return (long) $func; }"
-        done
-        echo "int main(void) { int ret = 0;"
-        # LTO could optimize out the test functions without this
-        for func in $funcs; do
-            echo " ret |= ((intptr_t)check_$func) & 0xFFFF;"
-        done
-        echo "return ret; }"
-    } | test_ld "cc" "$@" && enable $funcs && enable_sanitized $headers
+    print_func_headers_test "$headers" "$funcs" | test_ld "cc" "$@" &&
+        enable $funcs && enable_sanitized $headers
 }
 
 check_class_headers_cxx(){
@@ -1905,23 +1907,11 @@ check_host_cpp_condition(){
 
 check_host_lib(){
     log check_host_lib "$@"
-    headers="$1"
-    funcs="$2"
+    headers=$1
+    funcs=$2
     shift 2
-    {
-        for hdr in $headers; do
-            print_include $hdr
-        done
-        echo "#include <stdint.h>"
-        for func in $funcs; do
-            echo "long check_$func(void) { return (long) $func; }"
-        done
-        echo "int main(void) { int ret = 0;"
-        for func in $funcs; do
-            echo " ret |= ((intptr_t)check_$func) & 0xFFFF;"
-        done
-        echo "return ret; }"
-    } | test_host_ld "$@" && append host_extralibs "$@"
+    print_func_headers_test "$headers" "$funcs" | test_host_ld "$@" &&
+        append host_extralibs "$@"
 }
 
 cp_if_changed(){
-- 
2.54.0


From 433ed741dbda9d128c731aa4f88812a387db87c7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Kacper=20Michaj=C5=82ow?= <[email protected]>
Date: Sun, 18 Oct 2026 22:39:49 +0200
Subject: [PATCH 2/2] configure: do not enable leftover funcs in
 check_class_headers_cxx
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

The function probes classes and not function. This was copy paste error
that ended up here.

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

diff --git a/configure b/configure
index f3c8a1468e..a17b9cdb9e 100755
--- a/configure
+++ b/configure
@@ -1509,7 +1509,7 @@ check_class_headers_cxx(){
             i=$(expr $i + 1)
         done
         echo "return 0; }"
-    } | test_ld "cxx" "$@" && enable $funcs && enable_sanitized $headers
+    } | test_ld "cxx" "$@" && enable_sanitized $headers
 }
 
 test_cpp_condition(){
-- 
2.54.0

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

Reply via email to