Building a testdir on Android (API level 24), I get these compilation errors:
clang -DHAVE_CONFIG_H -DEXEEXT=\"\" -DEXEEXT=\"\" -DNO_XMALLOC -DEXEEXT=\"\" -I. -I../../gllib -I.. -DGNULIB_STRICT_CHECKING=1 -I/data/data/com.termux/files/home/local/include -Wall -fvisibility=hidden -g -O2 -c -o spawn.o ../../gllib/spawn.c In file included from ../../gllib/spawn.c:20: ./spawn.h:690:17: error: use of undeclared identifier 'POSIX_SPAWN_RESETIDS' [(((POSIX_SPAWN_RESETIDS | POSIX_SPAWN_SETPGROUP ^ ./spawn.h:690:40: error: use of undeclared identifier 'POSIX_SPAWN_SETPGROUP' [(((POSIX_SPAWN_RESETIDS | POSIX_SPAWN_SETPGROUP ^ ./spawn.h:691:19: error: use of undeclared identifier 'POSIX_SPAWN_SETSIGDEF' | POSIX_SPAWN_SETSIGDEF | POSIX_SPAWN_SETSIGMASK ^ ./spawn.h:691:43: error: use of undeclared identifier 'POSIX_SPAWN_SETSIGMASK' | POSIX_SPAWN_SETSIGDEF | POSIX_SPAWN_SETSIGMASK ^ ./spawn.h:693:18: error: use of undeclared identifier 'POSIX_SPAWN_RESETIDS' & POSIX_SPAWN_USEVFORK) ^ The reason is that the configure tests found that posix_spawn exists and therefore an attempt is made to use this native posix_spawn, but the headers don't contain the support for it — neither the constant definitions nor the function declarations. More generally $ nm --dynamic /system/lib/libc.so | grep LIBC_P produces a list of symbols that are not declared in the header files: 0003e520 T iconv@@LIBC_P 0003e586 T iconv_close@@LIBC_P 0003e3e8 T iconv_open@@LIBC_P 000429dc T posix_spawn@@LIBC_P 00042cc4 T posix_spawn_file_actions_addclose@@LIBC_P 00042d12 T posix_spawn_file_actions_adddup2@@LIBC_P 00042c4e T posix_spawn_file_actions_addopen@@LIBC_P 00042c22 T posix_spawn_file_actions_destroy@@LIBC_P 00042c06 T posix_spawn_file_actions_init@@LIBC_P 00042b40 T posix_spawnattr_destroy@@LIBC_P 00042b64 T posix_spawnattr_getflags@@LIBC_P 00042b76 T posix_spawnattr_getpgroup@@LIBC_P 00042bea T posix_spawnattr_getschedparam@@LIBC_P 00042bfc T posix_spawnattr_getschedpolicy@@LIBC_P 00042bc8 T posix_spawnattr_getsigdefault@@LIBC_P 00042b98 T posix_spawnattr_getsigmask@@LIBC_P 00042b24 T posix_spawnattr_init@@LIBC_P 00042b52 T posix_spawnattr_setflags@@LIBC_P 00042b6e T posix_spawnattr_setpgroup@@LIBC_P 00042be0 T posix_spawnattr_setschedparam@@LIBC_P 00042bf4 T posix_spawnattr_setschedpolicy@@LIBC_P 00042bb0 T posix_spawnattr_setsigdefault@@LIBC_P 00042b80 T posix_spawnattr_setsigmask@@LIBC_P 00042afc T posix_spawnp@@LIBC_P and also a list of symbols that are only declared when compiling for larger Android API levels. Namely, if func was added to Android API level, say, 28, then the libc.so has the symbol func always, whereas the header file <foo.h> declares func conditionally: #if __ANDROID_API__ >= 28 ... func (...) __INTRODUCED_IN(28); #endif Thus, when compiling with "clang -target armv7a-unknown-linux-android28", the function func is declared and exists in libc. Whereas when compiling with "clang -target armv7a-unknown-linux-android27", the function func is not declared but exists in libc. We need to treat this case like the case where func does not exist. These symbols are: 0007ce9c T __freading@@LIBC_P /usr/include/stdio_ext.h:int __freading(FILE* __fp) __INTRODUCED_IN(28); 0007cede T __fseterr@@LIBC_P /usr/include/stdio_ext.h:void __fseterr(FILE* __fp) __INTRODUCED_IN(28); 0007cea4 T __fwriting@@LIBC_P /usr/include/stdio_ext.h:int __fwriting(FILE* __fp) __INTRODUCED_IN(28); 00029574 T aligned_alloc@@LIBC_P /usr/include/stdlib.h:void* aligned_alloc(size_t __alignment, size_t __size) __INTRODUCED_IN(28); 0004eb8c T endhostent@@LIBC_P /usr/include/netdb.h:void endhostent(void) __INTRODUCED_IN(28); 00040120 T endnetent@@LIBC_P /usr/include/netdb.h:void endnetent(void) __INTRODUCED_IN(28); 00040122 T endprotoent@@LIBC_P /usr/include/netdb.h:void endprotoent(void) __INTRODUCED_IN(28); 0003ac8c T fexecve@@LIBC_P /usr/include/unistd.h:int fexecve(int __fd, char* const* __argv, char* const* __envp) __INTRODUCED_IN(28); 0007ca04 T fflush_unlocked@@LIBC_P /usr/include/stdio.h:int fflush_unlocked(FILE* __fp) __INTRODUCED_IN(28); 0007b88c T fgetc_unlocked@@LIBC_P /usr/include/stdio.h:int fgetc_unlocked(FILE* __fp) __INTRODUCED_IN(28); 0007b944 T fgets_unlocked@@LIBC_P /usr/include/stdio.h:char* fgets_unlocked(char* __buf, int __size, FILE* __fp) __INTRODUCED_IN(28); 0007ba90 T fputc_unlocked@@LIBC_P /usr/include/stdio.h:int fputc_unlocked(int __ch, FILE* __fp) __INTRODUCED_IN(28); 0007bbc4 T fputs_unlocked@@LIBC_P /usr/include/stdio.h:int fputs_unlocked(const char* __s, FILE* __fp) __INTRODUCED_IN(28); 0007cb78 T fread_unlocked@@LIBC_P /usr/include/stdio.h:size_t fread_unlocked(void* __buf, size_t __size, size_t __count, FILE* __fp) __INTRODUCED_IN(28); 0007bc44 T fwrite_unlocked@@LIBC_P /usr/include/stdio.h:size_t fwrite_unlocked(const void* __buf, size_t __size, size_t __count, FILE* __fp) __INTRODUCED_IN(28); 0003c28c T getentropy@@LIBC_P /usr/include/sys/random.h:int getentropy(void* __buffer, size_t __buffer_size) __wur __INTRODUCED_IN(28); 0003cdec T getlogin_r@@LIBC_P /usr/include/unistd.h:int getlogin_r(char* __buffer, size_t __buffer_size) __INTRODUCED_IN(28); 0004012c T getnetent@@LIBC_P /usr/include/netdb.h:struct netent* getnetent(void) __INTRODUCED_IN(28); 00040138 T getprotoent@@LIBC_P /usr/include/netdb.h:struct protoent* getprotoent(void) __INTRODUCED_IN(28); 000720d0 T getrandom@@LIBC_P /usr/include/sys/random.h:ssize_t getrandom(void* __buffer, size_t __buffer_size, unsigned int __flags) __wur __INTRODUCED_IN(28); 00058684 T hcreate@@LIBC_P /usr/include/search.h:int hcreate(size_t __n) __INTRODUCED_IN(28); 00058720 T hcreate_r@@LIBC_P /usr/include/search.h:int hcreate_r(size_t __n, struct hsearch_data* __table) __INTRODUCED_IN(28); 00058688 T hdestroy@@LIBC_P /usr/include/search.h:void hdestroy(void) __INTRODUCED_IN(28); 0005875e T hdestroy_r@@LIBC_P /usr/include/search.h:void hdestroy_r(struct hsearch_data* __table) __INTRODUCED_IN(28); 000586ac T hsearch@@LIBC_P /usr/include/search.h:ENTRY* hsearch(ENTRY __entry, ACTION __action) __INTRODUCED_IN(28); 00058772 T hsearch_r@@LIBC_P /usr/include/search.h:int hsearch_r(ENTRY __entry, ACTION __action, ENTRY** __result, struct hsearch_data* __table) __INTRODUCED_IN(28); 0007fbc2 W pthread_attr_getinheritsched@@LIBC_P /usr/include/pthread.h:int pthread_attr_getinheritsched(const pthread_attr_t* __attr, int* __flag) __INTRODUCED_IN(28); 0007fba4 W pthread_attr_setinheritsched@@LIBC_P /usr/include/pthread.h:int pthread_attr_setinheritsched(pthread_attr_t* __attr, int __flag) __INTRODUCED_IN(28); 00081aac T pthread_mutex_timedlock_monotonic_np@@LIBC_P /usr/include/pthread.h:int pthread_mutex_timedlock_monotonic_np(pthread_mutex_t* __mutex, const struct timespec* __timeout) 0008115a T pthread_mutexattr_getprotocol@@LIBC_P /usr/include/pthread.h:int pthread_mutexattr_getprotocol(const pthread_mutexattr_t* __attr, int* __protocol) __INTRODUCED_IN(28); 00081142 T pthread_mutexattr_setprotocol@@LIBC_P /usr/include/pthread.h:int pthread_mutexattr_setprotocol(pthread_mutexattr_t* __attr, int __protocol) __INTRODUCED_IN(28); 0008228a T pthread_rwlock_timedrdlock_monotonic_np@@LIBC_P /usr/include/pthread.h:int pthread_rwlock_timedrdlock_monotonic_np(pthread_rwlock_t* __rwlock, /usr/include/pthread.h- const struct timespec* __timeout) __INTRODUCED_IN(28); 000825da T pthread_rwlock_timedwrlock_monotonic_np@@LIBC_P /usr/include/pthread.h:int pthread_rwlock_timedwrlock_monotonic_np(pthread_rwlock_t* __rwlock, /usr/include/pthread.h- const struct timespec* __timeout) __INTRODUCED_IN(28); 00082b5c W pthread_setschedprio@@LIBC_P /usr/include/pthread.h:int pthread_setschedprio(pthread_t __pthread, int __priority) __INTRODUCED_IN(28); 00041bf4 T sem_timedwait_monotonic_np@@LIBC_P /usr/include/semaphore.h:int sem_timedwait_monotonic_np(sem_t* __sem, const struct timespec* __ts) __INTRODUCED_IN(28); 0004eb30 T sethostent@@LIBC_P /usr/include/netdb.h:void sethostent(int __stay_open) __INTRODUCED_IN(28); 0004013c T setnetent@@LIBC_P /usr/include/netdb.h:void setnetent(int __stay_open) __INTRODUCED_IN(28); 0004013e T setprotoent@@LIBC_P /usr/include/netdb.h:void setprotoent(int __stay_open) __INTRODUCED_IN(28); 0007646c T strptime_l@@LIBC_P /usr/include/time.h:char* strptime_l(const char* __s, const char* __fmt, struct tm* __tm, locale_t __l) __strftimelike(2) __INTRODUCED_IN(28); 00043774 T swab@@LIBC_P /usr/include/unistd.h:void swab(const void* __src, void* __dst, ssize_t __byte_count) __INTRODUCED_IN(28); 00070e48 T syncfs@@LIBC_P /usr/include/unistd.h:int syncfs(int __fd) __INTRODUCED_IN(28); 0004541a T wcsftime_l@@LIBC_P /usr/include/wchar.h:size_t wcsftime_l(wchar_t* __buf, size_t __n, const wchar_t* __fmt, const struct tm* __tm, locale_t __l) __INTRODUCED_IN(28); 00045422 T wcstod_l@@LIBC_P /usr/include/wchar.h:double wcstod_l(const wchar_t* __s, wchar_t** __end_ptr, locale_t __l) __INTRODUCED_IN(28); 00045426 T wcstof_l@@LIBC_P /usr/include/wchar.h:float wcstof_l(const wchar_t* __s, wchar_t** __end_ptr, locale_t __l) __INTRODUCED_IN(28); 0004542a T wcstol_l@@LIBC_P /usr/include/wchar.h:long wcstol_l(const wchar_t* __s, wchar_t** __end_ptr, int __base, locale_t __l) __INTRODUCED_IN(28); 00045432 T wcstoul_l@@LIBC_P /usr/include/wchar.h:unsigned long wcstoul_l(const wchar_t* __s, wchar_t** __end_ptr, int __base, locale_t __l) __INTRODUCED_IN(28); The solution to both problems is the same: For these functions, we need to look whether they are *declared and defined*, not only whether they are *defined*. 2023-01-05 Bruno Haible <br...@clisp.org> Recognize functions added in future versions of Android. * m4/gnulib-common.m4 (gl_CHECK_FUNCS_ANDROID): New macro. * m4/aligned_alloc.m4 (gl_FUNC_ALIGNED_ALLOC): Use gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS_ONCE. * m4/freading.m4 (gl_FUNC_FREADING): Likewise. * m4/fseterr.m4 (gl_FUNC_FSETERR): Likewise. * m4/fwriting.m4 (gl_FUNC_FWRITING): Likewise. * m4/getentropy.m4 (gl_FUNC_GETENTROPY): Likewise. * m4/getlogin_r.m4 (gl_CHECK_FUNCS_ANDROID): Likewise. * m4/getrandom.m4 (gl_FUNC_GETRANDOM): Likewise. * m4/glob.m4 (gl_PREREQ_GLOB): Likewise. * m4/spawn_h.m4 (gl_HAVE_POSIX_SPAWN): Likewise. * doc/glibc-functions/getentropy.texi: Mark function as existing in Android 9.0. * doc/glibc-functions/getrandom.texi: Likewise. * doc/posix-functions/pthread_attr_getinheritsched.texi: Likewise. * doc/posix-functions/pthread_attr_setinheritsched.texi: Likewise. diff --git a/doc/glibc-functions/getentropy.texi b/doc/glibc-functions/getentropy.texi index 4cee078402..4b2551c465 100644 --- a/doc/glibc-functions/getentropy.texi +++ b/doc/glibc-functions/getentropy.texi @@ -21,7 +21,7 @@ Portability problems fixed by Gnulib: @itemize @item This function is missing on some platforms: -glibc 2.24, Mac OS X 10.11, FreeBSD 11.0, NetBSD 9.0, OpenBSD 5.5, Minix 3.3, AIX 7.1, HP-UX 11.31, IRIX 6.5, Solaris 11.0, Cygwin 1.7.x, mingw, MSVC 14, Android 9.0. +glibc 2.24, Mac OS X 10.11, FreeBSD 11.0, NetBSD 9.0, OpenBSD 5.5, Minix 3.3, AIX 7.1, HP-UX 11.31, IRIX 6.5, Solaris 11.0, Cygwin 1.7.x, mingw, MSVC 14, Android 8.1. @item This function is declared in @code{<sys/random.h>}, not in @code{<unistd.h>}, on some platforms: diff --git a/doc/glibc-functions/getrandom.texi b/doc/glibc-functions/getrandom.texi index db817363cd..66e8588b32 100644 --- a/doc/glibc-functions/getrandom.texi +++ b/doc/glibc-functions/getrandom.texi @@ -21,7 +21,7 @@ Portability problems fixed by Gnulib: @itemize @item This function is missing on some platforms: -glibc 2.24, macOS 11.1, FreeBSD 11.0, NetBSD 9.0, OpenBSD 6.7, Minix 3.3, AIX 7.1, HP-UX 11.31, IRIX 6.5, Solaris 11.0, Cygwin 1.7.x, mingw, MSVC 14, Android 9.0. +glibc 2.24, macOS 11.1, FreeBSD 11.0, NetBSD 9.0, OpenBSD 6.7, Minix 3.3, AIX 7.1, HP-UX 11.31, IRIX 6.5, Solaris 11.0, Cygwin 1.7.x, mingw, MSVC 14, Android 8.1. @item This function has a different return type on some platforms: Solaris 11.4. diff --git a/doc/posix-functions/pthread_attr_getinheritsched.texi b/doc/posix-functions/pthread_attr_getinheritsched.texi index 12a5f955db..2d135a545a 100644 --- a/doc/posix-functions/pthread_attr_getinheritsched.texi +++ b/doc/posix-functions/pthread_attr_getinheritsched.texi @@ -14,5 +14,5 @@ Portability problems not fixed by Gnulib: @itemize @item This function is missing on some platforms: -Minix 3.1.8, mingw, MSVC 14, Android 9.0. +Minix 3.1.8, mingw, MSVC 14, Android 8.1. @end itemize diff --git a/doc/posix-functions/pthread_attr_setinheritsched.texi b/doc/posix-functions/pthread_attr_setinheritsched.texi index 652e41e616..6fad04c670 100644 --- a/doc/posix-functions/pthread_attr_setinheritsched.texi +++ b/doc/posix-functions/pthread_attr_setinheritsched.texi @@ -14,5 +14,5 @@ Portability problems not fixed by Gnulib: @itemize @item This function is missing on some platforms: -Minix 3.1.8, mingw, MSVC 14, Android 9.0. +Minix 3.1.8, mingw, MSVC 14, Android 8.1. @end itemize diff --git a/m4/aligned_alloc.m4 b/m4/aligned_alloc.m4 index 31681ac52a..d088701dbc 100644 --- a/m4/aligned_alloc.m4 +++ b/m4/aligned_alloc.m4 @@ -1,4 +1,4 @@ -# aligned_alloc.m4 serial 3 +# aligned_alloc.m4 serial 4 dnl Copyright (C) 2020-2023 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -12,7 +12,7 @@ AC_DEFUN([gl_FUNC_ALIGNED_ALLOC], dnl Persuade glibc and OpenBSD <stdlib.h> to declare aligned_alloc(). AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) - AC_CHECK_FUNCS_ONCE([aligned_alloc]) + gl_CHECK_FUNCS_ANDROID([aligned_alloc], [[#include <stdlib.h>]]) if test $ac_cv_func_aligned_alloc = yes; then dnl On macOS 11.1 and AIX 7.2, aligned_alloc returns NULL when the alignment dnl argument is smaller than sizeof (void *). diff --git a/m4/freading.m4 b/m4/freading.m4 index 35333369df..f0f4893335 100644 --- a/m4/freading.m4 +++ b/m4/freading.m4 @@ -1,4 +1,4 @@ -# freading.m4 serial 2 +# freading.m4 serial 3 dnl Copyright (C) 2007, 2009-2023 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -7,5 +7,8 @@ dnl with or without modifications, as long as this notice is preserved. AC_DEFUN([gl_FUNC_FREADING], [ AC_CHECK_HEADERS_ONCE([stdio_ext.h]) - AC_CHECK_FUNCS_ONCE([__freading]) + gl_CHECK_FUNCS_ANDROID([__freading], + [[#include <stdio.h> + #include <stdio_ext.h> + ]]) ]) diff --git a/m4/fseterr.m4 b/m4/fseterr.m4 index ecdc81e769..61ac03d49d 100644 --- a/m4/fseterr.m4 +++ b/m4/fseterr.m4 @@ -1,4 +1,4 @@ -# fseterr.m4 serial 1 +# fseterr.m4 serial 2 dnl Copyright (C) 2012-2023 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -6,5 +6,8 @@ dnl with or without modifications, as long as this notice is preserved. AC_DEFUN([gl_FUNC_FSETERR], [ - AC_CHECK_FUNCS_ONCE([__fseterr]) + gl_CHECK_FUNCS_ANDROID([__fseterr], + [[#include <stdio.h> + #include <stdio_ext.h> + ]]) ]) diff --git a/m4/fwriting.m4 b/m4/fwriting.m4 index eee7d50678..8631fdf323 100644 --- a/m4/fwriting.m4 +++ b/m4/fwriting.m4 @@ -1,4 +1,4 @@ -# fwriting.m4 serial 3 +# fwriting.m4 serial 4 dnl Copyright (C) 2007, 2009-2023 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -7,5 +7,8 @@ dnl with or without modifications, as long as this notice is preserved. AC_DEFUN([gl_FUNC_FWRITING], [ AC_CHECK_HEADERS_ONCE([stdio_ext.h]) - AC_CHECK_FUNCS_ONCE([__fwriting]) + gl_CHECK_FUNCS_ANDROID([__fwriting], + [[#include <stdio.h> + #include <stdio_ext.h> + ]]) ]) diff --git a/m4/getentropy.m4 b/m4/getentropy.m4 index 0c6cda88f5..352b04ee4f 100644 --- a/m4/getentropy.m4 +++ b/m4/getentropy.m4 @@ -1,4 +1,4 @@ -# getentropy.m4 +# getentropy.m4 serial 2 dnl Copyright 2020-2023 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,14 @@ dnl Written by Paul Eggert. AC_DEFUN([gl_FUNC_GETENTROPY], [ AC_REQUIRE([gl_UNISTD_H_DEFAULTS]) - AC_CHECK_FUNCS_ONCE([getentropy]) + gl_CHECK_FUNCS_ANDROID([getentropy], + [[#include <unistd.h> + /* Additional includes are needed before <sys/random.h> on uClibc + and Mac OS X. */ + #include <sys/types.h> + #include <stdlib.h> + #include <sys/random.h> + ]]) if test $ac_cv_func_getentropy = no; then HAVE_GETENTROPY=0 fi diff --git a/m4/getlogin_r.m4 b/m4/getlogin_r.m4 index db9e37af45..cbfe255ee1 100644 --- a/m4/getlogin_r.m4 +++ b/m4/getlogin_r.m4 @@ -1,4 +1,4 @@ -#serial 13 +#serial 14 # Copyright (C) 2005-2007, 2009-2023 Free Software Foundation, Inc. # @@ -25,7 +25,7 @@ AC_DEFUN([gl_FUNC_GETLOGIN_R], HAVE_DECL_GETLOGIN_R=0 fi - AC_CHECK_FUNCS_ONCE([getlogin_r]) + gl_CHECK_FUNCS_ANDROID([getlogin_r], [[#include <unistd.h>]]) if test $ac_cv_func_getlogin_r = no; then HAVE_GETLOGIN_R=0 else diff --git a/m4/getrandom.m4 b/m4/getrandom.m4 index 95111567d7..f2010c0213 100644 --- a/m4/getrandom.m4 +++ b/m4/getrandom.m4 @@ -1,4 +1,4 @@ -# getrandom.m4 serial 8 +# getrandom.m4 serial 9 dnl Copyright 2020-2023 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,13 @@ dnl Written by Paul Eggert. AC_DEFUN([gl_FUNC_GETRANDOM], [ AC_REQUIRE([gl_SYS_RANDOM_H_DEFAULTS]) - AC_CHECK_FUNCS_ONCE([getrandom]) + gl_CHECK_FUNCS_ANDROID([getrandom], + [[/* Additional includes are needed before <sys/random.h> on uClibc + and Mac OS X. */ + #include <sys/types.h> + #include <stdlib.h> + #include <sys/random.h> + ]]) if test "$ac_cv_func_getrandom" != yes; then HAVE_GETRANDOM=0 else diff --git a/m4/glob.m4 b/m4/glob.m4 index 4254b6e572..354581b3be 100644 --- a/m4/glob.m4 +++ b/m4/glob.m4 @@ -1,4 +1,4 @@ -# glob.m4 serial 26 +# glob.m4 serial 27 dnl Copyright (C) 2005-2007, 2009-2023 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -125,5 +125,6 @@ AC_DEFUN([gl_PREREQ_GLOB], [ AC_REQUIRE([gl_CHECK_TYPE_STRUCT_DIRENT_D_TYPE]) AC_CHECK_HEADERS_ONCE([unistd.h]) - AC_CHECK_FUNCS_ONCE([getlogin_r getpwnam_r]) + gl_CHECK_FUNCS_ANDROID([getlogin_r], [[#include <unistd.h>]]) + AC_CHECK_FUNCS_ONCE([getpwnam_r]) ]) diff --git a/m4/gnulib-common.m4 b/m4/gnulib-common.m4 index fb7fed41f8..26239caa2b 100644 --- a/m4/gnulib-common.m4 +++ b/m4/gnulib-common.m4 @@ -1,4 +1,4 @@ -# gnulib-common.m4 serial 75 +# gnulib-common.m4 serial 76 dnl Copyright (C) 2007-2023 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -1023,6 +1023,30 @@ AC_DEFUN([gl_CONDITIONAL_HEADER], m4_popdef([gl_header_name]) ]) +dnl gl_CHECK_FUNCS_ANDROID([func], [[#include <foo.h>]]) +dnl is like AC_CHECK_FUNCS([func]), taking into account a portability problem +dnl on Android. +dnl Namely, if func was added to Android API level, say, 28, then the libc.so +dnl has the symbol func always, whereas the header file <foo.h> declares func +dnl conditionally: +dnl #if __ANDROID_API__ >= 28 +dnl ... func (...) __INTRODUCED_IN(28); +dnl #endif +dnl Thus, when compiling with "clang -target armv7a-unknown-linux-android28", +dnl the function func is declared and exists in libc. +dnl Whereas when compiling with "clang -target armv7a-unknown-linux-android27", +dnl the function func is not declared but exists in libc. We need to treat this +dnl case like the case where func does not exist. +AC_DEFUN([gl_CHECK_FUNCS_ANDROID], +[ + AC_CHECK_DECL([$1], , , [$2]) + if test $ac_cv_have_decl_[$1] = yes; then + AC_CHECK_FUNCS([$1]) + else + ac_cv_func_[$1]=no + fi +]) + dnl Expands to some code for use in .c programs that, on native Windows, defines dnl the Microsoft deprecated alias function names to the underscore-prefixed dnl actual function names. With this macro, these function names are available diff --git a/m4/spawn_h.m4 b/m4/spawn_h.m4 index d2c5242326..118490adb7 100644 --- a/m4/spawn_h.m4 +++ b/m4/spawn_h.m4 @@ -1,4 +1,4 @@ -# spawn_h.m4 serial 21 +# spawn_h.m4 serial 22 dnl Copyright (C) 2008-2023 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -71,7 +71,7 @@ AC_DEFUN([gl_HAVE_POSIX_SPAWN], AC_SEARCH_LIBS([posix_spawn], [rt], [test "$ac_cv_search_posix_spawn" = "none required" || LIB_POSIX_SPAWN=$ac_cv_search_posix_spawn]) - AC_CHECK_FUNCS([posix_spawn]) + gl_CHECK_FUNCS_ANDROID([posix_spawn], [[#include <spawn.h>]]) LIBS=$gl_saved_libs if test $ac_cv_func_posix_spawn != yes; then