Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
* [FFmpeg-devel] [PATCH 1/2] ffbuild: compose linker response files in a loop
@ 2025-03-21 10:40 Gyan Doshi
  2025-03-21 10:40 ` [FFmpeg-devel] [PATCH 2/2] configure: add option to select use of response files Gyan Doshi
  2025-03-21 21:59 ` [FFmpeg-devel] [PATCH 1/2] ffbuild: compose linker response files in a loop Martin Storsjö
  0 siblings, 2 replies; 4+ messages in thread
From: Gyan Doshi @ 2025-03-21 10:40 UTC (permalink / raw)
  To: ffmpeg-devel

Avoids echo failing due to the same ARG_MAX limit that prompted
response files to be used with the linker.
---
 ffbuild/library.mak | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/ffbuild/library.mak b/ffbuild/library.mak
index 7e1871b74c..15302852ec 100644
--- a/ffbuild/library.mak
+++ b/ffbuild/library.mak
@@ -36,7 +36,8 @@ endif
 $(SUBDIR)$(LIBNAME): $(OBJS) $(STLIBOBJS)
 	$(RM) $@
 ifeq ($(AR_OBJS),true)
-	$(Q)echo $^ > $@.objs
+	-$(RM) $@.objs
+	$(Q)$(foreach ARG,$^,echo -n "$(ARG) " >> $@.objs;)
 	$(AR) $(ARFLAGS) $(AR_O) @$@.objs
 else
 	$(AR) $(ARFLAGS) $(AR_O) $^
@@ -73,7 +74,9 @@ $(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
+	-$(RM) $$@.objs
+	$(Q)$(eval LDARGS=$$(filter %.o,$$^))
+	$(Q)$(foreach ARG,$$(LDARGS),echo -n "$(ARG) " >> $$@.objs;)
 	$$(LD) $(SHFLAGS) $(LDFLAGS) $(LDSOFLAGS) $$(LD_O) @$$@.objs $(FFEXTRALIBS)
 else
 	$$(LD) $(SHFLAGS) $(LDFLAGS) $(LDSOFLAGS) $$(LD_O) $$(filter %.o,$$^) $(FFEXTRALIBS)
-- 
2.46.1

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [FFmpeg-devel] [PATCH 2/2] configure: add option to select use of response files
  2025-03-21 10:40 [FFmpeg-devel] [PATCH 1/2] ffbuild: compose linker response files in a loop Gyan Doshi
@ 2025-03-21 10:40 ` Gyan Doshi
  2025-03-21 21:59 ` [FFmpeg-devel] [PATCH 1/2] ffbuild: compose linker response files in a loop Martin Storsjö
  1 sibling, 0 replies; 4+ messages in thread
From: Gyan Doshi @ 2025-03-21 10:40 UTC (permalink / raw)
  To: ffmpeg-devel

---
 configure           | 27 ++++++++++++++++++++-------
 ffbuild/library.mak |  4 ++--
 2 files changed, 22 insertions(+), 9 deletions(-)

diff --git a/configure b/configure
index 14f7bcde0e..863b9adf22 100755
--- a/configure
+++ b/configure
@@ -427,6 +427,8 @@ Toolchain options:
   --enable-thumb           compile for Thumb instruction set
   --enable-lto[=arg]       use link-time optimization
   --env="ENV=override"     override the environment variables
+  --response-files=ARG     Pass list of objects to linker in a file to avoid command line length limits
+                           Valid values are: yes, no, auto(default)
 
 Advanced options (experts only):
   --malloc-prefix=PREFIX   prefix malloc and related names with PREFIX
@@ -4142,6 +4144,7 @@ objformat="elf32"
 x86asmexe_default="nasm"
 windres_default="windres"
 striptype="direct"
+ar_objs_default="auto"
 
 # OS
 target_os_default=$(tolower $(uname -s))
@@ -4438,6 +4441,10 @@ for opt do
         --enable-lto*)
             lto=-f${opt#--enable-}
         ;;
+        --response-files=*)
+            ar_objs=$optval
+            is_in $ar_objs "yes no auto" || die "Invalid value for response-files: $optval; Valid values are: yes, no, or auto"
+        ;;
         --enable-*=*|--disable-*=*)
             eval $(echo "${opt%%=*}" | sed 's/--/action=/;s/-/ thing=/')
             is_in "${thing}s" $COMPONENT_LIST || die_unknown "$opt"
@@ -5187,7 +5194,7 @@ test -n "$cc_type" && enable $cc_type ||
 : ${dep_cc_default:=$cc}
 : ${ld_default:=$cc}
 : ${host_ld_default:=$host_cc}
-set_default ar as objcc dep_cc ld ln_s host_ld windres
+set_default ar as objcc dep_cc ld ln_s host_ld windres ar_objs
 
 probe_cc as "$as"
 asflags_filter=$_flags_filter
@@ -7753,12 +7760,18 @@ case $ld_type in
     ;;
 esac
 
-{
-ar_out=${FFTMPDIR}/test$LIBSUF
-respfile="@/dev/null"
-out_arg="$(echo $ar_o | sed "s;\$@;$ar_out;g")"
-test_cmd $ar $arflags $out_arg $respfile && ar_objs="true" || ar_objs=""
-}
+if [ "$ar_objs" != "no" ]; then
+    ar_out=${FFTMPDIR}/test$LIBSUF
+    respfile="@/dev/null"
+    out_arg="$(echo $ar_o | sed "s;\$@;$ar_out;g")"
+    if test_cmd $ar $arflags $out_arg $respfile; then
+        ar_objs="yes"
+    elif [ "$ar_objs" = "auto" ]; then
+        ar_objs="no"
+    else
+        die "Response files are not available with this toolchain. Exiting"
+    fi
+fi
 
 enable frame_thread_encoder
 
diff --git a/ffbuild/library.mak b/ffbuild/library.mak
index 15302852ec..50a4cf74f2 100644
--- a/ffbuild/library.mak
+++ b/ffbuild/library.mak
@@ -35,7 +35,7 @@ OBJS += $(SHLIBOBJS)
 endif
 $(SUBDIR)$(LIBNAME): $(OBJS) $(STLIBOBJS)
 	$(RM) $@
-ifeq ($(AR_OBJS),true)
+ifeq ($(AR_OBJS),yes)
 	-$(RM) $@.objs
 	$(Q)$(foreach ARG,$^,echo -n "$(ARG) " >> $@.objs;)
 	$(AR) $(ARFLAGS) $(AR_O) @$@.objs
@@ -73,7 +73,7 @@ $(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)
+ifeq ($(AR_OBJS),yes)
 	-$(RM) $$@.objs
 	$(Q)$(eval LDARGS=$$(filter %.o,$$^))
 	$(Q)$(foreach ARG,$$(LDARGS),echo -n "$(ARG) " >> $$@.objs;)
-- 
2.46.1

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [FFmpeg-devel] [PATCH 1/2] ffbuild: compose linker response files in a loop
  2025-03-21 10:40 [FFmpeg-devel] [PATCH 1/2] ffbuild: compose linker response files in a loop Gyan Doshi
  2025-03-21 10:40 ` [FFmpeg-devel] [PATCH 2/2] configure: add option to select use of response files Gyan Doshi
@ 2025-03-21 21:59 ` Martin Storsjö
  2025-03-22  4:33   ` Gyan Doshi
  1 sibling, 1 reply; 4+ messages in thread
From: Martin Storsjö @ 2025-03-21 21:59 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

On Fri, 21 Mar 2025, Gyan Doshi wrote:

> Avoids echo failing due to the same ARG_MAX limit that prompted
> response files to be used with the linker.

I presume this is only a fix for a hypothetical issue, _if_ echo would be 
a native windows executable and not the msys2/cygwin one which bypasses 
the limit?

> ---
> ffbuild/library.mak | 7 +++++--
> 1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/ffbuild/library.mak b/ffbuild/library.mak
> index 7e1871b74c..15302852ec 100644
> --- a/ffbuild/library.mak
> +++ b/ffbuild/library.mak
> @@ -36,7 +36,8 @@ endif
> $(SUBDIR)$(LIBNAME): $(OBJS) $(STLIBOBJS)
> 	$(RM) $@
> ifeq ($(AR_OBJS),true)
> -	$(Q)echo $^ > $@.objs
> +	-$(RM) $@.objs
> +	$(Q)$(foreach ARG,$^,echo -n "$(ARG) " >> $@.objs;)

Does this instance even work, it looks broken, like it is missing 
something?

> 	$(AR) $(ARFLAGS) $(AR_O) @$@.objs
> else
> 	$(AR) $(ARFLAGS) $(AR_O) $^
> @@ -73,7 +74,9 @@ $(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
> +	-$(RM) $$@.objs
> +	$(Q)$(eval LDARGS=$$(filter %.o,$$^))
> +	$(Q)$(foreach ARG,$$(LDARGS),echo -n "$(ARG) " >> $$@.objs;)

Wouldn't this be quite significantly slow on msys2, where process creation 
is much slower than on unix? I think it's not worth to make things that 
much slower (which I only guess here) to fix a hypothetical issue.

// Martin

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [FFmpeg-devel] [PATCH 1/2] ffbuild: compose linker response files in a loop
  2025-03-21 21:59 ` [FFmpeg-devel] [PATCH 1/2] ffbuild: compose linker response files in a loop Martin Storsjö
@ 2025-03-22  4:33   ` Gyan Doshi
  0 siblings, 0 replies; 4+ messages in thread
From: Gyan Doshi @ 2025-03-22  4:33 UTC (permalink / raw)
  To: ffmpeg-devel



On 2025-03-22 03:29 am, Martin Storsjö wrote:
> On Fri, 21 Mar 2025, Gyan Doshi wrote:
>
>> Avoids echo failing due to the same ARG_MAX limit that prompted
>> response files to be used with the linker.
>
> I presume this is only a fix for a hypothetical issue, _if_ echo would 
> be a native windows executable and not the msys2/cygwin one which 
> bypasses the limit?

Yes, trying to address edge cases.

>
>> ---
>> ffbuild/library.mak | 7 +++++--
>> 1 file changed, 5 insertions(+), 2 deletions(-)
>>
>> diff --git a/ffbuild/library.mak b/ffbuild/library.mak
>> index 7e1871b74c..15302852ec 100644
>> --- a/ffbuild/library.mak
>> +++ b/ffbuild/library.mak
>> @@ -36,7 +36,8 @@ endif
>> $(SUBDIR)$(LIBNAME): $(OBJS) $(STLIBOBJS)
>>     $(RM) $@
>> ifeq ($(AR_OBJS),true)
>> -    $(Q)echo $^ > $@.objs
>> +    -$(RM) $@.objs
>> +    $(Q)$(foreach ARG,$^,echo -n "$(ARG) " >> $@.objs;)
>
> Does this instance even work, it looks broken, like it is missing 
> something?

Tested both static and shared building. All working with no noticeable 
speed difference although I didn't formally bench.

Regards,
Gyan


>
>>     $(AR) $(ARFLAGS) $(AR_O) @$@.objs
>> else
>>     $(AR) $(ARFLAGS) $(AR_O) $^
>> @@ -73,7 +74,9 @@ $(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
>> +    -$(RM) $$@.objs
>> +    $(Q)$(eval LDARGS=$$(filter %.o,$$^))
>> +    $(Q)$(foreach ARG,$$(LDARGS),echo -n "$(ARG) " >> $$@.objs;)
>
> Wouldn't this be quite significantly slow on msys2, where process 
> creation is much slower than on unix? I think it's not worth to make 
> things that much slower (which I only guess here) to fix a 
> hypothetical issue.
>
> // Martin
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-03-22  4:33 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-03-21 10:40 [FFmpeg-devel] [PATCH 1/2] ffbuild: compose linker response files in a loop Gyan Doshi
2025-03-21 10:40 ` [FFmpeg-devel] [PATCH 2/2] configure: add option to select use of response files Gyan Doshi
2025-03-21 21:59 ` [FFmpeg-devel] [PATCH 1/2] ffbuild: compose linker response files in a loop Martin Storsjö
2025-03-22  4:33   ` Gyan Doshi

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git