Fix for the Android x86-64 megazord with Android NDK-25
The new NDK doesn't link to `libgcc` anymore, which breaks our our NSS and SQLCipher libraries since they depended on the symbols from libclang_rt.builtins-x86_64-android` like `__extenddftf2`. See #5436 for more details. The change works around this by manually linking to the libclang_rt.builtins-x86_64-android library in this case. Added a doc on how to upgrade the Android NDK which hopefully will help us in the future. Extracted some common code from the the `build-*-android.sh` scripts to make these directions simpler.
This commit is contained in:
Родитель
eac793d16a
Коммит
2c97beb435
|
@ -89,6 +89,15 @@ fn link_nss_libs(kind: LinkingKind) {
|
|||
} else {
|
||||
println!("cargo:rustc-link-lib=c++");
|
||||
}
|
||||
let target_arch = env::var("CARGO_CFG_TARGET_ARCH").unwrap();
|
||||
if target_arch == "x86_64" && target_os == "android" {
|
||||
let android_home = env::var("ANDROID_HOME").expect("ANDROID_HOME not set");
|
||||
const ANDROID_NDK_VERSION: &str = "25.2.9519653";
|
||||
const LINUX_X86_64_LIB_DIR: &str =
|
||||
"/toolchains/llvm/prebuilt/linux-x86_64/lib64/clang/14.0.7/lib/linux/";
|
||||
println!("cargo:rustc-link-search={android_home}/ndk/{ANDROID_NDK_VERSION}/{LINUX_X86_64_LIB_DIR}");
|
||||
println!("cargo:rustc-link-lib=static=clang_rt.builtins-x86_64-android");
|
||||
}
|
||||
}
|
||||
|
||||
fn get_nss_libs(kind: LinkingKind) -> Vec<&'static str> {
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
Here's how to upgrade the Android NDK version:
|
||||
|
||||
* Update the version number in:
|
||||
* `build.gradle` (search for `ndkVersion`)
|
||||
* `taskcluster/docker/linux/Dockerfile` (search for `ANDROID_NDK_VERSION`)
|
||||
* `components/support/rc_crypto/nss/nss_build_common/src/lib.rs` (search for `ANDROID_NDK_VERSION`)
|
||||
* Update these docs by replacing the old version with the new one:
|
||||
* docs/building.md
|
||||
* docs/howtos/locally-building-jna.md
|
||||
* These may need updating if the directory structure changed between this version and the last
|
||||
* `libs/build-android-common.sh`: ensure the paths to the various binaries are correct.
|
||||
* `components/support/rc_crypto/nss/nss_build_common/src/lib.rs`: search for
|
||||
`LINUX_X86_64_LIB_DIR` and ensure this correctly points to the correct lib directory containing
|
||||
`libclang_rt.builtins-x86_64-android.a`.
|
|
@ -0,0 +1,17 @@
|
|||
#!/bin/bash
|
||||
# This script is sourced by the `build-*-android.sh` scripts. The shbang above
|
||||
# is to make shellcheck happy.
|
||||
|
||||
export AR="${TOOLCHAIN_PATH}/bin/llvm-ar"
|
||||
export CC="${TOOLCHAIN_PATH}/bin/${TOOLCHAIN}${ANDROID_NDK_API_VERSION}-clang"
|
||||
export CXX="${TOOLCHAIN_PATH}/bin/${TOOLCHAIN}${ANDROID_NDK_API_VERSION}-clang++"
|
||||
# For 32-bit ARM, the compiler is prefixed with armv7a-linux-androideabi
|
||||
if [[ "${TOOLCHAIN}" == "arm-linux-androideabi" ]]; then
|
||||
export CC="${TOOLCHAIN_PATH}/bin/armv7a-linux-androideabi${ANDROID_NDK_API_VERSION}-clang"
|
||||
export CXX="${TOOLCHAIN_PATH}/bin/armv7a-linux-androideabi${ANDROID_NDK_API_VERSION}-clang++"
|
||||
fi
|
||||
export LD="${TOOLCHAIN_PATH}/bin/ld"
|
||||
export NM="${TOOLCHAIN_PATH}/bin/llvm-nm"
|
||||
export RANLIB="${TOOLCHAIN_PATH}/bin/llvm-ranlib"
|
||||
export READELF="${TOOLCHAIN_PATH}/bin/llvm-readelf"
|
||||
|
|
@ -42,18 +42,8 @@ else
|
|||
fi
|
||||
NSPR_64="${NSPR_64:-""}"
|
||||
|
||||
export AR="${TOOLCHAIN_PATH}/bin/llvm-ar"
|
||||
export CC="${TOOLCHAIN_PATH}/bin/${TOOLCHAIN}${ANDROID_NDK_API_VERSION}-clang"
|
||||
export CXX="${TOOLCHAIN_PATH}/bin/${TOOLCHAIN}${ANDROID_NDK_API_VERSION}-clang++"
|
||||
# For 32-bit ARM, the compiler is prefixed with armv7a-linux-androideabi
|
||||
if [[ "${TOOLCHAIN}" == "arm-linux-androideabi" ]]; then
|
||||
export CC="${TOOLCHAIN_PATH}/bin/armv7a-linux-androideabi${ANDROID_NDK_API_VERSION}-clang"
|
||||
export CXX="${TOOLCHAIN_PATH}/bin/armv7a-linux-androideabi${ANDROID_NDK_API_VERSION}-clang++"
|
||||
fi
|
||||
export LD="${TOOLCHAIN_PATH}/bin/ld"
|
||||
export NM="${TOOLCHAIN_PATH}/bin/llvm-nm"
|
||||
export RANLIB="${TOOLCHAIN_PATH}/bin/llvm-ranlib"
|
||||
export READELF="${TOOLCHAIN_PATH}/bin/llvm-readelf"
|
||||
# shellcheck source=libs/build-android-common.sh
|
||||
source ./build-android-common.sh
|
||||
|
||||
# Build NSPR
|
||||
NSPR_BUILD_DIR=$(mktemp -d)
|
||||
|
|
|
@ -23,16 +23,8 @@ if [[ -d "${DIST_DIR}" ]]; then
|
|||
exit 0
|
||||
fi
|
||||
|
||||
export AR="${TOOLCHAIN_PATH}/bin/llvm-ar"
|
||||
export CC="${TOOLCHAIN_PATH}/bin/${TOOLCHAIN}${ANDROID_NDK_API_VERSION}-clang"
|
||||
export CXX="${TOOLCHAIN_PATH}/bin/${TOOLCHAIN}${ANDROID_NDK_API_VERSION}-clang++"
|
||||
# For 32-bit ARM, the compiler is prefixed with armv7a-linux-androideabi
|
||||
if [[ "${TOOLCHAIN}" == "arm-linux-androideabi" ]]; then
|
||||
export CC="${TOOLCHAIN_PATH}/bin/armv7a-linux-androideabi${ANDROID_NDK_API_VERSION}-clang"
|
||||
export CXX="${TOOLCHAIN_PATH}/bin/armv7a-linux-androideabi${ANDROID_NDK_API_VERSION}-clang++"
|
||||
fi
|
||||
export LD="${TOOLCHAIN_PATH}/bin/ld"
|
||||
export RANLIB="${TOOLCHAIN_PATH}/bin/llvm-ranlib"
|
||||
# shellcheck source=libs/build-android-common.sh
|
||||
source ./build-android-common.sh
|
||||
|
||||
if [[ "${TOOLCHAIN}" == "x86_64-linux-android" ]]
|
||||
then
|
||||
|
|
Загрузка…
Ссылка в новой задаче