From nobody Sat Mar 22 00:43:16 2025 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 4ZKLCR2nn2z5qxZr for ; Sat, 22 Mar 2025 00:43:31 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (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 4ZKLCQ5h1jz3TBH; Sat, 22 Mar 2025 00:43:30 +0000 (UTC) (envelope-from kostikbel@gmail.com) Authentication-Results: mx1.freebsd.org; none Received: from tom.home (kib@localhost [127.0.0.1] (may be forged)) by kib.kiev.ua (8.18.1/8.18.1) with ESMTP id 52M0hGh5057104; Sat, 22 Mar 2025 02:43:19 +0200 (EET) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua 52M0hGh5057104 Received: (from kostik@localhost) by tom.home (8.18.1/8.18.1/Submit) id 52M0hG4x057103; Sat, 22 Mar 2025 02:43:16 +0200 (EET) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Sat, 22 Mar 2025 02:43:16 +0200 From: Konstantin Belousov To: Mark Millard Cc: FreeBSD Current , Brooks Davis Subject: Re: The lib{c,sys} split in main: will man pages be updated for 15.0-RELEASE? Message-ID: References: <271975F8-802F-4A30-BBF6-AEA5BAA97C54.ref@yahoo.com> <271975F8-802F-4A30-BBF6-AEA5BAA97C54@yahoo.com> 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 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <271975F8-802F-4A30-BBF6-AEA5BAA97C54@yahoo.com> X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FORGED_GMAIL_RCVD,FREEMAIL_FROM, NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on tom.home 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:6939, ipnet:2001:470::/32, country:US] X-Rspamd-Queue-Id: 4ZKLCQ5h1jz3TBH X-Spamd-Bar: ---- On Fri, Mar 21, 2025 at 02:30:40PM -0700, Mark Millard wrote: > Under: > > # uname -apKU > FreeBSD 7950X3D-ZFS 15.0-CURRENT FreeBSD 15.0-CURRENT #4 main-n275926-a54a240c1b57-dirty: Thu Mar 13 00:44:25 PDT 2025 root@7950X3D-ZFS:/usr/obj/BUILDs/main-ZNV4-nodbg-clang/usr/main-src/amd64.amd64/sys/GENERIC-NODBG amd64 amd64 1500034 1500034 > > Looking, I see: > > # man -K "libc, -l" | more > /usr/share/man/man2/_Fork.2.gz: Standard C Library (libc, -lc) > /usr/share/man/man2/__syscall.2.gz: Standard C Library (libc, -lc) > /usr/share/man/man2/_exit.2.gz: Standard C Library (libc, -lc) > /usr/share/man/man2/_umtx_op.2.gz: Standard C Library (libc, -lc) > . . . > > But: > > # man -K "libsys, -l" | more > # > > (So nothing references libsys in a similar way.) > > # readelf -drs /lib/libsys.so.7 | sort -k8,8 | grep "\<_*errno\>" > 633: 000000000001d328 4 OBJECT GLOBAL DEFAULT 28 errno@FBSD_1.0 (2) > > # readelf -drs /lib/libc.so.7 | sort -k8,8 | grep "\<_*errno\>" > # > > # man errno > INTRO(2) FreeBSD System Calls Manual INTRO(2) > > NAME > intro, errno – introduction to system calls and their error numbers > > LIBRARY > Standard C Library (libc, -lc) > > SYNOPSIS > #include > #include > . . . > > (So "libc, -lc" is still referenced for errno in the man page.) > > (errno is just used as an example above.) First, libsys does not participate in the 'official' ABI of the FreeBSD userspace. This is indicated, in particular, by the man pages, which clearly and correctly state that syscall stubs symbols are supposed to be provided by libc, and apps must link to libc to get them. Libsys is the internal implementation detail which ABI is the subject to change if it is ever exposed in more formal way. I particularly do not think that traditional Unix ABI/API with 0/-1 and errno is good fit for libsys. Second, errno itself is very complicated and irrelevant thing. The symbol really should not be referenced by any ABI-compliant binary or dso, and it is provided only for formal ABI compat. Since long time, errno is defined as *__error(), and this is the current ABI for it. Since errno is an object and exported from dso (lets put aside libc vs libsys ATM), the reference to it ends up with the same sized object allocated in the referencing object, and with the COPY relocation. Now, and this is the worst part, it is indeed impossible to keep ABI of errno (in the part that the symbol is copied from libc and not libsys) with the libsys split, and still allow the main thread to directly access the errno location to get correct syscall error values. As result, errno is copied from libsys. So formally we somewhat break ABI, but I do think that this is the least possible breakage to still have (future) benefits of libsys.