Re: Please consider reducing build system churn

Alejandro Colomar <[email protected]> Sun, 28 Apr 2024 20:36:28 +0200
Newsgroups dev.linux.lists.liba2i,org.kernel.vger.linux-man
Message-ID <Zi6XMnu-5fiBg1S2@debian>
--GdEa+CTp+G/eUwTR
Content-Type: text/plain; protected-headers=v1; charset=utf-8
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
Date: Sun, 28 Apr 2024 20:36:28 +0200
From: Alejandro Colomar <[email protected]>
To: Sam James <[email protected]>
Cc: linux-man <[email protected]>, [email protected]
Subject: Re: Please consider reducing build system churn

Hi Sam,

On Sun, Apr 28, 2024 at 10:37:23AM +0200, Alejandro Colomar wrote:
> On Sun, Apr 28, 2024 at 02:19:55AM +0100, Sam James wrote:
> > With regard to d0d2e2f9a21e623db208b599643e7728d71e7e6f specifically, it
> > might be worth explaining: a) what liba2i is;

I forgot to explain what liba2i is.  You know, but for the list:

I've been contributing to the shadow project for some years, and
maintaining its stable branches for half a year.  While doing that, I
found consistent misuses of strto[u]l(3) and its family of functions.
And in the cases where it was correctly being used, the code was less
than desirable.

I claim that it's due to the messy interface of those functions; while
they are useful, they are very difficult to use correctly.

The first problem I fixed was that strtoul(3) doesn't reject negative
numbers, and behaves in a way most programmers wouldn't expect (unless
they know that function really well).
<https://github.com/shadow-maint/shadow/pull/875>

Then, I tried to do was use the NetBSD APIs strtoi/u(3), which are
provided by libbsd for GNU/Linux systems.  However, I realized that it
was still imperfect, since it doesn't provide type safety.  Also, since
Fedora and some other systems don't want libbsd as a dependency of
shadow, I had to implement my own strtoi(3) to work when shadow wasn't
being linked to libbsd.
<https://github.com/shadow-maint/shadow/pull/890>

When testing my implementation and libbsd's one, I realized that they
behaved different in a corner case, which results it was a bug in the
original design of the function.  Luckily, it was an undocumented
behavior, and we could fix it (and BTW, fixing it, fixed many existing
calls in both NetBSD and Debian).
<https://gnats.netbsd.org/cgi-bin/query-pr-single.pl?number=3D57828>

I found an old internal function of the shadow project, getlong(), which
seemed to have a better API, which provided type safety.  I then came up
with a design for a set of functions and macros which would be a hybrid
between shadow's getlong() and NetBSD's strtoi(3).  Those functions have
already been added to shadow recently.
<https://github.com/shadow-maint/shadow/pull/891>

And now I have a huge patch set for modifying the entire code base to
use calls to those new functions, replacing every call to older APIs.
<https://github.com/shadow-maint/shadow/pull/893>

While changing all uses to use the new APIs that I designed, I found
several bugs in the process, which are being fixed (most silently, with
no bug reports).  In some cases, I found code that is pasted from other
projects (e.g., the reproducible builds project).  That's why I thought
that writing a small library that would house these APIs would be an
improvement to many projects, not just this one.  The project is hosted
in <kernel.org>.  It has a mailing list (CCed in this message).
<https://git.kernel.org/pub/scm/libs/liba2i/liba2i.git>

I wrote a build system for it based on the one in this project, the
Linux man-pages.  I'm trying to keep both build systems as similar as
possible, to reduce the job of maintaining both.  For that, I use
diffoscope(1), to see the differences in every file.

Have a lovely day!
Alex

--=20
<https://www.alejandro-colomar.es/>
A client is hiring kernel driver, mm, and/or crypto developers;
contact me if interested.

--GdEa+CTp+G/eUwTR
Content-Type: application/pgp-signature; name="signature.asc"

-----BEGIN PGP SIGNATURE-----

iQIzBAABCgAdFiEE6jqH8KTroDDkXfJAnowa+77/2zIFAmYulywACgkQnowa+77/
2zLPFQ/+L04eB6bZ4IQwQNeBc4kpHJwavSDBr/vt5bwSO9zQRVgpALciAYnmKmwi
kAVfhh85bPJgLOMC/C9ktpdLO0l2VwTjGhMdnHWAFAaPFSCHh1ogfEPA9E/BjRd1
BSOou7h4wE90d/BaAdqh/GVzBFVdh+Xoy2QjEgG0skLH3nlo0wh3jYJtutR0GdjV
fEkafZCy++nssBTePPv//e3oHvnHmIZNkvRM19xEwcSm4dOS8DR5qpURwRkpaLBL
EFpjBu3EXxyTKmgsG/ZgGAo+9MVFryhdhiekLOW7InYFP7QV5FKh+WtpC6s8SqwW
ugXXq/LApyfXceJH9ZPG2wjCmM1lihTpD8Q/Eh5LpogdrHmm3Rfp5UPgeOtku7jT
m7wcnKpPM+A0TuYzYlAWYl7R6YUYjgPyiFXrSHkEdx9NIeVjAhNa47w3trPE91xL
CEJpuSELYn6K1xlfCtMTsP1CITHcHwopM/qsledB9sR/xvG8VZ77Z43jEFGPd6vv
bWe7sEfilVWbpOelw6ZrLNxtejoN4RRcU4xz3rrCcmBjyFXPNRx+xrIgweM2/Whx
90mjVsgircYJ9Pj8vMFpVhn7FU2wxZgt+WvD22/27CBH50cb8xHRk25bEA8sz7hL
a90zUI/dVrz4BfkEuqmWaRkpkIn5H/1qo12Ob6ANaPABuJ5S7GY=
=K+fL
-----END PGP SIGNATURE-----

--GdEa+CTp+G/eUwTR--