On Android 16, compiling Coreutils shows the following:

    gcc  -I. -I./lib  -Ilib -I./lib -Isrc -I./src    -Wno-cast-qual 
-Wno-conversion -Wno-float-equal -Wno-sign-compare -Wno-undef 
-Wno-unused-function -Wno-unused-parameter -Wno-float-conversion 
-Wimplicit-fallthrough -Wno-pedantic 
-Wno-tautological-constant-out-of-range-compare -Wno-sign-conversion 
-Wno-type-limits -Wno-unused-const-variable -Wno-error -g -O2 -MT 
lib/libcoreutils_a-dirchownmod.o -MD -MP -MF 
lib/.deps/libcoreutils_a-dirchownmod.Tpo -c -o lib/libcoreutils_a-dirchownmod.o 
`test -f 'lib/dirchownmod.c' || echo './'`lib/dirchownmod.c
    lib/dirchownmod.c:128:27: error: call to undeclared function 'lchmod'; ISO 
C99 and later do not support implicit function declarations 
[-Wimplicit-function-declaration]
      128 |                         ? lchmod (dir, chmod_mode)
          |                           ^
    1 error generated.

A similar error occurs for calls to qsort_r, sig2str, and str2sig.

This is because the functions are new to Android API level 36, therefore
the symbols are in libc. However, the declarations require
__ANDROID_API__ to be greater or equal to 36.

So, by default the declarations will not be visible:

    $ echo | clang -dM -E - | grep ANDROID_
    #define __ANDROID_API__ __ANDROID_MIN_SDK_VERSION__
    #define __ANDROID_MIN_SDK_VERSION__ 24

I have pushed the 3 attached patches to fix this by using
gl_CHECK_FUNCS_ANDROID and updated the documentation to mention the last
version these functions were missing.

Collin

>From 4bdd70e3cfa030ac5e3a46ed8c22fb44eb144b36 Mon Sep 17 00:00:00 2001
Message-ID: <4bdd70e3cfa030ac5e3a46ed8c22fb44eb144b36.1758434130.git.collin.fu...@gmail.com>
From: Collin Funk <[email protected]>
Date: Sat, 20 Sep 2025 22:36:22 -0700
Subject: [PATCH 1/3] lchmod: Port to Android API level 36.

* m4/lchmod.m4 (gl_FUNC_LCHMOD): Use gl_CHECK_FUNCS_ANDROID to check for
lchmod instead of AC_CHECK_FUNCS_ONCE.
* m4/lchown.m4 (gl_FUNC_LCHOWN): Likewise.
* doc/glibc-functions/lchmod.texi (lchmod): Document that the function
is missing on Android API 35 and lower.
---
 ChangeLog                       | 9 +++++++++
 doc/glibc-functions/lchmod.texi | 2 +-
 m4/lchmod.m4                    | 4 ++--
 m4/lchown.m4                    | 4 ++--
 4 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 3b4dbeb8ae..348009ed5a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2025-09-20  Collin Funk  <[email protected]>
+
+	lchmod: Port to Android API level 36.
+	* m4/lchmod.m4 (gl_FUNC_LCHMOD): Use gl_CHECK_FUNCS_ANDROID to check for
+	lchmod instead of AC_CHECK_FUNCS_ONCE.
+	* m4/lchown.m4 (gl_FUNC_LCHOWN): Likewise.
+	* doc/glibc-functions/lchmod.texi (lchmod): Document that the function
+	is missing on Android API 35 and lower.
+
 2025-09-20  Bruno Haible  <[email protected]>
 
 	pthread-once: Reduce link dependencies.
diff --git a/doc/glibc-functions/lchmod.texi b/doc/glibc-functions/lchmod.texi
index 35b70f83dc..83f8a192f1 100644
--- a/doc/glibc-functions/lchmod.texi
+++ b/doc/glibc-functions/lchmod.texi
@@ -9,7 +9,7 @@ @node lchmod
 @itemize
 @item
 This function is missing on some platforms:
-OpenBSD 7.5, Minix 3.1.8, AIX 5.1, Solaris 11.4, Cygwin 2.9, mingw, MSVC 14, Android 9.0.
+OpenBSD 7.5, Minix 3.1.8, AIX 5.1, Solaris 11.4, Cygwin 2.9, mingw, MSVC 14, Android API level 35.
 @item
 This function is not declared on some platforms:
 HP-UX 11.31.
diff --git a/m4/lchmod.m4 b/m4/lchmod.m4
index fd76834347..601d1d3da4 100644
--- a/m4/lchmod.m4
+++ b/m4/lchmod.m4
@@ -1,5 +1,5 @@
 # lchmod.m4
-# serial 10
+# serial 11
 dnl Copyright (C) 2005-2006, 2008-2025 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -16,7 +16,7 @@ AC_DEFUN([gl_FUNC_LCHMOD]
   dnl Persuade glibc <sys/stat.h> to declare lchmod().
   AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
 
-  AC_CHECK_FUNCS_ONCE([lchmod])
+  gl_CHECK_FUNCS_ANDROID([lchmod], [[#include <sys/stat.h>]])
   if test "$ac_cv_func_lchmod" = no; then
     HAVE_LCHMOD=0
   fi
diff --git a/m4/lchown.m4 b/m4/lchown.m4
index 72479bde0e..d2420b19d2 100644
--- a/m4/lchown.m4
+++ b/m4/lchown.m4
@@ -1,5 +1,5 @@
 # lchown.m4
-# serial 17
+# serial 18
 dnl Copyright (C) 1998, 2001, 2003-2007, 2009-2025 Free Software Foundation,
 dnl Inc.
 dnl This file is free software; the Free Software Foundation
@@ -17,7 +17,7 @@ AC_DEFUN([gl_FUNC_LCHOWN]
 [
   AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
   AC_REQUIRE([gl_FUNC_CHOWN])
-  AC_CHECK_FUNCS_ONCE([lchmod])
+  gl_CHECK_FUNCS_ANDROID([lchmod], [[#include <sys/stat.h>]])
   AC_CHECK_FUNCS([lchown])
   if test $ac_cv_func_lchown = no; then
     HAVE_LCHOWN=0
-- 
2.51.0

>From c751b471681258a0ac908453f26a67f1c2aebb75 Mon Sep 17 00:00:00 2001
Message-ID: <c751b471681258a0ac908453f26a67f1c2aebb75.1758434131.git.collin.fu...@gmail.com>
In-Reply-To: <4bdd70e3cfa030ac5e3a46ed8c22fb44eb144b36.1758434130.git.collin.fu...@gmail.com>
References: <4bdd70e3cfa030ac5e3a46ed8c22fb44eb144b36.1758434130.git.collin.fu...@gmail.com>
From: Collin Funk <[email protected]>
Date: Sat, 20 Sep 2025 22:41:16 -0700
Subject: [PATCH 2/3] qsort_r: Port to Android API level 36.

* m4/qsort_r.m4 (gl_FUNC_QSORT_R): Use gl_CHECK_FUNCS_ANDROID to check
for qsort_r instead of AC_CHECK_FUNCS_ONCE.
* doc/glibc-functions/qsort_r.texi: Document that the function is
missing on Android API 35 and lower.
---
 ChangeLog                        | 10 ++++++++--
 doc/posix-functions/qsort_r.texi |  2 +-
 m4/qsort_r.m4                    |  4 ++--
 3 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 348009ed5a..54414de58c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,11 +1,17 @@
 2025-09-20  Collin Funk  <[email protected]>
 
+	qsort_r: Port to Android API level 36.
+	* m4/qsort_r.m4 (gl_FUNC_QSORT_R): Use gl_CHECK_FUNCS_ANDROID to check
+	for qsort_r instead of AC_CHECK_FUNCS_ONCE.
+	* doc/glibc-functions/qsort_r.texi: Document that the function is
+	missing on Android API 35 and lower.
+
 	lchmod: Port to Android API level 36.
 	* m4/lchmod.m4 (gl_FUNC_LCHMOD): Use gl_CHECK_FUNCS_ANDROID to check for
 	lchmod instead of AC_CHECK_FUNCS_ONCE.
 	* m4/lchown.m4 (gl_FUNC_LCHOWN): Likewise.
-	* doc/glibc-functions/lchmod.texi (lchmod): Document that the function
-	is missing on Android API 35 and lower.
+	* doc/glibc-functions/lchmod.texi: Document that the function is missing
+	on Android API 35 and lower.
 
 2025-09-20  Bruno Haible  <[email protected]>
 
diff --git a/doc/posix-functions/qsort_r.texi b/doc/posix-functions/qsort_r.texi
index 98248ec233..e4a62b3818 100644
--- a/doc/posix-functions/qsort_r.texi
+++ b/doc/posix-functions/qsort_r.texi
@@ -13,7 +13,7 @@ @node qsort_r
 @itemize
 @item
 This function is missing on some platforms:
-glibc 2.7, NetBSD 10.0, OpenBSD 7.5, Minix 3.1.8, AIX 7.1, HP-UX 11.31, Solaris 11.4, Cygwin 1.7.x, mingw, MSVC 14, Android 9.0.
+glibc 2.7, NetBSD 10.0, OpenBSD 7.5, Minix 3.1.8, AIX 7.1, HP-UX 11.31, Solaris 11.4, Cygwin 1.7.x, mingw, MSVC 14, Android API level 35.
 @item
 This function has an incompatible API on some platforms:
 FreeBSD 13.4.
diff --git a/m4/qsort_r.m4 b/m4/qsort_r.m4
index b460198196..82fd964367 100644
--- a/m4/qsort_r.m4
+++ b/m4/qsort_r.m4
@@ -1,5 +1,5 @@
 # qsort_r.m4
-# serial 1
+# serial 2
 dnl Copyright 2014-2025 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -17,7 +17,7 @@ AC_DEFUN([gl_FUNC_QSORT_R]
 
   AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
 
-  AC_CHECK_FUNCS_ONCE([qsort_r])
+  gl_CHECK_FUNCS_ANDROID([qsort_r], [[#include <stdlib.h>]])
   if test $ac_cv_func_qsort_r = yes; then
     AC_CACHE_CHECK([for qsort_r signature], [gl_cv_qsort_r_signature],
       [AC_LINK_IFELSE(
-- 
2.51.0

>From cfef893be27e89099d69a6781f725a5cc6ccc48a Mon Sep 17 00:00:00 2001
Message-ID: <cfef893be27e89099d69a6781f725a5cc6ccc48a.1758434131.git.collin.fu...@gmail.com>
In-Reply-To: <4bdd70e3cfa030ac5e3a46ed8c22fb44eb144b36.1758434130.git.collin.fu...@gmail.com>
References: <4bdd70e3cfa030ac5e3a46ed8c22fb44eb144b36.1758434130.git.collin.fu...@gmail.com>
From: Collin Funk <[email protected]>
Date: Sat, 20 Sep 2025 22:45:29 -0700
Subject: [PATCH 3/3] sig2str: Port to Android API level 36.

* m4/sig2str.m4 (gl_FUNC_SIG2STR): Use gl_CHECK_FUNCS_ANDROID to check
for sig2str and str2sig instead of AC_CHECK_FUNCS.
* doc/posix-functions/sig2str.texi: Document that the function is
missing on Android API 35 and lower.
* doc/posix-functions/str2sig.texi: Likewise.
---
 ChangeLog                        | 7 +++++++
 doc/posix-functions/sig2str.texi | 2 +-
 doc/posix-functions/str2sig.texi | 2 +-
 m4/sig2str.m4                    | 5 +++--
 4 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 54414de58c..10b2ec4a6c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
 2025-09-20  Collin Funk  <[email protected]>
 
+	sig2str: Port to Android API level 36.
+	* m4/sig2str.m4 (gl_FUNC_SIG2STR): Use gl_CHECK_FUNCS_ANDROID to check
+	for sig2str and str2sig instead of AC_CHECK_FUNCS.
+	* doc/posix-functions/sig2str.texi: Document that the function is
+	missing on Android API 35 and lower.
+	* doc/posix-functions/str2sig.texi: Likewise.
+
 	qsort_r: Port to Android API level 36.
 	* m4/qsort_r.m4 (gl_FUNC_QSORT_R): Use gl_CHECK_FUNCS_ANDROID to check
 	for qsort_r instead of AC_CHECK_FUNCS_ONCE.
diff --git a/doc/posix-functions/sig2str.texi b/doc/posix-functions/sig2str.texi
index 4f6b7d1c50..dba8a7abec 100644
--- a/doc/posix-functions/sig2str.texi
+++ b/doc/posix-functions/sig2str.texi
@@ -11,7 +11,7 @@ @node sig2str
 @itemize
 @item
 This function is missing on many platforms:
-glibc 2.42, macOS 14, FreeBSD 14.0, NetBSD 10.0, OpenBSD 7.5, Minix 3.3.0, AIX 7.3.1, HP-UX 11.31, Cygwin 3.2.x, mingw, MSVC 14, Android 9.0.
+glibc 2.42, macOS 14, FreeBSD 14.0, NetBSD 10.0, OpenBSD 7.5, Minix 3.3.0, AIX 7.3.1, HP-UX 11.31, Cygwin 3.2.x, mingw, MSVC 14, Android API level 35.
 @end itemize
 
 Portability problems not fixed by Gnulib:
diff --git a/doc/posix-functions/str2sig.texi b/doc/posix-functions/str2sig.texi
index ac1a04e9d3..5fa5d70fce 100644
--- a/doc/posix-functions/str2sig.texi
+++ b/doc/posix-functions/str2sig.texi
@@ -11,7 +11,7 @@ @node str2sig
 @itemize
 @item
 This function is missing on many platforms:
-glibc 2.42, macOS 14, FreeBSD 14.0, NetBSD 10.0, OpenBSD 7.5, Minix 3.3.0, AIX 7.3.1, HP-UX 11.31, Cygwin 3.2.x, mingw, MSVC 14, Android 9.0.
+glibc 2.42, macOS 14, FreeBSD 14.0, NetBSD 10.0, OpenBSD 7.5, Minix 3.3.0, AIX 7.3.1, HP-UX 11.31, Cygwin 3.2.x, mingw, MSVC 14, Android API level 35.
 @end itemize
 
 Portability problems not fixed by Gnulib:
diff --git a/m4/sig2str.m4 b/m4/sig2str.m4
index d49e363f3a..4f713724bb 100644
--- a/m4/sig2str.m4
+++ b/m4/sig2str.m4
@@ -1,5 +1,5 @@
 # sig2str.m4
-# serial 8
+# serial 9
 dnl Copyright (C) 2002, 2005-2006, 2009-2025 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -9,7 +9,8 @@
 AC_DEFUN([gl_FUNC_SIG2STR],
 [
   AC_REQUIRE([gl_SIGNAL_H_DEFAULTS])
-  AC_CHECK_FUNCS([sig2str str2sig])
+  gl_CHECK_FUNCS_ANDROID([sig2str], [[#include <signal.h>]])
+  gl_CHECK_FUNCS_ANDROID([str2sig], [[#include <signal.h>]])
   if test $ac_cv_func_sig2str = no; then
     HAVE_SIG2STR=0
   fi
-- 
2.51.0

Reply via email to