From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2153) id 7E22B3858C62; Mon, 7 Nov 2022 23:36:30 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7E22B3858C62 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1667864190; bh=nyLwR472/x4yQWLmplYzuSoDGdOXygQE6pQsa4mnVS0=; h=From:To:Subject:Date:From; b=L6eK34iplGdMOAzP1I85khHtI7aO3pFI+EtlnR/Cr8L+mGBTZb5adrpfKiMdQDWi4 O5x8zIv1Mzac7EzcxIlKPeLF+2DeY7jg3LUlBcHGC0a46wfSSgT4PfKi1PAbcugm3B 9bwXLujU4IudvmIKhAh3Lry9LVEdCwVqmb5mPRTc= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Jakub Jelinek To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org Subject: [gcc r13-3763] libstdc++: Fix up libstdc++ build against glibc 2.25 or older [PR107562] X-Act-Checkin: gcc X-Git-Author: Jakub Jelinek X-Git-Refname: refs/heads/master X-Git-Oldrev: 93ab7d03dfbdd096c1d3c83e92d794bf4eed18df X-Git-Newrev: b457b779427b0f7b3fbac447811c9c52db5bc79e Message-Id: <20221107233630.7E22B3858C62@sourceware.org> Date: Mon, 7 Nov 2022 23:36:30 +0000 (GMT) List-Id: https://gcc.gnu.org/g:b457b779427b0f7b3fbac447811c9c52db5bc79e commit r13-3763-gb457b779427b0f7b3fbac447811c9c52db5bc79e Author: Jakub Jelinek Date: Tue Nov 8 00:35:09 2022 +0100 libstdc++: Fix up libstdc++ build against glibc 2.25 or older [PR107562] On Mon, Nov 07, 2022 at 05:48:42PM +0000, Jonathan Wakely wrote: > On Mon, 7 Nov 2022 at 16:11, Joseph Myers wrote: > > > > On Wed, 2 Nov 2022, Jakub Jelinek via Gcc-patches wrote: > > > > > APIs. So that one can build gcc against older glibc and then compile > > > user programs on newer glibc, the patch uses weak references unless > > > gcc is compiled against glibc 2.26+. strfromf128 unfortunately can't > > > > This support for older glibc doesn't actually seem to be working, on an > > older system with glibc 2.19 I'm seeing > > > > /scratch/jmyers/fsf/gcc-mainline/libstdc++-v3/src/c++17/floating_to_chars.cc:52:3: error: expected initializer before '__asm' > > 52 | __asm ("strfromf128"); > > | ^~~~~ > > > > and a series of subsequent errors. > > This seems to "fix" it (not sure if it's right though): > > #ifndef _GLIBCXX_HAVE_FLOAT128_MATH > extern "C" _Float128 __strtof128(const char*, char**) > __attribute__((__weak__)); > #endif > extern "C" _Float128 __strtof128(const char*, char**) > __asm ("strtof128"); It is, but floating_from_chars.cc has the same problem, and I think we can avoid the duplication, like this: 2022-11-08 Jakub Jelinek PR libstdc++/107562 * src/c++17/floating_from_chars.cc (__strtof128): Put __asm before __attribute__. * src/c++17/floating_to_chars.cc (__strfromf128): Likewise. Diff: --- libstdc++-v3/src/c++17/floating_from_chars.cc | 3 ++- libstdc++-v3/src/c++17/floating_to_chars.cc | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/libstdc++-v3/src/c++17/floating_from_chars.cc b/libstdc++-v3/src/c++17/floating_from_chars.cc index 11a9be68770..29eb4634e9d 100644 --- a/libstdc++-v3/src/c++17/floating_from_chars.cc +++ b/libstdc++-v3/src/c++17/floating_from_chars.cc @@ -63,10 +63,11 @@ extern "C" __ieee128 __strtoieee128(const char*, char**); && defined(__GLIBC_PREREQ) #define USE_STRTOF128_FOR_FROM_CHARS 1 extern "C" _Float128 __strtof128(const char*, char**) + __asm ("strtof128") #ifndef _GLIBCXX_HAVE_FLOAT128_MATH __attribute__((__weak__)) #endif - __asm ("strtof128"); + ; #endif #if _GLIBCXX_FLOAT_IS_IEEE_BINARY32 && _GLIBCXX_DOUBLE_IS_IEEE_BINARY64 \ diff --git a/libstdc++-v3/src/c++17/floating_to_chars.cc b/libstdc++-v3/src/c++17/floating_to_chars.cc index d6be6465b12..afce8d74c12 100644 --- a/libstdc++-v3/src/c++17/floating_to_chars.cc +++ b/libstdc++-v3/src/c++17/floating_to_chars.cc @@ -46,10 +46,11 @@ extern "C" int __sprintfieee128(char*, const char*, ...); #elif __FLT128_MANT_DIG__ == 113 && __LDBL_MANT_DIG__ != 113 \ && defined(__GLIBC_PREREQ) extern "C" int __strfromf128(char*, size_t, const char*, _Float128) + __asm ("strfromf128") #ifndef _GLIBCXX_HAVE_FLOAT128_MATH __attribute__((__weak__)) #endif - __asm ("strfromf128"); + ; #endif // This implementation crucially assumes float/double have the