On Thu, Apr 27, 2023 at 11:28:36AM +0100, Daniel P. Berrangé wrote: > On Thu, Apr 27, 2023 at 12:00:59PM +0200, Andrea Bolognani wrote: > > On Thu, Apr 27, 2023 at 11:50:05AM +0200, Michal Prívozník wrote: > > > But leaving meson aside, shouldn't we just use check_header() for every > > > header file then? I mean, this fixes this particular instance of the > > > problem, but can't we hit it again with say ifaddrs.h or any other > > > header file on the list? > > > > We could. The Meson documentation recommends not doing this, as > > check_header() is (understandably) slower than has_header(). > > > > I haven't tried to see how much slower we're actually talking... > > Maybe for the 20-ish headers that we care about, it wouldn't make a > > measurable difference? Especially since the results of the check are > > cached between Meson runs. > > I tried testing: > > diff --git a/meson.build b/meson.build > index c15003ce02..3ae02ce4df 100644 > --- a/meson.build > +++ b/meson.build > @@ -633,14 +633,14 @@ if host_machine.system() == 'freebsd' > endif > > foreach name : headers > - if cc.has_header(name) > + if cc.check_header(name) > conf.set('WITH_@0@'.format(name.underscorify().to_upper()), 1) > endif > endforeach > > # check for kernel header required by src/util/virnetdevbridge.c > if host_machine.system() == 'linux' > - if not cc.has_header('linux/sockios.h') > + if not cc.check_header('linux/sockios.h') > error('You must install kernel-headers in order to compile libvirt with QEMU or LXC support') > endif > endif > > > and could not measure any deterministic change in execution > time before/after I've just tried the same on a 4th generation low-voltage laptop CPU, with a patch that goes further and completely replaces all uses of has_header() with check_header(), and haven't been able to detect any meaningful change either. Let's go with the simpler and more reliable approach then :) -- Andrea Bolognani / Red Hat / Virtualization