Skip to contentSkip to conversation

configure: Test that gio libs from pkg-config work

PATCH In review Peter Maydell 3 participants 5 messages Sep 28, 2020 – Oct 19, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 configure: Test that gio libs from pkg-config work

On some hosts (eg Ubuntu Bionic) pkg-config returns a set of libraries for gio-2.0 which don't actually work when compiling statically. (Specifically, the returned library string includes -lmount, but not -lblkid which -lmount depends upon, so linking fails due to missing symbols.)

Check that the libraries work, and don't enable gio if they don't, in the same way we do for gnutls.

---
I wanted a statically-linked system emulation binary (which, yes, I know is not really something we support :-)). I got one with suitably liberal use of --disable-foo configure options, and this was the only thing I couldn't work around that way. The patch is needed because there's no --disable-gio. I suppose we could add that instead (or as well)...
Possibly meson offers a nicer way to do this, but this was simple and gnutls is doing the check this way already.

---
 configure | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
configure +9 -1
index e8e8e984f24..cd79227d763 100755
@@ -3762,13 +3762,21 @@ if test "$static" = yes && test "$mingw32" = yes; then
 fi
 
 if $pkg_config --atleast-version=$glib_req_ver gio-2.0; then
-    gio=yes
     gio_cflags=$($pkg_config --cflags gio-2.0)
     gio_libs=$($pkg_config --libs gio-2.0)
     gdbus_codegen=$($pkg_config --variable=gdbus_codegen gio-2.0)
     if [ ! -x "$gdbus_codegen" ]; then
         gdbus_codegen=
     fi
+    # Check that the libraries actually work -- Ubuntu 18.04 ships
+    # with pkg-config --static --libs data for gio-2.0 that is missing
+    # -lblkid and will give a link error.
+    write_c_skeleton
+    if compile_prog "" "gio_libs" ; then
+        gio=yes
+    else
+        gio=no
+    fi
 else
     gio=no
 fi
Signature · 1 line
2.20.1
#1 lore raw
Quoted 8 lines · Peter Maydell

I wanted a statically-linked system emulation binary (which, yes, I know is not really something we support :-)). I got one with suitably liberal use of --disable-foo configure options, and this was the only thing I couldn't work around that way. The patch is needed because there's no --disable-gio. I suppose we could add that instead (or as well)...
Possibly meson offers a nicer way to do this, but this was simple and gnutls is doing the check this way already.

No, you'd get just that warning about static libraries not being available; so I think either this patch or --disable-gio is fine.

Paolo

#2 lore raw
Quoted 11 lines · Paolo Bonzini
Quoted 8 lines · Peter Maydell

I wanted a statically-linked system emulation binary (which, yes, I know is not really something we support :-)). I got one with suitably liberal use of --disable-foo configure options, and this was the only thing I couldn't work around that way. The patch is needed because there's no --disable-gio. I suppose we could add that instead (or as well)...
Possibly meson offers a nicer way to do this, but this was simple and gnutls is doing the check this way already.

Quoted 2 lines

No, you'd get just that warning about static libraries not being available; so I think either this patch or --disable-gio is fine.

Could I have a Reviewed-by: if you're happy with this patch?

thanks
-- PMM

Reviewed-by
#3 lore raw
Quoted 12 lines · Peter Maydell
Quoted 11 lines · Paolo Bonzini
Quoted 8 lines · Peter Maydell

I wanted a statically-linked system emulation binary (which, yes, I know is not really something we support :-)). I got one with suitably liberal use of --disable-foo configure options, and this was the only thing I couldn't work around that way. The patch is needed because there's no --disable-gio. I suppose we could add that instead (or as well)...
Possibly meson offers a nicer way to do this, but this was simple and gnutls is doing the check this way already.

Quoted 4 lines
Quoted 2 lines

No, you'd get just that warning about static libraries not being available; so I think either this patch or --disable-gio is fine.

Could I have a Reviewed-by: if you're happy with this patch?

Reviewed-by on v1 1/1
#4 lore raw
In reply to Peter Maydell
Quoted 19 lines · Peter Maydell

On some hosts (eg Ubuntu Bionic) pkg-config returns a set of libraries for gio-2.0 which don't actually work when compiling statically. (Specifically, the returned library string includes -lmount, but not -lblkid which -lmount depends upon, so linking fails due to missing symbols.)

Check that the libraries work, and don't enable gio if they don't, in the same way we do for gnutls.

---
I wanted a statically-linked system emulation binary (which, yes, I know is not really something we support :-)). I got one with suitably liberal use of --disable-foo configure options, and this was the only thing I couldn't work around that way. The patch is needed because there's no --disable-gio. I suppose we could add that instead (or as well)...
Possibly meson offers a nicer way to do this, but this was simple and gnutls is doing the check this way already.

Quoted 3 lines
---
  configure | 10 +++++++++-
  1 file changed, 9 insertions(+), 1 deletion(-)