From nobody Sat Jun 27 21:44:13 2026 X-Original-To: freebsd-hackers@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4gnmK36m6pz6hlJy for ; Sat, 27 Jun 2026 21:44:23 +0000 (UTC) (envelope-from kargls@comcast.net) Received: from resqmta-h2p-567039.sys.comcast.net (resqmta-h2p-567039.sys.comcast.net [IPv6:2001:558:fd02:2446::9]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4gnmK33pCqz3NmG for ; Sat, 27 Jun 2026 21:44:23 +0000 (UTC) (envelope-from kargls@comcast.net) Authentication-Results: mx1.freebsd.org; none Received: from resomta-h2p-540626.sys.comcast.net ([96.102.179.210]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 256/256 bits) (Client did not present a certificate) by resqmta-h2p-567039.sys.comcast.net with ESMTPS id dYqdwfrSDOGgldaoxwnYQZ; Sat, 27 Jun 2026 21:44:15 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=comcast.net; s=20190202a; t=1782596655; bh=KU+vGFygqZ2xCfTpuoXrc+ukwmcTQ9VfaOysklcup84=; h=Received:Received:Message-ID:Date:MIME-Version:Subject:To:From: Content-Type:Xfinity-Spam-Result; b=fZoehcsGqgSqw6Hlu8/SsEabGl7ixhzxYxFt19g7+YQ8G4BUePfkt7yh+X85VC6dm afXpu37qKZ8EdvfMOPGULGcwJWC/4J5q3f+WJN8kfneYvJRi1lq2IdIm8a9XTSXhpv 6F/exW/wLLzYzYwT0HdqqkvvHA9TAA+IWfhm6LvqhQvvTiyN9qi0J//5vUgl6rnpTp tOjqZiSb9WOqSvqP9EFWHgJvf6aiu/XFylgDCTVoP/lNjT92fuOfn7OpRZg6InwNRA M9XaOoq+i/rRJiw7up40xn7AbiArRyf38329uVRioOZujYyoHVdycI/Yw6+7uv7qtS NCcCzEl0zN1xg== Received: from [10.0.0.30] ([73.97.237.216]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 256/256 bits) (Client did not present a certificate) by resomta-h2p-540626.sys.comcast.net with ESMTPSA id daovwfijLxREGdaowwDIif; Sat, 27 Jun 2026 21:44:14 +0000 Xfinity-QID: daovwfijLxREGdaoxwDIip Xfinity-Graffiti: 63808480674 Xfinity-Graffiti: 83904920052 Message-ID: Date: Sat, 27 Jun 2026 14:44:13 -0700 List-Id: Technical discussions relating to FreeBSD List-Archive: https://lists.freebsd.org/archives/freebsd-hackers List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-hackers@FreeBSD.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Please revert b2e843161d To: Adrian Chadd , Piotr Kubaj Cc: freebsd-hackers@freebsd.org References: <09C557A3-7D0A-42D7-A463-9E4162D86758@fubar.geek.nz> <29b5b60c-0395-410a-878c-e93b88927f2b@comcast.net> Content-Language: en-US From: Steve Kargl In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-CMAE-Envelope: MS4xfPKZslgPwErx+WgmmyLaDU9P58mUvvKmCjUZ4R24rF+CZVHGI/4NYAs40+/ttRRTQKAmECn9QPyqGc9aWd/NkHY4JsZ/2c9No+XzMTDa+sUd1WjxTVEm I255hdnvAPzf4EY7hPigHiIBpzukiR70EBDZWrVK3qyEAnYHy9fM1vUUuC6CHG78YoO7inwq212VSXluL7fvRFTAlL7S+J+uEGTB0jIp5PxIYnUWwesSC/Ny LincumOACPeE6PK8OAqhLg== X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[]; ASN(0.00)[asn:7922, ipnet:2001:558::/29, country:US] X-Rspamd-Queue-Id: 4gnmK33pCqz3NmG X-Spamd-Bar: ---- X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated On 6/27/26 11:49, Adrian Chadd wrote: > [cc'ing pkubaj about this, as it started with him and landing some > ppc64le float size changes] > > On Fri, 26 Jun 2026 at 10:20, Steve Kargl wrote: > >> My point is that a compiler will use its builtin if one is available >> in lieu of a function in libm. One does not need to pollute the msun >> source code with "#ifdef __builtin_XXX() #else ... #endif". It simply >> clutters comparisons to the libm code in NetBSD, OpenBSD, and Openlibm. >> I do recognize that one may need to specify a compiler option such >> as -mfma for gcc on amd64 to get a builtin. That is due to the lack >> of an fma instruction in the original amd64 instruction set. >> >> Can you at least add a cautionary comment in the source code that >> USE_BUILTIN_FMA[F] have only been tested on arm64 and may lead to >> segfaults on other architectures? > > So pkubaj@ changed the ppc64le long double from 64 -> 128 bits, and > there was a bunch of fallout from that. > > See https://reviews.freebsd.org/D57388 for more information. > I'm not surprised. I fixed a few bugs and implemented a couple ld128 functions but have no access to a ld128 system. markm gave me limited access to one of his systems to test changes a few years ago, but that's it. > There's also some missing functions he's found we also need, and that > is in https://reviews.freebsd.org/D57850 . Yes, there are "some missing functions", but I think there's a small difference in what is meant here. None of the *f128() are required by C23; whereas e.g., asinpi[fl](x) are. See https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=295884 There are ld128 asinpil, acospil, and atanpil implementations in the patch of that bug report. I've compiled the code on amd64, but have no current means for actually testing it. The patch in D57850 seems to be wrong. Instead of potential function call overhead in msun/powerpc/ld128_compat.c, e.g., long double acosf128(long double x) { return acosl(x); } one should likely use a weak reference in msun/src/e_acosl.c: #if LDBL_MANT_DIG == 128 __weak_reference(acosl, acosf128); #endif This would make acosf128 available on all ld128 architectures. Admittedly, I'm not sure if this conflicts with any particular compiler's _float128 or _float128_t. > So I/we would really like some guidance on what/where to do here. > I wonder if we would benefit from a "math" library group in reviews > so we can include that for some very targeted feedback. > > Steve, would you mind helping us navigate this? I'd super duper > appreciate it! There is the old freebsd-numerics@ mailing list. I suspect I'm the only person that is still subscribed. Typically, I sent a patch to the list. bde and I would exchange a few emails on the list, and then, ultimately he and I would have a long private email exchange. We're getting a bit off-topic for my original post. I think that the msun sources should not directly use compiler __builtin_XXX() functions. A compiler will use a builtin function if one is available (and yes, one might need to add a compiler option to get access to it). Direct use infers with the -fno-builtin compiler option. Finally, the USE_BUILTIN_* in msun code should have a comment about what arch it can be with and should likely be guarded with '#if defined(__arm64__)' (or whatever __yada applies). -- steve