From patchwork Wed Aug 4 10:37:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergei Trofimovich X-Patchwork-Id: 44570 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 4BCDA3853C19 for ; Wed, 4 Aug 2021 10:38:13 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4BCDA3853C19 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1628073493; bh=9QxbbncB12AZ0GqYGoMBhEaJLweJsxhORojbfi4TJ+c=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=Mw54apheq1yy88WkJJ6TG5SqHPxdMU6J3HbA7/ITmsDVDQtfAdOOO6oT+a5wVkHAt SmV2Hfhp5oimTr4yXKHptDCcN4kZtNT63D+CZ3Uvn2EFbCnOVmTV+0QIS0iCk1zI+x 1K7jSLl0p/IBZOtDNzIUZwZ7Kuco4WDG0j9cIDi0= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from smtp.gentoo.org (dev.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) by sourceware.org (Postfix) with ESMTP id DB43E3853C19 for ; Wed, 4 Aug 2021 10:37:48 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org DB43E3853C19 Received: by sf.home (Postfix, from userid 1000) id 84AB850AD9A0; Wed, 4 Aug 2021 11:37:44 +0100 (BST) To: libc-alpha@sourceware.org Subject: [PATCH] configure.ac: fix include header discovery on gcc-12 [BZ #28183] Date: Wed, 4 Aug 2021 11:37:39 +0100 Message-Id: <20210804103739.2755644-1-slyfox@gentoo.org> X-Mailer: git-send-email 2.32.0 MIME-Version: 1.0 X-Spam-Status: No, score=-12.0 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, KAM_SHORT, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Sergei Trofimovich via Libc-alpha From: Sergei Trofimovich Reply-To: Sergei Trofimovich Cc: Sergei Trofimovich Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" 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