Hello, What do you think of this patch as a fix for <http://www.open-mpi.org/community/lists/devel/2009/08/6590.php>?
The critical point here being of course, that if the end-user adds -fvisibility=hidden to CFLAGS, then the package author would have had to take care of annotating all needed symbols properly with __attribute__((visibility("default"))) I'm not sure what would be a good alternative way for the developer to specify "you can use hidden visibility with this program". Other than that, I have no idea when GCC introduced the visibility attribute (didn't find any changes web sites older than <http://gcc.gnu.org/gcc-3.1/changes.html>) so the 3.0 border is merely a guess. Does anybody know better? OK to apply (and add Josh to THANKS)? 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 Josh Hursey against OpenMPI. diff --git a/libltdl/m4/libtool.m4 b/libltdl/m4/libtool.m4 index bff1218..eebe990 100644 --- a/libltdl/m4/libtool.m4 +++ b/libltdl/m4/libtool.m4 @@ -1624,7 +1624,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) +void fnord () __attribute__((visibility("default"))); +#endif + +void fnord () { int i=42;} int main () { void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); @@ -1633,7 +1639,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