Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 195368

Summary: sys-apps/gawk-3.1.5-r5 fails to compile on uclibc due to `AI_ADDRCONFIG' undeclared
Product: Gentoo Linux Reporter: Natanael Copa <natanael.copa>
Component: New packagesAssignee: Embedded Gentoo Team <embedded>
Status: RESOLVED FIXED    
Severity: normal CC: christoph.gysin, clmason, dragos.delcea, gentoo-bugs, matthijs, napalmllama, robert
Priority: High    
Version: unspecified   
Hardware: All   
OS: Linux   
Whiteboard:
Package list:
Runtime testing required: ---

Description Natanael Copa 2007-10-10 12:25:05 UTC
if i386-gentoo-linux-uclibc-gcc -DDEFPATH="\".:/usr/share/awk\"" -DHAVE_CONFIG_H -DGAWK -DLOCALEDIR="\"/usr/share/locale\"" -I. -I. -I.     -march=i386 -Os -pipe -fomit-frame-pointer -MT io.o -MD -MP -MF ".deps/io.Tpo" -c -o io.o io.c; \
        then mv -f ".deps/io.Tpo" ".deps/io.Po"; else rm -f ".deps/io.Tpo"; exit 1; fi
if i386-gentoo-linux-uclibc-gcc -DDEFPATH="\".:/usr/share/awk\"" -DHAVE_CONFIG_H -DGAWK -DLOCALEDIR="\"/usr/share/locale\"" -I. -I. -I.     -march=i386 -Os -pipe -fomit-frame-pointer -MT main.o -MD -MP -MF ".deps/main.Tpo" -c -o main.o main.c; \
        then mv -f ".deps/main.Tpo" ".deps/main.Po"; else rm -f ".deps/main.Tpo"; exit 1; fi
io.c: In function `socketopen':
io.c:1150: error: `AI_ADDRCONFIG' undeclared (first use in this function)
io.c:1150: error: (Each undeclared identifier is reported only once
io.c:1150: error: for each function it appears in.)
if i386-gentoo-linux-uclibc-gcc -DDEFPATH="\".:/usr/share/awk\"" -DHAVE_CONFIG_H -DGAWK -DLOCALEDIR="\"/usr/share/locale\"" -I. -I. -I.     -march=i386 -Os -pipe -fomit-frame-pointer -MT msg.o -MD -MP -MF ".deps/msg.Tpo" -c -o msg.o msg.c; \
        then mv -f ".deps/msg.Tpo" ".deps/msg.Po"; else rm -f ".deps/msg.Tpo"; exit 1; fi
make[2]: *** [io.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[2]: Leaving directory `/var/tmp/portage/sys-apps/gawk-3.1.5-r5/work/gawk-3.1.5'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/var/tmp/portage/sys-apps/gawk-3.1.5-r5/work/gawk-3.1.5'
make: *** [all] Error 2
Comment 1 Jakub Moc (RETIRED) gentoo-dev 2007-10-10 16:38:52 UTC
emerge --info please.
Comment 2 Natanael Copa 2007-10-11 06:57:15 UTC
Doesn't the summary say it all?

Portage 2.1.3.9 (uclibc/x86/hardened, gcc-3.4.6, uclibc-0.9.28.3-r1, 2.6.22-vsgrsec-r1 i686)
=================================================================
System uname: 2.6.22-vsgrsec-r1 i686 Intel(R) Core(TM)2 CPU 6400 @ 2.13GHz
Timestamp of tree: Wed, 10 Oct 2007 11:30:01 +0000
app-shells/bash:     3.2_p17
dev-lang/python:     2.4.4-r5
dev-python/pycrypto: 2.0.1-r6
sys-apps/baselayout: 2.0.0_rc4-r1
sys-apps/sandbox:    1.2.17
sys-devel/autoconf:  2.61-r1
sys-devel/automake:  1.6.3, 1.8.5-r3, 1.9.6-r2, 1.10
sys-devel/binutils:  2.17-r1
sys-devel/gcc-config: 1.3.16
sys-devel/libtool:   1.5.24
virtual/os-headers:  2.6.22-r2
ACCEPT_KEYWORDS="x86"
CBUILD="i386-gentoo-linux-uclibc"
CFLAGS="-march=i386 -Os -pipe -fomit-frame-pointer"
CHOST="i386-gentoo-linux-uclibc"
CONFIG_PROTECT="/etc /var/bind"
CONFIG_PROTECT_MASK="/etc/env.d /etc/gconf /etc/gentoo-release /etc/php/apache2-php5/ext-active/ /etc/php/cgi-php5/ext-active/ /etc/php/cli-php5/ext-active/ /etc/revdep-rebuild /etc/terminfo"
CXXFLAGS="-Os -pipe"
DISTDIR="/var/cache/distfiles"
FEATURES="autoconfig buildpkg distlocks metadata-transfer nodoc noinfo noman sandbox sfperms strict unmerge-orphans userfetch"
GENTOO_MIRRORS="http://distfiles.gentoo.org http://distro.ibiblio.org/pub/linux/distributions/gentoo"
MAKEOPTS="-j3"
PKGDIR="/var/cache/packages/default"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --compress --force --whole-file --delete --delete-after --stats --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages --filter=H_**/files/digest-*"
PORTAGE_TMPDIR="/var/tmp"
PORTDIR="/usr/portage"
PORTDIR_OVERLAY="/usr/alpine-portage"
SYNC="rsync://rsync.gentoo.org/gentoo-portage"
USE="X509 bitmap-fonts bri bzip2 cli cracklib dri encode expat extensions hardened iproute2 ipv6 jpeg lua mad midi mmap mudflap ncurses netboot nonfsv4 ntfs ogg openmp oss pci pcmcia pic png pppd pri readline reflection rrdtool sensord session snmp speex spl ssl tdb truetype truetype-fonts type1-fonts uclibc uclibc++ udev usb userlocales wifi wordexp x86 xorg zaptel zlib" ALSA_PCM_PLUGINS="adpcm alaw asym copy dmix dshare dsnoop empty extplug file hooks iec958 ioplug ladspa lfloat linear meter mulaw multi null plug rate route share shm softvol" ELIBC="uclibc" INPUT_DEVICES="keyboard mouse evdev" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" MISDN_CARDS="avmfritz hfcmulti hfcpci hfcsmini hfcsusb netjetpci sedlfax w6692pci xhfc" USERLAND="GNU" VIDEO_CARDS="dummy fbdev v4l apm ark chips cirrus cyrix epson glint i128 i740 i810 imstt mach64 mga neomagic nsc nv r128 radeon rendition s3 s3virge savage siliconmotion sis sisusb tdfx tga trident tseng vesa vga via voodoo"
Unset:  CTARGET, EMERGE_DEFAULT_OPTS, INSTALL_MASK, LANG, LC_ALL, LDFLAGS, LINGUAS, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS

Comment 3 Natanael Copa 2007-10-11 07:01:27 UTC
uclibc needs to backport the netdb.h from uclibc-0.9.29 or use this patch:

--- /usr/include/netdb.h.orig   2007-10-11 06:55:18 +0000
+++ /usr/include/netdb.h        2007-10-11 06:55:36 +0000
@@ -401,6 +401,10 @@
 # define AI_PASSIVE    0x0001  /* Socket address is intended for `bind'.  */
 # define AI_CANONNAME  0x0002  /* Request for canonical name.  */
 # define AI_NUMERICHOST        0x0004  /* Don't use name resolution.  */
+# define AI_V4MAPPED    0x0008  /* IPv4 mapped addresses are acceptable.  */
+# define AI_ALL         0x0010  /* Return IPv4 mapped and IPv6 addresses.  */
+# define AI_ADDRCONFIG  0x0020  /* Use configuration of this host to choose
+                                   returned address type..  */
 
 /* Error values for `getaddrinfo' function.  */
 # define EAI_BADFLAGS    -1    /* Invalid value for `ai_flags' fiel
Comment 4 Clemmitt M. Sigler 2007-10-23 21:34:54 UTC
(In reply to comment #3)
> uclibc needs to backport the netdb.h from uclibc-0.9.29 or use this patch:
> 
> --- /usr/include/netdb.h.orig   2007-10-11 06:55:18 +0000
> +++ /usr/include/netdb.h        2007-10-11 06:55:36 +0000
> @@ -401,6 +401,10 @@
>  # define AI_PASSIVE    0x0001  /* Socket address is intended for `bind'.  */
>  # define AI_CANONNAME  0x0002  /* Request for canonical name.  */
>  # define AI_NUMERICHOST        0x0004  /* Don't use name resolution.  */
> +# define AI_V4MAPPED    0x0008  /* IPv4 mapped addresses are acceptable.  */
> +# define AI_ALL         0x0010  /* Return IPv4 mapped and IPv6 addresses.  */
> +# define AI_ADDRCONFIG  0x0020  /* Use configuration of this host to choose
> +                                   returned address type..  */
> 
>  /* Error values for `getaddrinfo' function.  */
>  # define EAI_BADFLAGS    -1    /* Invalid value for `ai_flags' fiel
> 

Confirmed.  I patched as above to help build a tinygentoo test env.  After this, `emerge --update world' ran successfully on a stage3-x86-uclibc-2006.1.tar.bz2 based build.

I didn't dissect the uclibc code, but I assume that since these defs were removed from the header file, the corresponding functionality was removed or was never implemented(?).  IOW, I didn't extensively test gawk or other binaries that depend on these defs.  YMMV.

I suppose some autoconf/make test will have to be implemented somewhere to test for AI_ADDRCONFIG and similar.  Ugh.
Comment 5 Christoph Brill (egore) (RESIGNED) 2007-10-24 12:51:33 UTC
I can confirm this, too. Is there anything planed to fix this in gentoo?
Comment 6 Matthijs Kooijman 2007-11-05 19:16:03 UTC
I've been looking around for a bit, and it turns out that in the next version of uclibc (0.9.29) does have the define in netdb.h (As comment #3 already said).

When looking at the commit that introduced this (r11195 from uClibc, [1]) it seems that only netdb.h was modified to add the define, without any functionality changes. Yet, in libc/inet/getaddrinfo.c [2] the define is also present along with the comment:
 /* The following declarations and definitions have been removed from
  *    the public header since we don't want people to use them.  */

So the addition to the netdb.h upstream might have been accidental. On the other hand, getaddrinfo.c does contain some code to handle the AI_ADDRCONF flag...

So, we can conclude that upgrading to 0.9.29 will solve the compiling problem (and this will happen sometime soon anyway? Or is Gentoo slow with libc updates?) Possibly there is a uclibc bug in there, that might break gawk (because AI_ADDRCONF is exposed but might not be fully implemented).

My EUR 0,02

[1]: http://www.uclibc.org/cgi-bin/viewcvs.cgi/trunk/uClibc/include/netdb.h?rev=11195&r1=9223&r2=11195
[2]: http://www.uclibc.org/cgi-bin/viewcvs.cgi/trunk/uClibc/libc/inet/getaddrinfo.c?rev=13492&view=markup
Comment 7 Natanael Copa 2007-11-07 12:31:48 UTC
(In reply to comment #6)
 
> So, we can conclude that upgrading to 0.9.29 will solve the compiling problem
> (and this will happen sometime soon anyway? Or is Gentoo slow with libc
> updates?)

upstream uclibc is slow. 0.9.29 has problems too and it seems like nobody can tell exactly what.

> Possibly there is a uclibc bug in there, that might break gawk
> (because AI_ADDRCONF is exposed but might not be fully implemented).

I have an 0.9.28.3-r2 almost done. I could verify the getaddrsinfo and backport if needed. I'm still not sure if thats desired. any comments from gentoo-embedded devs?

-nc
Comment 8 Natanael Copa 2007-11-08 09:45:56 UTC
Looking at the gawk code, it looks like its perfectly safe to just remove the  AI_ADDRCONFIG flag from gawk.

The code is relevant when opening the special gawk files /inet/* (see gawk man page under "Special filees")

The only difference is when there are no ip adresses configured. With AI_ADDRCONFIG, gawk will not even try to create and bind a socket, without AI_ADDRCONFIG, gawk wil try to create and bind a socket which will fail since there are not ip addresses configured. In both cases the result will be the same: returning an invalid filehandle.

OTOH, use of the AI_ADDRCONFIG flag seems to be implemented (by just creating a socket) so its safe to have the define in the public header.

I have no idea why they didn't want that ppl use the flag. might be its a GNU extension.
Comment 9 Natanael Copa 2007-11-08 10:07:50 UTC
This should be safe.

--- gawk-3.1.5/io.c.orig        2007-11-08 10:04:27 +0000
+++ gawk-3.1.5/io.c     2007-11-08 10:05:02 +0000
@@ -1147,7 +1147,7 @@
        int any_remote_host = strcmp(remotehostname, "0");
 
        memset (&lhints, '\0', sizeof (lhints));
-       lhints.ai_flags = AI_PASSIVE | AI_ADDRCONFIG;
+       lhints.ai_flags = AI_PASSIVE;
        lhints.ai_socktype = type;
 
        lerror = getaddrinfo (NULL, localpname, &lhints, &lres);
Comment 10 Christian Heim (RETIRED) gentoo-dev 2007-11-10 17:24:10 UTC
(In reply to comment #9)
> This should be safe.
> 
> --- gawk-3.1.5/io.c.orig        2007-11-08 10:04:27 +0000
> +++ gawk-3.1.5/io.c     2007-11-08 10:05:02 +0000
> @@ -1147,7 +1147,7 @@
>         int any_remote_host = strcmp(remotehostname, "0");
> 
>         memset (&lhints, '\0', sizeof (lhints));
> -       lhints.ai_flags = AI_PASSIVE | AI_ADDRCONFIG;
> +       lhints.ai_flags = AI_PASSIVE;
>         lhints.ai_socktype = type;
> 
>         lerror = getaddrinfo (NULL, localpname, &lhints, &lres);
> 

The weird thing (at least for me) is, that gawk-3.15-r3 works just fine with 0.9.28.3 .... So I'd bet it's something introduced between those revisions.
Comment 11 Christian Heim (RETIRED) gentoo-dev 2007-11-10 21:14:59 UTC
(In reply to comment #10)
> (In reply to comment #9)
> > This should be safe.
> > 
> > --- gawk-3.1.5/io.c.orig        2007-11-08 10:04:27 +0000
> > +++ gawk-3.1.5/io.c     2007-11-08 10:05:02 +0000
> > @@ -1147,7 +1147,7 @@
> >         int any_remote_host = strcmp(remotehostname, "0");
> > 
> >         memset (&lhints, '\0', sizeof (lhints));
> > -       lhints.ai_flags = AI_PASSIVE | AI_ADDRCONFIG;
> > +       lhints.ai_flags = AI_PASSIVE;
> >         lhints.ai_socktype = type;
> > 
> >         lerror = getaddrinfo (NULL, localpname, &lhints, &lres);
> > 
> 
> The weird thing (at least for me) is, that gawk-3.15-r3 works just fine with
> 0.9.28.3 .... So I'd bet it's something introduced between those revisions.

It's the IPv6 patch in -r5 that's making things go wrong.
Comment 12 Christian Heim (RETIRED) gentoo-dev 2007-12-29 12:40:44 UTC
Reassigning to the package maintainer. A simple solution would be the following:

@@ -11,7 +11,7 @@
 LICENSE="GPL-2"
 SLOT="0"
 KEYWORDS="alpha amd64 arm hppa ia64 m68k mips ppc ppc64 s390 sh sparc ~sparc-fbsd x86 ~x86-fbsd"
-IUSE="nls"
+IUSE="nls elibc_uclibc"

 RDEPEND=""
 DEPEND="${RDEPEND}
@@ -38,7 +38,7 @@
        epatch "${FILESDIR}"/${P}-numflags.patch
        epatch "${FILESDIR}"/${P}-syntaxerror.patch
        epatch "${FILESDIR}"/${P}-wconcat.patch
-       epatch "${FILESDIR}"/${P}-ipv6.patch
+       use elibc_uclibc || epatch "${FILESDIR}"/${P}-ipv6.patch
        epatch "${FILESDIR}"/${P}-mbread.patch
        epatch "${FILESDIR}"/${P}-freewstr2.patch #135931 #188740
 }
Comment 13 solar (RETIRED) gentoo-dev 2008-01-01 22:40:56 UTC
(In reply to comment #7)
> I have an 0.9.28.3-r2 almost done. I could verify the getaddrsinfo and backport
> if needed. I'm still not sure if thats desired. any comments from
> gentoo-embedded devs?

Yes that would be desired.
Comment 14 Christoph Gysin 2008-01-28 07:46:46 UTC
Why not:

use ipv6 && epatch "${FILESDIR}"/${P}-ipv6.patch
use ipv6 && use elibc_uclibc && eerror "Sorry, ipv6 patch doesn't work with uclibc"

Would be more obvious to me.
Comment 15 Natanael Copa 2008-02-05 07:48:45 UTC
(In reply to comment #14)
> Why not:
> 
> use ipv6 && epatch "${FILESDIR}"/${P}-ipv6.patch
> use ipv6 && use elibc_uclibc && eerror "Sorry, ipv6 patch doesn't work with
> uclibc"
> 
> Would be more obvious to me.
> 

the ipv6 patch works just fine if you only remove AI_ADDRCONFIG as shown in #9. It doesn't do anything really useful anyway (as explained in #8).

Comment 16 Natanael Copa 2008-02-05 07:53:17 UTC
(In reply to comment #13)
> (In reply to comment #7)
> > I have an 0.9.28.3-r2 almost done. I could verify the getaddrsinfo and backport
> > if needed. I'm still not sure if thats desired. any comments from
> > gentoo-embedded devs?
> 
> Yes that would be desired.
> 

When I realised that most of the changes I had prepared for 0.9.28.3-r2 was bogus (not really needed, just like in this bug) I gave up working on it.

I suggest that we apply patch in comment #9 if use ipv6 && use elibc_uclibc and then spend our forces to get 0.9.29 working rather than backporting.

Comment 17 SpanKY gentoo-dev 2012-04-22 16:07:56 UTC
sys-apps/gawk-3.1.8 emerges fine for me now