summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJérôme de Bretagne <jerome.debretagne@gmail.com>2019-11-06 21:45:58 +0100
committerJérôme de Bretagne <jerome.debretagne@gmail.com>2019-11-06 22:38:16 +0100
commit257e349058789c418dea2faab107cb238bcba987 (patch)
tree0ce5f52b9bc64de50175d877827231d1298990a2
parent21f14d1b89b21a2bdb630de3dd9c67c4642e5f14 (diff)
downloaderlang-257e349058789c418dea2faab107cb238bcba987.tar.gz
erts: Allow Android cross compilation to target Android 5.0 Lollipop
if_nameindex and if_freenameindex were added in Android 7.0 Nougat so guard their usages when targeting earlier Android versions. Update the Android documentation accordingly.
-rw-r--r--HOWTO/INSTALL-ANDROID.md4
-rw-r--r--erts/emulator/nifs/common/prim_net_nif.c7
-rw-r--r--xcomp/erl-xcomp-arm-android.conf2
-rw-r--r--xcomp/erl-xcomp-arm64-android.conf2
4 files changed, 9 insertions, 6 deletions
diff --git a/HOWTO/INSTALL-ANDROID.md b/HOWTO/INSTALL-ANDROID.md
index 34937b921e..5bef14d68f 100644
--- a/HOWTO/INSTALL-ANDROID.md
+++ b/HOWTO/INSTALL-ANDROID.md
@@ -29,7 +29,7 @@ to generate the configure scripts.
Use the following when compiling a 64-bit version.
- $ export NDK_ABI_PLAT=android24 # When targeting Android 7.0 Nougat
+ $ export NDK_ABI_PLAT=android21 # When targeting Android 5.0 Lollipop
$ ./otp_build configure \
--xcomp-conf=./xcomp/erl-xcomp-arm64-android.conf \
--without-ssl
@@ -37,7 +37,7 @@ Use the following when compiling a 64-bit version.
Use the following instead when compiling a 32-bit version.
- $ export NDK_ABI_PLAT=androideabi24 # When targeting Android 7.0 Nougat
+ $ export NDK_ABI_PLAT=androideabi21 # When targeting Android 5.0 Lollipop
$ ./otp_build configure \
--xcomp-conf=./xcomp/erl-xcomp-arm-android.conf \
--without-ssl
diff --git a/erts/emulator/nifs/common/prim_net_nif.c b/erts/emulator/nifs/common/prim_net_nif.c
index 5f7a2716f9..c7ecc99134 100644
--- a/erts/emulator/nifs/common/prim_net_nif.c
+++ b/erts/emulator/nifs/common/prim_net_nif.c
@@ -1109,7 +1109,7 @@ ERL_NIF_TERM nif_if_names(ErlNifEnv* env,
int argc,
const ERL_NIF_TERM argv[])
{
-#if defined(__WIN32__)
+#if defined(__WIN32__) || (defined(__ANDROID__) && (__ANDROID_API__ < 24))
return enif_raise_exception(env, MKA(env, "notsup"));
#else
ERL_NIF_TERM result;
@@ -1130,7 +1130,10 @@ ERL_NIF_TERM nif_if_names(ErlNifEnv* env,
-#if !defined(__WIN32__)
+/* if_nameindex and if_freenameindex were added in Android 7.0 Nougat. With
+the Android NDK Unified Headers, check that the build is targeting at least
+the corresponding API level 24. */
+#if !defined(__WIN32__) && !(defined(__ANDROID__) && (__ANDROID_API__ < 24))
static
ERL_NIF_TERM nif_names(ErlNifEnv* env)
{
diff --git a/xcomp/erl-xcomp-arm-android.conf b/xcomp/erl-xcomp-arm-android.conf
index 64f976fce8..1bddd2d8b9 100644
--- a/xcomp/erl-xcomp-arm-android.conf
+++ b/xcomp/erl-xcomp-arm-android.conf
@@ -87,7 +87,7 @@ NDK_SYSROOT=$NDK_ROOT/sysroot
# For older Android NDK versions still supporting GCC.
#CC="arm-linux-androideabi-gcc --sysroot=$NDK_SYSROOT"
# For more recent Android NDK versions only supporting Clang/LLVM.
-#NDK_ABI_PLAT=androideabi24 # when targeting Android 7.0 Nougat
+#NDK_ABI_PLAT=androideabi21 # when targeting Android 5.0 Lollipop
CC="armv7a-linux-$NDK_ABI_PLAT-clang"
# * `CFLAGS' - C compiler flags.
diff --git a/xcomp/erl-xcomp-arm64-android.conf b/xcomp/erl-xcomp-arm64-android.conf
index bedee510e1..e423651fed 100644
--- a/xcomp/erl-xcomp-arm64-android.conf
+++ b/xcomp/erl-xcomp-arm64-android.conf
@@ -85,7 +85,7 @@ NDK_SYSROOT=$NDK_ROOT/sysroot
# * `CC' - C compiler.
#
# For recent Android NDK versions only supporting Clang/LLVM.
-#NDK_ABI_PLAT=android24 # when targeting Android 7.0 Nougat
+#NDK_ABI_PLAT=android21 # when targeting Android 5.0 Lollipop
CC="aarch64-linux-$NDK_ABI_PLAT-clang"
# * `CFLAGS' - C compiler flags.