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 794606 - glib-2.56.0 fails to compile when res_nquery is not available
glib-2.56.0 fails to compile when res_nquery is not available
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: gio
2.56.x
Other Linux
: Normal critical
: 2.56
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2018-03-22 19:41 UTC by Sebastian
Modified: 2018-04-10 11:04 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Patch to fix the compile (642 bytes, patch)
2018-03-22 19:41 UTC, Sebastian
committed Details | Review
resolv.h (15.39 KB, text/plain)
2018-03-26 18:37 UTC, Sebastian
  Details

Description Sebastian 2018-03-22 19:41:06 UTC
Created attachment 370022 [details] [review]
Patch to fix the compile

Hi all,

When compiling while res_nquery is unavailable the build fails. This happens starting with glib-2.56.0.

The issue is that if HAVE_RES_NQUERY is not defined, then there is no "struct __res_state res" in "gio/gthreadedresolver.c". But a few lines below we have this:

#if defined(HAVE_RES_NDESTROY)
  res_ndestroy (&res);
#elif defined(HAVE_RES_NCLOSE)
  res_nclose (&res);
#elif defined(HAVE_RES_NINIT)
#error "Your platform has res_ninit() but not res_nclose() or res_ndestroy(). Please file a bug at https://bugzilla.gnome.org/enter_bug.cgi?product=glib"
#endif

So if HAVE_RES_NQUERY is undefined but, say, HAVE_RES_NDESTROY isn't, then there's an attempt to remove a struct that doesn't exit:

gthreadedresolver.c: In function 'do_lookup_records':
gthreadedresolver.c:875:16: error: 'res' undeclared (first use in this function); did you mean '_res'?
   res_nclose (&res);
                ^~~
                _res
gthreadedresolver.c:875:16: note: each undeclared identifier is reported only once for each function it appears in
make[7]: *** [Makefile:3334: libgio_2_0_la-gthreadedresolver.lo] Error 1


I think just adding another

#ifdef HAVE_RES_NQUERY
...
#endif

around the mentioned code block should do it.

This was seen on OpenWrt when compiling for the ARC target (uclibc). There's no res_nquery available:

checking for res_init... yes
checking for res_nclose... yes
checking for res_ndestroy... no
checking for res_ninit... yes
checking for res_nquery... no

Kind regards,
Seb 
should do the trick
Comment 1 Philip Withnall 2018-03-26 09:45:16 UTC
Review of attachment 370022 [details] [review]:

Why on earth would a platform have res_ninit() and res_nclose() but not res_nquery()?

Anyway, this patch looks good, thanks.
Comment 2 Philip Withnall 2018-03-26 09:50:33 UTC
Comment on attachment 370022 [details] [review]
Patch to fix the compile

Pushed to master; pushing to glib-2-56 shortly.
Comment 3 Philip Withnall 2018-03-26 09:53:37 UTC
Pushed to master and glib-2-56 with a minor change to add a comment, and a new commit message.

e2c16df4b (HEAD -> master, origin/master, origin/HEAD) gthreadedresolver: Fix compilation with res_nclose() but no res_nquery()
fe939d2b7 (HEAD -> glib-2-56, origin/glib-2-56) gthreadedresolver: Fix compilation with res_nclose() but no res_nquery()
Comment 4 Philip Withnall 2018-03-26 09:54:50 UTC
I’m not convinced this is the full solution though. It doesn’t make sense for a platform to provide res_ninit() and res_nclose(), but *not* res_nquery().

Sebastian, can you attach your /usr/include/resolv.h here please? I’d like to see if it provides an alternative thread-safe function to res_nquery(). Thanks.
Comment 5 Sebastian 2018-03-26 18:37:22 UTC
Created attachment 370160 [details]
resolv.h

Hi Philip,

This is the file you requested. It's more or less the same as the one from uclibc git: https://git.uclibc.org/uClibc/tree/include/resolv.h

Kind regards,
Seb
Comment 6 Emmanuele Bassi (:ebassi) 2018-03-26 19:39:20 UTC
uclibc being pretty useless:

https://git.uclibc.org/uClibc/tree/include/resolv.h#n417

```
int res_ninit (...)
void res_nclose (...)

#if 0
...
int res_nquery (...)
...
#endif
```

They just don't implement a bunch of API: https://git.uclibc.org/uClibc/tree/libc/inet/resolv.c
Comment 7 Philip Withnall 2018-04-10 11:04:29 UTC
That is it indeed. And it doesn’t look like there’s any alternative API to res_nquery() that they do implement. What a mess. ¯\_(ツ)_/¯

Thanks for the patch, Sebastian.

⇒ FIXED