From nobody Tue Jan 30 19:12:16 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 4TPZYT2hCTz59Npv for ; Tue, 30 Jan 2024 19:12:29 +0000 (UTC) (envelope-from yaneurabeya@gmail.com) Received: from mail-pg1-x536.google.com (mail-pg1-x536.google.com [IPv6:2607:f8b0:4864:20::536]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1D4" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4TPZYT0sXwz4YNt for ; Tue, 30 Jan 2024 19:12:29 +0000 (UTC) (envelope-from yaneurabeya@gmail.com) Authentication-Results: mx1.freebsd.org; none Received: by mail-pg1-x536.google.com with SMTP id 41be03b00d2f7-5ceb3fe708eso2666798a12.3 for ; Tue, 30 Jan 2024 11:12:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706641948; x=1707246748; darn=freebsd.org; h=to:in-reply-to:cc:references:message-id:date:subject:mime-version :from:content-transfer-encoding:from:to:cc:subject:date:message-id :reply-to; bh=9Vd/fWk58W/7iGNGuy5+bW4dTk/9Mk4M5m4QO6FcNMo=; b=JOFs3tZXja3fWuB1otTo6HLNxJGnr2UCumipbDD4qIUzHy/xo7PHpgVoGLmsfATH0d X38+dLylFAIeNp9jIN/ejMtu95Rg+BRZH0K986JMxLjrlPl0hU/2YacHNTEwAk5/Bl01 NSon73smFPv9J62kkyRUxVzFiUWhmsnYJErVrHzTJocyn6zxxlNpe0SyIXxUtfQrxcPZ Jwms2BVQQveqm/eV5TIq4L4SgEfBbOtGdxbFrQL2pNN38wx/FsHYivWzJNTxFU5epJXJ 9zTmMSPNzb2+GrPQVjpi3Ysh1iKJwmNuPNzXVE9TOC7qC25StZrpuYoGVnPtyY9XzWkj NuMQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706641948; x=1707246748; h=to:in-reply-to:cc:references:message-id:date:subject:mime-version :from:content-transfer-encoding:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=9Vd/fWk58W/7iGNGuy5+bW4dTk/9Mk4M5m4QO6FcNMo=; b=IBZnjlWOlPowQRonOXSt5iHbHt52Ymn3AHANn2D1NTCxtMnIUpPaLChb00DKGB5lE3 MiNPsmMMh0BDrF5M40EYXAgIYRdE9Q6cIjAAHQhLEv0NdxZl71m9i6jenZvJt5yzI665 kHb9iesDTmrzLIbMZz46Egcgvu7Vs1OKkAEOx3J4s5bIKjnLLdnhRBxWrQZtP+c4uhPV 8xyA4EMXbPFioVSZTNU6MR/Qsmx9956SrlWgPrzCBU677dWltOv0ckk+wu+XIFs29bkF /toBWDVHp3lsWjleqesqgfyUMNjptYYatirydz3VWOoPoN1OgCz/ZlvXHJ2Rmps1NnTO KPPQ== X-Gm-Message-State: AOJu0YxdrIgGspI92IfhMJpUmdozeHh6o1D4/f/XV4Jr2SVD/byGQWw4 eymyIYUwdmujvkaVwZ6B6V+zAE+qIpMqfPbKLt31JyoDDv0E60ALfFLbE4E6 X-Google-Smtp-Source: AGHT+IHJt2d4bbvlTQr3Bs7/rtArvGAzUtFZ3V4IG6IQq8Lfe3Ntht+rfhArofvVDFN+syN8tV9ZLQ== X-Received: by 2002:a17:902:ed04:b0:1d7:2403:ed20 with SMTP id b4-20020a170902ed0400b001d72403ed20mr6614099pld.16.1706641947464; Tue, 30 Jan 2024 11:12:27 -0800 (PST) Received: from smtpclient.apple (c-73-109-44-219.hsd1.wa.comcast.net. [73.109.44.219]) by smtp.gmail.com with ESMTPSA id 4-20020a170902ee4400b001d8ceaa1a5bsm4731175plo.304.2024.01.30.11.12.26 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 30 Jan 2024 11:12:26 -0800 (PST) Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable From: Enji Cooper 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 (1.0) Subject: Re: improving C++ libc headers Date: Tue, 30 Jan 2024 11:12:16 -0800 Message-Id: <7D5B040A-688E-47EA-8BF6-04AA18477399@gmail.com> References: Cc: freebsd-arch@freebsd.org In-Reply-To: To: Lexi Winter X-Mailer: iPhone Mail (21C66) X-Rspamd-Queue-Id: 4TPZYT0sXwz4YNt X-Spamd-Bar: ---- X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[]; ASN(0.00)[asn:15169, ipnet:2607:f8b0::/32, country:US] > On Jan 30, 2024, at 05:31, Lexi Winter wrote: >=20 > =EF=BB=BFhi list, >=20 > i am considering working up a patch to improve C++ libc headers in FreeBSD= . >=20 > the problem with the current headers (which come from clang/libc++) is > that this code compiles: >=20 > ------ > #include > auto main() -> int { > exit(0); > } > ------ >=20 > this should be a compile-time error, because does not declare > ::exit[0]. however, it works because is implemented like > this: >=20 > ------ > #include // exposes ::exit() >=20 > namespace std { > using ::exit; > // ... > } > ------ >=20 > i would like to replace this with an implementation that does this > instead: >=20 > ------ > namespace std { > extern "C" void exit(int); > // ... > } > ------ >=20 > 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. >=20 > 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. >=20 > to address some potential objections: >=20 > - 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. >=20 > - "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. >=20 > [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 Hi Lexi! That=E2=80=99s an interesting proposal! Given that this is a third-party library, I think it=E2=80=99s best to submi= t this proposal and patches up to the LLVM project (there are some folks in t= he FreeBSD project who are connected to LLVM, but arch is a wider distributi= on of folks and might not overlap with those individuals). The proposal woul= d be beneficial to multiple OSes=E2=80=94not just FreeBSD. Moreover, you mig= ht be able to convince others in the LLVM project to work with you to achiev= e the desired outcome sooner. Thank you again for sharing and starting this discussion! Cheers! -Enji