From nobody Tue Jan 30 13:30:54 2024 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 4TPQzV02fTz58rNH for ; Tue, 30 Jan 2024 13:31:02 +0000 (UTC) (envelope-from lexi@le-fay.org) Received: from thyme.eden.le-Fay.ORG (THYME.EDEN.LE-FAY.ORG [81.187.47.194]) by mx1.freebsd.org (Postfix) with ESMTP id 4TPQzT21QQz4brZ for ; Tue, 30 Jan 2024 13:31:01 +0000 (UTC) (envelope-from lexi@le-fay.org) Authentication-Results: mx1.freebsd.org; dkim=pass header.d=le-fay.org header.s=thyme header.b=LcMluT1x; dmarc=none; spf=pass (mx1.freebsd.org: domain of lexi@le-fay.org designates 81.187.47.194 as permitted sender) smtp.mailfrom=lexi@le-fay.org Received: from iris.eden.le-Fay.ORG (IRIS.EDEN.LE-FAY.ORG [IPv6:2001:8b0:aab5:106::18]) by thyme.eden.le-Fay.ORG (Postfix) with ESMTP id 8CC9E2A687 for ; Tue, 30 Jan 2024 13:30:54 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=le-fay.org; s=thyme; t=1706621454; bh=Pqw0l7i0VpKAOmufgZq4xOtpb3VH484EfTvI0V2OOhg=; h=Date:From:To:Subject; b=LcMluT1xT7PIu6SIUEupwHJceD7Hv513O3kHK7nQIK7TplWI434nak7o+15mDBKYX TKPb97/d119e3o+Iu5BilT1XLXMRKnuqyZIZyiT8qyGSiGtusCrRHeDCDkdz5CnjwL HEkeoBWX3/b/df8ZKqfr8CIZWimQ7ZSEimMsrric= Received: from ilythia.eden.le-fay.org (ILYTHIA.EDEN.LE-FAY.ORG [IPv6:2001:8b0:aab5:104:3::101]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by iris.eden.le-Fay.ORG (Postfix) with ESMTPSA id 801D489A9 for ; Tue, 30 Jan 2024 13:30:54 +0000 (GMT) Date: Tue, 30 Jan 2024 13:30:54 +0000 From: Lexi Winter To: freebsd-arch@freebsd.org Subject: improving C++ libc headers Message-ID: Mail-Followup-To: freebsd-arch@freebsd.org 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-sha256; protocol="application/pgp-signature"; boundary="nJjOCEOJipdTs2Bi" Content-Disposition: inline X-Spamd-Bar: ----- X-Spamd-Result: default: False [-5.49 / 15.00]; SIGNED_PGP(-2.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; NEURAL_HAM_SHORT(-0.99)[-0.991]; MIME_GOOD(-0.20)[multipart/signed,text/plain]; R_DKIM_ALLOW(-0.20)[le-fay.org:s=thyme]; R_SPF_ALLOW(-0.20)[+ip4:81.187.47.194:c]; RCVD_NO_TLS_LAST(0.10)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; MIME_TRACE(0.00)[0:+,1:+,2:~]; ARC_NA(0.00)[]; ASN(0.00)[asn:20712, ipnet:81.187.0.0/16, country:GB]; RCPT_COUNT_ONE(0.00)[1]; MISSING_XM_UA(0.00)[]; FROM_HAS_DN(0.00)[]; DMARC_NA(0.00)[le-fay.org]; MID_RHS_MATCH_FROMTLD(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; FROM_EQ_ENVFROM(0.00)[]; DWL_DNSWL_NONE(0.00)[le-fay.org:dkim]; TO_DN_NONE(0.00)[]; PREVIOUSLY_DELIVERED(0.00)[freebsd-arch@freebsd.org]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MLMMJ_DEST(0.00)[freebsd-arch@freebsd.org]; DKIM_TRACE(0.00)[le-fay.org:+] X-Rspamd-Queue-Id: 4TPQzT21QQz4brZ --nJjOCEOJipdTs2Bi Content-Type: text/plain; charset=us-ascii Content-Disposition: inline hi list, i am considering working up a patch to improve C++ libc headers in FreeBSD. the problem with the current headers (which come from clang/libc++) is that this code compiles: ------ #include auto main() -> int { exit(0); } ------ this should be a compile-time error, because does not declare ::exit[0]. however, it works because is implemented like this: ------ #include // exposes ::exit() namespace std { using ::exit; // ... } ------ i would like to replace this with an implementation that does this instead: ------ namespace std { extern "C" void exit(int); // ... } ------ i have done a very quick proof of concept for this and it does work; there are some more complicated edge cases, but nothing that can't be dealt with from what i can see. but before i put any amount of significant effort into this, i'd like to check if this is something that is likely to be merged. to address some potential objections: - i don't believe this can be handled upstream in libc++, because some of these headers require knowledge of the implementation - needs to know about 'struct __sFILE', for example. - "import std" should solve this properly, but there are a lot of implementation issues with this and it's not clear if/when it will ever be supported; in the mean time, the existing standard headers should behave correctly. [0] https://www.eel.is/c++draft/cstdlib.syn#header:%3Ccstdlib%3E [1] https://cgit.freebsd.org/src/tree/contrib/llvm-project/libcxx/include/cstdlib --nJjOCEOJipdTs2Bi Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQGzBAABCAAdFiEEuwt6MaPcv/+Mo+ftDHqbqZ41x5kFAmW4+gsACgkQDHqbqZ41 x5n1RAv/X0qs0gIRVtIM7tAfxJi7CFPmEgWH4crfPIpEQT+X3SfgDSO0HAMvleqt POidCb2xwAZ9xJ4AFBd0dL8U/BUfEfG4pRRkllku2SfQdf1VTx+gKi1kfNXnzWUq pEdZQSTI+oTy1lHraddimLV6aM+UrTH6KLCenwhkZcCtP5q11LiG7k3JJjfGKVYo vhlXWMz5qCy3tjU13/XeAP7BiuqCbcnwrJSa4Hxe8COOMwMmyl75BRIV1x/46ODG Xbnlv/poxl1bS0XwjYp+PkLFA6nR3jcb1P04mxcZqnF0fqAvGHTNVfI5/OXhHbZM H3jLHzpDRoTl9hyAGiL5uEPgWVatG4Qyjdteffk1HYupcEjr6TSOliCD0BGPGdLe UwN+EjnuIymRmbN0oLMGoSvRV5QkTig4DaaKSmiyHDYco8iZ2pmTg3mqnv0Pa3uI adXelkf2/GOgXWGkp1MO4du7Xr3hisdN565H3WbGTfhBbCl3N6GXdPdo6YJo3OJ2 WmwaP51e =so+Z -----END PGP SIGNATURE----- --nJjOCEOJipdTs2Bi--