From nobody Thu Sep 08 08:24:02 2022 X-Original-To: freebsd-current@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 4MNXGD3vxpz4bWjS for ; Thu, 8 Sep 2022 08:24:04 +0000 (UTC) (envelope-from theraven@FreeBSD.org) Received: from smtp.freebsd.org (smtp.freebsd.org [IPv6:2610:1c1:1:606c::24b:4]) (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-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "smtp.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4MNXGD3HxWz3kQn; Thu, 8 Sep 2022 08:24:04 +0000 (UTC) (envelope-from theraven@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1662625444; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=yrholDB23pJhwkOfXJLKAABzFsZuKdx6OhG/ZgODSbk=; b=B/gs7awXA4fKFaY6OFBKtqw8hMn3Q//QgmPjl0nFH7upOKgb4zb/bkxBEZxYPCAtsnryMV S+WTNedmfJnnTR/ySDDc5z8Vx+MNmwK+FdnBgTwZ98W1WO+OivGEyPhIPB0wC3T5LkbTEA Yvgzt986+bpgvsAF1fC+0Iz+x32RB6WtUBZphpG/qkbFUbJxQNhij0GPAA+c/xcDld60iI qQE36/OejvTBx052xJJE9gC+jZwbwB5Fo2S0zNGh10zcVxg8THcPS3/4H23HwbaKcO7bzC WkYDEDSyWD1atZ5eH29prtdy9k1TrKzgXb45F33dgFDwmvs+rwCa8RP6Okh/hw== Received: from smtp.theravensnest.org (smtp.theravensnest.org [45.77.103.195]) (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) (Authenticated sender: theraven) by smtp.freebsd.org (Postfix) with ESMTPSA id 4MNXGD2191z17nj; Thu, 8 Sep 2022 08:24:04 +0000 (UTC) (envelope-from theraven@FreeBSD.org) Received: from smtpclient.apple (host86-139-146-83.range86-139.btcentralplus.com [86.139.146.83]) by smtp.theravensnest.org (Postfix) with ESMTPSA id 5ADD69455; Thu, 8 Sep 2022 09:24:03 +0100 (BST) Content-Type: text/plain; charset=utf-8 List-Id: Discussions about the use of FreeBSD-current List-Archive: https://lists.freebsd.org/archives/freebsd-current List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-current@freebsd.org Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.120.0.1.13\)) Subject: Re: Header symbols that shouldn't be visible to ports? From: David Chisnall In-Reply-To: <20220907145524.7C9881FB@slippy.cwsent.com> Date: Thu, 8 Sep 2022 09:24:02 +0100 Cc: Alan Somers , Konstantin Belousov , FreeBSD CURRENT Content-Transfer-Encoding: quoted-printable Message-Id: <87CEB36F-4D12-4A3B-A38D-C1FECA2C5FD4@FreeBSD.org> References: <20220907145524.7C9881FB@slippy.cwsent.com> To: Cy Schubert X-Mailer: Apple Mail (2.3654.120.0.1.13) ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1662625444; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=yrholDB23pJhwkOfXJLKAABzFsZuKdx6OhG/ZgODSbk=; b=h/GTT7JV/EKmPO8in/QiGOY7/+2fmIhz46J1ZvItWAZpLrPz3Nw4ESv4KY+zSpx/eb4EY5 iQu6n9eADgbgkq6yM/1VwlV97OejrkyEuIoShmhs74Qvtkz0M/aT491U5TTxp5U2plcZLu LLEBOD/JzaZiCYHM83BKBHDMci/gAnsSy+1l7LM4Gns/5aUkxG3d3TDkdsgNHNnDeewoIx Ebg8o76BWBHhjOpfc38ucrXLcdy5/Q9KzBcuc0d2fnwDKH2PfjFKgr1ChEX8gMGOFrXGMV Yd4xULoBbUTemFdkMbOj7eGuBFUyB8OCvfZX/IQTAvXCZezE0K8QNEXJTq+6Jw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1662625444; a=rsa-sha256; cv=none; b=ZLeX+wQ9Mt9uZ0WHC0PIF23Y/Ybo1jrjAQCIqWx+2mcMHdr1AB7Wp2tLBtElWOVtmQEtbN MlXfTU5riiGCuASJkHxb6xprKF7KB4EzcHgfGVL21eUH2kxncvt8RkaSvWd2eSpZHCWVQ4 //m/j/9cCisd5MDkar9KKJvYHJsjkulZ6sNYsfe9zGvO95AQUmAA3yCvEnXx44HG4BoeUC LJQXos6aAPOAwVOI9zGi/V6KnXpjQOJfLihvEl0evL+f6S2RtnZa6bWF0DR9h5U5Z9HFU0 W3vSk6dcLbUIgxF9CmPJwxceXFou8JzMZUROJ3dxKbLJd/RUxmucNSdCXwFsow== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N On 7 Sep 2022, at 15:55, Cy Schubert wrote: >=20 > This is exactly what happened with DMD D. When 64-bit statfs was = introduced=20 > all DMD D compiled programs failed to run and recompiling didn't help. = The=20 > DMD upstream failed to understand the problem. Eventually the port had = to=20 > be removed. I=E2=80=99m not sure that I understand the problem. This should matter = only for libraries that pass a statbuf across their ABI boundary. = Anyone using libc will see the old version of the symbol and just use = the old statbuf. Anyone using the old syscall number and doing system = calls directly will see the compat version of the structure. Anyone = taking the statbuf and passing it to a C library compiled with the newer = headers will see compat problems (but the same is true for a C library = asking a C program to pass it a statbuf and having the two compiled = against different kernel versions). There=E2=80=99s a lot that we could do in system headers to make them = more FFI-friendly. For example: - Use `enum`s rather than `#define`s for constants. - Add the flags-enum attribute for flags, so that FFI layers that can = parse attributes get more semantic information. - Add non-null attributes on all arguments and returns that=20 - Use `static inline` functions instead of macros where possible and = expose them with a macro for `static inline` so that an FFI layer can = compile the headers in a mode that makes these functions that they can = link against. For Rust, this can be compiled to LLVM IR and linked = against and inlined into the Rust code, so things like the Capsicum = permissions bitmap setting code wouldn=E2=80=99t need duplicating in = Rust. - Mark functions with availability attributes so that FFI knows when = it=E2=80=99s using deprecated / unstable values and can make strong ABI = guarantees. - Add tests for the headers to the tree. In 12.0, someone decided to rewrite a load of kernel headers to use = macros instead of inline functions, which then broke C++ code in the = kernel by changing properly namespaced things into symbols that would = replace every identifier. I=E2=80=99d love to see a concerted effort to = use a post-1999 style for our headers. David