I get a build failure in the sunrpc/ subdirectory when building GLIBC on Alpine Linux 3.6.1. The toolchain has a target of `x86_64-alpine-linux-musl` so it's perhaps not officially supported by GLIBC. However this issue is the only thing that prevents GLIBC 2.25 from compiling in that environment so it would be worthwhile to fix it. musl libc defines certain types in its sys/types.h when _GNU_SOURCE or _BSD_SOURCE is set, such as `u_char`, `u_short`, and `caddr_t`. See: http://git.musl-libc.org/cgit/musl/tree/include/sys/types.h#n59 These are redefined inside GLIBC in `sunrpc/rpc/types.h`, causing 'conflicting types' issues. If GLIBC could detect the existance of these symbols at configure-time in the host libc it could then #ifdef away the redefinitions appropriately. This is the full error output: gcc -D_RPC_THREAD_SAFE_ -D_GNU_SOURCE -DIS_IN_build -include /buildstream/build/o/config.h rpc_clntout.c \ -o /buildstream/build/o/sunrpc/cross-rpc_clntout.o -MMD -MP -MF /buildstream/build/o/sunrpc/cross-rpc_clntout.o.dt -MT /buildstream/build/o/sunrpc/cross-rpc_clntout.o -c In file included from rpc_parse.c:39:0: rpc/types.h:78:9: error: unknown type name '__u_char' typedef __u_char u_char; ^~~~~~~~ rpc/types.h:78:18: error: conflicting types for 'u_char' typedef __u_char u_char; ^~~~~~ In file included from rpc/types.h:69:0, from rpc_parse.c:39: /usr/include/sys/types.h:64:23: note: previous declaration of 'u_char' was here typedef unsigned char u_char; ^~~~~~ In file included from rpc_parse.c:39:0: rpc/types.h:79:9: error: unknown type name '__u_short' typedef __u_short u_short; ^~~~~~~~~ rpc/types.h:79:19: error: conflicting types for 'u_short' typedef __u_short u_short; ^~~~~~~ In file included from rpc/types.h:69:0, from rpc_parse.c:39: /usr/include/sys/types.h:65:24: note: previous declaration of 'u_short' was here typedef unsigned short u_short, ushort; ^~~~~~~ In file included from rpc_parse.c:39:0: rpc/types.h:80:9: error: unknown type name '__u_int' typedef __u_int u_int; ^~~~~~~ rpc/types.h:80:17: error: conflicting types for 'u_int' typedef __u_int u_int; ^~~~~ In file included from rpc/types.h:69:0, from rpc_parse.c:39: /usr/include/sys/types.h:66:18: note: previous declaration of 'u_int' was here typedef unsigned u_int, uint; ^~~~~ In file included from rpc_parse.c:39:0: rpc/types.h:81:9: error: unknown type name '__u_long' typedef __u_long u_long; ^~~~~~~~ rpc/types.h:81:18: error: conflicting types for 'u_long' typedef __u_long u_long; ^~~~~~ In file included from rpc/types.h:69:0, from rpc_parse.c:39: /usr/include/sys/types.h:67:23: note: previous declaration of 'u_long' was here typedef unsigned long u_long, ulong; ^~~~~~ In file included from rpc_parse.c:39:0: rpc/types.h:82:9: error: unknown type name '__quad_t' typedef __quad_t quad_t; ^~~~~~~~ rpc/types.h:82:18: error: conflicting types for 'quad_t' typedef __quad_t quad_t; ^~~~~~ In file included from rpc/types.h:69:0, from rpc_parse.c:39: /usr/include/sys/types.h:68:19: note: previous declaration of 'quad_t' was here typedef long long quad_t; ^~~~~~ In file included from rpc_parse.c:39:0: rpc/types.h:83:9: error: unknown type name '__u_quad_t' typedef __u_quad_t u_quad_t; ^~~~~~~~~~ rpc/types.h:83:20: error: conflicting types for 'u_quad_t' typedef __u_quad_t u_quad_t; ^~~~~~~~ In file included from rpc/types.h:69:0, from rpc_parse.c:39: /usr/include/sys/types.h:69:28: note: previous declaration of 'u_quad_t' was here typedef unsigned long long u_quad_t; ^~~~~~~~ In file included from rpc_parse.c:39:0: rpc/types.h:84:9: error: unknown type name '__fsid_t' typedef __fsid_t fsid_t; ^~~~~~~~ rpc/types.h:88:9: error: unknown type name '__daddr_t' typedef __daddr_t daddr_t; ^~~~~~~~~ rpc/types.h:90:9: error: unknown type name '__caddr_t' typedef __caddr_t caddr_t; ^~~~~~~~~ rpc/types.h:90:19: error: conflicting types for 'caddr_t' typedef __caddr_t caddr_t; ^~~~~~~ In file included from rpc/types.h:69:0, from rpc_parse.c:39: /usr/include/sys/types.h:63:15: note: previous declaration of 'caddr_t' was here typedef char *caddr_t; ^~~~~~~ In file included from rpc_clntout.c:34:0: rpc/types.h:78:9: error: unknown type name '__u_char' typedef __u_char u_char; ^~~~~~~~ rpc/types.h:78:18: error: conflicting types for 'u_char' typedef __u_char u_char; ^~~~~~ In file included from rpc/types.h:69:0, from rpc_clntout.c:34: /usr/include/sys/types.h:64:23: note: previous declaration of 'u_char' was here typedef unsigned char u_char; ^~~~~~ In file included from rpc_clntout.c:34:0: rpc/types.h:79:9: error: unknown type name '__u_short' typedef __u_short u_short; ^~~~~~~~~ rpc/types.h:79:19: error: conflicting types for 'u_short' typedef __u_short u_short; ^~~~~~~ In file included from rpc/types.h:69:0, from rpc_clntout.c:34: /usr/include/sys/types.h:65:24: note: previous declaration of 'u_short' was here typedef unsigned short u_short, ushort; ^~~~~~~ In file included from rpc_clntout.c:34:0: rpc/types.h:80:9: error: unknown type name '__u_int' typedef __u_int u_int; ^~~~~~~ rpc/types.h:80:17: error: conflicting types for 'u_int' typedef __u_int u_int; ^~~~~ In file included from rpc/types.h:69:0, from rpc_clntout.c:34: /usr/include/sys/types.h:66:18: note: previous declaration of 'u_int' was here typedef unsigned u_int, uint; ^~~~~ In file included from rpc_clntout.c:34:0: rpc/types.h:81:9: error: unknown type name '__u_long' typedef __u_long u_long; ^~~~~~~~ rpc/types.h:81:18: error: conflicting types for 'u_long' typedef __u_long u_long; ^~~~~~ In file included from rpc/types.h:69:0, from rpc_clntout.c:34: /usr/include/sys/types.h:67:23: note: previous declaration of 'u_long' was here typedef unsigned long u_long, ulong; ^~~~~~ In file included from rpc_clntout.c:34:0: rpc/types.h:82:9: error: unknown type name '__quad_t' typedef __quad_t quad_t; ^~~~~~~~ rpc/types.h:82:18: error: conflicting types for 'quad_t' typedef __quad_t quad_t; ^~~~~~ In file included from rpc/types.h:69:0, from rpc_clntout.c:34: /usr/include/sys/types.h:68:19: note: previous declaration of 'quad_t' was here typedef long long quad_t; ^~~~~~ In file included from rpc_clntout.c:34:0: rpc/types.h:83:9: error: unknown type name '__u_quad_t' typedef __u_quad_t u_quad_t; ^~~~~~~~~~ rpc/types.h:83:20: error: conflicting types for 'u_quad_t' typedef __u_quad_t u_quad_t; ^~~~~~~~ In file included from rpc/types.h:69:0, from rpc_clntout.c:34: /usr/include/sys/types.h:69:28: note: previous declaration of 'u_quad_t' was here typedef unsigned long long u_quad_t; ^~~~~~~~ In file included from rpc_clntout.c:34:0: rpc/types.h:84:9: error: unknown type name '__fsid_t' typedef __fsid_t fsid_t; ^~~~~~~~ rpc/types.h:88:9: error: unknown type name '__daddr_t' typedef __daddr_t daddr_t; ^~~~~~~~~ rpc/types.h:90:9: error: unknown type name '__caddr_t' typedef __caddr_t caddr_t; ^~~~~~~~~ rpc/types.h:90:19: error: conflicting types for 'caddr_t' typedef __caddr_t caddr_t; ^~~~~~~ In file included from rpc/types.h:69:0, from rpc_clntout.c:34: /usr/include/sys/types.h:63:15: note: previous declaration of 'caddr_t' was here typedef char *caddr_t; ^~~~~~~ make[2]: *** [Makefile:167: /buildstream/build/o/sunrpc/cross-rpc_parse.o] Error 1 make[2]: *** Waiting for unfinished jobs.... make[2]: *** [Makefile:167: /buildstream/build/o/sunrpc/cross-rpc_clntout.o] Error 1 make[2]: Leaving directory '/buildstream/build/sunrpc' make[1]: *** [Makefile:215: sunrpc/others] Error 2 make[1]: Leaving directory '/buildstream/build' make: *** [Makefile:9: all] Error 2
Created attachment 10151 [details] Hack to fix compilation with musl (but breaking things for all other toolchains) Here's a patch which allows GLIBC to be compiled with an x86_64-alpine-linux-musl toolchain. It makes no attempt at maintaining compatibility with other toolchains so should definitely NOT be merged into glibc.
Some fixes for OS X and FreeBSD build systems were made in commit ae7080d30c68cfa0c81ce3422dca948f64a94f50; I suppose that could be a guide to fixing this. If libtirpc has its own rpcgen / librpcsvc another option would be to phase out support for building then in glibc at all.
Just ran into this as well. I would suggest removing those OS X/FreeBSD checks and guarding the u_char_defined check by an additional `#ifdef __GLIBC__`. It seems unreasonable to assume that any random libc would define `__u_char`. Does that sound reasonable?
Given Zack's work to clean up types used in installed headers, another possibility would be to make rpc/types.h just use unsigned char etc. unconditionally when defining these typedefs.