configure.ac: fix include header discovery on gcc-12 [BZ #28183]
Checks
Context |
Check |
Description |
dj/TryBot-apply_patch |
success
|
Patch applied to master at the time it was sent
|
dj/TryBot-32bit |
success
|
Build for i686
|
Commit Message
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 ...
<stdin>: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 <slyfox@gentoo.org>
---
configure | 37 ++++++++++++++++++++++++++++++++++---
configure.ac | 15 ++++++++++++---
2 files changed, 46 insertions(+), 6 deletions(-)
Comments
On Wed, 4 Aug 2021 11:37:39 +0100
Sergei Trofimovich <slyfox@gentoo.org> 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 ...
> <stdin>: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 <slyfox@gentoo.org>
> ---
> 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?
On 8/4/21 06:37, Sergei Trofimovich via Libc-alpha 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
This patch is technically correct IMO, but as-of today there isn't anything
in that path that actually impacts a glibc build with gcc 12.
I cannot reproduce the error that you quote below and I've tried a variety
of configurations using Fedora gcc 12.
I would accept this patch for master, but it needs a rebase and I will
review and ACK the rebase because I agree that from first-principles we may
want that extra path in the future.
Please rebase and post and TO me.
>
> 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 ...
> <stdin>: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 <slyfox@gentoo.org>
> ---
> 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
@@ -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
@@ -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