GNOME Bugzilla – Bug 794606
glib-2.56.0 fails to compile when res_nquery is not available
Last modified: 2018-04-10 11:04:29 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
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 on attachment 370022 [details] [review] Patch to fix the compile Pushed to master; pushing to glib-2-56 shortly.
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()
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.
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
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
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