From patchwork Fri Nov 12 20:23:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans-Peter Nilsson X-Patchwork-Id: 47574 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 58150385800F for ; Fri, 12 Nov 2021 20:23:36 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 58150385800F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1636748616; bh=8qmWNWduiHdUcwLczwI425/bg7G62gtaNJx5BqQ0xBQ=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=NQDl1WEwKuMhzRbMJglTi9p/cuwV3FR2Qi6/hUKK/dtbLThNm+/QajRVyYiZ9vyL4 g/M9rJzyiR4gg8XoCdQYMRqcQLR8E1VzXb+s7/FlTozv6A6v5wgEVVfwVkSskzISso gggsbi7nNhZW970E3VeGSOdoAcbJFOjjkQkKPhpg= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp1.axis.com (smtp1.axis.com [195.60.68.17]) by sourceware.org (Postfix) with ESMTPS id 03BBE385841B; Fri, 12 Nov 2021 20:23:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 03BBE385841B To: , Subject: [PATCH] libstdc++: Use GCC_TRY_COMPILE_OR_LINK for getentropy, arc4random MIME-Version: 1.0 Message-ID: <20211112202305.83D6A203AC@pchp3.se.axis.com> Date: Fri, 12 Nov 2021 21:23:05 +0100 X-Spam-Status: No, score=-11.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, 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: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Hans-Peter Nilsson via Gcc-patches From: Hans-Peter Nilsson Reply-To: Hans-Peter Nilsson Cc: jwakely@redhat.com Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" Since r12-5056-g3439657b0286, there has been a regression in test results; an additional 100 FAILs running the g++ and libstdc++ testsuite on cris-elf, a newlib target. The failures are linker errors, not finding a definition for getentropy. It appears newlib has since 2017-12-03 declarations of getentropy and arc4random, and provides an implementation of arc4random using getentropy, but provides no definition of getentropy, not even a stub yielding ENOSYS. This is similar to what it does for many other functions too. While fixing newlib (like adding said stub) would likely help, it still leaves older newlib releases hanging. Thankfully, the libstdc++ configury test can be improved to try linking where possible; using the bespoke GCC_TRY_COMPILE_OR_LINK instead of AC_TRY_COMPILE. BTW, I see a lack of consistency; some tests use AC_TRY_COMPILE and some GCC_TRY_COMPILE_OR_LINK for no apparent reason, but this commit just amends r12-5056-g3439657b0286. Testing for cris-elf is underway and the log says so far the related regressions are fixed. Ok to commit? libstdc++-v3: PR libstdc++/103166 * acinclude.m4 (GLIBCXX_CHECK_GETENTROPY, GLIBCXX_CHECK_ARC4RANDOM): Use GCC_TRY_COMPILE_OR_LINK instead of AC_TRY_COMPILE. * configure: Regenerate. --- libstdc++-v3/acinclude.m4 | 4 ++-- libstdc++-v3/configure | 53 +++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 53 insertions(+), 4 deletions(-) diff --git a/libstdc++-v3/acinclude.m4 b/libstdc++-v3/acinclude.m4 index 4adfdf646acb..30bd92d37f23 100644 --- a/libstdc++-v3/acinclude.m4 +++ b/libstdc++-v3/acinclude.m4 @@ -4839,7 +4839,7 @@ AC_DEFUN([GLIBCXX_CHECK_GETENTROPY], [ AC_LANG_CPLUSPLUS AC_MSG_CHECKING([for getentropy]) AC_CACHE_VAL(glibcxx_cv_getentropy, [ - AC_TRY_COMPILE( + GCC_TRY_COMPILE_OR_LINK( [#include ], [unsigned i; ::getentropy(&i, sizeof(i));], @@ -4862,7 +4862,7 @@ AC_DEFUN([GLIBCXX_CHECK_ARC4RANDOM], [ AC_LANG_CPLUSPLUS AC_MSG_CHECKING([for arc4random]) AC_CACHE_VAL(glibcxx_cv_arc4random, [ - AC_TRY_COMPILE( + GCC_TRY_COMPILE_OR_LINK( [#include ], [unsigned i = ::arc4random();], [glibcxx_cv_arc4random=yes], [glibcxx_cv_arc4random=no]) diff --git a/libstdc++-v3/configure b/libstdc++-v3/configure index 3a572475546f..3eb391f409f2 100755 --- a/libstdc++-v3/configure +++ b/libstdc++-v3/configure @@ -75445,7 +75445,8 @@ $as_echo_n "checking for getentropy... " >&6; } $as_echo_n "(cached) " >&6 else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + if test x$gcc_no_link = xyes; then + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int @@ -75463,6 +75464,30 @@ else glibcxx_cv_getentropy=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +else + if test x$gcc_no_link = xyes; then + as_fn_error $? "Link tests are not allowed after GCC_NO_EXECUTABLES." "$LINENO" 5 +fi +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +int +main () +{ +unsigned i; + ::getentropy(&i, sizeof(i)); + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_link "$LINENO"; then : + glibcxx_cv_getentropy=yes +else + glibcxx_cv_getentropy=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi fi @@ -75496,7 +75521,8 @@ $as_echo_n "checking for arc4random... " >&6; } $as_echo_n "(cached) " >&6 else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + if test x$gcc_no_link = xyes; then + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int @@ -75513,6 +75539,29 @@ else glibcxx_cv_arc4random=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +else + if test x$gcc_no_link = xyes; then + as_fn_error $? "Link tests are not allowed after GCC_NO_EXECUTABLES." "$LINENO" 5 +fi +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +int +main () +{ +unsigned i = ::arc4random(); + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_link "$LINENO"; then : + glibcxx_cv_arc4random=yes +else + glibcxx_cv_arc4random=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi fi