diff options
author | Sven Gothel <[email protected]> | 2019-12-23 23:50:54 +0100 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2019-12-23 23:50:54 +0100 |
commit | 26d06324312b8fe6980ff29ab9d443cc5ec2657f (patch) | |
tree | fb3a870d228964f93671c6c1217d93fbb3331fdb /make | |
parent | 53ae28fd2bc501b5de54fdbdf915d88f823eb11a (diff) |
Bug 1417 - Android: Classify SYSROOTs in NDK for native libraries (link) and headers (compile)
Utilizing '-sysroot' with the linker, we require standard FS layout.
'~/Android/Sdk/ndk/20.1.5948944/platforms/android-24/arch-arm64'
contains the proper std FS layout for libraries under usr/lib,
but lacks the header files.
We call this 'ANDROID_TOOLCHAIN_SYSROOT0' and shall be used for linking.
'~/Android/Sdk/ndk/20.1.5948944/toolchains/llvm/prebuilt/linux-x86_64/sysroot'
native libraries are not under std FS layout,
but headers are under std FS layout for compilation under usr/include.
We call this 'ANDROID_TOOLCHAIN_SYSROOT1' and shall be used for compilation.
Identified while working on openal-soft Android compilation,
where we need to pass ANDROID_TOOLCHAIN_SYSROOT0
Diffstat (limited to 'make')
-rw-r--r-- | make/lib/gluegen-cpptasks-android-aarch64.xml | 11 | ||||
-rw-r--r-- | make/lib/gluegen-cpptasks-android-armv6.xml | 11 | ||||
-rw-r--r-- | make/lib/gluegen-cpptasks-android-x86.xml | 11 | ||||
-rw-r--r-- | make/scripts/setenv-android-tools.sh | 64 |
4 files changed, 54 insertions, 43 deletions
diff --git a/make/lib/gluegen-cpptasks-android-aarch64.xml b/make/lib/gluegen-cpptasks-android-aarch64.xml index 2ebe9ee..ec9efd1 100644 --- a/make/lib/gluegen-cpptasks-android-aarch64.xml +++ b/make/lib/gluegen-cpptasks-android-aarch64.xml @@ -33,7 +33,7 @@ <target name="gluegen.cpptasks.configure.compiler" depends="setup.java.home.dir,declare.linux.android"> <echo message="Custom forced compiler Android NDK, linker.cfg.android" /> <compiler id="compiler.cfg.android" name="clang"> - <compilerarg value="--sysroot=${env.ANDROID_TOOLCHAIN_SYSROOT}" /> + <compilerarg value="--sysroot=${env.ANDROID_TOOLCHAIN_SYSROOT1}" /> <!-- include files, but libs not in std FS layout --> <compilerarg value="-v" /> @@ -70,7 +70,7 @@ <compilerarg value="-g" if="c.compiler.use-debug" /> <compilerarg value="-fno-omit-frame-pointer" if="c.compiler.use-debug" /> - <!-- includepath path="${env.ANDROID_TOOLCHAIN_SYSROOT_INC}" / --> + <!-- includepath path="${env.ANDROID_TOOLCHAIN_SYSROOT1_INC}" / --> <defineset> <define name="__unix__" /> <define name="__LP64__" /> <!-- default pre-defined macro for 64bit unix --> @@ -84,10 +84,9 @@ </compiler> <linker id="linker.cfg.android" name="clang"> - <linkerarg value="--sysroot=${env.ANDROID_TOOLCHAIN_SYSROOT}" /> - <!-- linkerarg value="-L${env.ANDROID_TOOLCHAIN_SYSROOT_LIB_0}" / --> - <linkerarg value="-L${env.ANDROID_TOOLCHAIN_SYSROOT_LIB_1}" /> - <linkerarg value="-Wl,-rpath-link=${env.ANDROID_TOOLCHAIN_SYSROOT_LIB_1}" /> + <linkerarg value="--sysroot=${env.ANDROID_TOOLCHAIN_SYSROOT0}" /> <!-- libs in std FS layout, but no include files --> + <linkerarg value="-L${env.ANDROID_TOOLCHAIN_SYSROOT0_LIB}" /> + <linkerarg value="-Wl,-rpath-link=${env.ANDROID_TOOLCHAIN_SYSROOT0_LIB}" /> <linkerarg value="-v" /> diff --git a/make/lib/gluegen-cpptasks-android-armv6.xml b/make/lib/gluegen-cpptasks-android-armv6.xml index 4e211c8..850d444 100644 --- a/make/lib/gluegen-cpptasks-android-armv6.xml +++ b/make/lib/gluegen-cpptasks-android-armv6.xml @@ -33,7 +33,7 @@ <target name="gluegen.cpptasks.configure.compiler" depends="setup.java.home.dir,declare.linux.android"> <echo message="Custom forced compiler Android NDK, linker.cfg.android" /> <compiler id="compiler.cfg.android" name="clang"> - <compilerarg value="--sysroot=${env.ANDROID_TOOLCHAIN_SYSROOT}" /> + <compilerarg value="--sysroot=${env.ANDROID_TOOLCHAIN_SYSROOT1}" /> <!-- include files, but libs not in std FS layout --> <compilerarg value="-v" /> @@ -70,7 +70,7 @@ <compilerarg value="-g" if="c.compiler.use-debug" /> <compilerarg value="-fno-omit-frame-pointer" if="c.compiler.use-debug" /> - <!-- includepath path="${env.ANDROID_TOOLCHAIN_SYSROOT_INC}" / --> + <!-- includepath path="${env.ANDROID_TOOLCHAIN_SYSROOT1_INC}" / --> <defineset> <define name="__unix__" /> <define name="__ARM_ARCH_5__" /> @@ -86,10 +86,9 @@ </compiler> <linker id="linker.cfg.android" name="clang"> - <linkerarg value="--sysroot=${env.ANDROID_TOOLCHAIN_SYSROOT}" /> - <!-- linkerarg value="-L${env.ANDROID_TOOLCHAIN_SYSROOT_LIB_0}" / --> - <linkerarg value="-L${env.ANDROID_TOOLCHAIN_SYSROOT_LIB_1}" /> - <linkerarg value="-Wl,-rpath-link=${env.ANDROID_TOOLCHAIN_SYSROOT_LIB_1}" /> + <linkerarg value="--sysroot=${env.ANDROID_TOOLCHAIN_SYSROOT0}" /> <!-- libs in std FS layout, but no include files --> + <linkerarg value="-L${env.ANDROID_TOOLCHAIN_SYSROOT0_LIB}" /> + <linkerarg value="-Wl,-rpath-link=${env.ANDROID_TOOLCHAIN_SYSROOT0_LIB}" /> <linkerarg value="-v" /> diff --git a/make/lib/gluegen-cpptasks-android-x86.xml b/make/lib/gluegen-cpptasks-android-x86.xml index bcdc76c..ef33daa 100644 --- a/make/lib/gluegen-cpptasks-android-x86.xml +++ b/make/lib/gluegen-cpptasks-android-x86.xml @@ -32,7 +32,7 @@ <target name="gluegen.cpptasks.configure.compiler" depends="setup.java.home.dir,declare.linux.android"> <echo message="Custom forced compiler Android NDK, linker.cfg.android" /> <compiler id="compiler.cfg.android" name="clang"> - <compilerarg value="--sysroot=${env.ANDROID_TOOLCHAIN_SYSROOT}" /> + <compilerarg value="--sysroot=${env.ANDROID_TOOLCHAIN_SYSROOT1}" /> <!-- include files, but libs not in std FS layout --> <compilerarg value="-v" /> @@ -69,7 +69,7 @@ <compilerarg value="-g" if="c.compiler.use-debug" /> <compilerarg value="-fno-omit-frame-pointer" if="c.compiler.use-debug" /> - <!-- includepath path="${env.ANDROID_TOOLCHAIN_SYSROOT_INC}" / --> + <!-- includepath path="${env.ANDROID_TOOLCHAIN_SYSROOT1_INC}" / --> <defineset> <define name="__unix__" /> @@ -81,10 +81,9 @@ </compiler> <linker id="linker.cfg.android" name="clang"> - <linkerarg value="--sysroot=${env.ANDROID_TOOLCHAIN_SYSROOT}" /> - <!-- linkerarg value="-L${env.ANDROID_TOOLCHAIN_SYSROOT_LIB_0}" / --> - <linkerarg value="-L${env.ANDROID_TOOLCHAIN_SYSROOT_LIB_1}" /> - <linkerarg value="-Wl,-rpath-link=${env.ANDROID_TOOLCHAIN_SYSROOT_LIB_1}" /> + <linkerarg value="--sysroot=${env.ANDROID_TOOLCHAIN_SYSROOT0}" /> <!-- libs in std FS layout, but no include files --> + <linkerarg value="-L${env.ANDROID_TOOLCHAIN_SYSROOT0_LIB}" /> + <linkerarg value="-Wl,-rpath-link=${env.ANDROID_TOOLCHAIN_SYSROOT0_LIB}" /> <linkerarg value="-v" /> diff --git a/make/scripts/setenv-android-tools.sh b/make/scripts/setenv-android-tools.sh index 7f7dd56..1742c97 100644 --- a/make/scripts/setenv-android-tools.sh +++ b/make/scripts/setenv-android-tools.sh @@ -40,10 +40,11 @@ # - ANDROID_NDK # - ANDROID_BUILDTOOLS_ROOT # - ANDROID_TOOLCHAIN_ROOT -# - ANDROID_TOOLCHAIN_SYSROOT -# - ANDROID_TOOLCHAIN_SYSROOT_INC -# - ANDROID_TOOLCHAIN_SYSROOT_LIB_0 -# - ANDROID_TOOLCHAIN_SYSROOT_LIB_1 +# - ANDROID_TOOLCHAIN_SYSROOT0 +# - ANDROID_TOOLCHAIN_SYSROOT0_LIB +# - ANDROID_TOOLCHAIN_SYSROOT1 +# - ANDROID_TOOLCHAIN_SYSROOT1_INC +# - ANDROID_TOOLCHAIN_SYSROOT1_LIB # # Android Studio SDK + NDK Filesystem Layout (official) # @@ -61,12 +62,17 @@ # ~/Android/Sdk/ndk/20.1.5948944/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android-ld (*) # ~/Android/Sdk/ndk/20.1.5948944/toolchains/llvm/prebuilt/linux-x86_64/aarch64-linux-android/bin/ld # ~/Android/Sdk/ndk/20.1.5948944/toolchains/llvm/prebuilt/linux-x86_64/bin/clang (*) -# ~/Android/Sdk/ndk/20.1.5948944/toolchains/llvm/prebuilt/linux-x86_64/sysroot +# ~/Android/Sdk/ndk/20.1.5948944/toolchains/llvm/prebuilt/linux-x86_64/sysroot (2) # ~/Android/Sdk/ndk/20.1.5948944/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include # ~/Android/Sdk/ndk/20.1.5948944/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib/aarch64-linux-android/libc.a (*) -# ~/Android/Sdk/ndk/20.1.5948944/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib/aarch64-linux-android/24/libc.a (*) +# ~/Android/Sdk/ndk/20.1.5948944/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib/aarch64-linux-android/24/libc.a (*) (2) +# ~/Android/Sdk/ndk/20.1.5948944/platforms/android-24/arch-arm64 (1) +# ~/Android/Sdk/ndk/20.1.5948944/platforms/android-24/arch-arm64/usr/lib/libc.a (*)(1) # # (*) tested by this script +# (1) ANDROID_TOOLCHAIN_SYSROOT0 exposes all libs with standard FS layout usr/lib, but no include files +# (2) ANDROID_TOOLCHAIN_SYSROOT1 exposes all libs but without standard FS layout, also exposes include files +# Native libraries of (1) and (2) are identical # # Having # ANDROID_HOME=~/Android/Sdk @@ -77,6 +83,8 @@ # ANDROID_BUILD_TOOLS_VERSION=29.0.2 # ANDROID_NDK_VERSION=20.1.5948944 # ANDROID_TOOLCHAIN_NAME aarch64-linux-android +# ANDROID_TOOLCHAIN_PLATFORM_NAME=arm64 +# ANDROID_SYSROOT_ABI=arm64 echo $0 @@ -139,10 +147,11 @@ echo echo Preset-2 echo ANDROID_BUILDTOOLS_ROOT ${ANDROID_BUILDTOOLS_ROOT} echo ANDROID_TOOLCHAIN_ROOT ${ANDROID_TOOLCHAIN_ROOT} -echo ANDROID_TOOLCHAIN_SYSROOT ${ANDROID_TOOLCHAIN_SYSROOT} -echo ANDROID_TOOLCHAIN_SYSROOT_INC ${ANDROID_TOOLCHAIN_SYSROOT_INC} -echo ANDROID_TOOLCHAIN_SYSROOT_LIB_0 ${ANDROID_TOOLCHAIN_SYSROOT_LIB_0} -echo ANDROID_TOOLCHAIN_SYSROOT_LIB_1 ${ANDROID_TOOLCHAIN_SYSROOT_LIB_1} +echo ANDROID_TOOLCHAIN_SYSROOT0 ${ANDROID_TOOLCHAIN_SYSROOT0} +echo ANDROID_TOOLCHAIN_SYSROOT0_LIB ${ANDROID_TOOLCHAIN_SYSROOT0_LIB} +echo ANDROID_TOOLCHAIN_SYSROOT1 ${ANDROID_TOOLCHAIN_SYSROOT1} +echo ANDROID_TOOLCHAIN_SYSROOT1_INC ${ANDROID_TOOLCHAIN_SYSROOT1_INC} +echo ANDROID_TOOLCHAIN_SYSROOT1_LIB ${ANDROID_TOOLCHAIN_SYSROOT1_LIB} echo check_exists() { @@ -230,10 +239,13 @@ fi ANDROID_BUILDTOOLS_ROOT=${ANDROID_HOME}/build-tools/${ANDROID_BUILD_TOOLS_VERSION} ANDROID_TOOLCHAIN_ROOT=${ANDROID_NDK}/toolchains/llvm/prebuilt/${ANDROID_HOST_TAG} -ANDROID_TOOLCHAIN_SYSROOT=${ANDROID_TOOLCHAIN_ROOT}/sysroot -ANDROID_TOOLCHAIN_SYSROOT_INC=${ANDROID_TOOLCHAIN_ROOT}/sysroot/usr/include -ANDROID_TOOLCHAIN_SYSROOT_LIB_0=${ANDROID_TOOLCHAIN_ROOT}/sysroot/usr/lib/${ANDROID_TOOLCHAIN_NAME} -ANDROID_TOOLCHAIN_SYSROOT_LIB_1=${ANDROID_TOOLCHAIN_ROOT}/sysroot/usr/lib/${ANDROID_TOOLCHAIN_NAME}/${ANDROID_API_LEVEL} + +ANDROID_TOOLCHAIN_SYSROOT0=${ANDROID_NDK}/platforms/android-${ANDROID_API_LEVEL}/arch-${ANDROID_SYSROOT_ABI} +ANDROID_TOOLCHAIN_SYSROOT0_LIB=${ANDROID_TOOLCHAIN_SYSROOT0}/usr/lib + +ANDROID_TOOLCHAIN_SYSROOT1=${ANDROID_TOOLCHAIN_ROOT}/sysroot +ANDROID_TOOLCHAIN_SYSROOT1_INC=${ANDROID_TOOLCHAIN_SYSROOT1}/usr/include +ANDROID_TOOLCHAIN_SYSROOT1_LIB=${ANDROID_TOOLCHAIN_SYSROOT1}/usr/lib/${ANDROID_TOOLCHAIN_NAME}/${ANDROID_API_LEVEL} # ~/Android/Sdk/build-tools/29.0.2/zipalign (*) check_exists ${ANDROID_BUILDTOOLS_ROOT}/zipalign @@ -244,11 +256,11 @@ check_exists ${ANDROID_TOOLCHAIN_ROOT}/bin/${ANDROID_TOOLCHAIN_NAME}-ld # ~/Android/Sdk/ndk/20.1.5948944/toolchains/llvm/prebuilt/linux-x86_64/bin/clang (*) check_exists ${ANDROID_TOOLCHAIN_ROOT}/bin/clang -# ~/Android/Sdk/ndk/20.1.5948944/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib/aarch64-linux-android/libc.a (*) -check_exists ${ANDROID_TOOLCHAIN_SYSROOT_LIB_0}/libc.a +# ~/Android/Sdk/ndk/20.1.5948944/platforms/android-24/arch-arm64/usr/lib/libc.a (*) +check_exists ${ANDROID_TOOLCHAIN_SYSROOT0_LIB}/libc.a # ~/Android/Sdk/ndk/20.1.5948944/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib/aarch64-linux-android/24/libc.a (*) -check_exists ${ANDROID_TOOLCHAIN_SYSROOT_LIB_1}/libc.a +check_exists ${ANDROID_TOOLCHAIN_SYSROOT1_LIB}/libc.a export ANDROID_HOME export ANDROID_API_LEVEL @@ -264,10 +276,11 @@ export ANDROID_NDK export ANDROID_BUILDTOOLS_ROOT export ANDROID_TOOLCHAIN_ROOT -export ANDROID_TOOLCHAIN_SYSROOT -export ANDROID_TOOLCHAIN_SYSROOT_INC -export ANDROID_TOOLCHAIN_SYSROOT_LIB_0 -export ANDROID_TOOLCHAIN_SYSROOT_LIB_1 +export ANDROID_TOOLCHAIN_SYSROOT0 +export ANDROID_TOOLCHAIN_SYSROOT0_LIB +export ANDROID_TOOLCHAIN_SYSROOT1 +export ANDROID_TOOLCHAIN_SYSROOT1_INC +export ANDROID_TOOLCHAIN_SYSROOT1_LIB echo "Postset-0 (user)" echo ANDROID_HOME ${ANDROID_HOME} @@ -286,10 +299,11 @@ echo echo Postset-2 echo ANDROID_BUILDTOOLS_ROOT ${ANDROID_BUILDTOOLS_ROOT} echo ANDROID_TOOLCHAIN_ROOT ${ANDROID_TOOLCHAIN_ROOT} -echo ANDROID_TOOLCHAIN_SYSROOT ${ANDROID_TOOLCHAIN_SYSROOT} -echo ANDROID_TOOLCHAIN_SYSROOT_INC ${ANDROID_TOOLCHAIN_SYSROOT_INC} -echo ANDROID_TOOLCHAIN_SYSROOT_LIB_0 ${ANDROID_TOOLCHAIN_SYSROOT_LIB_0} -echo ANDROID_TOOLCHAIN_SYSROOT_LIB_1 ${ANDROID_TOOLCHAIN_SYSROOT_LIB_1} +echo ANDROID_TOOLCHAIN_SYSROOT0 ${ANDROID_TOOLCHAIN_SYSROOT0} +echo ANDROID_TOOLCHAIN_SYSROOT0_LIB ${ANDROID_TOOLCHAIN_SYSROOT0_LIB} +echo ANDROID_TOOLCHAIN_SYSROOT1 ${ANDROID_TOOLCHAIN_SYSROOT1} +echo ANDROID_TOOLCHAIN_SYSROOT1_INC ${ANDROID_TOOLCHAIN_SYSROOT1_INC} +echo ANDROID_TOOLCHAIN_SYSROOT1_LIB ${ANDROID_TOOLCHAIN_SYSROOT1_LIB} echo export -p | grep ANDROID |