libtool-patches
[Top][All Lists]
Advanced

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

Re: [PATCH] Allow dlopen self test to work with gcc's -fvisibility=hidde


From: Ralf Wildenhues
Subject: Re: [PATCH] Allow dlopen self test to work with gcc's -fvisibility=hidden.
Date: Tue, 8 Sep 2009 07:38:47 +0200
User-agent: Mutt/1.5.20 (2009-08-09)

* Peter O'Gorman wrote on Mon, Sep 07, 2009 at 11:16:05PM CEST:
> Ralf Wildenhues wrote:
> 
> > No, it must have been earlier.  gcc-3.3 (Debian 3.3.6-15) accepts it,
> > gcc-2.95.4 rejects it.
> 
> Ah, ok - this is it?
> 
> 2002-11-26  Richard Henderson  <address@hidden>
> 
>         * c-common.c (handle_visibility_attribute): Accept "default".

Yes, I think so.  That would indicate that 3.3 is the first version to
have it, given the GCC timeline.  So, based on that, ok to apply this
instead?

Thanks,
Ralf

    Allow dlopen self test to work with gcc's -fvisibility=hidden.
    
    * libltdl/m4/libtool.m4 (_LT_TRY_DLOPEN_SELF): Declare default
    visibility for the symbol we are going to test dlopen (NULL)
    when a GCC version is used that understands the visibility
    attribute, under the assumption that if -fvisibility=hidden
    will be used, the user code will be sufficiently annotated
    for visibility of needed symbols from the main executable.
    * THANKS: Update.
    Report by Jost Hursey against OpenMPI.

diff --git a/libltdl/m4/libtool.m4 b/libltdl/m4/libtool.m4
index bb1097f..662a88b 100644
--- a/libltdl/m4/libtool.m4
+++ b/libltdl/m4/libtool.m4
@@ -1651,7 +1651,13 @@ else
 #  endif
 #endif
 
-void fnord() { int i=42;}
+/* When -fvisbility=hidden is used, assume the code has been annotated
+   correspondingly for the symbols needed.  */
+#if defined(__GNUC__) && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || 
(__GNUC__ > 3))
+void fnord () __attribute__((visibility("default")));
+#endif
+
+void fnord () { int i=42; }
 int main ()
 {
   void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW);
@@ -1660,7 +1666,11 @@ int main ()
   if (self)
     {
       if (dlsym (self,"fnord"))       status = $lt_dlno_uscore;
-      else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore;
+      else
+        {
+         if (dlsym( self,"_fnord"))  status = $lt_dlneed_uscore;
+          else puts (dlerror ());
+       }
       /* dlclose (self); */
     }
   else




reply via email to

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