[PATCH] meson: Skip detection of sched_* functionality on Hurd

We use the presence of sched_setscheduler() and cpu_set_t as witnesses for whether we can set process affinity and the like. This entire class of functionality is missing on Hurd, but unfortunately it still gets advertised, so the end result is that a number of warnings are produced during build: sched_get_priority_max is not implemented and will always fail sched_get_priority_min is not implemented and will always fail sched_getaffinity is not implemented and will always fail sched_setaffinity is not implemented and will always fail Don't even attempt to detect the known-broken APIs, so that we don't get compiler warnings and can report the missing functionality correctly at runtime if attempts to use it are made. Signed-off-by: Andrea Bolognani <abologna@redhat.com> --- meson.build | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/meson.build b/meson.build index 7845f60ff7..eef00ee32a 100644 --- a/meson.build +++ b/meson.build @@ -584,13 +584,19 @@ functions = [ 'posix_fallocate', 'posix_memalign', 'prlimit', - 'sched_setscheduler', 'setgroups', 'setrlimit', 'symlink', 'sysctlbyname', ] +# sched_* APIs are know to be broken on Hurd +if host_machine.system() != 'gnu' + functions += [ + 'sched_setscheduler', + ] +endif + stat_functions = [ '__lxstat', '__lxstat64', @@ -669,8 +675,6 @@ symbols = [ # Check for BSD approach for setting MAC addr [ 'net/if_dl.h', 'link_addr', '#include <sys/types.h>\n#include <sys/socket.h>' ], - - [ 'sched.h', 'cpu_set_t' ], ] if host_machine.system() == 'linux' @@ -680,6 +684,13 @@ if host_machine.system() == 'linux' ] endif +# sched_* APIs are know to be broken on Hurd +if host_machine.system() != 'gnu' + symbols += [ + [ 'sched.h', 'cpu_set_t' ], + ] +endif + foreach symbol : symbols if cc.has_header_symbol(symbol[0], symbol[1], args: '-D_GNU_SOURCE', prefix: symbol.get(2, '')) conf.set('WITH_DECL_@0@'.format(symbol[1].to_upper()), 1) -- 2.43.2

On 2/23/24 16:52, Andrea Bolognani wrote:
We use the presence of sched_setscheduler() and cpu_set_t as witnesses for whether we can set process affinity and the like.
This entire class of functionality is missing on Hurd, but unfortunately it still gets advertised, so the end result is that a number of warnings are produced during build:
sched_get_priority_max is not implemented and will always fail sched_get_priority_min is not implemented and will always fail sched_getaffinity is not implemented and will always fail sched_setaffinity is not implemented and will always fail
This feels like a Hurd bug, sorry. Unless there is bug report against Hurd (IOW, there's a chance this is fixed), I don't we should work around it. Otherwise we'd be turning libvirt into a dumpster of workarounds. Michal

On Mon, Feb 26, 2024 at 11:25:12AM +0100, Michal Prívozník wrote:
On 2/23/24 16:52, Andrea Bolognani wrote:
We use the presence of sched_setscheduler() and cpu_set_t as witnesses for whether we can set process affinity and the like.
This entire class of functionality is missing on Hurd, but unfortunately it still gets advertised, so the end result is that a number of warnings are produced during build:
sched_get_priority_max is not implemented and will always fail sched_get_priority_min is not implemented and will always fail sched_getaffinity is not implemented and will always fail sched_setaffinity is not implemented and will always fail
This feels like a Hurd bug, sorry. Unless there is bug report against Hurd (IOW, there's a chance this is fixed), I don't we should work around it. Otherwise we'd be turning libvirt into a dumpster of workarounds.
I've figured out a more sane approach, which also comes with free bug fixes as a bonus :) https://lists.libvirt.org/archives/list/devel@lists.libvirt.org/thread/MZZWE... -- Andrea Bolognani / Red Hat / Virtualization
participants (2)
-
Andrea Bolognani
-
Michal Prívozník