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 788806 - Impossible to build static glib via meson
Impossible to build static glib via meson
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: build
unspecified
Other All
: Normal normal
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks: 790954
 
 
Reported: 2017-10-11 01:34 UTC by Charles Barto
Modified: 2018-01-05 14:30 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
patchfile (2.31 KB, patch)
2017-10-11 01:34 UTC, Charles Barto
needs-work Details | Review
meson: work around meson not passing on the threads dependency when link_with is used (1.32 KB, patch)
2018-01-05 12:28 UTC, Christoph Reiter (lazka)
committed Details | Review

Description Charles Barto 2017-10-11 01:34:42 UTC
Created attachment 361298 [details] [review]
patchfile

glib's autotools build system has the --enable-shared option, and since the meson files use shared_library instead of library it's impossible to build static libs. I tried changeing this and things worked once I added threads as a dependency for the test applications. I'm not sure how this is supposed to be handled in meson. The world's simplest patch is attached.
Comment 1 Nirbheek Chauhan 2017-10-11 08:50:45 UTC
This patch is correct but probably incomplete because I don't see the copylibs addressed here. Also, the static build was broken on Windows (for autotools also) last I checked because of the way we initialize constructors.

I can't do a proper review of this right now, but I do want to see this fixed (on all platforms).
Comment 2 Charles Barto 2017-10-11 13:28:17 UTC
ah yes. Windows breakage. I can try and test things on windows as well. (I knew that windows box would come in handy for something besides 20 year old HW vendor software!)
Comment 3 Charles Barto 2017-10-11 13:42:08 UTC
as far as I can tell meson builds don't work on windows at all.... I tried with clang (msvc abi), gcc (msys2 mingw64 6.3.0) and msvc 19.11.25508.2. It had trouble finding glibconfig.h. I'll look into it more but there may already be a bug.
Comment 4 Emmanuele Bassi (:ebassi) 2017-10-11 14:15:21 UTC
(In reply to Charles Barto from comment #3)
> as far as I can tell meson builds don't work on windows at all.... I tried
> with clang (msvc abi), gcc (msys2 mingw64 6.3.0) and msvc 19.11.25508.2. It
> had trouble finding glibconfig.h. I'll look into it more but there may
> already be a bug.

You need to build from Git; building from release tarballs with Meson is currently broken/not supported.
Comment 5 Xavier Claessens 2017-12-04 18:09:15 UTC
Using library() is the right thing to do here. Note that it will also allow building both static and shared at the same time once those PR gets merged:

https://github.com/mesonbuild/meson/pull/2711
https://github.com/mesonbuild/meson/pull/2717
Comment 6 Xavier Claessens 2017-12-04 18:11:07 UTC
(In reply to Nirbheek Chauhan from comment #1)
> This patch is correct but probably incomplete because I don't see the
> copylibs addressed here.

What do you mean with copylibs?
Comment 7 Xavier Claessens 2018-01-03 16:43:23 UTC
Review of attachment 361298 [details] [review]:

::: glib/meson.build
@@ -221,3 @@
 endif
-
-libglib = shared_library('glib-2.0',

You removed a blank line by mistake.

@@ +236,2 @@
 libglib_dep = declare_dependency(link_with : libglib,
+  dependencies: thread_dep,

Why is this needed? Seems unrelated to the current bug at least.
Comment 8 Christoph Reiter (lazka) 2018-01-04 05:01:15 UTC
This patch is a subset of the one in bug 784995 (meson: fix static build under Windows)
Comment 9 Xavier Claessens 2018-01-04 21:29:56 UTC
(In reply to Xavier Claessens from comment #7)
> @@ +236,2 @@
>  libglib_dep = declare_dependency(link_with : libglib,
> +  dependencies: thread_dep,
> 
> Why is this needed? Seems unrelated to the current bug at least.

A similar patch just got merged, so I'm closing this bug. The only difference is that extra dependency, if you think it was important please open a new bug for it.
Comment 10 Xavier Claessens 2018-01-04 21:34:58 UTC
Oops, actually it won't build with default_library=static unless I add that dep.
Comment 11 Xavier Claessens 2018-01-04 21:39:18 UTC
Wondering if this is a meson bug, actually.
Comment 12 Christoph Reiter (lazka) 2018-01-04 21:56:25 UTC
I've found this: https://github.com/mesonbuild/meson/issues/1426
Comment 13 Christoph Reiter (lazka) 2018-01-05 12:28:50 UTC
Created attachment 366376 [details] [review]
meson: work around meson not passing on the threads  dependency when link_with is used

When using link_with with declare_dependency() or executable() the threads
dependency is not passed on. To work around the issue add the threads dependency
manually. See https://github.com/mesonbuild/meson/issues/1426

This makes the static build on Linux work.
Comment 14 Xavier Claessens 2018-01-05 14:07:39 UTC
Review of attachment 366376 [details] [review]:

@+1