From nobody Tue Oct 4 15:57:39 2022 X-Original-To: freebsd-arch@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 4Mhj5d4FQ0z4f83w for ; Tue, 4 Oct 2022 15:57:41 +0000 (UTC) (envelope-from brooks@spindle.one-eyed-alien.net) Received: from spindle.one-eyed-alien.net (spindle.one-eyed-alien.net [199.48.129.229]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4Mhj5c4JWXz3xQw; Tue, 4 Oct 2022 15:57:40 +0000 (UTC) (envelope-from brooks@spindle.one-eyed-alien.net) Received: by spindle.one-eyed-alien.net (Postfix, from userid 3001) id D2B2A3C0199; Tue, 4 Oct 2022 15:57:39 +0000 (UTC) Date: Tue, 4 Oct 2022 15:57:39 +0000 From: Brooks Davis To: Alexander Richardson Cc: Brooks Davis , freebsd-arch@freebsd.org Subject: Re: enabling float128 support in clang? Message-ID: <20221004155739.GA84006@spindle.one-eyed-alien.net> References: <20221003184310.GA20951@spindle.one-eyed-alien.net> List-Id: Discussion related to FreeBSD architecture List-Archive: https://lists.freebsd.org/archives/freebsd-arch List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-arch@freebsd.org MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="rwEMma7ioTxnRzrJ" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) X-Rspamd-Queue-Id: 4Mhj5c4JWXz3xQw X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=none; spf=none (mx1.freebsd.org: domain of brooks@spindle.one-eyed-alien.net has no SPF policy when checking 199.48.129.229) smtp.mailfrom=brooks@spindle.one-eyed-alien.net X-Spamd-Result: default: False [-2.90 / 15.00]; SIGNED_PGP(-2.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; SUBJECT_ENDS_QUESTION(1.00)[]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; AUTH_NA(1.00)[]; NEURAL_HAM_SHORT(-1.00)[-0.999]; FORGED_SENDER(0.30)[brooks@freebsd.org,brooks@spindle.one-eyed-alien.net]; MIME_GOOD(-0.20)[multipart/signed,text/plain]; ARC_NA(0.00)[]; MLMMJ_DEST(0.00)[freebsd-arch@freebsd.org]; R_DKIM_NA(0.00)[]; ASN(0.00)[asn:36236, ipnet:199.48.128.0/22, country:US]; MIME_TRACE(0.00)[0:+,1:+,2:~]; TO_DN_SOME(0.00)[]; FREEFALL_USER(0.00)[brooks]; FROM_HAS_DN(0.00)[]; RCVD_TLS_LAST(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; RCPT_COUNT_THREE(0.00)[3]; DMARC_NA(0.00)[freebsd.org]; FROM_NEQ_ENVFROM(0.00)[brooks@freebsd.org,brooks@spindle.one-eyed-alien.net]; R_SPF_NA(0.00)[no SPF record]; RCVD_COUNT_TWO(0.00)[2] X-ThisMailContainsUnwantedMimeParts: N --rwEMma7ioTxnRzrJ Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Oct 04, 2022 at 04:02:05PM +0100, Alexander Richardson wrote: > On Mon, 3 Oct 2022 at 19:43, Brooks Davis wrote: > > > > TL;DR: Is there a reason not to enable float128 support in clang for > > x86? > > > > Due to a build breakage with the flang runtime, I recently noticed that > > unlike most other OSes we don't support float128 in clang. It's enable > > in modern GCC and other OSes have it enable in clang: > > - Hakiu 2018: https://reviews.llvm.org/D54901 > > - Solaris 2018: https://reviews.llvm.org/D41240 > > - WASM 2019: https://reviews.llvm.org/D57154 > > - Dragonfly 2021: https://reviews.llvm.org/D111760 > > - OpenBSD (history hard to find...) > > > > Is there a known reason not to enable this? > > > > Patch to enable below (I'm a bit skeptical of the __FLOAT128__ part as > > GCC doesn't define it...) > > > > -- Brooks > > > > diff --git a/clang/lib/Basic/Targets/OSTargets.h b/clang/lib/Basic/Targ= ets/OSTargets.h > > index c75f7d9fbafe..ea95f40e81a0 100644 > > --- a/clang/lib/Basic/Targets/OSTargets.h > > +++ b/clang/lib/Basic/Targets/OSTargets.h > > @@ -232,6 +232,9 @@ protected: > > // setting this to 1 is conforming even if all the basic source > > // character literals have the same encoding as char and wchar_t. > > Builder.defineMacro("__STDC_MB_MIGHT_NEQ_WC__", "1"); > > + > > + if (this->HasFloat128) > > + Builder.defineMacro("__FLOAT128__"); > > } > > > > public: > > @@ -241,6 +244,7 @@ public: > > default: > > case llvm::Triple::x86: > > case llvm::Triple::x86_64: > > + this->HasFloat128 =3D true; > > this->MCountName =3D ".mcount"; > > break; > > case llvm::Triple::mips: > > >=20 > I think this makes sense and may even motivate me to try and get the > necessary library calls merged to compiler-rt > (https://reviews.llvm.org/D98261). Sounds good. I'll submit a review. > One thing to note is that your current patch will also enable float128 > for AArch64 (and other targets), which I don't believe any other OS > does. > I think it makes sense to restrict it to just x86 to avoid executing > code in the compiler that has not been well tested. I believe for all > other supported architectures long double is the same as float128 so > it probably doesn't make too much sense to enable it there anyway. Oops, that was an oversight. Thanks for catching. I'll restructure the block like the OpenBSD one (x86 falls through to default). -- Brooks --rwEMma7ioTxnRzrJ Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEcBAEBAgAGBQJjPFfzAAoJEKzQXbSebgfAU0AH/RtCX+FFx9GAsXccCNC9Ml5Y thlaGG8HVKz7J9Hk275MXhOeUgbq5OxC+zPX+LNttPD5u9PEGgB7T6ID+FC7uNuD 3mLgJXlCY1snS0szG1BJ8M5/6HfIzG1F9WlKZFdokZKOVsAGyePMakylN2M7hV2b Es4dq4r5/jT8QiVNuC/h8vayZCFgX30HL7ZwCkuyfJJOm6gfUIraTF1m8/0ch5FD d69lzuXPr/KjEvsmJbp9uBJzcG06DW2rfpnXXLdhN3i+oMQCXVZoYUIc+CM4tu0G XX1E606EJU7NDwcLm7QcrKVk01nEt38mu7eE5LudibpQoEVBakT5DPbxEBYIdd8= =56d0 -----END PGP SIGNATURE----- --rwEMma7ioTxnRzrJ--