1# Copyright 2013 The Chromium Authors 2# Use of this source code is governed by a BSD-style license that can be 3# found in the LICENSE file. 4 5import("//build/config/android/config.gni") 6import("//build/config/clang/clang.gni") 7import("//build/config/compiler/compiler.gni") 8import("//build/config/ozone.gni") 9import("//build/config/sysroot.gni") # Imports android/config.gni. 10import("//build/toolchain/gcc_toolchain.gni") 11 12declare_args() { 13 # Whether unstripped binaries, i.e. compiled with debug symbols, should be 14 # considered runtime_deps rather than stripped ones. 15 android_unstripped_runtime_outputs = true 16} 17 18template("android_clang_toolchain") { 19 clang_toolchain(target_name) { 20 assert(defined(invoker.toolchain_args), 21 "toolchain_args must be defined for android_clang_toolchain()") 22 23 toolchain_args = { 24 forward_variables_from(invoker.toolchain_args, "*") 25 current_os = "android" 26 use_debug_fission = false 27 } 28 29 # Output linker map files for binary size analysis. 30 enable_linker_map = true 31 32 strip = rebase_path("$clang_base_path/bin/llvm-strip", root_build_dir) 33 34 use_unstripped_as_runtime_outputs = android_unstripped_runtime_outputs 35 36 # Don't use .cr.so for loadable_modules since they are always loaded via 37 # absolute path. 38 loadable_module_extension = ".so" 39 40 # We propagate configs to allow cross-toolchain JNI include directories to 41 # work. This flag does not otherwise affect our build, but if applied to 42 # non-android toolchains, it causes unwanted configs from perfetto to 43 # propagate from host_toolchain deps. 44 propagates_configs = true 45 } 46} 47 48android_clang_toolchain("android_clang_x86") { 49 toolchain_args = { 50 current_cpu = "x86" 51 52 # We lack the libclang_rt.profile library for x86 and x86_64, so we cannot 53 # link any binaries that are generated with coverage instrumentation. 54 # Therefore we need to turn off 'use_clang_coverage' for this toolchain. 55 # TODO(crbug.com/865376) 56 use_clang_coverage = false 57 58 # This turns off all of the LaCrOS-specific flags. A LaCrOS related build 59 # may use |ash_clang_x64| or |lacros_clang_x64| toolchain, which are 60 # chromeos toolchains, to build Ash-Chrome or Lacros-Chrome in a 61 # subdirectory, and because chromeos toolchain uses android toolchain, which 62 # eventually resulted in that android toolchains being used inside a LaCrOS 63 # build. 64 also_build_ash_chrome = false 65 also_build_lacros_chrome = false 66 chromeos_is_browser_only = false 67 ozone_platform = "" 68 ozone_platform_wayland = false 69 } 70} 71 72android_clang_toolchain("android_clang_arm") { 73 toolchain_args = { 74 current_cpu = "arm" 75 } 76} 77 78android_clang_toolchain("android_clang_mipsel") { 79 toolchain_args = { 80 current_cpu = "mipsel" 81 } 82} 83 84android_clang_toolchain("android_clang_x64") { 85 toolchain_args = { 86 current_cpu = "x64" 87 88 # We lack the libclang_rt.profile library for x86 and x86_64, so we cannot 89 # link any binaries that are generated with coverage instrumentation. 90 # Therefore we need to turn off 'use_clang_coverage' for this toolchain. 91 # TODO(crbug.com/865376) 92 use_clang_coverage = false 93 94 # This turns off all of the LaCrOS-specific flags. A LaCrOS related build 95 # may use |ash_clang_x64| or |lacros_clang_x64| toolchain, which are 96 # chromeos toolchains, to build Ash-Chrome or Lacros-Chrome in a 97 # subdirectory, and because chromeos toolchain uses android toolchain, which 98 # eventually resulted in that android toolchains being used inside a LaCrOS 99 # build. 100 also_build_ash_chrome = false 101 also_build_lacros_chrome = false 102 chromeos_is_browser_only = false 103 ozone_platform = "" 104 ozone_platform_wayland = false 105 } 106} 107 108android_clang_toolchain("android_clang_arm64") { 109 toolchain_args = { 110 current_cpu = "arm64" 111 } 112} 113 114android_clang_toolchain("android_clang_arm64_hwasan") { 115 toolchain_args = { 116 current_cpu = "arm64" 117 is_hwasan = true 118 android64_ndk_api_level = 29 119 } 120} 121 122android_clang_toolchain("android_clang_mips64el") { 123 toolchain_args = { 124 current_cpu = "mips64el" 125 } 126} 127 128# Placeholder for riscv64 support, not tested since the toolchain is not ready. 129android_clang_toolchain("android_clang_riscv64") { 130 toolchain_args = { 131 current_cpu = "riscv64" 132 } 133} 134 135# Toolchain for creating native libraries that can be used by 136# robolectric_binary targets. It does not emulate NDK APIs nor make available 137# NDK header files. 138# Targets that opt into defining JNI entrypoints should use the 139# //third_party/jdk:jdk config to make jni.h available. 140# This toolchain will set: 141# is_linux = true 142# is_android = false 143# is_robolectric = true 144clang_toolchain("robolectric_$host_cpu") { 145 toolchain_args = { 146 current_os = host_os 147 current_cpu = host_cpu 148 is_robolectric = true 149 } 150} 151