unofficial mirror of libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] configure.ac: fix include header discovery on gcc-12 [BZ #28183]
@ 2021-08-04 10:37 Sergei Trofimovich via Libc-alpha
  2021-08-16 18:15 ` Sergei Trofimovich via Libc-alpha
  2023-02-04 23:46 ` Carlos O'Donell via Libc-alpha
  0 siblings, 2 replies; 3+ messages in thread
From: Sergei Trofimovich via Libc-alpha @ 2021-08-04 10:37 UTC (permalink / raw)
  To: libc-alpha; +Cc: Sergei Trofimovich

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
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] configure.ac: fix include header discovery on gcc-12 [BZ #28183]
  2021-08-04 10:37 [PATCH] configure.ac: fix include header discovery on gcc-12 [BZ #28183] Sergei Trofimovich via Libc-alpha
@ 2021-08-16 18:15 ` Sergei Trofimovich via Libc-alpha
  2023-02-04 23:46 ` Carlos O'Donell via Libc-alpha
  1 sibling, 0 replies; 3+ messages in thread
From: Sergei Trofimovich via Libc-alpha @ 2021-08-16 18:15 UTC (permalink / raw)
  To: libc-alpha

[-- Attachment #1: Type: text/plain, Size: 4925 bytes --]

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?

-- 

  Sergei

[-- Attachment #2: Цифровая подпись OpenPGP --]
[-- Type: application/pgp-signature, Size: 981 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] configure.ac: fix include header discovery on gcc-12 [BZ #28183]
  2021-08-04 10:37 [PATCH] configure.ac: fix include header discovery on gcc-12 [BZ #28183] Sergei Trofimovich via Libc-alpha
  2021-08-16 18:15 ` Sergei Trofimovich via Libc-alpha
@ 2023-02-04 23:46 ` Carlos O'Donell via Libc-alpha
  1 sibling, 0 replies; 3+ messages in thread
From: Carlos O'Donell via Libc-alpha @ 2023-02-04 23:46 UTC (permalink / raw)
  To: Sergei Trofimovich, libc-alpha

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

-- 
Cheers,
Carlos.


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-02-04 23:46 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-04 10:37 [PATCH] configure.ac: fix include header discovery on gcc-12 [BZ #28183] Sergei Trofimovich via Libc-alpha
2021-08-16 18:15 ` Sergei Trofimovich via Libc-alpha
2023-02-04 23:46 ` Carlos O'Donell via Libc-alpha

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).