mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Alejandro Colomar <alx@kernel.org>
To: Rich Felker <dalias@libc.org>
Cc: Guillem Jover <guillem@hadrons.org>,
	libc-alpha@sourceware.org, musl@lists.openwall.com,
	libbsd@lists.freedesktop.org,
	"Serge E. Hallyn" <serge@hallyn.com>,
	"Skyler Ferrante (RIT Student)" <sjf5462@rit.edu>,
	Iker Pedrosa <ipedrosa@redhat.com>,
	Christian Brauner <christian@brauner.io>
Subject: Re: [musl] Re: Tweaking the program name for <err.h> functions
Date: Sat, 9 Mar 2024 16:49:42 +0100	[thread overview]
Message-ID: <ZeyFHOoY5gJWgc4X@debian> (raw)
In-Reply-To: <20240309150258.GS4163@brightrain.aerifal.cx>

[-- Attachment #1: Type: text/plain, Size: 3625 bytes --]

Hi Rich,

On Sat, Mar 09, 2024 at 10:02:58AM -0500, Rich Felker wrote:
> > How about adding setprogname(3) (and getprogname(3)) to GNU and musl
> > libc?
> 
> I really don't think they meet the criteria for inclusion. They don't
> have historical cross platform precedent, they're not something we've
> hit existing applications failing to build for lack of, they don't let
> you do anything you couldn't already do, and the semantics would be
> unclear

I would ask the BSD authors of the API to learn all the implications of
the pair of functions.  I don't know them.  Maybe Guillem knows.

> (do they just configure the

> legacy err.h functions?

Why would you call err.h legacy?  What do you offer to use instead?
snprintf(3) + perror(3) + exit(3)?

How about bugs in such NIH cases?  You'd fix them in every project where
you've written the same bug?  That's why we have libraries.  I don't
mind if the entirety of err.h was moved to a liberr standalone library,
but you have kidnapped those APIs in libc.  Would you release them?

> set
> __progname/program_invocation_short_name? modify argv[0]?)

Would you promise to keep __progname/program_invocation_short_name as a
way to configure err.h in musl/glibc?  If so, then maybe one can write a
portable library that wraps the unportable set of libc's.  But since you
own err.h, _you_ must be the one making a contract.  It's up to you to
decide which contract you want to offer.  I suggest making the same
contract present in the BSDs.

> 
> The entire err.h function set in musl is 67 lines that compile down to
> less than 500 bytes of machine code. If there's not a portable way to
> configure them the way you want,

There's not a portable way to configure them, AFAIK.  You could say it's
glibc and musl's fault, for importing the err.h functions without
importing setprogname(3).  In the BSD world, where these APIs
originated, they seem to be configurable portably (within BSDs).  And
with libbsd, you can get relative portability to other systems.

You have a problem when you want to call these functions in a core
package, like shadow, because some distributions refuse to include
libbsd in their core packages.

> and you refuse to run a configure
> script of some sort to determine if the setprogname function some
> systems need exists, the simpler solution,

I don't refuse to do that, but it means I also need to write code to
handle the case where it's not available, and do some non-portable stuff
in that case.

In fact, I'll need to do that anyway, at least for some years until all
systems I care about have a version of libc that has the functions.

But, I'd like to be able to remove that code in, say, 5 or 10 years from
now.

> rather than trying to get
> new contracts into libc and wait for them to be widely available, is
> to copy-and-paste those 67 lines and customize them as needed in your
> program, no?

I partially agree with you, in that I don't like adding new contracts
into libc.  But that contract was already added broken into glibc and
musl.  I suggest you remove err.h from libc, and let a standalone
library to implement them separately, allowing to configure them.

I don't agree with your suggestion of going the NIH way.

Maybe I'll push a bit harder for inclusion of libbsd in distributions.
Then it'll be the problem of distributors to either package libbsd, or
do a lot of work to patch projects to not rely on libbsd.  It's not a
bad idea, actually.

> 
> Rich

Have a lovely day!
Alex

-- 
<https://www.alejandro-colomar.es/>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2024-03-09 15:50 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <Zeo-oJOyN9YQXVb1@debian>
     [not found] ` <ZepcO2pa0cwsqr3u@thunder.hadrons.org>
2024-03-08  0:52   ` Alejandro Colomar
2024-03-09 15:02     ` Rich Felker
2024-03-09 15:49       ` Alejandro Colomar [this message]
2024-03-09 18:35         ` Andreas Schwab
2024-03-09 18:46           ` Alejandro Colomar
2024-03-09 19:18             ` Markus Wichmann
2024-03-09 19:25             ` Rich Felker
2024-03-09 21:44         ` Thorsten Glaser
2024-03-10  6:01         ` NRK
2024-03-10 13:17           ` Alejandro Colomar
2024-03-10 14:01             ` NRK
2024-03-10 19:39               ` Rich Felker
2024-03-10 22:25                 ` Alejandro Colomar
2024-03-10 23:22                 ` Thorsten Glaser
2024-03-10 23:44                   ` Rich Felker
2024-03-11  0:19                     ` Thorsten Glaser
2024-03-11  0:46                       ` Alejandro Colomar
2024-03-11 14:46                         ` Skyler Ferrante (RIT Student)
2024-03-11 15:09                           ` Andreas Schwab
2024-03-11 15:30                             ` Skyler Ferrante (RIT Student)
2024-03-11 18:23                               ` Florian Weimer
2024-03-11 18:48                                 ` Skyler Ferrante (RIT Student)
2024-03-11 19:05                                   ` enh
2024-03-11 19:44                                     ` Rich Felker
2024-03-11 20:35                                       ` enh
2024-03-11 19:47                               ` Rich Felker
2024-03-11 20:08                                 ` Skyler Ferrante (RIT Student)
2024-03-11 20:39                                   ` enh
2024-03-11 21:21                                 ` Laurent Bercot
2024-03-11 22:05                                 ` Thorsten Glaser
2024-03-12  0:18                                 ` Gabriel Ravier
2024-03-12  0:43                                   ` Rich Felker
2024-03-12  3:23                                     ` Gabriel Ravier
2024-03-12 14:44                                       ` Rich Felker
2024-03-12 13:54                                   ` Florian Weimer
2024-03-12 14:21                                     ` Zack Weinberg
2024-03-12 14:31                                       ` Florian Weimer
2024-03-12 14:42                                         ` Rich Felker
2024-03-12 19:25                                           ` Zack Weinberg
2024-03-12 21:19                                             ` Rich Felker
2024-03-13  8:28                                             ` Florian Weimer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZeyFHOoY5gJWgc4X@debian \
    --to=alx@kernel.org \
    --cc=christian@brauner.io \
    --cc=dalias@libc.org \
    --cc=guillem@hadrons.org \
    --cc=ipedrosa@redhat.com \
    --cc=libbsd@lists.freedesktop.org \
    --cc=libc-alpha@sourceware.org \
    --cc=musl@lists.openwall.com \
    --cc=serge@hallyn.com \
    --cc=sjf5462@rit.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).