bug-gnulib@gnu.org mirror (unofficial)
 help / color / mirror / Atom feed
From: Bruno Haible <bruno@clisp.org>
To: bug-gnulib@gnu.org, Paul Eggert <eggert@cs.ucla.edu>
Cc: Po Lu <luangruo@yahoo.com>
Subject: Re: API levels and functions on Android
Date: Thu, 19 Jan 2023 00:23:45 +0100	[thread overview]
Message-ID: <11306703.GINRyM86WL@nimes> (raw)
In-Reply-To: <0390f375-dfcb-458d-3200-639db8a41c02@cs.ucla.edu>

Paul Eggert wrote:
> > +  gl_CHECK_FUNCS_ANDROID([utimensat], [[#include <sys/stat.h>]])
> >     if test $ac_cv_func_utimensat = no; then
> >       HAVE_UTIMENSAT=0
> REPLACE_UTIMENSAT=1 means utimensat is present but broken and needs to 
> be replaced. However, $ac_cv_func_utimensat = no means utimensat is 
> absent. So I'm puzzled as to why REPLACE_UTIMENSAT=1 would be 
> appropriate here.

Deployment on Android is a bit special: When a developer compiles an app,
they specify an "API level". This API level designates the minimum Android
version on which the app will work. For example [1][2]:

  18 = Android 4.3
  19 = Android 4.4
  20 = Android 4.4W
  21 = Android 5.0
  22 = Android 5.1
  23 = Android 6.0
  24 = Android 7.0
  25 = Android 7.1
  26 = Android 8.0
  27 = Android 8.1
  28 = Android 9
  29 = Android 10
  30 = Android 11
  31 = Android 12
  32 = Android 12L
  33 = Android 13

Now, some functions get added to libc over time. For example, the glob and
globfree functions are being added in API level 28. So, when a developer
*compiles* for an API level < 28 but tests the app on a device with API level
≥ 28, the two functions will not be declared in the header files but will be
present in libc.

By the way the gl_CHECK_FUNCS_ANDROID macro works so far, when a function is
not declared, it reports it as "missing" (ac_cv_func_...=no). This is a good
approximation, and will usually work fine.

But there is a conflict: Gnulib, when ac_cv_func_glob=no, will define the
function 'glob' (not 'rpl_glob'), since Gnulib so far assumes that a build
is for one OS version. So, we can arrive at a situation where
  - the OS defines 'glob' in libc.so, and
  - the app defines 'glob' in its shared library.
By ELF rules, the 'glob' symbol from the app's shared library will override
the one from libc. Which is OK for the app. But some calls from within libc
might behave unexpectedly if they suddenly call the 'glob' function from the

Defining REPLACE_GLOB=1 despite HAVE_GLOB=0 will be the way to make Gnulib
define 'rpl_glob' instead of 'glob', so that there is no conflict with libc.so.

I still need to work out the details how this would/will work. So as to
do things correctly on Android, while OTOH not adding lots of configure tests
for the other platforms...


[1] https://developer.android.com/studio/releases/platforms
[2] https://apilevels.com/

  reply	other threads:[~2023-01-18 23:54 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <87o7qw6jap.fsf.ref@yahoo.com>
2023-01-18 13:53 ` Follow up to last post Po Lu
2023-01-18 22:18   ` Paul Eggert
2023-01-18 23:23     ` Bruno Haible [this message]
2023-01-19  4:24       ` API levels and functions on Android Paul Eggert
2023-01-19 10:27         ` Bruno Haible
2023-01-19  0:44     ` Follow up to last post Po Lu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

  List information: https://lists.gnu.org/mailman/listinfo/bug-gnulib

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=11306703.GINRyM86WL@nimes \
    --to=bruno@clisp.org \
    --cc=bug-gnulib@gnu.org \
    --cc=eggert@cs.ucla.edu \
    --cc=luangruo@yahoo.com \


* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).