GNOME Bugzilla – Bug 788806
Impossible to build static glib via meson
Last modified: 2018-01-05 14:30:52 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.
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).
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!)
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.
(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.
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
(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?
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.
This patch is a subset of the one in bug 784995 (meson: fix static build under Windows)
(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.
Oops, actually it won't build with default_library=static unless I add that dep.
Wondering if this is a meson bug, actually.
I've found this: https://github.com/mesonbuild/meson/issues/1426
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.
Review of attachment 366376 [details] [review]: @+1