[FFmpeg-devel] [PATCH] ffbuild: use response files only if ar accepts them

Gyan Doshi ffmpeg at gyani.pro
Mon Mar 17 17:16:48 EET 2025


This is to not break linking with toolchains that don't support reading
args from a 'response file'.
---
I've assumed that ld on a system will have same support as ar.

 configure           | 7 +++++++
 ffbuild/library.mak | 8 ++++++++
 2 files changed, 15 insertions(+)

diff --git a/configure b/configure
index f6964c4ee1..d84e32196d 100755
--- a/configure
+++ b/configure
@@ -5230,6 +5230,12 @@ else
     ar_o='$@'
 fi
 
+if $ar 2>&1 | grep -qi  "@.*file"; then
+    ar_objs="true"
+else
+    ar_objs=""
+fi
+
 add_cflags $extra_cflags
 add_cxxflags $extra_cxxflags
 add_objcflags $extra_objcflags
@@ -8133,6 +8139,7 @@ DEPX86ASM=$x86asmexe
 DEPX86ASMFLAGS=\$(X86ASMFLAGS)
 AR=$ar
 ARFLAGS=$arflags
+AR_OBJS=$ar_objs
 AR_O=$ar_o
 AR_CMD=$ar
 NM_CMD=$nm
diff --git a/ffbuild/library.mak b/ffbuild/library.mak
index 72e3872157..7e1871b74c 100644
--- a/ffbuild/library.mak
+++ b/ffbuild/library.mak
@@ -35,8 +35,12 @@ OBJS += $(SHLIBOBJS)
 endif
 $(SUBDIR)$(LIBNAME): $(OBJS) $(STLIBOBJS)
 	$(RM) $@
+ifeq ($(AR_OBJS),true)
 	$(Q)echo $^ > $@.objs
 	$(AR) $(ARFLAGS) $(AR_O) @$@.objs
+else
+	$(AR) $(ARFLAGS) $(AR_O) $^
+endif
 	$(RANLIB) $@
 	-$(RM) $@.objs
 
@@ -68,8 +72,12 @@ $(SUBDIR)$(SLIBNAME): $(SUBDIR)$(SLIBNAME_WITH_MAJOR)
 
 $(SUBDIR)$(SLIBNAME_WITH_MAJOR): $(OBJS) $(SHLIBOBJS) $(SLIBOBJS) $(SUBDIR)lib$(NAME).ver
 	$(SLIB_CREATE_DEF_CMD)
+ifeq ($(AR_OBJS),true)
 	$(Q)echo $$(filter %.o,$$^) > $$@.objs
 	$$(LD) $(SHFLAGS) $(LDFLAGS) $(LDSOFLAGS) $$(LD_O) @$$@.objs $(FFEXTRALIBS)
+else
+	$$(LD) $(SHFLAGS) $(LDFLAGS) $(LDSOFLAGS) $$(LD_O) $$(filter %.o,$$^) $(FFEXTRALIBS)
+endif
 	$(SLIB_EXTRA_CMD)
 	-$(RM) $$@.objs
 
-- 
2.46.1



More information about the ffmpeg-devel mailing list