bug-gnulib@gnu.org mirror (unofficial)
 help / color / mirror / Atom feed
From: Bruno Haible <bruno@clisp.org>
To: bug-gnulib@gnu.org
Subject: Fix link errors on Android 4.3
Date: Wed, 11 Jan 2023 10:53:39 +0100	[thread overview]
Message-ID: <7865076.SKYDtnEIZr@nimes> (raw)

Building a testdir on Android 4.3, I see these link errors:

terminal-gcc -mandroid -D__ANDROID__ -std=gnu99  -Wno-error -O2  -L/data/data/com.spartacusrex.spartacuside/files/local/lib -o test-asyncsafe-spin1 test-asyncsafe-spin1.o libtests.a ../gllib/libgnu.a libtests.a ../gllib/libgnu.a libtests.a  -lm -lm -lm -lm -lm -lm -lm -lm -lm -lm -lm
../gllib/libgnu.a(asyncsafe-spin.o): In function `asyncsafe_spin_lock':
asyncsafe-spin.c:(.text+0x20): undefined reference to `__sync_val_compare_and_swap_4'
../gllib/libgnu.a(asyncsafe-spin.o): In function `asyncsafe_spin_unlock':
asyncsafe-spin.c:(.text+0x40): undefined reference to `__sync_val_compare_and_swap_4'
collect2: ld returned 1 exit status
make[4]: *** [test-asyncsafe-spin1] Error 1
terminal-gcc -mandroid -D__ANDROID__ -std=gnu99  -Wno-error -O2  -L/data/data/com.spartacusrex.spartacuside/files/local/lib -o test-asyncsafe-spin2 test-asyncsafe-spin2.o libtests.a ../gllib/libgnu.a libtests.a ../gllib/libgnu.a libtests.a     -lm -lm -lm -lm -lm -lm -lm -lm -lm -lm -lm
../gllib/libgnu.a(asyncsafe-spin.o): In function `asyncsafe_spin_lock':
asyncsafe-spin.c:(.text+0x20): undefined reference to `__sync_val_compare_and_swap_4'
../gllib/libgnu.a(asyncsafe-spin.o): In function `asyncsafe_spin_unlock':
asyncsafe-spin.c:(.text+0x40): undefined reference to `__sync_val_compare_and_swap_4'
collect2: ld returned 1 exit status
make[4]: *** [test-asyncsafe-spin2] Error 1

Apparently the runtime support for these GCC built-ins is not contained in
the Android libc for this version.

This patch fixes the errors.


2023-01-11  Bruno Haible  <bruno@clisp.org>

	Fix link errors on Android 4.3.
	* lib/asyncsafe-spin.c: Don't use the GCC >= 4.1 builtins on Android.
	* lib/pthread-spin.c: Likewise.
	* lib/simple-atomic.c: Likewise.

diff --git a/lib/asyncsafe-spin.c b/lib/asyncsafe-spin.c
index 7a74c32077..66e1669924 100644
--- a/lib/asyncsafe-spin.c
+++ b/lib/asyncsafe-spin.c
@@ -136,7 +136,7 @@ do_unlock (asyncsafe_spinlock_t *lock)
 #  elif (((__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 1)) \
           && !defined __sparc__) \
          || __clang_major__ >= 3) \
-        && !defined __ibmxl__
+        && !defined __ibmxl__ && !defined __ANDROID__
 /* Use GCC built-ins (available in GCC >= 4.1, except on SPARC, and
    clang >= 3.0).
    Documentation:
diff --git a/lib/pthread-spin.c b/lib/pthread-spin.c
index ca3e88755a..e551f733cf 100644
--- a/lib/pthread-spin.c
+++ b/lib/pthread-spin.c
@@ -164,7 +164,7 @@ pthread_spin_destroy (pthread_spinlock_t *lock)
 
 # elif (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 1) \
         || __clang_major__ >= 3) \
-       && !defined __ibmxl__
+       && !defined __ibmxl__ && !defined __ANDROID__
 /* Use GCC built-ins (available in GCC >= 4.1 and clang >= 3.0).
    Documentation:
    <https://gcc.gnu.org/onlinedocs/gcc-4.1.2/gcc/Atomic-Builtins.html>  */
diff --git a/lib/simple-atomic.c b/lib/simple-atomic.c
index 4e52447ed6..ffa126613c 100644
--- a/lib/simple-atomic.c
+++ b/lib/simple-atomic.c
@@ -69,7 +69,7 @@ atomic_compare_and_swap_ptr (uintptr_t volatile *vp,
 # if (((__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 1)) \
        && !defined __sparc__) \
       || __clang_major__ >= 3) \
-     && !defined __ibmxl__
+     && !defined __ibmxl__ && !defined __ANDROID__
 /* Use GCC built-ins (available in GCC >= 4.1, except on SPARC, and
    clang >= 3.0).
    Documentation:





             reply	other threads:[~2023-01-11  9:54 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-11  9:53 Bruno Haible [this message]
2023-01-11 17:11 ` Fix link errors on Android 4.3 Bruno Haible

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:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  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=7865076.SKYDtnEIZr@nimes \
    --to=bruno@clisp.org \
    --cc=bug-gnulib@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* 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).