This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch] search for versioned shared libraries


Hi,

This patch makes libltdl search for versioned .sos in addition to .la
and unversioned .so files.  The search order
is .la, .so.${libgcj_major_version}, .so.  This search order is useful
when multiple versions of the same .so are installed in the same place.
The unversioned .la file can be removed and the proper library will
always be resolved.

Also, there was a Makefile.am bug that prevented libgcj.so from being
linked when libltdl was modified.  I've included a fix in this patch.

OK to commit?

Tom

2005-03-15  Thomas Fitzsimmons  <fitzsim@redhat.com>

	* Makefile.am (libgcj_la_DEPENDENCIES): Add LIBLTDL.
	* Makefile.in: Regenerate.
	* aclocal.m4: Regenerate.
	* external/Makefile.in: Regenerate.
	* external/sax/Makefile.in: Regenerate.
	* external/w3c_dom/Makefile.in: Regenerate.
	* gcj/Makefile.in: Regenerate.
	* include/Makefile.in: Regenerate.
	* testsuite/Makefile.in: Regenerate.

2005-03-11  Thomas Fitzsimmons  <fitzsim@redhat.com>

	* ltdl.c (shlib_version_ext): Define.
	(tryall_dlopen): Uncomment access check.
	(lt_dlopenext): Check for shlib_version_ext.

	* Makefile.in: Regenerate.
	* acinclude.m4 (LTDL_SHLIB_VERSION_EXT): Define.
	* aclocal.m4: Regenerate.
	* config-h.in (LTDL_SHLIB_VERSION_EXT): Define.
	* configure: Regenerate.

Index: Makefile.am
===================================================================
RCS file: /cvs/gcc/gcc/libjava/Makefile.am,v
retrieving revision 1.461
diff -u -r1.461 Makefile.am
--- Makefile.am	11 Mar 2005 17:35:30 -0000	1.461
+++ Makefile.am	15 Mar 2005 22:27:27 -0000
@@ -257,7 +257,7 @@
 	$(LIBFFI) $(ZLIBS) $(GCLIBS) $(propertyo_files)
 libgcj_la_DEPENDENCIES = libgcj-@gcc_version@.jar \
 	java/lang/fdlibm.h java/lang/ieeefp.h java/lang/mprec.h \
-	$(libgcj_la_LIBADD)
+	$(LIBLTDL) $(libgcj_la_LIBADD)
 libgcj_la_LINK = $(LIBLINK)
 
 
Index: libltdl/acinclude.m4
===================================================================
RCS file: /cvs/gcc/gcc/libjava/libltdl/acinclude.m4,v
retrieving revision 1.5
diff -u -r1.5 acinclude.m4
--- libltdl/acinclude.m4	3 May 2004 20:48:13 -0000	1.5
+++ libltdl/acinclude.m4	15 Mar 2005 22:27:41 -0000
@@ -6091,6 +6091,9 @@
 if test -n "$libltdl_cv_shlibext"; then
   AC_DEFINE_UNQUOTED(LTDL_SHLIB_EXT, "$libltdl_cv_shlibext",
     [Define to the extension used for shared libraries, say, ".so".])
+  libltdl_cv_shlibversionext=.so.`grep -v '^\#' ${srcdir}/../libtool-version | awk -F: '{ print $'1' }'`
+  AC_DEFINE_UNQUOTED(LTDL_SHLIB_VERSION_EXT, "$libltdl_cv_shlibversionext",
+    [Define to the versioned extension used for shared libraries, say, ".so.5".])
 fi
 ])# AC_LTDL_SHLIBEXT
 
Index: libltdl/config-h.in
===================================================================
RCS file: /cvs/gcc/gcc/libjava/libltdl/config-h.in,v
retrieving revision 1.4
diff -u -r1.4 config-h.in
--- libltdl/config-h.in	11 Mar 2004 00:27:37 -0000	1.4
+++ libltdl/config-h.in	15 Mar 2005 22:27:41 -0000
@@ -158,6 +158,10 @@
 /* Define to the extension used for shared libraries, say, ".so". */
 #undef LTDL_SHLIB_EXT
 
+/* Define to the versioned extension used for shared libraries, say, ".so.5".
+   */
+#undef LTDL_SHLIB_VERSION_EXT
+
 /* Define to the system default library search path. */
 #undef LTDL_SYSSEARCHPATH
 
Index: libltdl/ltdl.c
===================================================================
RCS file: /cvs/gcc/gcc/libjava/libltdl/ltdl.c,v
retrieving revision 1.7
diff -u -r1.7 ltdl.c
--- libltdl/ltdl.c	25 Dec 2003 19:33:06 -0000	1.7
+++ libltdl/ltdl.c	15 Mar 2005 22:27:43 -0000
@@ -859,6 +859,7 @@
 static	const char	objdir[]		= LTDL_OBJDIR;
 static	const char	archive_ext[]		= LTDL_ARCHIVE_EXT;
 #ifdef	LTDL_SHLIB_EXT
+static	const char	shlib_version_ext[]	= LTDL_SHLIB_VERSION_EXT;
 static	const char	shlib_ext[]		= LTDL_SHLIB_EXT;
 #endif
 #ifdef	LTDL_SYSSEARCHPATH
@@ -2388,17 +2389,14 @@
   cur = *handle;
   if (filename)
     {
-      /* Comment out the check of file permissions using access.
-	 This call seems to always return -1 with error EACCES.
-      */
       /* We need to catch missing file errors early so that
-	 file_not_found() can detect what happened.
+	 file_not_found() can detect what happened. */
       if (access (filename, R_OK) != 0)
 	{
 	  LT_DLMUTEX_SETERROR (LT_DLSTRERROR (FILE_NOT_FOUND));
 	  ++errors;
 	  goto done;
-	} */
+	}
 
       cur->info.filename = lt_estrdup (filename);
       if (!cur->info.filename)
@@ -3425,10 +3423,11 @@
   return 0;
 }
 
-/* If FILENAME has an ARCHIVE_EXT or SHLIB_EXT extension, try to
-   open the FILENAME as passed.  Otherwise try appending ARCHIVE_EXT,
-   and if a file is still not found try again with SHLIB_EXT appended
-   instead.  */
+/* If FILENAME has an ARCHIVE_EXT, SHLIB_VERSION_EXT or SHLIB_EXT
+   extension, try to open the FILENAME as passed.  Otherwise try
+   appending ARCHIVE_EXT, and if a file is still not found try again
+   with SHLIB_VERSION_EXT appended.  If the file is still not found,
+   try again with SHLIB_EXT appended.  */
 lt_dlhandle
 lt_dlopenext (filename)
      const char *filename;
@@ -3453,6 +3452,7 @@
      to try appending additional extensions.  */
   if (ext && ((strcmp (ext, archive_ext) == 0)
 #ifdef LTDL_SHLIB_EXT
+	      || (strcmp (ext, shlib_version_ext) == 0)
 	      || (strcmp (ext, shlib_ext) == 0)
 #endif
       ))
@@ -3481,8 +3481,34 @@
     }
 
 #ifdef LTDL_SHLIB_EXT
+  /* Try appending SHLIB_VERSION_EXT.   */
+  if (LT_STRLEN (shlib_version_ext) > LT_STRLEN (archive_ext))
+    {
+      LT_DLFREE (tmp);
+      tmp = LT_EMALLOC (char, len + LT_STRLEN (shlib_version_ext) + 1);
+      if (!tmp)
+	return 0;
+
+      strcpy (tmp, filename);
+    }
+  else
+    {
+      tmp[len] = LT_EOS_CHAR;
+    }
+
+  strcat(tmp, shlib_version_ext);
+  errors = try_dlopen (&handle, tmp);
+
+  /* As before, if the file was found but loading failed, return now
+     with the current error message.  */
+  if (handle || ((errors > 0) && !file_not_found ()))
+    {
+      LT_DLFREE (tmp);
+      return handle;
+    }
+
   /* Try appending SHLIB_EXT.   */
-  if (LT_STRLEN (shlib_ext) > LT_STRLEN (archive_ext))
+  if (LT_STRLEN (shlib_ext) > LT_STRLEN (shlib_version_ext))
     {
       LT_DLFREE (tmp);
       tmp = LT_EMALLOC (char, len + LT_STRLEN (shlib_ext) + 1);

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]