bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Relocation patch for cygwin


From: Bruno Haible
Subject: Re: Relocation patch for cygwin
Date: Mon, 3 Oct 2011 13:26:31 +0200
User-agent: KMail/1.13.6 (Linux/2.6.37.6-0.5-desktop; KDE/4.6.0; x86_64; ; )

Charles Wilson wrote:
> On 9/26/2011 6:00 PM, Bruno Haible wrote:
> > It is normal that --enable-relocatable has a runtime cost. Certainly when
> > you apply --enable-relocatable to small, fast programs like 'id' or 'pwd'
> > the runtime cost will be more perceivable than with programs which run
> > for longer than 1 second on average, such as 'emacs' or 'm4'.
> 
> On 9/26/2011 1:30 AM, jojolino wrote:
> > there is '-DENABLE_RELOCATABLE=1' in
> > http://git.savannah.gnu.org/cgit/gettext.git/tree/gettext-runtime/intl/Makefile.in
> > which cannot be affected by `--enable-relocation`.
> 
> Shouldn't the value of ENABLE_RELOCATABLE depend on whether
> --enable-relocatable was used?

The value of ENABLE_RELOCATABLE is 1 in libintl because I want the public API
(list of exported symbols) to be independent of the configure options.

But jojolino has a point about the speed: I measure 0.3 ms for consuming
/proc/self/maps on Linux, and 3 ms or 5 ms on Cygwin 1.5 and Cygwin 1.7
respectively (on a slower machine).

And you have a point, that this stuff is usually not needed on Cygwin, because
libintl is part of the standard Cygwin distribution and therefore people rarely
need to package it inside relocatable packages.

I'm applying this change to gnulib, from where it will propagate to libiconv
and libintl.

Only it's a pity that you gave me the advice to use Cygwin's /proc/self/maps,
which I did [2], and now we discover that it is much slower than the Win32
API calls that I had originally.

[1] http://cygwin.com/ml/cygwin/2011-01/msg00410.html
[2] 
http://git.savannah.gnu.org/gitweb/?p=gnulib.git;a=commitdiff;h=b8d53f77acf1ed08ba808014e534e07c9dd40daf


2011-10-03  Bruno Haible  <address@hidden>

        relocatable-lib[-lgpl]: Avoid expensive /proc access on Linux, Cygwin.
        * lib/relocatable.c (ENABLE_COSTLY_RELOCATABLE): New macro.
        (compute_curr_prefix, shared_library_fullname,
        find_shared_library_fullname, get_shared_library_fullname, relocate):
        Use it together with PIC && INSTALLDIR.
        Reported by <address@hidden>
        via Charles Wilson <address@hidden>.

--- lib/relocatable.c.orig      Mon Oct  3 12:54:27 2011
+++ lib/relocatable.c   Mon Oct  3 12:53:22 2011
@@ -85,6 +85,19 @@
 # define FILE_SYSTEM_PREFIX_LEN(P) 0
 #endif
 
+/* Whether to enable the more costly support for relocatable libraries.
+   It allows libraries to be have been installed with a different original
+   prefix than the program.  But it is quite costly, especially on Cygwin
+   platforms, see below.  Therefore we enable it by default only on native
+   Win32 platforms.  */
+#ifndef ENABLE_COSTLY_RELOCATABLE
+# if (defined _WIN32 || defined __WIN32__) && !defined __CYGWIN__
+#  define ENABLE_COSTLY_RELOCATABLE 1
+# else
+#  define ENABLE_COSTLY_RELOCATABLE 0
+# endif
+#endif
+
 /* Original installation prefix.  */
 static char *orig_prefix;
 static size_t orig_prefix_len;
@@ -154,7 +167,7 @@
 #endif
 }
 
-#if !defined IN_LIBRARY || (defined PIC && defined INSTALLDIR)
+#if !defined IN_LIBRARY || (defined PIC && defined INSTALLDIR && 
ENABLE_COSTLY_RELOCATABLE)
 
 /* Convenience function:
    Computes the current installation prefix, based on the original
@@ -284,7 +297,7 @@
 
 #endif /* !IN_LIBRARY || PIC */
 
-#if defined PIC && defined INSTALLDIR
+#if defined PIC && defined INSTALLDIR && ENABLE_COSTLY_RELOCATABLE
 
 /* Full pathname of shared library, or NULL.  */
 static char *shared_library_fullname;
@@ -330,7 +343,9 @@
 #if (defined __linux__ && (__GLIBC__ >= 2 || defined __UCLIBC__)) || defined 
__CYGWIN__
   /* Linux has /proc/self/maps. glibc 2 and uClibc have the getline()
      function.
-     Cygwin >= 1.5 has /proc/self/maps and the getline() function too.  */
+     Cygwin >= 1.5 has /proc/self/maps and the getline() function too.
+     But it is costly: ca. 0.3 ms on Linux, 3 ms on Cygwin 1.5, and 5 ms on
+     Cygwin 1.7.  */
   FILE *fp;
 
   /* Open the current process' maps file.  It describes one VMA per line.  */
@@ -403,7 +418,7 @@
 const char *
 relocate (const char *pathname)
 {
-#if defined PIC && defined INSTALLDIR
+#if defined PIC && defined INSTALLDIR && ENABLE_COSTLY_RELOCATABLE
   static int initialized;
 
   /* Initialization code for a shared library.  */



reply via email to

[Prev in Thread] Current Thread [Next in Thread]