(unknown)

Ileana Dumitrescu <[email protected]> Thu, 7 Aug 2025 15:03:27 -0400 (EDT)
Newsgroups gmane.comp.gnu.libtool.cvs
Message-ID <[email protected]>
branch: master
commit c69efe983d0edbee2b0528d2012e4016d628f362
Author: Pierre Ossman <[email protected]>
AuthorDate: Tue Apr 1 16:44:51 2025 +0300

    ltmain.in: Fix reordering --as-needed
    
    Libtool was reordering flags like, --as-needed, which broke its usage,
    since the relevant libraries were no longer following the flag.
    
    Reported: https://savannah.gnu.org/support/?111213
    
    * build-aux/ltmain.in: Add check for --as-needed and --no-as-needed
      flags.
---
 build-aux/ltmain.in | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/build-aux/ltmain.in b/build-aux/ltmain.in
index 1417745c..294ed43c 100644
--- a/build-aux/ltmain.in
+++ b/build-aux/ltmain.in
@@ -5580,6 +5580,11 @@ func_mode_link ()
 	arg=$func_stripname_result
 	;;
 
+	-Wl,--as-needed|-Wl,--no-as-needed)
+	deplibs="$deplibs $arg"
+	continue
+	;;
+
       -Wl,*)
 	func_stripname '-Wl,' '' "$arg"
 	args=$func_stripname_result
@@ -6008,6 +6013,15 @@ func_mode_link ()
 	lib=
 	found=false
 	case $deplib in
+	-Wl,--as-needed|-Wl,--no-as-needed)
+	   if test prog,link = "$linkmode,$pass"; then
+         compile_deplibs="$deplib $compile_deplibs"
+         finalize_deplibs="$deplib $finalize_deplibs"
+       else
+         deplibs="$deplib $deplibs"
+       fi
+       continue
+       ;;
 	-mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \
         |-threads|-fopenmp|-fopenmp=*|-openmp|-mp|-xopenmp|-omp|-qsmp=*)
 	  if test prog,link = "$linkmode,$pass"; then