PATCH: Fix libtool with linking against archive

H . J . Lu hjl@lucon.org
Mon Oct 22 11:51:00 GMT 2001


Here is a patch for binutils to fix linking against an archive when
building a shared library. It is complete bogus to put

dependency_libs='-L..... -lfoo"

in *.la for libfoo.a when building a shared library. I checked out
libtool from CVS. But libtool.m4 is very different from the one
in binutils so that I couldn't provide a patch.


H.J.
-----
2001-10-22  H.J. Lu <hjl@gnu.org>

	* ltmain.sh: Allow link against an archive when building a
	shared library.

	* libtool.m4 (lt_cv_deplibs_check_method): Always use
	file_magic for Linux ELF.

Index: libtool.m4
===================================================================
RCS file: /work/cvs/gnu/binutils/libtool.m4,v
retrieving revision 1.1.1.7
retrieving revision 1.4
diff -u -p -r1.1.1.7 -r1.4
--- libtool.m4	2001/05/21 17:33:45	1.1.1.7
+++ libtool.m4	2001/10/22 16:57:57	1.4
@@ -596,13 +596,7 @@ irix5* | irix6*)
 
 # This must be Linux ELF.
 linux-gnu*)
-  case $host_cpu in
-  alpha* | hppa* | i*86 | powerpc* | sparc* | ia64* )
-    lt_cv_deplibs_check_method=pass_all ;;
-  *)
-    # glibc up to 2.1.1 does not perform some relocations on ARM
-    lt_cv_deplibs_check_method=['file_magic ELF [0-9][0-9]*-bit [LM]SB (shared object|dynamic lib )'] ;;
-  esac
+  lt_cv_deplibs_check_method=['file_magic ELF [0-9][0-9]*-bit [LM]SB (shared object|dynamic lib )']
   lt_cv_file_magic_test_file=`echo /lib/libc.so* /lib/libc-*.so`
   ;;
 
Index: ltmain.sh
===================================================================
RCS file: /work/cvs/gnu/binutils/ltmain.sh,v
retrieving revision 1.17
retrieving revision 1.19
diff -u -p -r1.17 -r1.19
--- ltmain.sh	2001/06/02 04:47:07	1.17
+++ ltmain.sh	2001/10/22 16:57:57	1.19
@@ -2890,6 +2890,13 @@ EOF
 			*) potlib=`$echo "X$potlib" | $Xsed -e 's,[^/]*$,,'`"$potliblink";;
 			esac
 		      done
+		      # It is ok to link against an archive when
+		      # building a shared library.
+		      if $AR -t $potlib > /dev/null 2>&1; then
+			newdeplibs="$newdeplibs $a_deplib"
+			a_deplib=""
+			break 2
+		      fi
 		      if eval $file_magic_cmd \"\$potlib\" 2>/dev/null \
 			 | sed 10q \
 			 | egrep "$file_magic_regex" > /dev/null; then



More information about the Binutils mailing list