[vlc-devel] [PATCH 3.0 03/17] extras/tools: Add another libtool patch for building with lld on windows

Steve Lhomme robux4 at ycbcr.xyz
Fri Mar 27 16:57:05 CET 2020


From: Martin Storsjö <martin at martin.st>

On Windows, the maximum command line length is rather low; linking
libqt_plugin.la will reach this limit (but this seems to currently be
the only module linked which reaches the limit). In these cases, instead
of passing the list of object files to link on the command line, the list
is passed via a file. GCC/GNU ld supports both a response file and linker
scripts, while clang/lld only supports response files. This patch
reverses the priority between the two, by preferring response files.

This patch is included in the libtool package in msys2, which can be
considered some sort of active upstream.

(cherry picked from commit 1c738deebab7ef262341d3e37e8eaff093981390)
---
 .../tools/libtool-2.4.2-response-files.patch  | 83 +++++++++++++++++++
 extras/tools/tools.mak                        |  1 +
 2 files changed, 84 insertions(+)
 create mode 100644 extras/tools/libtool-2.4.2-response-files.patch

diff --git a/extras/tools/libtool-2.4.2-response-files.patch b/extras/tools/libtool-2.4.2-response-files.patch
new file mode 100644
index 0000000000..d85aceaecd
--- /dev/null
+++ b/extras/tools/libtool-2.4.2-response-files.patch
@@ -0,0 +1,83 @@
+From 5fe8ae738927cd2c7e6d786b359e39876c84630c Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Martin=20Storsj=C3=B6?= <martin at martin.st>
+Date: Wed, 10 Oct 2018 10:47:21 +0300
+Subject: [PATCH] Prefer response files over linker scripts for mingw tools
+
+The GCC/binutils tools support response files just fine, while
+lld (impersonating GNU ld) only supports response files, not
+linker scripts. Using a linker script as input just to pass a
+list of files is overkill for cases when a response file is enough.
+---
+ libltdl/config/ltmain.m4sh | 28 ++++++++++++++--------------
+ libltdl/m4/libtool.m4      |  2 ++
+ 2 files changed, 16 insertions(+), 14 deletions(-)
+
+diff --git a/libltdl/config/ltmain.m4sh b/libltdl/config/ltmain.m4sh
+index 2641327..f6b4217 100644
+--- a/libltdl/config/ltmain.m4sh
++++ b/libltdl/config/ltmain.m4sh
+@@ -7545,20 +7545,7 @@ EOF
+ 	  last_robj=
+ 	  k=1
+ 
+-	  if test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "$with_gnu_ld" = yes; then
+-	    output=${output_objdir}/${output_la}.lnkscript
+-	    func_verbose "creating GNU ld script: $output"
+-	    echo 'INPUT (' > $output
+-	    for obj in $save_libobjs
+-	    do
+-	      func_to_tool_file "$obj"
+-	      $ECHO "$func_to_tool_file_result" >> $output
+-	    done
+-	    echo ')' >> $output
+-	    func_append delfiles " $output"
+-	    func_to_tool_file "$output"
+-	    output=$func_to_tool_file_result
+-	  elif test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "X$file_list_spec" != X; then
++	  if test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "X$file_list_spec" != X; then
+ 	    output=${output_objdir}/${output_la}.lnk
+ 	    func_verbose "creating linker input file list: $output"
+ 	    : > $output
+@@ -7577,6 +7564,19 @@ EOF
+ 	    func_append delfiles " $output"
+ 	    func_to_tool_file "$output"
+ 	    output=$firstobj\"$file_list_spec$func_to_tool_file_result\"
++	  elif test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "$with_gnu_ld" = yes; then
++	    output=${output_objdir}/${output_la}.lnkscript
++	    func_verbose "creating GNU ld script: $output"
++	    echo 'INPUT (' > $output
++	    for obj in $save_libobjs
++	    do
++	      func_to_tool_file "$obj"
++	      $ECHO "$func_to_tool_file_result" >> $output
++	    done
++	    echo ')' >> $output
++	    func_append delfiles " $output"
++	    func_to_tool_file "$output"
++	    output=$func_to_tool_file_result
+ 	  else
+ 	    if test -n "$save_libobjs"; then
+ 	      func_verbose "creating reloadable object files..."
+diff --git a/libltdl/m4/libtool.m4 b/libltdl/m4/libtool.m4
+index 6f93d32..2c5c2f0 100644
+--- a/libltdl/m4/libtool.m4
++++ b/libltdl/m4/libtool.m4
+@@ -4750,6 +4750,7 @@ _LT_EOF
+       _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
+       _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1 DATA/;s/^.*[[ ]]__nm__\([[^ ]]*\)[[ ]][[^ ]]*/\1 DATA/;/^I[[ ]]/d;/^[[AITW]][[ ]]/s/.* //'\'' | sort | uniq > $export_symbols'
+       _LT_TAGVAR(exclude_expsyms, $1)=['[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname']
++      _LT_TAGVAR(file_list_spec, $1)='@'
+ 
+       if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then
+         _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+@@ -6166,6 +6167,7 @@ if test "$_lt_caught_CXX_error" != yes; then
+ 	  _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
+ 	  _LT_TAGVAR(always_export_symbols, $1)=no
+ 	  _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
++	  _LT_TAGVAR(file_list_spec, $1)='@'
+ 
+ 	  if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then
+ 	    _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+-- 
+2.7.4
+
diff --git a/extras/tools/tools.mak b/extras/tools/tools.mak
index 1d058f521b..0ed5701c74 100644
--- a/extras/tools/tools.mak
+++ b/extras/tools/tools.mak
@@ -104,6 +104,7 @@ libtool: libtool-$(LIBTOOL_VERSION).tar.gz
 	$(APPLY) libtool-2.4.2-bitcode.patch
 	$(APPLY) libtool-2.4.2-san.patch
 	$(APPLY) libtool-2.4.6-clang-libs.patch
+	$(APPLY) libtool-2.4.2-response-files.patch
 	$(MOVE)
 
 .libtool: libtool .automake
-- 
2.17.1



More information about the vlc-devel mailing list