GNOME Bugzilla – Bug 707298
libgobject should be linked with -Wl,-z,nodelete
Last modified: 2014-04-10 06:02:03 UTC
See https://bugzilla.gnome.org/show_bug.cgi?id=705535#c4 : > we haven't supported unloading libgobject for a *long* while. the type system > itself does not support reloading its data, and code assumes that types will > survive for the entire duration of the process life time. Since some non-Gnome-ecosystem applications like vlc do currently attempt to unload libgobject (because the main executable doesn't link to libgobject, but some of its plugins do indirectly link to it) and therefore segfault when using glib-2.36 or newer, we should try building libgobject with the -z,nodelete flag if available, indicating that the library, once loaded, should not be unloaded at runtime.
Created attachment 253875 [details] [review] proposed patch
The config check for this option is less than awesome. I modified it, introducing a typo, to test if it is working properly, and it's not. The log says this: /usr/bin/ld: warning: -z nodelet ignored. but the check comes back positive... I guess in a sense, that's sort of successful -- the build didn't fail. Would be nice if we could find a better check, though.
I copied the same check that glib's configure already uses to check for -Wl,-Bsymbolic-functions when setting GLIB_LINK_FLAGS. If it doesn't work, it ought to be fixed there too.
The difference between the two checks is that ld ignores unknown -z flags, but doesn't ignore completely unknown flags (like if -Bsymbolic-functions) did not exist. compare: [desrt@moonpix src]$ ld -z nodele ld: warning: -z nodele ignored. [desrt@moonpix src]$ ld -Bsymbolic-foo ld: unrecognized option '-Bsymbolic-foo' ld: use the --help option for usage information This is maybe slightly academic because we're testing the behaviour of a version of ld that already accepts -z nodelete (and others that don't know this flag very well may error out entirely), but I'd still feel better if we had a check that actually failed on unknown flags instead of proceeding as if they were supported.
Created attachment 256196 [details] [review] proposed patch, v2 OK, second try: check for -Wl,-z,nodelete using -Wl,--fatal-warnings. Of course, there is no way to know whether random non-gnu linkers will have the --fatal-warnings option, but at least this should detect any gnu ld.bfd releases that for whatever reason do not support -z nodelete.
Review of attachment 256196 [details] [review]: Thanks for the patch. Please commit.
Committed to master and glib-2-40 branch: https://git.gnome.org/browse/glib/commit/?id=2b178c762fbc0706031e9890ba190233e243a602 and https://git.gnome.org/browse/glib/commit/?h=glib-2-40&id=3662eb9759fe225d1c214db6927c667a1b733e8a