"GOT", but the "O" is a cute, smiling pufferfish. Index | Thread | Search

From:
Maximilian Lorlacks <maxlorlax@protonmail.com>
Subject:
portable: includes of sys/queue.h vs. compat
To:
"gameoftrees@openbsd.org" <gameoftrees@openbsd.org>
Date:
Sun, 11 Sep 2022 11:07:36 +0000
Reply-To:
Maximilian Lorlacks <maxlorlax@protonmail.com>

Download raw body.

Thread
Hi all,

I tried building -portable on Ubuntu 22.04.  libbsd-dev is not
installed.  I invoked configure just as "./configure".

The build failed in two places, namely
libexec/got-fetch-pack/got-fetch-pack.c and
lib/object_idset.c.  This is because they:
1. include <sys/queue.h> before got_compat.h
2. use the _SAFE macros which glibc sys/queue.h does not provide.

The include guard #define in glibc <sys/queue.h> prevents code in
compat/queue.h from being loaded.

This build only partially worked in the first place because glibc
ships its own semi-outdated queue.h that provides all macros except
their _SAFE variants.  Those are required in the two aforementioned
files, leading to a broken build.

However, in observing this issue, I noticed that the problem is
systemic.  In dozens of files, <sys/queue.h> is included directly
rather than via compat/queue.h.

I suspect that proper fix (especially one for platforms with no
<sys/queue.h> at all) would consist of either:

1. removing all inclusions of <sys/queue.h>
2. mandate a working libbsd-overlay
3. change the include guard in compat/queue.h.

I expect that option 1 is untenable maintenance effort
for keeping up with the main, non-portable version of GoT.
However, it may also be the only correct one for platforms that
do not have a <sys/queue.h> at all.  This seems to be a scenario
that -portable tries to support going by the checks in
configure.ac.

Option 3 has the drawback that it may re-define some macros
(which seems inelegant to me) and that build will still fail
on any platform that does not have a <sys/queue.h> at alll.

Hence, option 2 is likely the way to go.

Perhaps there is a fourth option I have not yet thought of
that is worth pursuing.

I'd be happy to do the work for either,
but I did not dare presume which option the project prefer.

Cheers,

Max