When trying to compile a (previously working) program against glibc-2.22, I got compilation errors due to getaddrinfo not being found. When trying to compile a short test program with `gcc -Wall gai.c', gcc outputs numerous errors with regards to getaddrinfo/gai_strerror/freeadrrinfo not being declared and not being able to determine the storage size of the addrinfo struct. The same program compiles on a system with sys-libs/glibc-2.20-r2 and used to compile with sys-libs/glibc-2.21-r1 (haven't tried downgrading glibc yet). Test Program: #define _POSIX_C_SOURCE 1 #include <stdio.h> #include <string.h> #include <sys/types.h> #include <sys/socket.h> #include <netdb.h> #include <netinet/in.h> int main() { struct addrinfo hints, *res; int ret; memset(&hints, 0, sizeof(hints)); hints.ai_family = AF_UNSPEC; hints.ai_socktype = SOCK_STREAM; hints.ai_protocol = IPPROTO_TCP; if ((ret = getaddrinfo("google.com", "443", &hints, &res)) != 0) { const char *err = gai_strerror(ret); printf("getaddrinfo: %s\n", err); return 1; } freeaddrinfo(res); return 0; } Reproducible: Always Steps to Reproduce: 1. Create/copy test program into gai.c 2. gcc -Wall gai.c Actual Results: Program does not compile. Expected Results: Program compiles normally.
So I tried downgrading glibc, it didn't really work: glibc-2.22-r1] bash: loadlocale.c:130: _nl_intern_locale_data: Assertion `cnt < (sizeof (_nl_value_type_LC_COLLATE) / sizeof (_nl_value_type_LC_COLLATE[0]))' failed. * The ebuild phase 'postrm' has been killed by signal 6. bash: loadlocale.c:130: _nl_intern_locale_data: Assertion `cnt < (sizeof (_nl_value_type_LC_COLLATE) / sizeof (_nl_value_type_LC_COLLATE[0]))' failed. Sandboxed process killed by signal: Aborted Now when I try running most programs I get a loadlocale error: locale: loadlocale.c:130: _nl_intern_locale_data: Assertion `cnt < (sizeof (_nl_value_type_LC_COLLATE) / sizeof (_nl_value_type_LC_COLLATE[0]))' failed. I guess it's restore from backup time.
Compiling the test program works with sys-libs/glibc-2.21-r1
Why are you setting _POSIX_C_SOURCE to 1? Your test program compiles sucessfully when that is unset or set to a greater value like 200809L.
I defined _POSIX_C_SOURCE 1 because the original program that had the error uses std=c99 (instead of the default gnu89) and because of getaddrinfo(3): Feature Test Macro Requirements for glibc (see feature_test_macros(7)): getaddrinfo(), freeaddrinfo(), gai_strerror(): _POSIX_C_SOURCE >= 1 || _XOPEN_SOURCE || _POSIX_SOURCE Was this just a case of glibc being out of date with sys-apps/man-pages?
Changing the define for _POSIX_C_SOURCE to 200809L fixes compilation on glibc-2.22. Should I file a bug against sys-apps/man-pages?
Let's let the toolchain guys weigh in.
the change in question was deliberate -- see upstream report: https://sourceware.org/bugzilla/show_bug.cgi?id=18529 the man-page is incorrect, but that has been reported already: http://article.gmane.org/gmane.linux.man/9657/match=getaddrinfo