On Wed, 4 Aug 2021 11:37:39 +0100 Sergei Trofimovich wrote: > In https://gcc.gnu.org/PR101305 gcc introduced ABI-specific > internal `include` include directory: > > gcc-12: > /usr/lib/gcc/x86_64-pc-linux-gnu/12.0.0/32/include > /usr/lib/gcc/x86_64-pc-linux-gnu/12.0.0/include > gcc-11: > /usr/lib/gcc/x86_64-pc-linux-gnu/11.2.0/include > > glibc's build system tries to extract only one of them and fails > the build for 32-bit ABI on x86_64: > > ../glibc/configure \ > --prefix=/usr \ > --build=x86_64-pc-linux-gnu \ > --host=i686-pc-linux-gnu \ > --with-headers=/usr/include \ > CC='x86_64-pc-linux-gnu-gcc -m32' \ > CXX='x86_64-pc-linux-gnu-g++ -m32' && > make > > python3 -B ../scripts/gen-as-const.py ... > :1:10: fatal error: stddef.h: No such file or directory > > To workaround the failure we extend `configure.ac` to also > lookup `stddef.h` include directory and add it as a lower priority > search path. > > Signed-off-by: Sergei Trofimovich > --- > configure | 37 ++++++++++++++++++++++++++++++++++--- > configure.ac | 15 ++++++++++++--- > 2 files changed, 46 insertions(+), 6 deletions(-) > > diff --git a/configure b/configure > index 9619c10991..cac124f346 100755 > --- a/configure > +++ b/configure > @@ -5452,15 +5452,46 @@ $as_echo "$as_me: WARNING: > *** some features or tests will be disabled. > *** Check the INSTALL file for required versions." >&2;} > > -# if using special system headers, find out the compiler's sekrit > -# header directory and add that to the list. NOTE: Only does the right > -# thing on a system that doesn't need fixincludes. (Not presently a problem.) > +# If using special system headers, find out the compiler's internal > +# header directory and add that to the list to negate -nostdinc effect. > +# NOTE: Only does the right thing on a system that doesn't need fixincludes. > +# (Not presently a problem.) > +# NOTE: sometimes 'include' is also present in gcc's ABI-specific paths > +# like in https://sourceware.org/PR28183. To avoid it we probe a known > +# 'stddef.h' header that resides in a common include directory. > if test -n "$sysheaders"; then > SYSINCLUDES=-nostdinc > for d in include include-fixed; do > i=`$CC -print-file-name="$d"` && test "x$i" != x && test "x$i" != "x$d" && > SYSINCLUDES="$SYSINCLUDES -isystem $i" > done > + for f in include/stddef.h; do > + i=`$CC -print-file-name="$f"` && test "x$i" != x && test "x$i" != "x$f" && > + d=`$as_dirname -- "$i" || > +$as_expr X"$i" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ > + X"$i" : 'X\(//\)[^/]' \| \ > + X"$i" : 'X\(//\)$' \| \ > + X"$i" : 'X\(/\)' \| . 2>/dev/null || > +$as_echo X"$i" | > + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ > + s//\1/ > + q > + } > + /^X\(\/\/\)[^/].*/{ > + s//\1/ > + q > + } > + /^X\(\/\/\)$/{ > + s//\1/ > + q > + } > + /^X\(\/\).*/{ > + s//\1/ > + q > + } > + s/.*/./; q'` && > + SYSINCLUDES="$SYSINCLUDES -isystem $d" > + done > SYSINCLUDES="$SYSINCLUDES \ > -isystem `echo $sysheaders | sed 's/:/ -isystem /g'`" > if test -n "$CXX"; then > diff --git a/configure.ac b/configure.ac > index 34ecbba540..9507a552ff 100644 > --- a/configure.ac > +++ b/configure.ac > @@ -1083,15 +1083,24 @@ test -n "$aux_missing" && AC_MSG_WARN([ > *** some features or tests will be disabled. > *** Check the INSTALL file for required versions.]) > > -# if using special system headers, find out the compiler's sekrit > -# header directory and add that to the list. NOTE: Only does the right > -# thing on a system that doesn't need fixincludes. (Not presently a problem.) > +# If using special system headers, find out the compiler's internal > +# header directory and add that to the list to negate -nostdinc effect. > +# NOTE: Only does the right thing on a system that doesn't need fixincludes. > +# (Not presently a problem.) > +# NOTE: sometimes 'include' is also present in gcc's ABI-specific paths > +# like in https://sourceware.org/PR28183. To avoid it we probe a known > +# 'stddef.h' header that resides in a common include directory. > if test -n "$sysheaders"; then > SYSINCLUDES=-nostdinc > for d in include include-fixed; do > i=`$CC -print-file-name="$d"` && test "x$i" != x && test "x$i" != "x$d" && > SYSINCLUDES="$SYSINCLUDES -isystem $i" > done > + for f in include/stddef.h; do > + i=`$CC -print-file-name="$f"` && test "x$i" != x && test "x$i" != "x$f" && > + d=`AS_DIRNAME(["$i"])` && > + SYSINCLUDES="$SYSINCLUDES -isystem $d" > + done > SYSINCLUDES="$SYSINCLUDES \ > -isystem `echo $sysheaders | sed 's/:/ -isystem /g'`" > if test -n "$CXX"; then Does approach look reasonable? -- Sergei