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: 61018 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 A3E6D3852C58 for ; Wed, 23 Nov 2022 08:56:01 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A3E6D3852C58 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1669193761; 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=Byj8t6APu91f5aQGL+fd7V/8nNFfKFXVWJp9741kj4XwGO189afh4KBKYNlVOraml R+a+bx4SQEmt7yab6mDgiPRUNhpACEKinIQZiB2Ye1AUfCSKlBHi/Xp03sNmNKu0HZ WxrTsKADP42hZLFkqMFVa+fPOxVslv7rIJ5DJq84= 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+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" 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{}}; }