0
0
mirror of https://github.com/zeromq/libzmq.git synced 2024-12-27 15:41:05 +08:00
libzmq/builds/android/android_build_helper.sh

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

493 lines
19 KiB
Bash
Raw Normal View History

#!/usr/bin/env bash
#
# Copyright (c) 2014, Joe Eli McIlvain
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
#
# 3. Neither the name of the copyright holder nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
# THE POSSIBILITY OF SUCH DAMAGE.
#
###
#
# https://github.com/jemc/android_build_helper
# android_build_helper.sh
#
# The following is a helper script for setting up android builds for
# "native" libraries maintained with an autotools build system.
# It merely helps to create the proper cross-compile environment.
# It makes no attempt to wrap the library or make it accessible to Java code;
# the intention is to make the bare library available to other "native" code.
#
# To get the latest version of this script, please download from:
# https://github.com/jemc/android_build_helper
#
# You are free to modify this script, but if you add improvements,
# please consider submitting a pull request to the aforementioned upstream
# repository for the benefit of other users.
#
########################################################################
# Utilities & helper functions
Problem: Android APP fails to load ZMQ (ARM64 only) (#4442) * Problem: Android APP fails to load ZMQ (ARM64 only) Seen with physical Android devices running ARM64. Not seen with ARM, X86 or X86_64. Any Android APP loading ZMQ fails with: ``` [FATAL] Couldn't load library library zmq from jar. Dependency is required! ``` Unpack zyre-android-2.0.1.jar, find libzmq.so for ARM64 and look for missing symbols: ``` prompt> unzip zyre-android-2.0.1.jar prompt> cd lib/arm64-v8a prompt> nm --undefined-only ./libzmq.so | head U __aarch64_ldadd4_acq U __aarch64_ldadd4_acq_rel U __aarch64_ldadd4_rel U __aarch64_ldadd4_relax U __aarch64_ldadd8_acq_rel U __aarch64_ldadd8_relax U __aarch64_swp8_acq U __aarch64_swp8_acq_rel U __aarch64_swp8_rel U __aarch64_swp8_relax prompt> ``` Some more symbols are missing, but those are relevant for this issue. OK. These symbols are present in libc++_shared, but not exported ...: ``` prompt> nm libc++_shared.so | grep aarch64 00000000000ee6d0 t __aarch64_cas1_acq_rel 00000000000ee7a0 t __aarch64_cas8_acq_rel 00000000001028f0 b __aarch64_have_lse_atomics 00000000000ee840 t __aarch64_ldadd4_acq_rel 00000000000ee810 t __aarch64_ldadd4_rel 00000000000ee8a0 t __aarch64_ldadd8_acq_rel 00000000000ee870 t __aarch64_ldadd8_relax 00000000000ee7e0 t __aarch64_swp8_acq_rel prompt> ``` Issue seen also on the WEB, with GCC & CLANG: - https://bugzilla.redhat.com/show_bug.cgi?id=1830472 - https://github.com/flutter/buildroot/pull/434/commits/cea175b83895943c30fb3e2c17e3c43bd619a6b9 - ... Solution: Add `-mno-outline-atomics` to CXXFLAGS (FLUTTER fix). Additionaly, had to introduce NDK_NUMBER. This variable is calculated in `android_build_helper.sh`. It represents the numeric form of NDK_VERSION: ``` NDK_VERSION --> NDK_NUMBER android-ndk-r25 --> 2500 android-ndk-r23c --> 2303 android-ndk-r22 --> 2200 android-ndk-r21e --> 2105 ... and so on ``` This will help a few other things (NDK download ?).
2022-10-18 11:19:15 +02:00
########################################################################
function android_build_trace {
if [ -n "${BUILD_ARCH}" ] ; then
echo "LIBZMQ (${BUILD_ARCH}) - $*"
else
echo "LIBZMQ - $*"
fi
}
Problem: Android APP fails to load ZMQ (ARM64 only) (#4442) * Problem: Android APP fails to load ZMQ (ARM64 only) Seen with physical Android devices running ARM64. Not seen with ARM, X86 or X86_64. Any Android APP loading ZMQ fails with: ``` [FATAL] Couldn't load library library zmq from jar. Dependency is required! ``` Unpack zyre-android-2.0.1.jar, find libzmq.so for ARM64 and look for missing symbols: ``` prompt> unzip zyre-android-2.0.1.jar prompt> cd lib/arm64-v8a prompt> nm --undefined-only ./libzmq.so | head U __aarch64_ldadd4_acq U __aarch64_ldadd4_acq_rel U __aarch64_ldadd4_rel U __aarch64_ldadd4_relax U __aarch64_ldadd8_acq_rel U __aarch64_ldadd8_relax U __aarch64_swp8_acq U __aarch64_swp8_acq_rel U __aarch64_swp8_rel U __aarch64_swp8_relax prompt> ``` Some more symbols are missing, but those are relevant for this issue. OK. These symbols are present in libc++_shared, but not exported ...: ``` prompt> nm libc++_shared.so | grep aarch64 00000000000ee6d0 t __aarch64_cas1_acq_rel 00000000000ee7a0 t __aarch64_cas8_acq_rel 00000000001028f0 b __aarch64_have_lse_atomics 00000000000ee840 t __aarch64_ldadd4_acq_rel 00000000000ee810 t __aarch64_ldadd4_rel 00000000000ee8a0 t __aarch64_ldadd8_acq_rel 00000000000ee870 t __aarch64_ldadd8_relax 00000000000ee7e0 t __aarch64_swp8_acq_rel prompt> ``` Issue seen also on the WEB, with GCC & CLANG: - https://bugzilla.redhat.com/show_bug.cgi?id=1830472 - https://github.com/flutter/buildroot/pull/434/commits/cea175b83895943c30fb3e2c17e3c43bd619a6b9 - ... Solution: Add `-mno-outline-atomics` to CXXFLAGS (FLUTTER fix). Additionaly, had to introduce NDK_NUMBER. This variable is calculated in `android_build_helper.sh`. It represents the numeric form of NDK_VERSION: ``` NDK_VERSION --> NDK_NUMBER android-ndk-r25 --> 2500 android-ndk-r23c --> 2303 android-ndk-r22 --> 2200 android-ndk-r21e --> 2105 ... and so on ``` This will help a few other things (NDK download ?).
2022-10-18 11:19:15 +02:00
function android_build_check_fail {
if [ ! ${#ANDROID_BUILD_FAIL[@]} -eq 0 ]; then
android_build_trace "Android build failed for the following reasons:"
for reason in "${ANDROID_BUILD_FAIL[@]}"; do
local formatted_reason=" ${reason}"
echo "${formatted_reason}"
done
exit 1
fi
}
function android_download_ndk {
if [ -d "${ANDROID_NDK_ROOT}" ] ; then
# NDK folder detected, let's assume it's valid ...
android_build_trace "Using existing NDK folder '${ANDROID_NDK_ROOT}'."
return
fi
if [ ! -d "$(dirname "${ANDROID_NDK_ROOT}")" ] ; then
ANDROID_BUILD_FAIL+=("Cannot download NDK in a non existing folder")
ANDROID_BUILD_FAIL+=(" $(dirname "${ANDROID_NDK_ROOT}/")")
fi
if [ -z "${ANDROID_NDK_FILENAME}" ] ; then
ANDROID_BUILD_FAIL+=("Please set the ANDROID_NDK_FILENAME environment variable")
fi
android_build_check_fail
android_build_trace "Downloading NDK '${NDK_VERSION}'..."
(
cd "$(dirname "${ANDROID_NDK_ROOT}")" \
&& rm -f "${ANDROID_NDK_FILENAME}" \
&& wget -q "http://dl.google.com/android/repository/${ANDROID_NDK_FILENAME}" -O "${ANDROID_NDK_FILENAME}" \
&& android_build_trace "Extracting NDK '${ANDROID_NDK_FILENAME}'..." \
&& unzip -q "${ANDROID_NDK_FILENAME}" \
&& android_build_trace "NDK extracted under '${ANDROID_NDK_ROOT}'."
) || {
ANDROID_BUILD_FAIL+=("Failed to install NDK ('${NDK_VERSION}')")
ANDROID_BUILD_FAIL+=(" ${ANDROID_NDK_FILENAME}")
}
android_build_check_fail
}
function android_build_set_env {
BUILD_ARCH=$1
platform="$(uname | tr '[:upper:]' '[:lower:]')"
case "${platform}" in
linux*)
if [ $NDK_NUMBER -ge 2300 ] ; then
# Since NDK 23, NDK archives are renamed.
export ANDROID_NDK_FILENAME=${NDK_VERSION}-linux.zip
else
export ANDROID_NDK_FILENAME=${NDK_VERSION}-linux-x86_64.zip
fi
export ANDROID_BUILD_PLATFORM=linux-x86_64
;;
darwin*)
if [ $NDK_NUMBER -ge 2300 ] ; then
# Since NDK 23, NDK archives are renamed.
export ANDROID_NDK_FILENAME=${NDK_VERSION}-darwin.zip
else
export ANDROID_NDK_FILENAME=${NDK_VERSION}-darwin-x86_64.zip
fi
export ANDROID_BUILD_PLATFORM=darwin-x86_64
;;
*) android_build_trace "Unsupported platform ('${platform}')" ; exit 1 ;;
esac
export TOOLCHAIN_PATH="${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/${ANDROID_BUILD_PLATFORM}/bin"
# Set variables for each architecture
if [ "${BUILD_ARCH}" == "arm" ]; then
export TOOLCHAIN_HOST="arm-linux-androideabi"
export TOOLCHAIN_COMP="armv7a-linux-androideabi${MIN_SDK_VERSION}"
export TOOLCHAIN_ABI="armeabi-v7a"
export TOOLCHAIN_ARCH="arm"
elif [ "${BUILD_ARCH}" == "x86" ]; then
export TOOLCHAIN_HOST="i686-linux-android"
export TOOLCHAIN_COMP="i686-linux-android${MIN_SDK_VERSION}"
export TOOLCHAIN_ABI="x86"
export TOOLCHAIN_ARCH="x86"
elif [ "${BUILD_ARCH}" == "arm64" ]; then
export TOOLCHAIN_HOST="aarch64-linux-android"
export TOOLCHAIN_COMP="aarch64-linux-android${MIN_SDK_VERSION}"
export TOOLCHAIN_ABI="arm64-v8a"
export TOOLCHAIN_ARCH="arm64"
elif [ "${BUILD_ARCH}" == "x86_64" ]; then
export TOOLCHAIN_HOST="x86_64-linux-android"
export TOOLCHAIN_COMP="x86_64-linux-android${MIN_SDK_VERSION}"
export TOOLCHAIN_ABI="x86_64"
export TOOLCHAIN_ARCH="x86_64"
fi
# Since NDK r22 the "platforms" dir got removed
if [ -d "${ANDROID_NDK_ROOT}/platforms" ]; then
export ANDROID_BUILD_SYSROOT="${ANDROID_NDK_ROOT}/platforms/android-${MIN_SDK_VERSION}/arch-${TOOLCHAIN_ARCH}"
else
export ANDROID_BUILD_SYSROOT="${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/${ANDROID_BUILD_PLATFORM}/sysroot"
fi
export ANDROID_BUILD_PREFIX="${ANDROID_BUILD_DIR}/prefix/${TOOLCHAIN_ARCH}"
Problem: Android APP fails to load ZMQ since NDK r25.x (#4437) * Problem: Android APP fails to load ZMQ since NDK r25.x With the help of the dump of ./configure options (former PR): ``` LIBZMQ (arm) - ./configure options to build 'LIBZMQ': > --quiet > TOOLCHAIN=/tmp/android-ndk-r25/toolchains/llvm/prebuilt/linux-x86_64 > CC=/tmp/android-ndk-r25/toolchains/llvm/prebuilt/linux-x86_64/bin/armv7a-linux-androideabi21-clang > CXX=/tmp/android-ndk-r25/toolchains/llvm/prebuilt/linux-x86_64/bin/armv7a-linux-androideabi21-clang++ > LD=/tmp/android-ndk-r25/toolchains/llvm/prebuilt/linux-x86_64/bin/ld > AS=/tmp/android-ndk-r25/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-as > AR=/tmp/android-ndk-r25/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ar > RANLIB=/tmp/android-ndk-r25/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ranlib > STRIP=/tmp/android-ndk-r25/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-strip > CFLAGS= -D_GNU_SOURCE -D_REENTRANT -D_THREAD_SAFE > CPPFLAGS= -I/home/stephan/git/zproject-android-testing/libzmq/builds/android/prefix/arm/include > CXXFLAGS= > LDFLAGS=-L/home/stephan/git/zproject-android-testing/libzmq/builds/android/prefix/arm/lib -L/tmp/android-ndk-r25/sour\ ces/cxx-stl/llvm-libc++/libs/armeabi-v7a > LIBS=-lc -ldl -lm -llog -lc++_shared > PKG_CONFIG_LIBDIR=/tmp/android-ndk-r25/prebuilt/linux-x86_64/lib/pkgconfig > PKG_CONFIG_PATH=/home/stephan/git/zproject-android-testing/libzmq/builds/android/prefix/arm/lib/pkgconfig > PKG_CONFIG_SYSROOT_DIR=/tmp/android-ndk-r25/toolchains/llvm/prebuilt/linux-x86_64/sysroot > PKG_CONFIG_DIR= > --with-sysroot=/tmp/android-ndk-r25/toolchains/llvm/prebuilt/linux-x86_64/sysroot > --host=arm-linux-androideabi > --prefix=/home/stephan/git/zproject-android-testing/libzmq/builds/android/prefix/arm > --disable-curve > --without-docs ``` We can observe that LDFLAGS has invalid `-L<path_to_libc++_shared.so>`: ``` -L/tmp/android-ndk-r25/sources/cxx-stl/llvm-libc++/libs/armeabi-v7a ``` This path is no more valid, since NDK r25, where one should use LLVM path. Ok, once this is fixed, ./configure requires also the path to libc.so. I don't understand why libc.so is now required, actually, but without this, ./configure fails to build its conftest. Solution: Fix invalid LDFLAGS. Notes: - To be reported to CZMQ/ZYRE via ZPROJECT. - Tested successfully with Android Emulator (x86 & x86_64). - Still need some more work, as execution still fails with physical devices (observed on arm64). - Introduced `ANDROID_STL`, `ANDROID_STL_ROOT` & `ANDROID_LIBC_ROOT`. All are initialized in `android_build_helper.sh`. - New mechanism **MUST** be compatible with former NDK versions.
2022-10-11 22:40:13 +02:00
# Since NDK r25, libc++_shared.so is no more in 'sources/cxx-stl/...'
export ANDROID_STL="libc++_shared.so"
if [ -x "${ANDROID_NDK_ROOT}/sources/cxx-stl/llvm-libc++/libs/${TOOLCHAIN_ABI}/${ANDROID_STL}" ] ; then
export ANDROID_STL_ROOT="${ANDROID_NDK_ROOT}/sources/cxx-stl/llvm-libc++/libs/${TOOLCHAIN_ABI}"
else
export ANDROID_STL_ROOT="${ANDROID_BUILD_SYSROOT}/usr/lib/${TOOLCHAIN_HOST}"
# NDK 25 requires -L<path-to-libc.so> ...
# I don't understand why, but without it, ./configure fails to build a valid 'conftest'.
export ANDROID_LIBC_ROOT="${ANDROID_BUILD_SYSROOT}/usr/lib/${TOOLCHAIN_HOST}/${MIN_SDK_VERSION}"
fi
}
function android_build_env {
##
# Check that necessary environment variables are set
if [ -z "$ANDROID_NDK_ROOT" ]; then
ANDROID_BUILD_FAIL+=("Please set the ANDROID_NDK_ROOT environment variable")
ANDROID_BUILD_FAIL+=(" (eg. \"/home/user/android/android-ndk-r25\")")
fi
if [ -z "$TOOLCHAIN_PATH" ]; then
ANDROID_BUILD_FAIL+=("Please set the TOOLCHAIN_PATH environment variable")
ANDROID_BUILD_FAIL+=(" (eg. \"/home/user/android/android-ndk-r25/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin\")")
fi
if [ -z "$TOOLCHAIN_HOST" ]; then
ANDROID_BUILD_FAIL+=("Please set the TOOLCHAIN_HOST environment variable")
ANDROID_BUILD_FAIL+=(" (eg. \"arm-linux-androideabi\")")
fi
if [ -z "$TOOLCHAIN_COMP" ]; then
ANDROID_BUILD_FAIL+=("Please set the TOOLCHAIN_COMP environment variable")
ANDROID_BUILD_FAIL+=(" (eg. \"armv7a-linux-androideabi\")")
fi
if [ -z "$TOOLCHAIN_ABI" ]; then
ANDROID_BUILD_FAIL+=("Please set the TOOLCHAIN_ABI environment variable")
ANDROID_BUILD_FAIL+=(" (eg. \"armeabi-v7a\")")
fi
if [ -z "$TOOLCHAIN_ARCH" ]; then
ANDROID_BUILD_FAIL+=("Please set the TOOLCHAIN_ARCH environment variable")
ANDROID_BUILD_FAIL+=(" (eg. \"arm\")")
fi
android_build_check_fail
##
# Check that directories given by environment variables exist
if [ ! -d "$ANDROID_NDK_ROOT" ]; then
ANDROID_BUILD_FAIL+=("The ANDROID_NDK_ROOT directory does not exist")
ANDROID_BUILD_FAIL+=(" ${ANDROID_NDK_ROOT}")
fi
Problem: Android APP fails to load ZMQ since NDK r25.x (#4437) * Problem: Android APP fails to load ZMQ since NDK r25.x With the help of the dump of ./configure options (former PR): ``` LIBZMQ (arm) - ./configure options to build 'LIBZMQ': > --quiet > TOOLCHAIN=/tmp/android-ndk-r25/toolchains/llvm/prebuilt/linux-x86_64 > CC=/tmp/android-ndk-r25/toolchains/llvm/prebuilt/linux-x86_64/bin/armv7a-linux-androideabi21-clang > CXX=/tmp/android-ndk-r25/toolchains/llvm/prebuilt/linux-x86_64/bin/armv7a-linux-androideabi21-clang++ > LD=/tmp/android-ndk-r25/toolchains/llvm/prebuilt/linux-x86_64/bin/ld > AS=/tmp/android-ndk-r25/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-as > AR=/tmp/android-ndk-r25/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ar > RANLIB=/tmp/android-ndk-r25/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ranlib > STRIP=/tmp/android-ndk-r25/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-strip > CFLAGS= -D_GNU_SOURCE -D_REENTRANT -D_THREAD_SAFE > CPPFLAGS= -I/home/stephan/git/zproject-android-testing/libzmq/builds/android/prefix/arm/include > CXXFLAGS= > LDFLAGS=-L/home/stephan/git/zproject-android-testing/libzmq/builds/android/prefix/arm/lib -L/tmp/android-ndk-r25/sour\ ces/cxx-stl/llvm-libc++/libs/armeabi-v7a > LIBS=-lc -ldl -lm -llog -lc++_shared > PKG_CONFIG_LIBDIR=/tmp/android-ndk-r25/prebuilt/linux-x86_64/lib/pkgconfig > PKG_CONFIG_PATH=/home/stephan/git/zproject-android-testing/libzmq/builds/android/prefix/arm/lib/pkgconfig > PKG_CONFIG_SYSROOT_DIR=/tmp/android-ndk-r25/toolchains/llvm/prebuilt/linux-x86_64/sysroot > PKG_CONFIG_DIR= > --with-sysroot=/tmp/android-ndk-r25/toolchains/llvm/prebuilt/linux-x86_64/sysroot > --host=arm-linux-androideabi > --prefix=/home/stephan/git/zproject-android-testing/libzmq/builds/android/prefix/arm > --disable-curve > --without-docs ``` We can observe that LDFLAGS has invalid `-L<path_to_libc++_shared.so>`: ``` -L/tmp/android-ndk-r25/sources/cxx-stl/llvm-libc++/libs/armeabi-v7a ``` This path is no more valid, since NDK r25, where one should use LLVM path. Ok, once this is fixed, ./configure requires also the path to libc.so. I don't understand why libc.so is now required, actually, but without this, ./configure fails to build its conftest. Solution: Fix invalid LDFLAGS. Notes: - To be reported to CZMQ/ZYRE via ZPROJECT. - Tested successfully with Android Emulator (x86 & x86_64). - Still need some more work, as execution still fails with physical devices (observed on arm64). - Introduced `ANDROID_STL`, `ANDROID_STL_ROOT` & `ANDROID_LIBC_ROOT`. All are initialized in `android_build_helper.sh`. - New mechanism **MUST** be compatible with former NDK versions.
2022-10-11 22:40:13 +02:00
if [ ! -d "$ANDROID_STL_ROOT" ]; then
ANDROID_BUILD_FAIL+=("The ANDROID_STL_ROOT directory does not exist")
ANDROID_BUILD_FAIL+=(" ${ANDROID_STL_ROOT}")
fi
if [ -n "${ANDROID_LIBC_ROOT}" ] && [ ! -d "${ANDROID_LIBC_ROOT}" ]; then
ANDROID_BUILD_FAIL+=("The ANDROID_LIBC_ROOT directory does not exist")
ANDROID_BUILD_FAIL+=(" ${ANDROID_LIBC_ROOT}")
fi
if [ ! -d "$TOOLCHAIN_PATH" ]; then
ANDROID_BUILD_FAIL+=("The TOOLCHAIN_PATH directory does not exist")
ANDROID_BUILD_FAIL+=(" ${TOOLCHAIN_PATH}")
fi
##
# Set up some local variables and check them
if [ ! -d "$ANDROID_BUILD_SYSROOT" ]; then
ANDROID_BUILD_FAIL+=("The ANDROID_BUILD_SYSROOT directory does not exist")
ANDROID_BUILD_FAIL+=(" ${ANDROID_BUILD_SYSROOT}")
fi
mkdir -p "$ANDROID_BUILD_PREFIX" || {
ANDROID_BUILD_FAIL+=("Failed to make ANDROID_BUILD_PREFIX directory")
ANDROID_BUILD_FAIL+=(" ${ANDROID_BUILD_PREFIX}")
}
android_build_check_fail
}
function _android_build_opts_process_binaries {
local TOOLCHAIN="${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/${ANDROID_BUILD_PLATFORM}"
local CC="${TOOLCHAIN_PATH}/${TOOLCHAIN_COMP}-clang"
local CXX="${TOOLCHAIN_PATH}/${TOOLCHAIN_COMP}-clang++"
# Since NDK r22 the "platforms" dir got removed and the default linker is LLD
if [ -d "${ANDROID_NDK_ROOT}/platforms" ]; then
local LD="${TOOLCHAIN_PATH}/${TOOLCHAIN_HOST}-ld"
else
local LD="${TOOLCHAIN_PATH}/ld"
fi
# Since NDK r24 this binary was removed due to LLVM being now the default
if [ ! -x "${TOOLCHAIN_PATH}/${TOOLCHAIN_HOST}-as" ]; then
local AS="${TOOLCHAIN_PATH}/llvm-as"
else
local AS="${TOOLCHAIN_PATH}/${TOOLCHAIN_HOST}-as"
fi
# Since NDK r23 those binaries were removed due to LLVM being now the default
if [ ! -x "${TOOLCHAIN_PATH}/${TOOLCHAIN_HOST}-ar" ]; then
local AR="${TOOLCHAIN_PATH}/llvm-ar"
local RANLIB="${TOOLCHAIN_PATH}/llvm-ranlib"
local STRIP="${TOOLCHAIN_PATH}/llvm-strip"
else
local AR="${TOOLCHAIN_PATH}/${TOOLCHAIN_HOST}-ar"
local RANLIB="${TOOLCHAIN_PATH}/${TOOLCHAIN_HOST}-ranlib"
local STRIP="${TOOLCHAIN_PATH}/${TOOLCHAIN_HOST}-strip"
fi
if [ ! -x "${CC}" ]; then
ANDROID_BUILD_FAIL+=("The CC binary does not exist or is not executable")
ANDROID_BUILD_FAIL+=(" ${CC}")
fi
if [ ! -x "${CXX}" ]; then
ANDROID_BUILD_FAIL+=("The CXX binary does not exist or is not executable")
ANDROID_BUILD_FAIL+=(" ${CXX}")
fi
if [ ! -x "${LD}" ]; then
ANDROID_BUILD_FAIL+=("The LD binary does not exist or is not executable")
ANDROID_BUILD_FAIL+=(" ${LD}")
fi
if [ ! -x "${AS}" ]; then
ANDROID_BUILD_FAIL+=("The AS binary does not exist or is not executable")
ANDROID_BUILD_FAIL+=(" ${AS}")
fi
if [ ! -x "${AR}" ]; then
ANDROID_BUILD_FAIL+=("The AR binary does not exist or is not executable")
ANDROID_BUILD_FAIL+=(" ${AR}")
fi
if [ ! -x "${RANLIB}" ]; then
ANDROID_BUILD_FAIL+=("The RANLIB binary does not exist or is not executable")
ANDROID_BUILD_FAIL+=(" ${RANLIB}")
fi
if [ ! -x "${STRIP}" ]; then
ANDROID_BUILD_FAIL+=("The STRIP binary does not exist or is not executable")
ANDROID_BUILD_FAIL+=(" ${STRIP}")
fi
ANDROID_BUILD_OPTS+=("TOOLCHAIN=${TOOLCHAIN}")
ANDROID_BUILD_OPTS+=("CC=${CC}")
ANDROID_BUILD_OPTS+=("CXX=${CXX}")
ANDROID_BUILD_OPTS+=("LD=${LD}")
ANDROID_BUILD_OPTS+=("AS=${AS}")
ANDROID_BUILD_OPTS+=("AR=${AR}")
ANDROID_BUILD_OPTS+=("RANLIB=${RANLIB}")
ANDROID_BUILD_OPTS+=("STRIP=${STRIP}")
android_build_check_fail
}
# Set the ANDROID_BUILD_OPTS variable to a bash array of configure options
function android_build_opts {
ANDROID_BUILD_OPTS=()
_android_build_opts_process_binaries
# Since NDK r23 we don't need -lgcc due to LLVM being now the default
if [ ! -x "${TOOLCHAIN_PATH}/${TOOLCHAIN_HOST}-ar" ]; then
local LIBS="-lc -ldl -lm -llog -lc++_shared"
else
local LIBS="-lc -lgcc -ldl -lm -llog -lc++_shared"
fi
local LDFLAGS="-L${ANDROID_BUILD_PREFIX}/lib"
Problem: Android APP fails to load ZMQ since NDK r25.x (#4437) * Problem: Android APP fails to load ZMQ since NDK r25.x With the help of the dump of ./configure options (former PR): ``` LIBZMQ (arm) - ./configure options to build 'LIBZMQ': > --quiet > TOOLCHAIN=/tmp/android-ndk-r25/toolchains/llvm/prebuilt/linux-x86_64 > CC=/tmp/android-ndk-r25/toolchains/llvm/prebuilt/linux-x86_64/bin/armv7a-linux-androideabi21-clang > CXX=/tmp/android-ndk-r25/toolchains/llvm/prebuilt/linux-x86_64/bin/armv7a-linux-androideabi21-clang++ > LD=/tmp/android-ndk-r25/toolchains/llvm/prebuilt/linux-x86_64/bin/ld > AS=/tmp/android-ndk-r25/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-as > AR=/tmp/android-ndk-r25/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ar > RANLIB=/tmp/android-ndk-r25/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ranlib > STRIP=/tmp/android-ndk-r25/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-strip > CFLAGS= -D_GNU_SOURCE -D_REENTRANT -D_THREAD_SAFE > CPPFLAGS= -I/home/stephan/git/zproject-android-testing/libzmq/builds/android/prefix/arm/include > CXXFLAGS= > LDFLAGS=-L/home/stephan/git/zproject-android-testing/libzmq/builds/android/prefix/arm/lib -L/tmp/android-ndk-r25/sour\ ces/cxx-stl/llvm-libc++/libs/armeabi-v7a > LIBS=-lc -ldl -lm -llog -lc++_shared > PKG_CONFIG_LIBDIR=/tmp/android-ndk-r25/prebuilt/linux-x86_64/lib/pkgconfig > PKG_CONFIG_PATH=/home/stephan/git/zproject-android-testing/libzmq/builds/android/prefix/arm/lib/pkgconfig > PKG_CONFIG_SYSROOT_DIR=/tmp/android-ndk-r25/toolchains/llvm/prebuilt/linux-x86_64/sysroot > PKG_CONFIG_DIR= > --with-sysroot=/tmp/android-ndk-r25/toolchains/llvm/prebuilt/linux-x86_64/sysroot > --host=arm-linux-androideabi > --prefix=/home/stephan/git/zproject-android-testing/libzmq/builds/android/prefix/arm > --disable-curve > --without-docs ``` We can observe that LDFLAGS has invalid `-L<path_to_libc++_shared.so>`: ``` -L/tmp/android-ndk-r25/sources/cxx-stl/llvm-libc++/libs/armeabi-v7a ``` This path is no more valid, since NDK r25, where one should use LLVM path. Ok, once this is fixed, ./configure requires also the path to libc.so. I don't understand why libc.so is now required, actually, but without this, ./configure fails to build its conftest. Solution: Fix invalid LDFLAGS. Notes: - To be reported to CZMQ/ZYRE via ZPROJECT. - Tested successfully with Android Emulator (x86 & x86_64). - Still need some more work, as execution still fails with physical devices (observed on arm64). - Introduced `ANDROID_STL`, `ANDROID_STL_ROOT` & `ANDROID_LIBC_ROOT`. All are initialized in `android_build_helper.sh`. - New mechanism **MUST** be compatible with former NDK versions.
2022-10-11 22:40:13 +02:00
if [ -n "${ANDROID_LIBC_ROOT}" ] ; then
LDFLAGS+=" -L${ANDROID_LIBC_ROOT}"
Problem: Android APP fails to load ZMQ since NDK r25.x (#4437) * Problem: Android APP fails to load ZMQ since NDK r25.x With the help of the dump of ./configure options (former PR): ``` LIBZMQ (arm) - ./configure options to build 'LIBZMQ': > --quiet > TOOLCHAIN=/tmp/android-ndk-r25/toolchains/llvm/prebuilt/linux-x86_64 > CC=/tmp/android-ndk-r25/toolchains/llvm/prebuilt/linux-x86_64/bin/armv7a-linux-androideabi21-clang > CXX=/tmp/android-ndk-r25/toolchains/llvm/prebuilt/linux-x86_64/bin/armv7a-linux-androideabi21-clang++ > LD=/tmp/android-ndk-r25/toolchains/llvm/prebuilt/linux-x86_64/bin/ld > AS=/tmp/android-ndk-r25/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-as > AR=/tmp/android-ndk-r25/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ar > RANLIB=/tmp/android-ndk-r25/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ranlib > STRIP=/tmp/android-ndk-r25/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-strip > CFLAGS= -D_GNU_SOURCE -D_REENTRANT -D_THREAD_SAFE > CPPFLAGS= -I/home/stephan/git/zproject-android-testing/libzmq/builds/android/prefix/arm/include > CXXFLAGS= > LDFLAGS=-L/home/stephan/git/zproject-android-testing/libzmq/builds/android/prefix/arm/lib -L/tmp/android-ndk-r25/sour\ ces/cxx-stl/llvm-libc++/libs/armeabi-v7a > LIBS=-lc -ldl -lm -llog -lc++_shared > PKG_CONFIG_LIBDIR=/tmp/android-ndk-r25/prebuilt/linux-x86_64/lib/pkgconfig > PKG_CONFIG_PATH=/home/stephan/git/zproject-android-testing/libzmq/builds/android/prefix/arm/lib/pkgconfig > PKG_CONFIG_SYSROOT_DIR=/tmp/android-ndk-r25/toolchains/llvm/prebuilt/linux-x86_64/sysroot > PKG_CONFIG_DIR= > --with-sysroot=/tmp/android-ndk-r25/toolchains/llvm/prebuilt/linux-x86_64/sysroot > --host=arm-linux-androideabi > --prefix=/home/stephan/git/zproject-android-testing/libzmq/builds/android/prefix/arm > --disable-curve > --without-docs ``` We can observe that LDFLAGS has invalid `-L<path_to_libc++_shared.so>`: ``` -L/tmp/android-ndk-r25/sources/cxx-stl/llvm-libc++/libs/armeabi-v7a ``` This path is no more valid, since NDK r25, where one should use LLVM path. Ok, once this is fixed, ./configure requires also the path to libc.so. I don't understand why libc.so is now required, actually, but without this, ./configure fails to build its conftest. Solution: Fix invalid LDFLAGS. Notes: - To be reported to CZMQ/ZYRE via ZPROJECT. - Tested successfully with Android Emulator (x86 & x86_64). - Still need some more work, as execution still fails with physical devices (observed on arm64). - Introduced `ANDROID_STL`, `ANDROID_STL_ROOT` & `ANDROID_LIBC_ROOT`. All are initialized in `android_build_helper.sh`. - New mechanism **MUST** be compatible with former NDK versions.
2022-10-11 22:40:13 +02:00
fi
LDFLAGS+=" -L${ANDROID_STL_ROOT}"
CFLAGS+=" -D_GNU_SOURCE -D_REENTRANT -D_THREAD_SAFE"
CPPFLAGS+=" -I${ANDROID_BUILD_PREFIX}/include"
Problem: Android APP fails to load ZMQ (ARM64 only) (#4442) * Problem: Android APP fails to load ZMQ (ARM64 only) Seen with physical Android devices running ARM64. Not seen with ARM, X86 or X86_64. Any Android APP loading ZMQ fails with: ``` [FATAL] Couldn't load library library zmq from jar. Dependency is required! ``` Unpack zyre-android-2.0.1.jar, find libzmq.so for ARM64 and look for missing symbols: ``` prompt> unzip zyre-android-2.0.1.jar prompt> cd lib/arm64-v8a prompt> nm --undefined-only ./libzmq.so | head U __aarch64_ldadd4_acq U __aarch64_ldadd4_acq_rel U __aarch64_ldadd4_rel U __aarch64_ldadd4_relax U __aarch64_ldadd8_acq_rel U __aarch64_ldadd8_relax U __aarch64_swp8_acq U __aarch64_swp8_acq_rel U __aarch64_swp8_rel U __aarch64_swp8_relax prompt> ``` Some more symbols are missing, but those are relevant for this issue. OK. These symbols are present in libc++_shared, but not exported ...: ``` prompt> nm libc++_shared.so | grep aarch64 00000000000ee6d0 t __aarch64_cas1_acq_rel 00000000000ee7a0 t __aarch64_cas8_acq_rel 00000000001028f0 b __aarch64_have_lse_atomics 00000000000ee840 t __aarch64_ldadd4_acq_rel 00000000000ee810 t __aarch64_ldadd4_rel 00000000000ee8a0 t __aarch64_ldadd8_acq_rel 00000000000ee870 t __aarch64_ldadd8_relax 00000000000ee7e0 t __aarch64_swp8_acq_rel prompt> ``` Issue seen also on the WEB, with GCC & CLANG: - https://bugzilla.redhat.com/show_bug.cgi?id=1830472 - https://github.com/flutter/buildroot/pull/434/commits/cea175b83895943c30fb3e2c17e3c43bd619a6b9 - ... Solution: Add `-mno-outline-atomics` to CXXFLAGS (FLUTTER fix). Additionaly, had to introduce NDK_NUMBER. This variable is calculated in `android_build_helper.sh`. It represents the numeric form of NDK_VERSION: ``` NDK_VERSION --> NDK_NUMBER android-ndk-r25 --> 2500 android-ndk-r23c --> 2303 android-ndk-r22 --> 2200 android-ndk-r21e --> 2105 ... and so on ``` This will help a few other things (NDK download ?).
2022-10-18 11:19:15 +02:00
if [ ${NDK_NUMBER} -ge 2400 ] ; then
if [ "${BUILD_ARCH}" = "arm64" ] ; then
Problem: Android APP fails to load ZMQ (ARM64 only) (#4442) * Problem: Android APP fails to load ZMQ (ARM64 only) Seen with physical Android devices running ARM64. Not seen with ARM, X86 or X86_64. Any Android APP loading ZMQ fails with: ``` [FATAL] Couldn't load library library zmq from jar. Dependency is required! ``` Unpack zyre-android-2.0.1.jar, find libzmq.so for ARM64 and look for missing symbols: ``` prompt> unzip zyre-android-2.0.1.jar prompt> cd lib/arm64-v8a prompt> nm --undefined-only ./libzmq.so | head U __aarch64_ldadd4_acq U __aarch64_ldadd4_acq_rel U __aarch64_ldadd4_rel U __aarch64_ldadd4_relax U __aarch64_ldadd8_acq_rel U __aarch64_ldadd8_relax U __aarch64_swp8_acq U __aarch64_swp8_acq_rel U __aarch64_swp8_rel U __aarch64_swp8_relax prompt> ``` Some more symbols are missing, but those are relevant for this issue. OK. These symbols are present in libc++_shared, but not exported ...: ``` prompt> nm libc++_shared.so | grep aarch64 00000000000ee6d0 t __aarch64_cas1_acq_rel 00000000000ee7a0 t __aarch64_cas8_acq_rel 00000000001028f0 b __aarch64_have_lse_atomics 00000000000ee840 t __aarch64_ldadd4_acq_rel 00000000000ee810 t __aarch64_ldadd4_rel 00000000000ee8a0 t __aarch64_ldadd8_acq_rel 00000000000ee870 t __aarch64_ldadd8_relax 00000000000ee7e0 t __aarch64_swp8_acq_rel prompt> ``` Issue seen also on the WEB, with GCC & CLANG: - https://bugzilla.redhat.com/show_bug.cgi?id=1830472 - https://github.com/flutter/buildroot/pull/434/commits/cea175b83895943c30fb3e2c17e3c43bd619a6b9 - ... Solution: Add `-mno-outline-atomics` to CXXFLAGS (FLUTTER fix). Additionaly, had to introduce NDK_NUMBER. This variable is calculated in `android_build_helper.sh`. It represents the numeric form of NDK_VERSION: ``` NDK_VERSION --> NDK_NUMBER android-ndk-r25 --> 2500 android-ndk-r23c --> 2303 android-ndk-r22 --> 2200 android-ndk-r21e --> 2105 ... and so on ``` This will help a few other things (NDK download ?).
2022-10-18 11:19:15 +02:00
CXXFLAGS+=" -mno-outline-atomics"
fi
Problem: Android APP fails to load ZMQ (ARM64 only) (#4442) * Problem: Android APP fails to load ZMQ (ARM64 only) Seen with physical Android devices running ARM64. Not seen with ARM, X86 or X86_64. Any Android APP loading ZMQ fails with: ``` [FATAL] Couldn't load library library zmq from jar. Dependency is required! ``` Unpack zyre-android-2.0.1.jar, find libzmq.so for ARM64 and look for missing symbols: ``` prompt> unzip zyre-android-2.0.1.jar prompt> cd lib/arm64-v8a prompt> nm --undefined-only ./libzmq.so | head U __aarch64_ldadd4_acq U __aarch64_ldadd4_acq_rel U __aarch64_ldadd4_rel U __aarch64_ldadd4_relax U __aarch64_ldadd8_acq_rel U __aarch64_ldadd8_relax U __aarch64_swp8_acq U __aarch64_swp8_acq_rel U __aarch64_swp8_rel U __aarch64_swp8_relax prompt> ``` Some more symbols are missing, but those are relevant for this issue. OK. These symbols are present in libc++_shared, but not exported ...: ``` prompt> nm libc++_shared.so | grep aarch64 00000000000ee6d0 t __aarch64_cas1_acq_rel 00000000000ee7a0 t __aarch64_cas8_acq_rel 00000000001028f0 b __aarch64_have_lse_atomics 00000000000ee840 t __aarch64_ldadd4_acq_rel 00000000000ee810 t __aarch64_ldadd4_rel 00000000000ee8a0 t __aarch64_ldadd8_acq_rel 00000000000ee870 t __aarch64_ldadd8_relax 00000000000ee7e0 t __aarch64_swp8_acq_rel prompt> ``` Issue seen also on the WEB, with GCC & CLANG: - https://bugzilla.redhat.com/show_bug.cgi?id=1830472 - https://github.com/flutter/buildroot/pull/434/commits/cea175b83895943c30fb3e2c17e3c43bd619a6b9 - ... Solution: Add `-mno-outline-atomics` to CXXFLAGS (FLUTTER fix). Additionaly, had to introduce NDK_NUMBER. This variable is calculated in `android_build_helper.sh`. It represents the numeric form of NDK_VERSION: ``` NDK_VERSION --> NDK_NUMBER android-ndk-r25 --> 2500 android-ndk-r23c --> 2303 android-ndk-r22 --> 2200 android-ndk-r21e --> 2105 ... and so on ``` This will help a few other things (NDK download ?).
2022-10-18 11:19:15 +02:00
fi
ANDROID_BUILD_OPTS+=("CFLAGS=${CFLAGS} ${ANDROID_BUILD_EXTRA_CFLAGS}")
ANDROID_BUILD_OPTS+=("CPPFLAGS=${CPPFLAGS} ${ANDROID_BUILD_EXTRA_CPPFLAGS}")
ANDROID_BUILD_OPTS+=("CXXFLAGS=${CXXFLAGS} ${ANDROID_BUILD_EXTRA_CXXFLAGS}")
ANDROID_BUILD_OPTS+=("LDFLAGS=${LDFLAGS} ${ANDROID_BUILD_EXTRA_LDFLAGS}")
ANDROID_BUILD_OPTS+=("LIBS=${LIBS} ${ANDROID_BUILD_EXTRA_LIBS}")
ANDROID_BUILD_OPTS+=("PKG_CONFIG_LIBDIR=${ANDROID_NDK_ROOT}/prebuilt/${ANDROID_BUILD_PLATFORM}/lib/pkgconfig")
ANDROID_BUILD_OPTS+=("PKG_CONFIG_PATH=${ANDROID_BUILD_PREFIX}/lib/pkgconfig")
ANDROID_BUILD_OPTS+=("PKG_CONFIG_SYSROOT_DIR=${ANDROID_BUILD_SYSROOT}")
ANDROID_BUILD_OPTS+=("PKG_CONFIG_DIR=")
ANDROID_BUILD_OPTS+=("--with-sysroot=${ANDROID_BUILD_SYSROOT}")
ANDROID_BUILD_OPTS+=("--host=${TOOLCHAIN_HOST}")
ANDROID_BUILD_OPTS+=("--prefix=${ANDROID_BUILD_PREFIX}")
android_build_check_fail
}
# Parse readelf output to verify the correct linking of libraries.
# The first argument should be the soname of the newly built library.
# The rest of the arguments should be the sonames of dependencies.
# All sonames should be unversioned for android (no trailing numbers).
function android_build_verify_so {
local soname="$1"
shift # Get rid of first argument - the rest represent dependencies
local sofile="${ANDROID_BUILD_PREFIX}/lib/${soname}"
if [ ! -f "${sofile}" ]; then
ANDROID_BUILD_FAIL+=("Found no library named ${soname}")
ANDROID_BUILD_FAIL+=(" ${sofile}")
fi
android_build_check_fail
local READELF="${TOOLCHAIN_PATH}/${TOOLCHAIN_HOST}-readelf"
if command -v "${READELF}" >/dev/null 2>&1 ; then
local readelf_bin="${READELF}"
elif command -v readelf >/dev/null 2>&1 ; then
local readelf_bin="readelf"
elif command -v greadelf >/dev/null 2>&1 ; then
local readelf_bin="greadelf"
else
ANDROID_BUILD_FAIL+=("Could not find any of readelf, greadelf, or ${READELF}")
fi
android_build_check_fail
local elfoutput
elfoutput=$(LC_ALL=C $readelf_bin -d "${sofile}")
local soname_regexp='soname: \[([[:alnum:]\.]+)\]'
if [[ $elfoutput =~ $soname_regexp ]]; then
local parsed_soname="${BASH_REMATCH[1]}"
if [ "${parsed_soname}" != "${soname}" ]; then
ANDROID_BUILD_FAIL+=("Actual soname of library ${soname} is incorrect (or versioned):")
ANDROID_BUILD_FAIL+=(" ${parsed_soname}")
fi
else
ANDROID_BUILD_FAIL+=("Failed to meaningfully parse readelf output for library ${soname}:")
ANDROID_BUILD_FAIL+=(" ${elfoutput}")
fi
for dep_soname in "$@" ; do
local dep_sofile="${ANDROID_BUILD_PREFIX}/lib/${dep_soname}"
if [ ! -f "${dep_sofile}" ]; then
ANDROID_BUILD_FAIL+=("Found no library named ${dep_soname}")
ANDROID_BUILD_FAIL+=(" ${dep_sofile}")
elif [[ $elfoutput != *"library: [${dep_soname}]"* ]]; then
ANDROID_BUILD_FAIL+=("Library ${soname} was expected to be linked to library with soname:")
ANDROID_BUILD_FAIL+=(" ${dep_soname}")
fi
done
android_build_check_fail
}
Problem: Android build system needs some debug (./configure options) Proposal is to dump ./configure options to have an output like below: ``` LIBZMQ (x86_64) - ./configure options to build 'LIBZMQ': > --quiet > TOOLCHAIN=/tmp/android-ndk-r25/toolchains/llvm/prebuilt/linux-x86_64 > CC=/tmp/android-ndk-r25/toolchains/llvm/prebuilt/linux-x86_64/bin/x86_64-linux-android21-clang > CXX=/tmp/android-ndk-r25/toolchains/llvm/prebuilt/linux-x86_64/bin/x86_64-linux-android21-clang++ > LD=/tmp/android-ndk-r25/toolchains/llvm/prebuilt/linux-x86_64/bin/ld > AS=/tmp/android-ndk-r25/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-as > AR=/tmp/android-ndk-r25/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ar > RANLIB=/tmp/android-ndk-r25/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ranlib > STRIP=/tmp/android-ndk-r25/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-strip > CFLAGS= -D_GNU_SOURCE -D_REENTRANT -D_THREAD_SAFE > CPPFLAGS= -I/builds/CrisalidBox/zproject-android-testing/libzmq/builds/android/prefix/x86_64/include > CXXFLAGS= > LDFLAGS=-L/builds/CrisalidBox/zproject-android-testing/libzmq/builds/android/prefix/x86_64/lib -L/tmp/android-ndk-r25/sources/cxx-stl/llvm-libc++/libs/x86_64 > LIBS=-lc -ldl -lm -llog -lc++_shared > PKG_CONFIG_LIBDIR=/tmp/android-ndk-r25/prebuilt/linux-x86_64/lib/pkgconfig > PKG_CONFIG_PATH=/builds/CrisalidBox/zproject-android-testing/libzmq/builds/android/prefix/x86_64/lib/pkgconfig > PKG_CONFIG_SYSROOT_DIR=/tmp/android-ndk-r25/toolchains/llvm/prebuilt/linux-x86_64/sysroot > PKG_CONFIG_DIR= > --with-sysroot=/tmp/android-ndk-r25/toolchains/llvm/prebuilt/linux-x86_64/sysroot > --host=x86_64-linux-android > --prefix=/builds/CrisalidBox/zproject-android-testing/libzmq/builds/android/prefix/x86_64 > --disable-curve > --without-docs ``` Note: This mechanism is currently in use to identify/fix a bug in a recent PR for NDK update. This mechanism is added before every call of `./configure`. To be reported to CZMQ/ZYRE (via ZPROJECT).
2022-10-05 18:17:46 +02:00
function android_show_configure_opts {
local tag=$1
shift
android_build_trace "./configure options to build '${tag}':"
Problem: Android build system needs some debug (./configure options) Proposal is to dump ./configure options to have an output like below: ``` LIBZMQ (x86_64) - ./configure options to build 'LIBZMQ': > --quiet > TOOLCHAIN=/tmp/android-ndk-r25/toolchains/llvm/prebuilt/linux-x86_64 > CC=/tmp/android-ndk-r25/toolchains/llvm/prebuilt/linux-x86_64/bin/x86_64-linux-android21-clang > CXX=/tmp/android-ndk-r25/toolchains/llvm/prebuilt/linux-x86_64/bin/x86_64-linux-android21-clang++ > LD=/tmp/android-ndk-r25/toolchains/llvm/prebuilt/linux-x86_64/bin/ld > AS=/tmp/android-ndk-r25/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-as > AR=/tmp/android-ndk-r25/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ar > RANLIB=/tmp/android-ndk-r25/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ranlib > STRIP=/tmp/android-ndk-r25/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-strip > CFLAGS= -D_GNU_SOURCE -D_REENTRANT -D_THREAD_SAFE > CPPFLAGS= -I/builds/CrisalidBox/zproject-android-testing/libzmq/builds/android/prefix/x86_64/include > CXXFLAGS= > LDFLAGS=-L/builds/CrisalidBox/zproject-android-testing/libzmq/builds/android/prefix/x86_64/lib -L/tmp/android-ndk-r25/sources/cxx-stl/llvm-libc++/libs/x86_64 > LIBS=-lc -ldl -lm -llog -lc++_shared > PKG_CONFIG_LIBDIR=/tmp/android-ndk-r25/prebuilt/linux-x86_64/lib/pkgconfig > PKG_CONFIG_PATH=/builds/CrisalidBox/zproject-android-testing/libzmq/builds/android/prefix/x86_64/lib/pkgconfig > PKG_CONFIG_SYSROOT_DIR=/tmp/android-ndk-r25/toolchains/llvm/prebuilt/linux-x86_64/sysroot > PKG_CONFIG_DIR= > --with-sysroot=/tmp/android-ndk-r25/toolchains/llvm/prebuilt/linux-x86_64/sysroot > --host=x86_64-linux-android > --prefix=/builds/CrisalidBox/zproject-android-testing/libzmq/builds/android/prefix/x86_64 > --disable-curve > --without-docs ``` Note: This mechanism is currently in use to identify/fix a bug in a recent PR for NDK update. This mechanism is added before every call of `./configure`. To be reported to CZMQ/ZYRE (via ZPROJECT).
2022-10-05 18:17:46 +02:00
for opt in "$@"; do
2022-10-06 11:32:57 +02:00
echo " > ${opt}"
Problem: Android build system needs some debug (./configure options) Proposal is to dump ./configure options to have an output like below: ``` LIBZMQ (x86_64) - ./configure options to build 'LIBZMQ': > --quiet > TOOLCHAIN=/tmp/android-ndk-r25/toolchains/llvm/prebuilt/linux-x86_64 > CC=/tmp/android-ndk-r25/toolchains/llvm/prebuilt/linux-x86_64/bin/x86_64-linux-android21-clang > CXX=/tmp/android-ndk-r25/toolchains/llvm/prebuilt/linux-x86_64/bin/x86_64-linux-android21-clang++ > LD=/tmp/android-ndk-r25/toolchains/llvm/prebuilt/linux-x86_64/bin/ld > AS=/tmp/android-ndk-r25/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-as > AR=/tmp/android-ndk-r25/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ar > RANLIB=/tmp/android-ndk-r25/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ranlib > STRIP=/tmp/android-ndk-r25/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-strip > CFLAGS= -D_GNU_SOURCE -D_REENTRANT -D_THREAD_SAFE > CPPFLAGS= -I/builds/CrisalidBox/zproject-android-testing/libzmq/builds/android/prefix/x86_64/include > CXXFLAGS= > LDFLAGS=-L/builds/CrisalidBox/zproject-android-testing/libzmq/builds/android/prefix/x86_64/lib -L/tmp/android-ndk-r25/sources/cxx-stl/llvm-libc++/libs/x86_64 > LIBS=-lc -ldl -lm -llog -lc++_shared > PKG_CONFIG_LIBDIR=/tmp/android-ndk-r25/prebuilt/linux-x86_64/lib/pkgconfig > PKG_CONFIG_PATH=/builds/CrisalidBox/zproject-android-testing/libzmq/builds/android/prefix/x86_64/lib/pkgconfig > PKG_CONFIG_SYSROOT_DIR=/tmp/android-ndk-r25/toolchains/llvm/prebuilt/linux-x86_64/sysroot > PKG_CONFIG_DIR= > --with-sysroot=/tmp/android-ndk-r25/toolchains/llvm/prebuilt/linux-x86_64/sysroot > --host=x86_64-linux-android > --prefix=/builds/CrisalidBox/zproject-android-testing/libzmq/builds/android/prefix/x86_64 > --disable-curve > --without-docs ``` Note: This mechanism is currently in use to identify/fix a bug in a recent PR for NDK update. This mechanism is added before every call of `./configure`. To be reported to CZMQ/ZYRE (via ZPROJECT).
2022-10-05 18:17:46 +02:00
done
echo ""
}
########################################################################
# Initialization
########################################################################
# Get directory of current script (if not already set)
# This directory is also the basis for the build directories the get created.
if [ -z "$ANDROID_BUILD_DIR" ]; then
ANDROID_BUILD_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
fi
# Set up a variable to hold the global failure reasons, separated by newlines
# (Empty string indicates no failure)
ANDROID_BUILD_FAIL=()
########################################################################
# Initialization
########################################################################
# Get directory of current script (if not already set)
# This directory is also the basis for the build directories the get created.
if [ -z "$ANDROID_BUILD_DIR" ]; then
ANDROID_BUILD_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
fi
# Set up a variable to hold the global failure reasons, separated by newlines
# (Empty string indicates no failure)
ANDROID_BUILD_FAIL=()
########################################################################
# Sanity checks
########################################################################
if [ -z "${NDK_VERSION}" ] ; then
android_build_trace "NDK_VERSION not set !"
exit 1
fi
case "${NDK_VERSION}" in
"android-ndk-r"[0-9][0-9] ) : ;;
"android-ndk-r"[0-9][0-9][a-z] ) : ;;
* ) android_build_trace "Invalid format for NDK_VERSION ('${NDK_VERSION}')" ; exit 1 ;;
esac
if [ -z "${ANDROID_NDK_ROOT}" ] ; then
android_build_trace "ANDROID_NDK_ROOT not set !"
exit 1
fi
########################################################################
# Compute NDK version into a numeric form:
# android-ndk-r21e -> 2105
# android-ndk-r25 -> 2500
########################################################################
export NDK_NUMBER="$(( $(echo "${NDK_VERSION}"|sed -e 's|android-ndk-r||g' -e 's|[a-z]||g') * 100 ))"
NDK_VERSION_LETTER="$(echo "${NDK_VERSION}"|sed -e 's|android-ndk-r[0-9][0-9]||g'|tr '[:lower:]' '[:upper:]')"
if [ -n "${NDK_VERSION_LETTER}" ] ; then
NDK_NUMBER=$(( $(( NDK_NUMBER + $(printf '%d' \'"${NDK_VERSION_LETTER}") )) - 64 ))
fi
android_build_trace "Configured NDK_VERSION: ${NDK_VERSION} ($NDK_NUMBER)."