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/sanitizers/sanitizers.gni") |
| 7 import("//build/config/sysroot.gni") |
7 | 8 |
8 assert(is_android) | 9 assert(is_android) |
9 | 10 |
| 11 use_gold = current_cpu == "x86" || current_cpu == "x64" || current_cpu == "arm" |
| 12 |
10 # This is included by reference in the //build/config/compiler config that | 13 # This is included by reference in the //build/config/compiler config that |
11 # is applied to all targets. It is here to separate out the logic that is | 14 # is applied to all targets. It is here to separate out the logic that is |
12 # Android-only. | 15 # Android-only. |
13 config("compiler") { | 16 config("compiler") { |
14 cflags = [ | 17 cflags = [ |
15 "-ffunction-sections", | 18 "-ffunction-sections", |
16 "-fno-short-enums", | 19 "-fno-short-enums", |
17 ] | 20 ] |
18 defines = [ | 21 defines = [ |
19 "ANDROID", | 22 "ANDROID", |
20 | 23 |
21 # The NDK has these things, but doesn't define the constants to say that it | 24 # The NDK has these things, but doesn't define the constants to say that it |
22 # does. Define them here instead. | 25 # does. Define them here instead. |
23 "HAVE_SYS_UIO_H", | 26 "HAVE_SYS_UIO_H", |
24 ] | 27 ] |
| 28 ldflags = [] |
25 | 29 |
| 30 if (!is_clang) { |
| 31 # Clang doesn't support these flags. |
| 32 cflags += [ "-finline-limit=64" ] |
| 33 } |
26 if (is_clang) { | 34 if (is_clang) { |
27 rebased_android_toolchain_root = | 35 rebased_android_toolchain_root = |
28 rebase_path(android_toolchain_root, root_build_dir) | 36 rebase_path(android_toolchain_root, root_build_dir) |
29 assert(rebased_android_toolchain_root != "") # Mark as used. | 37 assert(rebased_android_toolchain_root != "") # Mark as used. |
30 if (current_cpu == "mipsel") { | 38 if (current_cpu == "mipsel") { |
31 cflags += [ | 39 cflags += [ |
32 # TODO(gordanac) Enable integrated-as. | 40 # TODO(gordanac) Enable integrated-as. |
33 "-no-integrated-as", | 41 "-no-integrated-as", |
34 "-B${rebased_android_toolchain_root}/bin", # Else /usr/bin/as gets pick
ed up. | 42 "-B${rebased_android_toolchain_root}/bin", # Else /usr/bin/as gets pick
ed up. |
35 ] | 43 ] |
36 } | 44 } |
37 } else { | |
38 # Clang doesn't support these flags. | |
39 cflags += [ "-finline-limit=64" ] | |
40 } | 45 } |
41 | 46 |
42 ldflags = [ | 47 # Use gold for Android for most CPU architectures. |
| 48 if (use_gold) { |
| 49 ldflags += [ "-fuse-ld=gold" ] |
| 50 if (is_clang) { |
| 51 # Let clang find the ld.gold in the NDK. |
| 52 ldflags += [ "--gcc-toolchain=$rebased_android_toolchain_root" ] |
| 53 } |
| 54 |
| 55 # Use -mstackrealign due to a bug on ia32 Jelly Bean. |
| 56 # See crbug.com/521527 |
| 57 if (current_cpu == "x86") { |
| 58 cflags += [ "-mstackrealign" ] |
| 59 } |
| 60 } |
| 61 |
| 62 if (current_cpu == "mipsel" && is_clang) { |
| 63 # Let clang find the ld.bfd in the NDK. |
| 64 ldflags += [ "--gcc-toolchain=$rebased_android_toolchain_root" ] |
| 65 } |
| 66 |
| 67 ldflags += [ |
43 "-Wl,--build-id=sha1", | 68 "-Wl,--build-id=sha1", |
44 "-Wl,--no-undefined", | 69 "-Wl,--no-undefined", |
45 | 70 |
46 # Don't allow visible symbols from libgcc or libc++ to be | 71 # Don't allow visible symbols from libgcc or libc++ to be |
47 # re-exported. | 72 # re-exported. |
48 "-Wl,--exclude-libs=libgcc.a", | 73 "-Wl,--exclude-libs=libgcc.a", |
49 "-Wl,--exclude-libs=libc++_static.a", | 74 "-Wl,--exclude-libs=libc++_static.a", |
50 | 75 |
51 # Don't allow visible symbols from libraries that contain | 76 # Don't allow visible symbols from libraries that contain |
52 # assembly code with symbols that aren't hidden properly. | 77 # assembly code with symbols that aren't hidden properly. |
53 # http://crbug.com/448386 | 78 # http://crbug.com/448386 |
54 "-Wl,--exclude-libs=libvpx_assembly_arm.a", | 79 "-Wl,--exclude-libs=libvpx_assembly_arm.a", |
55 ] | 80 ] |
| 81 if (current_cpu == "arm" && !use_order_profiling) { |
| 82 ldflags += [ |
| 83 # Enable identical code folding to reduce size. |
| 84 "-Wl,--icf=all", |
| 85 ] |
| 86 } |
56 | 87 |
57 if (is_clang) { | 88 if (is_clang) { |
58 if (current_cpu == "arm") { | 89 if (current_cpu == "arm") { |
59 abi_target = "arm-linux-androideabi" | 90 abi_target = "arm-linux-androideabi" |
60 } else if (current_cpu == "x86") { | 91 } else if (current_cpu == "x86") { |
61 abi_target = "i686-linux-androideabi" | 92 abi_target = "i686-linux-androideabi" |
62 } else if (current_cpu == "arm64") { | 93 } else if (current_cpu == "arm64") { |
63 # Place holder for arm64 support, not tested. | 94 # Place holder for arm64 support, not tested. |
64 # TODO: Enable clang support for Android Arm64. http://crbug.com/539781 | 95 # TODO: Enable clang support for Android Arm64. http://crbug.com/539781 |
65 abi_target = "aarch64-linux-android" | 96 abi_target = "aarch64-linux-android" |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 # issues with libc++ (crbug.com/456380). | 174 # issues with libc++ (crbug.com/456380). |
144 if (current_cpu != "mipsel" && current_cpu != "mips64el") { | 175 if (current_cpu != "mipsel" && current_cpu != "mips64el") { |
145 ldflags += [ "-Wl,--warn-shared-textrel" ] | 176 ldflags += [ "-Wl,--warn-shared-textrel" ] |
146 } | 177 } |
147 } | 178 } |
148 | 179 |
149 config("executable_config") { | 180 config("executable_config") { |
150 cflags = [ "-fPIE" ] | 181 cflags = [ "-fPIE" ] |
151 asmflags = [ "-fPIE" ] | 182 asmflags = [ "-fPIE" ] |
152 ldflags = [ "-pie" ] | 183 ldflags = [ "-pie" ] |
| 184 |
| 185 if (!use_gold) { |
| 186 # ld needs help finding libraries when linking. |
| 187 _rebased_sysroot = rebase_path(sysroot, root_build_dir) |
| 188 ldflags += [ "-Wl,-rpath-link=.:$_rebased_sysroot/usr/lib" ] |
| 189 } |
153 } | 190 } |
154 | 191 |
155 config("hide_native_jni_exports") { | 192 config("hide_native_jni_exports") { |
156 ldflags = [ "-Wl,--version-script=" + | 193 ldflags = [ "-Wl,--version-script=" + |
157 rebase_path("//build/android/android_no_jni_exports.lst") ] | 194 rebase_path("//build/android/android_no_jni_exports.lst") ] |
158 } | 195 } |
159 | 196 |
160 # Instrumentation ------------------------------------------------------------- | 197 # Instrumentation ------------------------------------------------------------- |
161 # | 198 # |
162 # The BUILDCONFIG file sets the "default_cygprofile_instrumentation" config on | 199 # The BUILDCONFIG file sets the "default_cygprofile_instrumentation" config on |
(...skipping 22 matching lines...) Expand all Loading... |
185 | 222 |
186 # Avoid errors with current NDK: | 223 # Avoid errors with current NDK: |
187 # "third_party/android_tools/ndk/toolchains/arm-linux-androideabi-4.6/preb
uilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.6/include/arm_neon.h:34
26:3: error: argument must be a constant" | 224 # "third_party/android_tools/ndk/toolchains/arm-linux-androideabi-4.6/preb
uilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.6/include/arm_neon.h:34
26:3: error: argument must be a constant" |
188 "-finstrument-functions-exclude-file-list=arm_neon.h", | 225 "-finstrument-functions-exclude-file-list=arm_neon.h", |
189 ] | 226 ] |
190 } | 227 } |
191 } | 228 } |
192 | 229 |
193 config("no_cygprofile_instrumentation") { | 230 config("no_cygprofile_instrumentation") { |
194 } | 231 } |
OLD | NEW |