From patchwork Tue Dec 12 08:09:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 177132 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp7577063vqy; Tue, 12 Dec 2023 00:10:20 -0800 (PST) X-Google-Smtp-Source: AGHT+IHcr4NnkAlOzZB7AZgkYsUwof375v6bmoCMuuKnYhXZXdmSm1YsYue69oHdK+nT0plfjLfa X-Received: by 2002:a05:620a:4145:b0:77e:fba3:4f28 with SMTP id k5-20020a05620a414500b0077efba34f28mr7471674qko.126.1702368620595; Tue, 12 Dec 2023 00:10:20 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1702368620; cv=pass; d=google.com; s=arc-20160816; b=IbsyKnOPKwXHSdUiFnE2BOUZdQHrNAvm9UIfXf/UtbnPKlwEfcpZiszPBhXU/zjNz0 ghfXNq7y1qJtp112krOrm8oO9KqRKKt0N3sMrubnAPh9pX5FQYHF1N/11FIq08BHsK+c DavX9g86VfogCC3HIIHo+olP54d8uBYQ0Ur79FewJqgsxreYbVVZY309tJ9wjyDU2+iP 6VR0xQ8elFmFjNYpeL7bkkXmPVK4uomL71WV7eJHZCBw7not6r6dVHl+Az82MsqEMZiB lwndrKbVybNt7/M7giGdT146dQ5RxDFTymKQmScaNoQ56cfhWKPLshZUIsvea3DBQB8J Lf4Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:reply-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-disposition :mime-version:message-id:subject:to:from:date:dkim-signature :arc-filter:dmarc-filter:delivered-to; bh=zRKIWqQF8Gi35pnJ8ZuCjuLLLKS0EKfr/S3evVpUic4=; fh=hPrbWPhweUx4V0GV9uXJqbyAzg2ABmTz7kczrAQqMmM=; b=GH3nzyMYPg0tQpSZOTQmVpVioqP1zM6ctcTu+juvbC0JYJCl/O6PdXGDF44B6vitzo qdG6+zQhDzzjBw6d45CqkXZEvG6ui1BxxpII01lJpMqSBeEY30u9MCovEuWvDa6LdlXg 39V/0vDq3VbXKglpVZK8Rk5NRlEl9IE0wljzDKyrwVwiKgGpd9ylIlgsn5oAiaYjfcEk ZkOMhpw8KtImwKwpE4KuLrC305JqcaCsC9/8Jk81Z/6G4GtFa40FjgIudNAMrJYYT8X3 IA0kMeMuxTvDr8jCKmGXrU5MUJPh6wlJZfVqtXRep57OBTLfEVysqNzkmuvZ8q1UV/iE GU8Q== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=LtCLypp5; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from server2.sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id x14-20020a05620a14ae00b0077d8969c31bsi9749056qkj.506.2023.12.12.00.10.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Dec 2023 00:10:20 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=LtCLypp5; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 6A202385AC22 for ; Tue, 12 Dec 2023 08:10:19 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id F21703858C78 for ; Tue, 12 Dec 2023 08:09:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org F21703858C78 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org F21703858C78 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1702368596; cv=none; b=snqQCNxs02MPwhm7DdRUAGk09IvSZq2sLk+hOpMAhfy+Q6e1+ckkZY/r40OOjWt/Usiuf6oW62IUfInKeX7yO1Dx6MOotzRQFFa/mdYxzr7g0a/rdfbgsj8qsO/b9o3p37lbDe2xsSijEYqpotNRkLu6aYaAEO4M9z72xZ7nK5M= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1702368596; c=relaxed/simple; bh=6LCzwGZyzgDnc3ZNcj9ChSgNMkxEc+qNBJDlyGx/5Zo=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=JM2xFE3lP0/955rUOJ+zUZkfH/uisvWSzNbTmljyc9L7E7A2W+1rYe7mYYQScXlV1YrDgBEjpxgH0BJ6xvVDzJc869jZZ2dPk4gYAthVXjlvVIax2nCt+BeBvaoqLGixn6ZvNjYFAJU4KO/NpF1NXCCsCu0c0Uvx50nMhfO6ywg= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1702368594; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type; bh=zRKIWqQF8Gi35pnJ8ZuCjuLLLKS0EKfr/S3evVpUic4=; b=LtCLypp5/hQO4A1t/X3jaFm12CDvdkhCeG9C4Y4IklXIjm3sFvnPe+dtB2tjCj94Ai2jU0 2T2zze+rBMubZfJZWnpypeSmY7A2cZJ6Oq2JpLDvjdKD5Nd9+wKvb/K+lKPA+/z2tKajJP HL176gS0CyJGEfK84rh1nVSqW6XwlPE= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-615-b4Dbx5AvPvKhMfIaibbgWg-1; Tue, 12 Dec 2023 03:09:53 -0500 X-MC-Unique: b4Dbx5AvPvKhMfIaibbgWg-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 0BD91101A551 for ; Tue, 12 Dec 2023 08:09:53 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.192.92]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C498E51E3 for ; Tue, 12 Dec 2023 08:09:52 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.17.1/8.17.1) with ESMTPS id 3BC89oDC1696254 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT) for ; Tue, 12 Dec 2023 09:09:50 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 3BC89nXm1696253 for gcc-patches@gcc.gnu.org; Tue, 12 Dec 2023 09:09:49 +0100 Date: Tue, 12 Dec 2023 09:09:49 +0100 From: Jakub Jelinek To: gcc-patches@gcc.gnu.org Subject: [committed] libquadmath: Restore linking against -lm on most targets [PR112963] Message-ID: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.5 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-Spam-Status: No, score=-3.4 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Jakub Jelinek Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785062879013102205 X-GMAIL-MSGID: 1785062879013102205 Hi! The r14-4825 change added AC_CHECK_LIBM to libquadmath configure.ac and replaced unconditional linking with -lm with linking with $(LIBM) determined by that. Unfortunately that broke bare metal targets because AC_CHECK_LIBM attempts to link against -lm and this was after (unconditional) GCC_NO_EXECUTABLES. Then r14-4863 partially reverted that change (no longer AC_CHECK_LIBM), but didn't revert the Makefile.am change of -lm to $(LIBM), which had the effect that libquadmath is not linked against -lm on any arch. That is a serious problem though e.g. on Linux, because libquadmath calls a few libm entrypoints and e.g. on powerpc64le the underlinking can cause crashes in IFUNC resolvers of libm. Instead of adding further reversion of the r14-4825 commit and use -lm unconditionally again, this patch adds an AC_CHECK_LIBM like substitutions with the *-ncr-sysv4.3* target handling removed (I think we don't support such targets, especially not in libquadmath) and with the default case replaced by simple using -lm. That is something in between using -lm unconditionally and what AC_CHECK_LIBM does if it would work on bare metal - we know from GCC 13 and earlier that we can link -lm on all targets libquadmath is built for, and just white list a couple of targets which we know don't have separate -lm and don't want to link against that (like Darwin, Cygwin, ...). Bootstrapped/regtested on x86_64-linux and i686-linux, committed to trunk. 2023-12-12 Jakub Jelinek PR libquadmath/112963 * configure.ac (LIBM): Readd AC_CHECK_LIBM-like check without doing AC_CHECK_LIB in it. * configure: Regenerated. * Makefile.in: Regenerated. Jakub --- libquadmath/configure.ac.jj 2023-11-02 07:49:22.120795297 +0100 +++ libquadmath/configure.ac 2023-12-11 19:03:50.823783215 +0100 @@ -122,6 +122,20 @@ esac AC_SUBST(toolexecdir) AC_SUBST(toolexeclibdir) +# AC_CHECK_LIBM variant which avoids AC_CHECK_LIB (that doesn't work +# on bare metal). In the past we've used -lm in Makefile.am unconditionally, +# let's use it there unless target knows it doesn't need that. +LIBM= +case $host in +*-*-beos* | *-*-cegcc* | *-*-cygwin* | *-*-haiku* | *-*-pw32* | *-*-darwin*) + # These system don't have libm, or don't need it + ;; +*) + LIBM=-lm + ;; +esac +AC_SUBST([LIBM]) + AC_CHECK_HEADERS(fenv.h langinfo.h locale.h wchar.h wctype.h limits.h ctype.h printf.h errno.h) LIBQUAD_CHECK_MATH_H_SIGNGAM --- libquadmath/configure.jj 2023-11-02 07:49:22.119795311 +0100 +++ libquadmath/configure 2023-12-11 19:04:04.239598274 +0100 @@ -644,6 +644,7 @@ LIBQUAD_USE_SYMVER_GNU_FALSE LIBQUAD_USE_SYMVER_GNU_TRUE LIBQUAD_USE_SYMVER_FALSE LIBQUAD_USE_SYMVER_TRUE +LIBM toolexeclibdir toolexecdir MAINT @@ -10921,7 +10922,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 10924 "configure" +#line 10925 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -11027,7 +11028,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 11030 "configure" +#line 11031 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -12260,6 +12261,20 @@ esac +# AC_CHECK_LIBM variant which avoids AC_CHECK_LIB (that doesn't work +# on bare metal). In the past we've used -lm in Makefile.am unconditionally, +# let's use it there unless target knows it doesn't need that. +LIBM= +case $host in +*-*-beos* | *-*-cegcc* | *-*-cygwin* | *-*-haiku* | *-*-pw32* | *-*-darwin*) + # These system don't have libm, or don't need it + ;; +*) + LIBM=-lm + ;; +esac + + for ac_header in fenv.h langinfo.h locale.h wchar.h wctype.h limits.h ctype.h printf.h errno.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` --- libquadmath/Makefile.in.jj 2023-11-02 07:49:22.108795464 +0100 +++ libquadmath/Makefile.in 2023-12-11 19:04:57.971857555 +0100 @@ -355,6 +355,7 @@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ +LIBM = @LIBM@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@