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

MSYS2 emulates ln -s by copying the target unless native links are
requested, so the src link test never passed there and out of tree
builds on Windows got the absolute source path in every -I flag and
dependency file. Native links need Developer Mode or the symlink
privilege. When that is missing, both MSYS2 and Cygwin fall back to link
types only their own tools can read, which the shell test accepts while
the compiler cannot open a header through them.

Request native links for the two ln -s calls and replace the shell test
with compiling a header through the link, which is what -Isrc/ needs.


From 867f637574b80f934c629acff1ea8c4693d0d6b3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Kacper=20Michaj=C5=82ow?= <[email protected]>
Date: Mon, 21 Sep 2026 20:09:56 +0200
Subject: [PATCH] configure: create native symlinks on Windows and test them
 with the compiler
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

MSYS2 emulates ln -s by copying the target unless native links are
requested, so the src link test never passed there and out of tree
builds on Windows got the absolute source path in every -I flag and
dependency file. Native links need Developer Mode or the symlink
privilege. When that is missing, both MSYS2 and Cygwin fall back to link
types only their own tools can read, which the shell test accepts while
the compiler cannot open a header through them.

Request native links for the two ln -s calls and replace the shell test
with compiling a header through the link, which is what -Isrc/ needs.

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

diff --git a/configure b/configure
index 6901344317..052f46a415 100755
--- a/configure
+++ b/configure
@@ -6317,16 +6317,25 @@ case $target_os in
         ;;
 esac
 
+# Ask for native links and keep the link only if the compiler works with them.
+link_dir(){
+    MSYS="$MSYS winsymlinks:native" CYGWIN="$CYGWIN winsymlinks:native" $ln_s 
"$@"
+}
+
 # test if creating links works
 link_dest=$(mktemp -u $TMPDIR/dest_XXXXXXXX)
 link_name=$(mktemp -u $TMPDIR/name_XXXXXXXX)
+link_works=no
 mkdir "$link_dest"
-$ln_s "$link_dest" "$link_name"
-touch "$link_dest/test_file"
-if [ "$source_path" != "." ] && [ "$source_path" != "./src" ] && ([ ! -d src ] 
|| [ -L src ]) && [ -e "$link_name/test_file" ]; then
+link_dir "$link_dest" "$link_name"
+touch "$link_dest/link_test.h"
+test_cc -I"$link_name" <<EOF && link_works=yes
+#include "link_test.h"
+EOF
+if [ "$source_path" != "." ] && [ "$source_path" != "./src" ] && ([ ! -d src ] 
|| [ -L src ]) && [ "$link_works" = yes ]; then
     # create link to source path
     [ -e src ] && rm src
-    $ln_s "$source_path" src
+    link_dir "$source_path" src
     source_link=src
 else
     # creating directory links doesn't work
-- 
2.52.0

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

Reply via email to