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: 81951 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 7A1B63857BA0 for ; Tue, 12 Dec 2023 08:10:11 +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+patchwork=sourceware.org@gcc.gnu.org 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@