| Index: build/config/android/BUILD.gn
|
| diff --git a/build/config/android/BUILD.gn b/build/config/android/BUILD.gn
|
| index 5492693f560fc02885b96524070503f9e7f0cf07..6f9258f8d8043aca0f68764131b94bfa38c48e1b 100644
|
| --- a/build/config/android/BUILD.gn
|
| +++ b/build/config/android/BUILD.gn
|
| @@ -3,8 +3,11 @@
|
| # found in the LICENSE file.
|
|
|
| import("//build/config/android/config.gni")
|
| +import("//build/config/sanitizers/sanitizers.gni")
|
| import("//build/config/sysroot.gni")
|
|
|
| +assert(is_android)
|
| +
|
| config("sdk") {
|
| if (sysroot != "") {
|
| cflags = [ "--sysroot=" + sysroot ]
|
| @@ -30,3 +33,112 @@ config("hide_native_jni_exports") {
|
| ldflags = [ "-Wl,--version-script=" +
|
| rebase_path("//build/android/android_no_jni_exports.lst") ]
|
| }
|
| +
|
| +# This is included by reference in the //build/config/compiler config that
|
| +# is applied to all targets. It is here to separate out the logic that is
|
| +# Android-only.
|
| +config("compiler") {
|
| + cflags = [
|
| + "-ffunction-sections",
|
| + "-funwind-tables",
|
| + "-fno-short-enums",
|
| + ]
|
| + defines = [
|
| + "ANDROID",
|
| +
|
| + # The NDK has these things, but doesn't define the constants to say that it
|
| + # does. Define them here instead.
|
| + "HAVE_SYS_UIO_H",
|
| + ]
|
| + ldflags = []
|
| +
|
| + if (!is_clang) {
|
| + # Clang doesn't support these flags.
|
| + cflags += [ "-finline-limit=64" ]
|
| + }
|
| + if (is_clang) {
|
| + rebased_android_toolchain_root =
|
| + rebase_path(android_toolchain_root, root_build_dir)
|
| + if (current_cpu == "arm") {
|
| + cflags += [
|
| + # TODO(hans) Enable integrated-as (crbug.com/124610).
|
| + "-no-integrated-as",
|
| + "-B${rebased_android_toolchain_root}/bin", # Else /usr/bin/as gets picked up.
|
| + ]
|
| + }
|
| + }
|
| +
|
| + if (is_asan) {
|
| + # Android build relies on -Wl,--gc-sections removing unreachable code.
|
| + # ASan instrumentation for globals inhibits this and results in a library
|
| + # with unresolvable relocations.
|
| + # TODO(eugenis): find a way to reenable this.
|
| + cflags += [ "-mllvm -asan-globals=0" ]
|
| + }
|
| +
|
| + # Use gold for Android for most CPU architectures.
|
| + if (current_cpu == "x86" || current_cpu == "x64" || current_cpu == "arm") {
|
| + ldflags += [ "-fuse-ld=gold" ]
|
| + if (is_clang) {
|
| + # Let clang find the ld.gold in the NDK.
|
| + ldflags += [ "--gcc-toolchain=$rebased_android_toolchain_root" ]
|
| + }
|
| +
|
| + # Use -mstackrealign due to a bug on ia32 Jelly Bean.
|
| + # See crbug.com/521527
|
| + if (current_cpu == "x86") {
|
| + cflags += [ "-mstackrealign" ]
|
| + }
|
| + }
|
| +
|
| + ldflags += [
|
| + "-Wl,--no-undefined",
|
| +
|
| + # Don't allow visible symbols from libgcc or libc++ to be
|
| + # re-exported.
|
| + "-Wl,--exclude-libs=libgcc.a",
|
| + "-Wl,--exclude-libs=libc++_static.a",
|
| +
|
| + # Don't allow visible symbols from libraries that contain
|
| + # assembly code with symbols that aren't hidden properly.
|
| + # http://crbug.com/448386
|
| + "-Wl,--exclude-libs=libvpx_assembly_arm.a",
|
| + ]
|
| + if (current_cpu == "arm") {
|
| + ldflags += [
|
| + # Enable identical code folding to reduce size.
|
| + "-Wl,--icf=safe",
|
| + ]
|
| + }
|
| +
|
| + if (is_clang) {
|
| + if (current_cpu == "arm") {
|
| + abi_target = "arm-linux-androideabi"
|
| + } else if (current_cpu == "x86") {
|
| + abi_target = "i686-linux-androideabi"
|
| + } else if (current_cpu == "arm64") {
|
| + # Place holder for arm64 support, not tested.
|
| + abi_target = "aarch64-linux-androideabi"
|
| + } else if (current_cpu == "x64") {
|
| + # Place holder for x64 support, not tested.
|
| + # TODO: Enable clang support for Android x64. http://crbug.com/346626
|
| + abi_target = "x86_64-linux-androideabi"
|
| + } else if (current_cpu == "mipsel") {
|
| + # Place holder for mips support, not tested.
|
| + abi_target = "mipsel-linux-androideabi"
|
| + } else if (current_cpu == "mips64el") {
|
| + # Place holder for mips64 support, not tested.
|
| + abi_target = "mips64el-linux-androideabi"
|
| + } else {
|
| + assert(false, "Architecture not supported")
|
| + }
|
| + cflags += [
|
| + "-target",
|
| + abi_target,
|
| + ]
|
| + ldflags += [
|
| + "-target",
|
| + abi_target,
|
| + ]
|
| + }
|
| +}
|
|
|