GNOME Bugzilla – Bug 139567
Detection of RTLD_GLOBAL is broken
Last modified: 2011-02-18 16:07:46 UTC
The configure script has a check to see if RTLD_GLOBAL works properly or not. This check does not work, because it detects that RTLD_GLOBAL doesn't work properly under NetBSD, while it does. The problems of this are exposed later in other libraries using glib (specially, I got crazy to see why gstreamer did not work at all on my computer). Why the check breaks... well, it uses libpthread.so as a test case. In NetBSD, this library can't be loaded at runtime by a non-threaded application. That is, if you have a program that's not linked with libpthread, opening a module at runtime that uses it results in a coredump. This is because the program startup code is different for threaded applications. So, the check in configure breaks, and glib is built without RTLD_GLOBAL support (a thing that you won't notice until it's very late). Eww. I've fixed it by changing the check to use 'libintl' as a test case (which is required anyway by glib). It works. This is what has been done in pkgsrc (the NetBSD packaging system) to fix this issue: http://mail-index.netbsd.org/pkgsrc-changes/2004/04/06/0004.html The attached patch does the same. Furthermore, it could be a good idea to show a big warning from glib when a program tries to g_module_load a library with global binding, if it's not available (because the application won't work, probably).
Created attachment 26514 [details] [review] Sample patch
The problem with this approach is that libintl is not actually required by glib on all platforms. This linux box doesn't have it, for example, since gnu libc includes the gettext functionality...
Ew... so which library could be a good candidate for testing? Another approach could be to build a loadable plugin from the configure script, and then use that to do the dlopen test... It seems that libtool is already available at that point, so the plugin could be built in a portable way.
I don't know a good candidate. Building a small test library just for the test might be the best option, but it is a bit more work, of course...and you'll have to deal with locating the uninstalled library.
Created attachment 27308 [details] [review] Patch that creates a test library This patch creates a small plugin (using libtool) to issue the RTLD_GLOBAL test. Don't know if it's completely right... but works :P