@samitouri / QOSamiQemu / commits / 5435254739

meson: fix close_range detection on older glibc

The has_function('close_range') check succeeds at link time on hosts with kernel >= 5.9 even when glibc does not declare the function (glibc < 2.34, e.g. AlmaLinux 8 / CentOS 8 with glibc 2.28). This causes CONFIG_CLOSE_RANGE to be set, but compilation then fails with: error: implicit declaration of function 'close_range' Fix by adding a prefix that includes <unistd.h>, so the meson check only succeeds when the C library actually declares close_range() in its headers. Signed-off-by: Quan Sun <Quan.Sun@windriver.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> Message-ID: <20260522201850.1342167-1-Quan.Sun@windriver.com> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>

Quan Sun committed May 22, 2026 at 13:18 UTC 5435254739dfdcc86cf5793def83cec6e5b53822
1 file changed +1 -1
meson.build
+1 -1
@@ -2596,7 +2596,7 @@ if host_os == 'windows'
2596 endif
2597
2598 # has_function
2599 -config_host_data.set('CONFIG_CLOSE_RANGE', cc.has_function('close_range'))
2599 +config_host_data.set('CONFIG_CLOSE_RANGE', cc.has_function('close_range', prefix: '#include <unistd.h>'))
2600 config_host_data.set('CONFIG_ACCEPT4', cc.has_function('accept4'))
2601 config_host_data.set('CONFIG_CLOCK_ADJTIME', cc.has_function('clock_adjtime'))
2602 config_host_data.set('CONFIG_DUP3', cc.has_function('dup3'))