This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
Patch: RFC: make libltdl search for version-specific symlinks first
- From: Thomas Fitzsimmons <fitzsim at redhat dot com>
- To: java-patches at gcc dot gnu dot org
- Date: Mon, 23 Aug 2004 13:10:47 -0400
- Subject: Patch: RFC: make libltdl search for version-specific symlinks first
Hi,
This patch makes libltdl search for a version-specific DSO before
searching for the corresponding versionless DSO. This will allow
multiple ABI-incompatible versions of libgcj to be installed in parallel
in the same prefix. Currently, this isn't possible because libltdl
finds only the versionless .so symlink, so only the most
recently-installed libgcj will find the correct version of the peer
library.
Currently, libltdl searches for the peer library like this: first it
looks for lib-gnu-java-awt-peer-gtk.la. Failing that, it looks for
lib-gnu-java-awt-peer-gtk.so. This patch adds an intermediate search
for lib-gnu-java-awt-peer-gtk.so.n, where n is the ABI version number.
Comments?
Tom
diff -ru -x configure -x config-h.in -x aclocal.m4 -x Makefile.in libltdl.orig/acinclude.m4 libltdl/acinclude.m4
--- libltdl.orig/acinclude.m4 2004-08-20 17:52:29.000000000 -0400
+++ libltdl/acinclude.m4 2004-08-20 21:56:21.000000000 -0400
@@ -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
Only in libltdl: autom4te.cache
diff -ru -x configure -x config-h.in -x aclocal.m4 -x Makefile.in libltdl.orig/ltdl.c libltdl/ltdl.c
--- libltdl.orig/ltdl.c 2004-08-20 17:52:29.000000000 -0400
+++ libltdl/ltdl.c 2004-08-21 00:18:50.000000000 -0400
@@ -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);