Bruno Haible via GNU coreutils General Discussion <[email protected]> writes:
> On Android 9.0, in the Termux app, there are also some compilation warnings: > > ../src/ls.c:1215:13: warning: call to undeclared function 'statx'; ISO C99 > and later do not support implicit function declarations > [-Wimplicit-function-declaration] > ../src/stat.c:1397:8: warning: call to undeclared function 'statx'; ISO C99 > and later do not support implicit function declarations > [-Wimplicit-function-declaration] > ../src/sync.c:144:25: warning: call to undeclared function 'syncfs'; ISO C99 > and later do not support implicit function declarations > [-Wimplicit-function-declaration] > > statx is only available in Android API 30 or newer. This is its > declaration in <sys/stat.h>: > > -------------------------------------------------------------------------------- > #if defined(__USE_GNU) > /** > * [statx(2)](http://man7.org/linux/man-pages/man2/statx.2.html) returns > * extended file status information. > * > * Returns 0 on success and returns -1 and sets `errno` on failure. > * > * Available since API level 30. > */ > > #if __ANDROID_API__ >= 30 > int statx(int __dir_fd, const char* _Nonnull __path, int __flags, unsigned > __mask, struct statx* _Nonnull __buf) __INTRODUCED_IN(30); > #endif /* __ANDROID_API__ >= 30 */ > > #endif > -------------------------------------------------------------------------------- > > Bruno Pádraig, okay to commit the attached patch before the release? It allows me to build on Android 16 using the following: $ ./configure LDFLAGS='-landroid-selinux' This uses the default API level of 24 where statx and syncfs are missing. Therefore we need to use gl_CHECK_FUNCS_ANDROID. Collin P.S. I guess LDFLAGS='-landroid-selinux' should be in Gnulib somewhere, but termux already passes it to configure so that is not a new thing.
>From 483fa3b9ab2e6c4781ab6d4672077b7a6b7ed1a9 Mon Sep 17 00:00:00 2001 Message-ID: <483fa3b9ab2e6c4781ab6d4672077b7a6b7ed1a9.1758487522.git.collin.fu...@gmail.com> From: Collin Funk <[email protected]> Date: Sun, 21 Sep 2025 13:40:18 -0700 Subject: [PATCH] build: fix missing declarations on Android * configure.ac: Check for statx using gl_CHECK_FUNCS_ANDROID since it is hidden for Android API level <= 30. * m4/jm-macros.m4 (coreutils_MACROS): Check for syncfs using gl_CHECK_FUNCS_ANDROID since it is hidden for Android API level <= 28. --- configure.ac | 4 ++-- m4/jm-macros.m4 | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index bcd41a71c..274eff42f 100644 --- a/configure.ac +++ b/configure.ac @@ -367,8 +367,8 @@ if test $ac_cv_func_getattrat = yes; then AC_SUBST([LIB_NVPAIR]) fi -# glibc >= 2.28 and linux kernel >= 4.11 -AC_CHECK_FUNCS([statx]) +# glibc >= 2.28 and linux kernel >= 4.11, Android API level 30. +gl_CHECK_FUNCS_ANDROID([statx], [[#include <sys/stat.h>]]) # SCO-ODT-3.0 is reported to need -los to link programs using initgroups AC_CHECK_FUNCS([initgroups]) diff --git a/m4/jm-macros.m4 b/m4/jm-macros.m4 index 883b59677..598c2476d 100644 --- a/m4/jm-macros.m4 +++ b/m4/jm-macros.m4 @@ -71,11 +71,13 @@ AC_DEFUN([coreutils_MACROS] sethostname siginterrupt sync - syncfs sysinfo tcgetpgrp ]) + # Android API level 30. + gl_CHECK_FUNCS_ANDROID([syncfs], [[#include <unistd.h>]]) + # These checks are for Interix, to avoid its getgr* functions, in favor # of these replacements. The replacement functions are much more efficient # because they do not query the domain controller for user information -- 2.51.0
