]> git.ipfire.org Git - thirdparty/libtool.git/commitdiff
ltmain.in: Fix reordering --as-needed
authorPierre Ossman <ossman@cendio.se>
Tue, 1 Apr 2025 13:44:51 +0000 (16:44 +0300)
committerIleana Dumitrescu <ileanadumitrescu95@gmail.com>
Thu, 7 Aug 2025 17:20:19 +0000 (20:20 +0300)
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

index 1417745cf17bc091b77d32031124841ea46a24dd..294ed43c31e4018608c959c3bbdac320e18c466f 100644 (file)
@@ -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