On Thu, Apr 27, 2023 at 11:50:05AM +0200, Michal Prívozník wrote:
On 4/27/23 11:41, Andrea Bolognani wrote:
> +# headers for which we need to check actual usability. in most
> +# cases, checking for presence is enough (and it's way faster)
> +check_headers = [
> + 'linux/kvm.h',
> +]
> +
> +foreach name : check_headers
> + if cc.check_header(name)
> + conf.set('WITH_@0(a)'.format(name.underscorify().to_upper()), 1)
> + endif
> +endforeach
One could argue, that the semantics of has_header() is broken then. What
good is there to check if the host has a header file when compiler
rejects it subsequently?
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.
Anyway, I believe the reason why only linux/kvm.h is proving to be
problematic here is that KVM support might or might not be present
depending on the architecture. All the other stuff is going to be
affected by whether or not we're targeting Linux, not the specific
Linux architecture.
--
Andrea Bolognani / Red Hat / Virtualization