OLD | NEW |
1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 import("//build/config/android/config.gni") | 5 import("//build/config/android/config.gni") |
| 6 import("//build/config/sanitizers/sanitizers.gni") |
6 import("//build/config/sysroot.gni") | 7 import("//build/config/sysroot.gni") |
7 | 8 |
| 9 assert(is_android) |
| 10 |
8 config("sdk") { | 11 config("sdk") { |
9 if (sysroot != "") { | 12 if (sysroot != "") { |
10 cflags = [ "--sysroot=" + sysroot ] | 13 cflags = [ "--sysroot=" + sysroot ] |
11 ldflags = [ "--sysroot=" + sysroot ] | 14 ldflags = [ "--sysroot=" + sysroot ] |
12 | 15 |
13 # Need to get some linker flags out of the sysroot. | 16 # Need to get some linker flags out of the sysroot. |
14 sysroot_ld_path = rebase_path("//build/config/linux/sysroot_ld_path.py") | 17 sysroot_ld_path = rebase_path("//build/config/linux/sysroot_ld_path.py") |
15 ldflags += [ exec_script(sysroot_ld_path, | 18 ldflags += [ exec_script(sysroot_ld_path, |
16 [ | 19 [ |
17 rebase_path("//build/linux/sysroot_ld_path.sh"), | 20 rebase_path("//build/linux/sysroot_ld_path.sh"), |
18 sysroot, | 21 sysroot, |
19 ], | 22 ], |
20 "value") ] | 23 "value") ] |
21 } | 24 } |
22 } | 25 } |
23 | 26 |
24 config("executable_config") { | 27 config("executable_config") { |
25 cflags = [ "-fPIE" ] | 28 cflags = [ "-fPIE" ] |
26 ldflags = [ "-pie" ] | 29 ldflags = [ "-pie" ] |
27 } | 30 } |
28 | 31 |
29 config("hide_native_jni_exports") { | 32 config("hide_native_jni_exports") { |
30 ldflags = [ "-Wl,--version-script=" + | 33 ldflags = [ "-Wl,--version-script=" + |
31 rebase_path("//build/android/android_no_jni_exports.lst") ] | 34 rebase_path("//build/android/android_no_jni_exports.lst") ] |
32 } | 35 } |
| 36 |
| 37 # This is included by reference in the //build/config/compiler config that |
| 38 # is applied to all targets. It is here to separate out the logic that is |
| 39 # Android-only. |
| 40 config("compiler") { |
| 41 cflags = [ |
| 42 "-ffunction-sections", |
| 43 "-funwind-tables", |
| 44 "-fno-short-enums", |
| 45 ] |
| 46 defines = [ |
| 47 "ANDROID", |
| 48 |
| 49 # The NDK has these things, but doesn't define the constants to say that it |
| 50 # does. Define them here instead. |
| 51 "HAVE_SYS_UIO_H", |
| 52 ] |
| 53 ldflags = [] |
| 54 |
| 55 if (!is_clang) { |
| 56 # Clang doesn't support these flags. |
| 57 cflags += [ "-finline-limit=64" ] |
| 58 } |
| 59 if (is_clang) { |
| 60 rebased_android_toolchain_root = |
| 61 rebase_path(android_toolchain_root, root_build_dir) |
| 62 if (current_cpu == "arm") { |
| 63 cflags += [ |
| 64 # TODO(hans) Enable integrated-as (crbug.com/124610). |
| 65 "-no-integrated-as", |
| 66 "-B${rebased_android_toolchain_root}/bin", # Else /usr/bin/as gets pick
ed up. |
| 67 ] |
| 68 } |
| 69 } |
| 70 |
| 71 if (is_asan) { |
| 72 # Android build relies on -Wl,--gc-sections removing unreachable code. |
| 73 # ASan instrumentation for globals inhibits this and results in a library |
| 74 # with unresolvable relocations. |
| 75 # TODO(eugenis): find a way to reenable this. |
| 76 cflags += [ "-mllvm -asan-globals=0" ] |
| 77 } |
| 78 |
| 79 # Use gold for Android for most CPU architectures. |
| 80 if (current_cpu == "x86" || current_cpu == "x64" || current_cpu == "arm") { |
| 81 ldflags += [ "-fuse-ld=gold" ] |
| 82 if (is_clang) { |
| 83 # Let clang find the ld.gold in the NDK. |
| 84 ldflags += [ "--gcc-toolchain=$rebased_android_toolchain_root" ] |
| 85 } |
| 86 |
| 87 # Use -mstackrealign due to a bug on ia32 Jelly Bean. |
| 88 # See crbug.com/521527 |
| 89 if (current_cpu == "x86") { |
| 90 cflags += [ "-mstackrealign" ] |
| 91 } |
| 92 } |
| 93 |
| 94 ldflags += [ |
| 95 "-Wl,--no-undefined", |
| 96 |
| 97 # Don't allow visible symbols from libgcc or libc++ to be |
| 98 # re-exported. |
| 99 "-Wl,--exclude-libs=libgcc.a", |
| 100 "-Wl,--exclude-libs=libc++_static.a", |
| 101 |
| 102 # Don't allow visible symbols from libraries that contain |
| 103 # assembly code with symbols that aren't hidden properly. |
| 104 # http://crbug.com/448386 |
| 105 "-Wl,--exclude-libs=libvpx_assembly_arm.a", |
| 106 ] |
| 107 if (current_cpu == "arm") { |
| 108 ldflags += [ |
| 109 # Enable identical code folding to reduce size. |
| 110 "-Wl,--icf=safe", |
| 111 ] |
| 112 } |
| 113 |
| 114 if (is_clang) { |
| 115 if (current_cpu == "arm") { |
| 116 abi_target = "arm-linux-androideabi" |
| 117 } else if (current_cpu == "x86") { |
| 118 abi_target = "i686-linux-androideabi" |
| 119 } else if (current_cpu == "arm64") { |
| 120 # Place holder for arm64 support, not tested. |
| 121 abi_target = "aarch64-linux-androideabi" |
| 122 } else if (current_cpu == "x64") { |
| 123 # Place holder for x64 support, not tested. |
| 124 # TODO: Enable clang support for Android x64. http://crbug.com/346626 |
| 125 abi_target = "x86_64-linux-androideabi" |
| 126 } else if (current_cpu == "mipsel") { |
| 127 # Place holder for mips support, not tested. |
| 128 abi_target = "mipsel-linux-androideabi" |
| 129 } else if (current_cpu == "mips64el") { |
| 130 # Place holder for mips64 support, not tested. |
| 131 abi_target = "mips64el-linux-androideabi" |
| 132 } else { |
| 133 assert(false, "Architecture not supported") |
| 134 } |
| 135 cflags += [ |
| 136 "-target", |
| 137 abi_target, |
| 138 ] |
| 139 ldflags += [ |
| 140 "-target", |
| 141 abi_target, |
| 142 ] |
| 143 } |
| 144 } |
OLD | NEW |