Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 13 Nov 2021 14:23:20 +0200
From:      Konstantin Belousov <kostikbel@gmail.com>
To:        Gerald Pfeifer <gerald@pfeifer.com>
Cc:        Yasuhiro Kimura <yasu@freebsd.org>, freebsd-current@freebsd.org, kde@freebsd.org, Damjan Jovanovic <damjan.jov@gmail.com>
Subject:   Re: Build of devel/ninja and lang/gcc11 fails with latest 14-CURRENT amd64
Message-ID:  <YY%2BuOH3/o6EvS4a4@kib.kiev.ua>
In-Reply-To: <76e4f589-2df5-8f6f-ac9d-403020f8587b@pfeifer.com>
References:  <20211113.053153.925491349721631675.yasu@FreeBSD.org> <YY7xEDOd7XOrrAGj@kib.kiev.ua> <76e4f589-2df5-8f6f-ac9d-403020f8587b@pfeifer.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Sat, Nov 13, 2021 at 09:54:47AM +0100, Gerald Pfeifer wrote:
> On Sat, 13 Nov 2021, Konstantin Belousov wrote:
> >> ----------------------------------------------------------------------
> >> commit 160b4b922b6
> >> Author: Konstantin Belousov <kib@FreeBSD.org>
> >> Date:   Sat Oct 23 00:17:21 2021
> >> 
> >>     Add real sched.h
> >> 
> >>     It is required by IEEE Std 1003.1-2008 AKA POSIX.
> >> 
> >>     Put some Linux compatibility stuff under BSD_VISIBLE namespace, in
> >>     particular, sys/cpuset.h definitions.  Also, if user really want
> >>     Linux compatibility, she can request cpu_set_t typedef with
> >>     _WITH_CPU_SET_T define.
> >> 
> >>     Reviewed by:    jhb
> >>     Sponsored by:   The FreeBSD Foundation
> >>     MFC after:      1 week
> >>     Differential revision:  https://reviews.freebsd.org/D32901
> >> ----------------------------------------------------------------------
> >> 
> >> It seems likely this is the cause of build error.
> > Ninja builds with the following patch, other failing ports have a chance
> > as well.
> > 
> > commit 1acaa4bb838c074c29926cb34b7827efb26cdc85
> > Author: Konstantin Belousov <kib@FreeBSD.org>
> > Date:   Thu Nov 11 10:01:54 2021 +0200
> > 
> >     sched.h: Make cpu_set_t compat typedef visible unconditionally
> >     
> >     or rather, visible if BSD namespace is enabled, instead of requiring
> >     _WITH_CPU_SET_T define to expose it.  It seems a lot of code assumes
> >     that presence of sched_getaffinity() implies existence of cpu_set_t.
> >     
> >     Reported by:    portmgr (antoine)
> >     Sponsored by:   The FreeBSD Foundation
> >     MFC after:      1 week
> > 
> > diff --git a/include/sched.h b/include/sched.h
> > index 1c41cda79046..2d4f301c9718 100644
> > --- a/include/sched.h
> > +++ b/include/sched.h
> > @@ -34,13 +34,8 @@
> >  #include <sys/sched.h>
> >  #if __BSD_VISIBLE
> >  #include <sys/cpuset.h>
> > -#endif /* __BSD_VISIBLE */
> > -
> > -#if __BSD_VISIBLE
> > -#ifdef _WITH_CPU_SET_T
> >  struct _cpuset;
> >  typedef struct _cpuset cpu_set_t;
> > -#endif /* _WITH_CPU_SET_T */
> >  #endif /* __BSD_VISIBLE */
> >  
> >  __BEGIN_DECLS
> 
> I also got a build notification for emulators/wine and believe 
> emulators/wine-devel is impacted as well.
> 
> The code in question looks as follows, and it seems your follow
> up patch should address this?
> 
>   int set_thread_affinity( struct thread *thread, affinity_t affinity )
>   {
>       int ret = 0;
>   #ifdef HAVE_SCHED_SETAFFINITY
>       if (thread->unix_tid != -1)
>       {
>           cpu_set_t set;
>           int i;
>           affinity_t mask;
> 
>           CPU_ZERO( &set );
>           for (i = 0, mask = 1; mask; i++, mask <<= 1)
>               if (affinity & mask) CPU_SET( i, &set );
> 
>           ret = sched_setaffinity( thread->unix_tid, sizeof(set), &set );
>       }
>   #endif
> 
> If so, it looks like your work unleashes enhanced functionality on 
> FreeBSD! Nice.
> 
> Original notification message below.

I have to hide these features under opt-in feature macro test.  You would
need to pass -D_WITH_CPU_SET_T to compiler, both at the configure and
build stage, to get to the functionality.  But for wine it seems yes,
what I added should be enough to get thread affinity features working.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?YY%2BuOH3/o6EvS4a4>