unofficial mirror of libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Carlos O'Donell via Libc-alpha <libc-alpha@sourceware.org>
To: Sergei Trofimovich <slyfox@gentoo.org>, libc-alpha@sourceware.org
Subject: Re: [PATCH] configure.ac: fix include header discovery on gcc-12 [BZ #28183]
Date: Sat, 4 Feb 2023 18:46:25 -0500	[thread overview]
Message-ID: <3f53d014-9788-d773-8bb4-e87b013e1e10@redhat.com> (raw)
In-Reply-To: <20210804103739.2755644-1-slyfox@gentoo.org>

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.


      parent reply	other threads:[~2023-02-04 23:46 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/libc/involved.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3f53d014-9788-d773-8bb4-e87b013e1e10@redhat.com \
    --to=libc-alpha@sourceware.org \
    --cc=carlos@redhat.com \
    --cc=slyfox@gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).