This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
Re: Patch: RFC: make libltdl search for version-specific symlinks first
Hi Tom, hi list,
Thanks for your comments. I have written a revised patch. Please
review it. I have a ChangeLog entry now too.
Michael
2004-09-09 Thomas Fitzsimmons <fitzsim@redhat.com>
Michael Koch <konqueror@gmx.de>
* libltdl/acinclude.m4: Define LTDL_SHLIB_VERSION_EXT
* libltdl/ltdl.c
(ltdlopen_ext): Try to open library with LTDL_SHLIB_VERSION_EXT
first.
* libltdl/config-h.in, libltdl/configure: Regenerated.
Index: libltdl/acinclude.m4
===================================================================
RCS file: /cvs/gcc/gcc/libjava/libltdl/acinclude.m4,v
retrieving revision 1.4.8.1
diff -u -r1.4.8.1 acinclude.m4
--- libltdl/acinclude.m4 24 Jun 2004 05:31:44 -0000 1.4.8.1
+++ libltdl/acinclude.m4 9 Sep 2004 06:47:38 -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.3.16.1
diff -u -r1.3.16.1 config-h.in
--- libltdl/config-h.in 24 Jun 2004 05:31:45 -0000 1.3.16.1
+++ libltdl/config-h.in 9 Sep 2004 06:47:38 -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/configure
===================================================================
RCS file: /cvs/gcc/gcc/libjava/libltdl/configure,v
retrieving revision 1.10.8.1
diff -u -r1.10.8.1 configure
--- libltdl/configure 24 Jun 2004 05:31:46 -0000 1.10.8.1
+++ libltdl/configure 9 Sep 2004 06:47:47 -0000
@@ -19623,6 +19623,12 @@
#define LTDL_SHLIB_EXT "$libltdl_cv_shlibext"
_ACEOF
+ libltdl_cv_shlibversionext=.so.`grep -v '^\#' ${srcdir}/../libtool-version | awk -F: '{ print $'1' }'`
+
+cat >>confdefs.h <<_ACEOF
+#define LTDL_SHLIB_VERSION_EXT "$libltdl_cv_shlibversionext"
+_ACEOF
+
fi
@@ -20453,7 +20459,7 @@
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<EOF
-#line 20456 "configure"
+#line 20462 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
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 9 Sep 2004 06:47:47 -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 SHLIB_VERSION_EXT, ARCHIVE_EXT or SHLIB_EXT
+ extension, try to open the FILENAME as passed. Otherwise try
+ appending SHLIB_VERSION_EXT, and if a file is still not found try
+ again with ARCHIVE_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
))
@@ -3460,6 +3460,24 @@
return lt_dlopen (filename);
}
+#ifdef LTDL_SHLIB_EXT
+ /* Try appending SHLIB_VERSION_EXT. */
+ tmp = LT_EMALLOC (char, len + LT_STRLEN (shlib_version_ext) + 1);
+ if (!tmp)
+ return 0;
+
+ strcpy (tmp, filename);
+ strcat(tmp, shlib_version_ext);
+ errors = try_dlopen (&handle, tmp);
+
+ LT_DLFREE (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 ()))
+ return handle;
+#endif
+
/* First try appending ARCHIVE_EXT. */
tmp = LT_EMALLOC (char, len + LT_STRLEN (archive_ext) + 1);
if (!tmp)