https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94089
Bug ID: 94089 Summary: fixincludes of <bits/statx.h> breaks gcc after glibc-2.31 upgrade Product: gcc Version: 10.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: bootstrap Assignee: unassigned at gcc dot gnu.org Reporter: mikpelinux at gmail dot com Target Milestone: --- A gcc built against glibc-2.30 (and some earlier releases) will fixinclude <bits/statx.h> and store a modified copy in its installation. This copy differs from glibc's as follows: @@ -1,3 +1,12 @@ +/* DO NOT EDIT THIS FILE. + + It has been auto-edited by fixincludes from: + + "/tmp/cross-x86_64/usr/include/bits/statx.h" + + This had to be done to correct non-standard usages in the + original, manufacturer supplied header file. */ + /* statx-related definitions and declarations. Linux version. Copyright (C) 2018-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. @@ -26,7 +35,7 @@ /* Use "" to work around incorrect macro expansion of the __has_include argument (GCC PR 80005). */ -#if __glibc_has_include ("linux/stat.h") +#if __glibc_has_include ("__linux__/stat.h") # include "linux/stat.h" # ifdef STATX_TYPE # define __statx_timestamp_defined 1 The incorrect replacement of linux with __linux__ is tracked as PR91085, but that is not the issue reported here. Now assume this compiler installation is used with glibc-2.31 (for instance, due to an OS upgrade), and try to compile the following: > cat test.c #define _GNU_SOURCE #include <sys/stat.h> int main (void) { return 0; } > /tmp/cross-x86_64/bin/x86_64-unknown-linux-gcc -Wall -O2 -c test.c In file included from /tmp/cross-x86_64/usr/include/sys/stat.h:446, from test.c:2: /tmp/cross-x86_64/lib/gcc/x86_64-unknown-linux/8.4.0/include-fixed/bits/statx.h:38:25: error: missing binary operator before token "(" #if __glibc_has_include ("__linux__/stat.h") This error occurs because the fixincluded <bits/statx.h> refers to the __glibc_had_include () macro which was removed in glibc-2.31. If this gcc is now used to bootstrap another on on the glibc-2.31 system, lots of configure tests fail, and the build errors out in libiberty: gcc -c -DHAVE_CONFIG_H -g -I. -I/tmp/gcc-9.3.0-RC-20200305/libiberty/../include -W -Wall -Wwrite-strings -Wc++-compat -Wstrict-prototypes -Wshadow=local -pedantic -D_GNU_SOURCE -fpic /tmp/gcc-9.3.0-RC-20200305/libiberty/regex.c -o pic/regex.o; \ else true; fi In file included from /tmp/gcc-9.3.0-RC-20200305/libiberty/regex.c:38: ./config.h:568:15: error: two or more data types in declaration specifiers #define pid_t int ^~~ ./config.h:571:17: error: two or more data types in declaration specifiers #define ssize_t int ^~~ make[3]: *** [Makefile:1167: regex.o] Error 1 make[3]: Leaving directory '/tmp/objdir/libiberty' make[2]: *** [Makefile:11197: all-stage1-libiberty] Error 2 make[2]: Leaving directory '/tmp/objdir' make[1]: *** [Makefile:21422: stage1-bubble] Error 2 make[1]: Leaving directory '/tmp/objdir' make: *** [Makefile:993: all] Error 2 This error is the result of configure tests that failed due to direct or indirect includes of <sys/stat.h>. This is what I noticed after an upgrade from Fedora 30 to Fedora 31: my existing gcc:s could no longer bootstrap new ones. While one could argue that glibc-2.31 was in error to remove the __glibc_has_include () macro, gcc is also in error for creating that unnecessary dependency in the first place: it should not have fixincluded <bits/statx.h>. The error is easily reproduced by building a cross with glibc-2.30 and then updating it to glibc-2.31 (which is why some of the samples above mention a cross rather than a native compiler).