meson: fix close_range detection on older glibc
PATCH 1/1 meson: fix close_range detection on older glibc
From: Quan Sun <[email protected]>
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.
--- meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
meson.build +1 -1
@@ -2596,7 +2596,7 @@ if host_os == 'windows' endif # has_function -config_host_data.set('CONFIG_CLOSE_RANGE', cc.has_function('close_range')) +config_host_data.set('CONFIG_CLOSE_RANGE', cc.has_function('close_range', prefix: '#include <unistd.h>')) config_host_data.set('CONFIG_ACCEPT4', cc.has_function('accept4')) config_host_data.set('CONFIG_CLOCK_ADJTIME', cc.has_function('clock_adjtime')) config_host_data.set('CONFIG_DUP3', cc.has_function('dup3'))
Signature · 1 line
2.43.0
Quoted 23 lines · On 22/5/26 22:18, [email protected] wrote:
From: Quan Sun <[email protected]>
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 causesCONFIG_CLOSE_RANGEto 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 declaresclose_range()in its headers.Signed-off-by Quan Sun <[email protected]>--- meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)meson.build +0
-0
meson.build if host_os == 'windows' · line 2602
Quoted 8 lines
meson.build +1
-1@@ -2596,7 +2596,7 @@ if host_os == 'windows' endif # has_function -config_host_data.set('CONFIG_CLOSE_RANGE', cc.has_function('close_range')) +config_host_data.set('CONFIG_CLOSE_RANGE', cc.has_function('close_range', prefix: '#include <unistd.h>')) config_host_data.set('CONFIG_ACCEPT4', cc.has_function('accept4')) config_host_data.set('CONFIG_CLOCK_ADJTIME', cc.has_function('clock_adjtime')) config_host_data.set('CONFIG_DUP3', cc.has_function('dup3'))