After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 791100 - Allow static build of modules
Allow static build of modules
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: network
unspecified
Other Linux
: Normal normal
: ---
Assigned To: gtkdev
gtkdev
Depends on: 684282
Blocks: 791372
 
 
Reported: 2017-12-01 20:59 UTC by Xavier Claessens
Modified: 2018-01-04 22:33 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
gnutls: Allow static build (2.35 KB, patch)
2017-12-01 21:04 UTC, Xavier Claessens
none Details | Review
gnutls: Allow static build (2.37 KB, patch)
2017-12-01 21:08 UTC, Xavier Claessens
none Details | Review
Allow static build of modules (5.23 KB, patch)
2017-12-01 21:52 UTC, Xavier Claessens
committed Details | Review
Add 'static-modules' option (3.42 KB, patch)
2017-12-03 03:39 UTC, Xavier Claessens
committed Details | Review

Description Xavier Claessens 2017-12-01 20:59:19 UTC
Once bug #684282 gets fixed, we should rename g_io_module_load/unload/query so they can be statically linked.
Comment 1 Xavier Claessens 2017-12-01 21:04:05 UTC
Created attachment 364784 [details] [review]
gnutls: Allow static build
Comment 2 Xavier Claessens 2017-12-01 21:08:29 UTC
Created attachment 364785 [details] [review]
gnutls: Allow static build
Comment 3 Xavier Claessens 2017-12-01 21:11:53 UTC
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.
Comment 4 Xavier Claessens 2017-12-01 21:52:12 UTC
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.
Comment 5 Michael Catanzaro 2017-12-02 00:37:11 UTC
shared_module() is for libraries that are intended to be dlopened(), like glib-networking. shared_library() is for normal libraries.
Comment 6 Xavier Claessens 2017-12-03 03:39:12 UTC
Created attachment 364839 [details] [review]
Add 'static-modules' option

When enabled both a shared module and static library are built for each
module.
Comment 7 Michael Catanzaro 2017-12-28 00:33:37 UTC
If you land the patch in bug #684282, then just leave another comment here and I'll take a look at this one.
Comment 8 Xavier Claessens 2018-01-04 16:18:06 UTC
Patches got merged in glib master.
Comment 9 Michael Catanzaro 2018-01-04 18:53:07 UTC
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
Comment 10 Michael Catanzaro 2018-01-04 18:56:42 UTC
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.
Comment 11 Michael Catanzaro 2018-01-04 18:57:48 UTC
(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.
Comment 12 Xavier Claessens 2018-01-04 19:09:34 UTC
Attachment 364789 [details] pushed as 293b10c - Allow static build of modules
Attachment 364839 [details] pushed as a3e65ab - Add 'static-modules' option
Comment 13 Xavier Claessens 2018-01-04 19:10:23 UTC
I made it depend on 2.55.0 because even master is not at 2.55.1 yet.
Comment 14 Xavier Claessens 2018-01-04 19:23:16 UTC
(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
Comment 15 Michael Catanzaro 2018-01-04 22:33:17 UTC
(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.