OLD | NEW |
(Empty) | |
| 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 |
| 3 # found in the LICENSE file. |
| 4 |
| 5 import("//build/config/android/config.gni") |
| 6 import("//build/config/sanitizers/sanitizers.gni") |
| 7 |
| 8 assert(is_android) |
| 9 |
| 10 # 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 |
| 12 # Android-only. |
| 13 config("compiler") { |
| 14 cflags = [ |
| 15 "-ffunction-sections", |
| 16 "-fno-short-enums", |
| 17 ] |
| 18 defines = [ |
| 19 "ANDROID", |
| 20 |
| 21 # The NDK has these things, but doesn't define the constants to say that it |
| 22 # does. Define them here instead. |
| 23 "HAVE_SYS_UIO_H", |
| 24 ] |
| 25 |
| 26 if (is_clang) { |
| 27 rebased_android_toolchain_root = |
| 28 rebase_path(android_toolchain_root, root_build_dir) |
| 29 assert(rebased_android_toolchain_root != "") # Mark as used. |
| 30 if (current_cpu == "mipsel") { |
| 31 cflags += [ |
| 32 # TODO(gordanac) Enable integrated-as. |
| 33 "-no-integrated-as", |
| 34 "-B${rebased_android_toolchain_root}/bin", # Else /usr/bin/as gets pick
ed up. |
| 35 ] |
| 36 } |
| 37 } else { |
| 38 # Clang doesn't support these flags. |
| 39 cflags += [ "-finline-limit=64" ] |
| 40 } |
| 41 |
| 42 ldflags = [ |
| 43 "-Wl,--build-id=sha1", |
| 44 "-Wl,--no-undefined", |
| 45 |
| 46 # Don't allow visible symbols from libgcc or libc++ to be |
| 47 # re-exported. |
| 48 "-Wl,--exclude-libs=libgcc.a", |
| 49 "-Wl,--exclude-libs=libc++_static.a", |
| 50 |
| 51 # Don't allow visible symbols from libraries that contain |
| 52 # assembly code with symbols that aren't hidden properly. |
| 53 # http://crbug.com/448386 |
| 54 "-Wl,--exclude-libs=libvpx_assembly_arm.a", |
| 55 ] |
| 56 |
| 57 if (is_clang) { |
| 58 if (current_cpu == "arm") { |
| 59 abi_target = "arm-linux-androideabi" |
| 60 } else if (current_cpu == "x86") { |
| 61 abi_target = "i686-linux-androideabi" |
| 62 } else if (current_cpu == "arm64") { |
| 63 # Place holder for arm64 support, not tested. |
| 64 # TODO: Enable clang support for Android Arm64. http://crbug.com/539781 |
| 65 abi_target = "aarch64-linux-android" |
| 66 } else if (current_cpu == "x64") { |
| 67 # Place holder for x64 support, not tested. |
| 68 # TODO: Enable clang support for Android x64. http://crbug.com/539781 |
| 69 abi_target = "x86_64-linux-androideabi" |
| 70 } else if (current_cpu == "mipsel") { |
| 71 abi_target = "mipsel-linux-android" |
| 72 } else if (current_cpu == "mips64el") { |
| 73 # Place holder for mips64 support, not tested. |
| 74 abi_target = "mips64el-linux-androideabi" |
| 75 } else { |
| 76 assert(false, "Architecture not supported") |
| 77 } |
| 78 cflags += [ "--target=$abi_target" ] |
| 79 ldflags += [ "--target=$abi_target" ] |
| 80 } |
| 81 |
| 82 # Assign any flags set for the C compiler to asmflags so that they are sent |
| 83 # to the assembler. |
| 84 asmflags = cflags |
| 85 } |
| 86 |
| 87 # This is included by reference in the //build/config/compiler:runtime_library |
| 88 # config that is applied to all targets. It is here to separate out the logic |
| 89 # that is Android-only. Please see that target for advice on what should go in |
| 90 # :runtime_library vs. :compiler. |
| 91 config("runtime_library") { |
| 92 # NOTE: The libc++ header include paths below are specified in cflags_cc |
| 93 # rather than include_dirs because they need to come after include_dirs. |
| 94 # Think of them like system headers, but don't use '-isystem' because the |
| 95 # arm-linux-androideabi-4.4.3 toolchain (circa Gingerbread) will exhibit |
| 96 # strange errors. The include ordering here is important; change with |
| 97 # caution. |
| 98 cflags_cc = [ |
| 99 "-isystem" + |
| 100 rebase_path("$android_libcpp_root/libcxx/include", root_build_dir), |
| 101 "-isystem" + rebase_path( |
| 102 "$android_ndk_root/sources/cxx-stl/llvm-libc++abi/libcxxabi/include"
, |
| 103 root_build_dir), |
| 104 "-isystem" + |
| 105 rebase_path("$android_ndk_root/sources/android/support/include", |
| 106 root_build_dir), |
| 107 ] |
| 108 |
| 109 defines = [ "__GNU_SOURCE=1" ] # Necessary for clone(). |
| 110 ldflags = [ "-nostdlib" ] |
| 111 lib_dirs = [ android_libcpp_lib_dir ] |
| 112 |
| 113 # The libc++ runtime library (must come first). |
| 114 # ASan needs to dynamically link to libc++ even in static builds so |
| 115 # that it can interpose operator new. |
| 116 if (is_component_build || is_asan) { |
| 117 libs = [ "c++_shared" ] |
| 118 } else { |
| 119 libs = [ "c++_static" ] |
| 120 } |
| 121 |
| 122 # Manually link the libgcc.a that the cross compiler uses. This is |
| 123 # absolute because the linker will look inside the sysroot if it's not. |
| 124 libs += [ |
| 125 rebase_path(android_libgcc_file), |
| 126 "c", |
| 127 ] |
| 128 |
| 129 # Clang with libc++ does not require an explicit atomic library reference. |
| 130 if (!is_clang) { |
| 131 libs += [ "atomic" ] |
| 132 } |
| 133 |
| 134 if (is_clang) { |
| 135 # Work around incompatibilities between bionic and clang headers. |
| 136 defines += [ |
| 137 "__compiler_offsetof=__builtin_offsetof", |
| 138 "nan=__builtin_nan", |
| 139 ] |
| 140 } |
| 141 |
| 142 # TODO(jdduke) Re-enable on mips after resolving linking |
| 143 # issues with libc++ (crbug.com/456380). |
| 144 if (current_cpu != "mipsel" && current_cpu != "mips64el") { |
| 145 ldflags += [ "-Wl,--warn-shared-textrel" ] |
| 146 } |
| 147 } |
| 148 |
| 149 config("executable_config") { |
| 150 cflags = [ "-fPIE" ] |
| 151 asmflags = [ "-fPIE" ] |
| 152 ldflags = [ "-pie" ] |
| 153 } |
| 154 |
| 155 config("hide_native_jni_exports") { |
| 156 ldflags = [ "-Wl,--version-script=" + |
| 157 rebase_path("//build/android/android_no_jni_exports.lst") ] |
| 158 } |
| 159 |
| 160 # Instrumentation ------------------------------------------------------------- |
| 161 # |
| 162 # The BUILDCONFIG file sets the "default_cygprofile_instrumentation" config on |
| 163 # targets by default. You can override whether the cygprofile instrumentation is |
| 164 # used on a per-target basis: |
| 165 # |
| 166 # configs -= [ "//build/config/android:default_cygprofile_instrumentation" ] |
| 167 # configs += [ "//build/config/android:no_cygprofile_instrumentation" ] |
| 168 |
| 169 config("default_cygprofile_instrumentation") { |
| 170 if (use_order_profiling) { |
| 171 configs = [ ":cygprofile_instrumentation" ] |
| 172 } else { |
| 173 configs = [ ":no_cygprofile_instrumentation" ] |
| 174 } |
| 175 } |
| 176 |
| 177 config("cygprofile_instrumentation") { |
| 178 defines = [ "CYGPROFILE_INSTRUMENTATION=1" ] |
| 179 cflags = [ "-finstrument-functions" ] |
| 180 |
| 181 if (!is_clang) { |
| 182 cflags += [ |
| 183 # Allow mmx intrinsics to inline, so that the compiler can expand the intr
insics. |
| 184 "-finstrument-functions-exclude-file-list=mmintrin.h", |
| 185 |
| 186 # 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" |
| 188 "-finstrument-functions-exclude-file-list=arm_neon.h", |
| 189 ] |
| 190 } |
| 191 } |
| 192 |
| 193 config("no_cygprofile_instrumentation") { |
| 194 } |
OLD | NEW |