Re: Did something change with sys/cpuset.h in CURRENT?

From: Sergey Kandaurov <pluknet_at_gmail.com>
Date: Sun, 11 Jul 2021 22:19:49 UTC
On Sun, 11 Jul 2021 at 23:02, Craig Leres <leres@freebsd.org> wrote:

>
> I've gotten a couple of pkg-fallout reports for security/zeek but I'm
> not finding any mailing list chatter referencing cpusetid_t. I also did
> a checkout of https://git.FreeBSD.org/src.git and don't see any recent
> changes (or anything in UPDATING) that would impact the use of
> sys/cpuset.h.
>
> Could someone please point me in the right direction?
>
>                 Craig
>
> Maintainer:     leres@FreeBSD.org
> Log URL:
>
> http://beefy17.nyi.freebsd.org/data/main-i386-default/pf44e1c1de734_s63ca9ea4f3/logs/zeek-4.0.3.log
> Build URL:
>
> http://beefy17.nyi.freebsd.org/build.html?mastername=main-i386-default&build=pf44e1c1de734_s63ca9ea4f3
> Log:
>
> =>> Building security/zeek
> build started at Sun Jul 11 05:19:11 UTC 2021
> port directory: /usr/ports/security/zeek
> package name: zeek-4.0.3
> building for: FreeBSD main-i386-default-job-05 14.0-CURRENT FreeBSD
> 14.0-CURRENT 1400025 i386
> maintained by: leres@FreeBSD.org
> Makefile ident:
> Poudriere version: 3.2.8-8-gaf08dbda
> Host OSVERSION: 1400008
> Jail OSVERSION: 1400025
> Job Id: 05
>
> [...]
>
> In file included from
>
> /wrkdirs/usr/ports/security/zeek/work/zeek-4.0.3/auxil/highwayhash/highwayhash/os_specific.cc:56:
> /usr/include/sys/cpuset.h:153:12: error: unknown type name 'cpusetid_t'
> int     cpuset(cpusetid_t *);
>                 ^
> /usr/include/sys/cpuset.h:154:18: error: unknown type name 'cpuwhich_t';
> did you mean '__cpuwhich_t'?
> int     cpuset_setid(cpuwhich_t, id_t, cpusetid_t);
>                       ^
> /usr/include/sys/_types.h:146:14: note: '__cpuwhich_t' declared here
> typedef int             __cpuwhich_t;   /* which parameter for cpuset. */
>                          ^
>

In zeek-4.0.3 (to which the port was recently updated from 4.0.2)
the header inclusion order has changed; the relevant diff:

 #ifdef __FreeBSD__
 #define OS_FREEBSD 1
-#include <sys/param.h>
 #include <sys/cpuset.h>
+#include <sys/param.h>
 #include <unistd.h>
 #else
 #define OS_FREEBSD 0

- sys/cpuset.h requires sys/types.h to define cpusetid_t (and friends),
- sys/params.h includes sys/types.h

  this is documented in cpuset(2)

This works on stable versions such as FreeBSD 13.0 w/ clang 11.0.1, though.
This is seemingly due to a header pollution fixed in llvmorg-12 import.
Before that, sys/types were included indirectly with #include <random>:
random -> istream -> ostream -> locale -> nl_types.h -> sys/types.h
With llvmorg-12 import, istream / ostream are replaced with iosfwd.