(unknown)

Ileana Dumitrescu <[email protected]> Wed, 20 Nov 2024 10:40:53 -0500 (EST)
Newsgroups gmane.comp.gnu.libtool.cvs
Message-ID <[email protected]>
branch: master
commit eed74d650aecb91f556d52c8d5f4018035daeb16
Author: Martin Storsjö <[email protected]>
AuthorDate: Wed Oct 10 10:47:21 2018 +0300

    libtool: 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.
    
    * build-aux/ltmain.in: Move creation of ld script.
    * m4/libtool.m4: Add new variable tag for file_list_spec.
    * NEWS: Update.
---
 NEWS                |  3 +++
 build-aux/ltmain.in | 28 ++++++++++++++--------------
 m4/libtool.m4       |  2 ++
 3 files changed, 19 insertions(+), 14 deletions(-)

diff --git a/NEWS b/NEWS
index ab986ba0..96b79902 100644
--- a/NEWS
+++ b/NEWS
@@ -23,6 +23,9 @@ NEWS - list of user-visible changes between releases of GNU Libtool
 
   - Fix path comparison by removing trailing slashes on install commands.
 
+  - Fix linking for mingw with lld by prefering response files over the
+    linker script.
+
 ** Changes in supported systems or compilers:
 
   - Support additional flang-based compilers, 'f18' and 'f95'.
diff --git a/build-aux/ltmain.in b/build-aux/ltmain.in
index be94b032..83aaaf92 100644
--- a/build-aux/ltmain.in
+++ b/build-aux/ltmain.in
@@ -7937,20 +7937,7 @@ func_mode_link ()
 	  last_robj=
 	  k=1
 
-	  if test -n "$save_libobjs" && test : != "$skipped_export" && test yes = "$with_gnu_ld"; 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 : != "$skipped_export" && test -n "$file_list_spec"; then
+	  if test -n "$save_libobjs" && test : != "$skipped_export" && test -n "$file_list_spec"; then
 	    output=$output_objdir/$output_la.lnk
 	    func_verbose "creating linker input file list: $output"
 	    : > $output
@@ -7969,6 +7956,19 @@ func_mode_link ()
 	    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 : != "$skipped_export" && test yes = "$with_gnu_ld"; 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/m4/libtool.m4 b/m4/libtool.m4
index 0a9c9afa..d0d36865 100644
--- a/m4/libtool.m4
+++ b/m4/libtool.m4
@@ -5204,6 +5204,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'
@@ -6781,6 +6782,7 @@ if test yes != "$_lt_caught_CXX_error"; 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'