From patchwork Wed Nov 23 08:55:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 24801 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2671396wrr; Wed, 23 Nov 2022 00:56:22 -0800 (PST) X-Google-Smtp-Source: AA0mqf4L+8E94Ar7nbaieAe6YNTgJa/jmjNXp0/7MNEXeEiiV0Zw3mhxbDhgJ1KxahqZhVo4gG+3 X-Received: by 2002:a17:906:124d:b0:7ad:b822:d2e4 with SMTP id u13-20020a170906124d00b007adb822d2e4mr22908583eja.35.1669193782610; Wed, 23 Nov 2022 00:56:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669193782; cv=none; d=google.com; s=arc-20160816; b=Y5cMva5FqYw6W0piybUYdx7KVobkaJdhTZdT/21crMBYrGjC3dpFjK1XchI08NwWHA Z00Jst0avJp39nLJtNnR/d17dvj8Do7lO88OSwE9HY6KKFFACpdImEuyM9VCY/B1PY0Q BxM7gcOKGxyggKCRpJ8jAKyyaLsmzwm1orfCwR7PKMVBqlsyQJN4Tlk6Hqqv6VEbLC0h I9/mB5ecNWctlnnG8aHI2uFZWfG3mdCMaycHbm1zkmw3QTMvCyULioZtmEkph4rtjKDl zxF4GnnbkWDlNHiiAnkdeZZmvFXz8Df1LGo32ZgprWHcpj6Ksu6E9xrONGDYJ74i+Cm1 XXyw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-disposition:mime-version:message-id:subject:cc:to:date :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=OzD3fG5UL8sVxy3By/qNnZjN3mxnD0WO9tk+2D7dtuk=; b=Vzz+36dRWkBjB5AK1oK1ld2khEKxGhscRPcseSJJlRiuChGHfuLOHEzosKZXB1X+VH ExBrzsX3+QDhZgxktkvMVByzZLycXxOF5oplGHxbVhQZ+qJUkJbL7x89UQ3Y+Qn56Iej aj04/DR+tcWWnN+DvapWm3Xz6avjyCAT+kwnKMEEs/gLoYahLMjTIlIFJoLyxm1psLSM u//xDKKKltcVwVwpg542p1ERgGGh8grwlyN4zUl4mgbo1rw/mU6TDGj0jBCdn7hnVltX Z86DtD/qiVoTj37/pJwO7v0P2byG0hNe4L7wBFQiDzIeW66sBrXn7iV8uMxqxilO248I 3J0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=UOQKq+x+; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id ds19-20020a170907725300b007ae417013d6si11905412ejc.336.2022.11.23.00.56.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Nov 2022 00:56:22 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=UOQKq+x+; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 842EB3852C6B for ; Wed, 23 Nov 2022 08:56:18 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 842EB3852C6B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1669193778; bh=OzD3fG5UL8sVxy3By/qNnZjN3mxnD0WO9tk+2D7dtuk=; h=Date:To:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=UOQKq+x+dT3QkK0aXhaIp/ItCVyABeciXxtEjSPavY/88vK/TfY4M3DLOekGXe5mK WwngFYFB4hveR1vdQiRWUtM55vdJDlHROsHyvZMtr1LQaJXmft/7c30GEG8egchFIz jCtOuRqYe+SWxQUBJn0MQaB7YLPfqtLQh9dBwNTQ= 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 1D8F83858C30 for ; Wed, 23 Nov 2022 08:55:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 1D8F83858C30 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-647-M_gYY0XAOfaXPDIIcyVjQg-1; Wed, 23 Nov 2022 03:55:06 -0500 X-MC-Unique: M_gYY0XAOfaXPDIIcyVjQg-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 2045F2932486; Wed, 23 Nov 2022 08:55:06 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.194.202]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D3DBC1415114; Wed, 23 Nov 2022 08:55:05 +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 2AN8t1RL2527547 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Wed, 23 Nov 2022 09:55:01 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 2AN8t1ia2527546; Wed, 23 Nov 2022 09:55:01 +0100 Date: Wed, 23 Nov 2022 09:55:00 +0100 To: Jonathan Wakely Cc: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [PATCH] libstdc++: Fix libstdc++ build on some targets [PR107811] Message-ID: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-Spam-Status: No, score=-3.9 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_H2, SPF_HELO_NONE, SPF_NONE, TXREP 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.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Jakub Jelinek via Gcc-patches From: Jakub Jelinek Reply-To: Jakub Jelinek Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750276539655060024?= X-GMAIL-MSGID: =?utf-8?q?1750276539655060024?= Hi! fast_float library relies on size_t being 32-bit or larger and float/double being IEEE single/double. Otherwise we only use strtod/strtof. In 3 spots I've used fast_float namespace stuff unconditionally in one function, which breaks the build if fast_float is disabled. Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2022-11-23 Jakub Jelinek PR libstdc++/107811 * src/c++17/floating_from_chars.cc (__floating_from_chars_hex): Guard fast_float uses with #if USE_LIB_FAST_FLOAT and for mantissa_bits and exponent_bits provide a fallback. Jakub --- libstdc++-v3/src/c++17/floating_from_chars.cc.jj 2022-11-08 09:54:37.533397224 +0100 +++ libstdc++-v3/src/c++17/floating_from_chars.cc 2022-11-22 14:03:10.365474110 +0100 @@ -783,11 +783,16 @@ namespace using uint_t = conditional_t, uint32_t, conditional_t, uint64_t, uint16_t>>; +#if USE_LIB_FAST_FLOAT constexpr int mantissa_bits = fast_float::binary_format::mantissa_explicit_bits(); constexpr int exponent_bits = is_same_v ? 11 : is_same_v ? 5 : 8; +#else + constexpr int mantissa_bits = is_same_v ? 23 : 52; + constexpr int exponent_bits = is_same_v ? 8 : 11; +#endif constexpr int exponent_bias = (1 << (exponent_bits - 1)) - 1; __glibcxx_requires_valid_range(first, last); @@ -945,8 +950,11 @@ namespace else if (mantissa_idx >= -4) { if constexpr (is_same_v +#if USE_LIB_FAST_FLOAT || is_same_v) + fast_float::floating_type_bfloat16_t> +#endif + ) { __glibcxx_assert(mantissa_idx == -1); mantissa |= hexit >> 1; @@ -1130,6 +1138,7 @@ namespace } if constexpr (is_same_v || is_same_v) memcpy(&value, &result, sizeof(result)); +#if USE_LIB_FAST_FLOAT else if constexpr (is_same_v) { uint32_t res = uint32_t{result} << 16; @@ -1156,6 +1165,7 @@ namespace | ((uint32_t{result} & 0x8000) << 16)); memcpy(value.x, &res, sizeof(res)); } +#endif return {first, errc{}}; }