GNOME Bugzilla – Bug 791100
Allow static build of modules
Last modified: 2018-01-04 22:33:17 UTC
Once bug #684282 gets fixed, we should rename g_io_module_load/unload/query so they can be statically linked.
Created attachment 364784 [details] [review] gnutls: Allow static build
Created attachment 364785 [details] [review] gnutls: Allow static build
glib-networking is now meson only, so something needs to be done in meson to allow static build of modules. I'm not sure what's the difference between shared_module() and shared_library(), maybe something similar to https://github.com/mesonbuild/meson/pull/2711 will be needed.
Created attachment 364789 [details] [review] Allow static build of modules To be able to static link all modules into an executable, g_io_module_load/unload/query() symbols needs to be renamed to the new naming scheme supported by glib 2.56. Those functions should also support receiving NULL GIOModule, and register the extension point manually since they won't be pre-discovered by reading giomodule.cache.
shared_module() is for libraries that are intended to be dlopened(), like glib-networking. shared_library() is for normal libraries.
Created attachment 364839 [details] [review] Add 'static-modules' option When enabled both a shared module and static library are built for each module.
If you land the patch in bug #684282, then just leave another comment here and I'll take a look at this one.
Patches got merged in glib master.
Review of attachment 364789 [details] [review]: Accepted, but please: * Make it depend on GLib >= 2.55.1 in meson.build * Wait until that is released before committing
Review of attachment 364839 [details] [review]: I was tempted to say that you should use meson's library() function instead, which allows toggling between shared and static, but I think that won't work because we need to use shared_module(), not shared_library(). So this looks good, if you rename the option: ::: meson_options.txt @@ +5,3 @@ option('pkcs11_support', type: 'boolean', value: true, description: 'support for PKCS#11 using p11-kit') option('installed_tests', type: 'boolean', value: false, description: 'enable installed tests') +option('static-modules', type: 'boolean', value: false, description: 'build static modules') static_modules, with an underscore. Needs to be renamed everywhere, of course.
(In reply to Michael Catanzaro from comment #9) > * Wait until that is released before committing Actually it should be fine to commit now, there's no reason to wait. I'll just need to remember to not release until GLib does a release.
Attachment 364789 [details] pushed as 293b10c - Allow static build of modules Attachment 364839 [details] pushed as a3e65ab - Add 'static-modules' option
I made it depend on 2.55.0 because even master is not at 2.55.1 yet.
(In reply to Michael Catanzaro from comment #10) > Review of attachment 364839 [details] [review] [review]: > > I was tempted to say that you should use meson's library() function instead, > which allows toggling between shared and static, but I think that won't work > because we need to use shared_module(), not shared_library(). That was my initial plan, especially since I have PR on meson[1] to have library() able to build both shared AND static in one build, using the same extract_all_objects() trick internally. Maybe at some point meson could do the same for shared_module() but it's not clear yet how. IMHO, library() should have a "module mode" which does exactly the same as shared_module() with the benefit that it would also respect the default_library=both option I proposed in the PR. [1] https://github.com/mesonbuild/meson/pull/2711
(In reply to Xavier Claessens from comment #13) > I made it depend on 2.55.0 because even master is not at 2.55.1 yet. I'll bump it, since it has new stuff that we want.