tech-pkg archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: not cmake fallout in pkgsrc/lang/compiler-rt



> Date: Thu, 13 Feb 2025 21:31:26 +0100
> From: Thomas Klausner <wiz%gatalith.at@localhost>
> 
> On Thu, Feb 13, 2025 at 08:27:18PM +0000, David Brownlee wrote:
> > Not been able to build lang/compiler-rt on NetBSD-10 for a couple of
> > weeks, possibly since the recent cmake changes
> > 
> > (it could well be due to something else)
> > 
> > Can anyone else build lang/compiler-rt OK? Its being pulled in in an
> > attempt to build www/chromium
> 
> I guess it might have been broken by my patch to add support for
> NetBSD-current, but I don't understand how. I'll attach the patch for
> review - you can try removing it locally to confirm the theory.
> 
> The missing system was moved to its own file on -current, so we need
> to include the new header now to get it.
> 
> I don't understand why including sys/param.h breaks the old way of
> making the symbol available.

sys/param.h pulls in a huge pile of other crud -- it's awful.  Ideally
we would empty it of everything except __NetBSD_Version__ and the
related macros.  (I would suggest those be put in a different header
file like sys/version.h, but that doesn't work -- we can't do that
retroactively for past versions!)

In this case, sys/param.h pulls in sys/sysctl.h, which (when _KMEMUSER
is defined) pulls in sys/ucontext.h, which in turns pulls in
machine/mcontext.h, which is where the _RTLD_SOURCE conditional used
to live.  After you've included machine/mcontext.h, including it again
doesn't do anything because of the double-include protection we put on
all^Wmost header files.

So after you have included sys/param.h, it's too late to decide to
define _RTLD_SOURCE to expose the TLS-related definitions.

Probably best to do something like this:

#if SANITIZER_NETBSD
#  define _RTLD_SOURCE
#  include <machine/mcontext.h>
#  undef _RTLD_SOURCE
#  include <sys/param.h>
#  if __NetBSD_Version__ >= 1099001200
#    include <machine/lwp_private.h>
#  endif
...
#endif

Or, if that doesn't work, try <sys/ucontext.h> instead of
<machine/mcontext.h> -- the point is to keep the scope of the
_RTLD_SOURCE kludge as limited as possible so it doesn't affect
anything it shouldn't.


Home | Main Index | Thread Index | Old Index