1# Copyright 2015 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 5# Toolchain-related configuration that may be needed outside the context of the 6# toolchain() rules themselves. 7 8import("//build/config/cast.gni") 9import("//build/config/chrome_build.gni") 10import("//build_overrides/build.gni") 11 12declare_args() { 13 # If this is set to true, we use the revision in the llvm repo to determine 14 # the CLANG_REVISION to use, instead of the version hard-coded into 15 # //tools/clang/scripts/update.py. This should only be used in 16 # conjunction with setting the llvm_force_head_revision DEPS variable when 17 # `gclient runhooks` is run as well. 18 llvm_force_head_revision = false 19 20 # Cronet is shipped in AOSP, where it is built using the Android Mainline 21 # Clang. Please refer to go/cronet-builders-with-mainline-clang-design for 22 # more information. 23 # If this arg is set to true, we use the Android Mainline LLVM. 24 llvm_android_mainline = false 25 26 # Used for binary size analysis. 27 generate_linker_map = is_android && is_official_build 28 29 # Whether this toolchain is to be used for building host tools that are 30 # consumed during the build process. That includes proc macros and Cargo build 31 # scripts. 32 toolchain_for_rust_host_build_tools = false 33} 34 35if (generate_linker_map) { 36 assert(is_official_build || is_castos || is_cast_android, 37 "Linker map files should only be generated when is_official_build = " + 38 "true or is_castos = true or is_cast_android = true") 39 assert(current_os == "android" || current_os == "linux" || 40 target_os == "android" || target_os == "linux" || 41 target_os == "chromeos", 42 "Linker map files should only be generated for Android, Linux, " + 43 "or ChromeOS.") 44} 45 46declare_args() { 47 if (llvm_android_mainline) { # https://crbug.com/1481060 48 clang_version = "17" 49 } else { 50 clang_version = "19" 51 } 52} 53 54# Extension for shared library files (including leading dot). 55if (is_apple) { 56 shlib_extension = ".dylib" 57} else if (is_posix || is_fuchsia) { 58 shlib_extension = ".so" 59} else if (is_win) { 60 shlib_extension = ".dll" 61} else { 62 assert(false, "Platform not supported") 63} 64 65# Same extension but for the host platform. We have significantly fewer host 66# platforms. 67if (host_os == "mac") { 68 host_shlib_extension = ".dylib" 69} else if (host_os == "win") { 70 host_shlib_extension = ".dll" 71} else if (host_os == "linux" || host_os == "aix") { 72 host_shlib_extension = ".so" 73} else { 74 assert(false, "Host platform not supported") 75} 76 77# Prefix for shared library files. 78if (is_posix || is_fuchsia) { 79 shlib_prefix = "lib" 80} else { 81 shlib_prefix = "" 82} 83 84# Directory for shared library files. 85if (is_fuchsia) { 86 shlib_subdir = "/lib" 87} else { 88 shlib_subdir = "" 89} 90 91# While other "tool"s in a toolchain are specific to the target of that 92# toolchain, the "stamp" and "copy" tools are really generic to the host; 93# but each toolchain must define them separately. GN doesn't allow a 94# template instantiation inside a toolchain definition, so some boilerplate 95# has to be repeated in each toolchain to define these two tools. These 96# four variables reduce the duplication in that boilerplate. 97stamp_description = "STAMP {{output}}" 98copy_description = "COPY {{source}} {{output}}" 99if (host_os == "win") { 100 _tool_wrapper_path = 101 rebase_path("//build/toolchain/win/tool_wrapper.py", root_build_dir) 102 103 stamp_command = "cmd /c type nul > \"{{output}}\"" 104 copy_command = "\"$python_path\" $_tool_wrapper_path recursive-mirror {{source}} {{output}}" 105} else { 106 stamp_command = "touch {{output}}" 107 copy_command = "ln -f {{source}} {{output}} 2>/dev/null || (rm -rf {{output}} && cp -af {{source}} {{output}})" 108} 109 110# This variable is true if the current toolchain is one of the target 111# toolchains, i.e. a toolchain which is being used to build the main Chrome 112# binary. This generally means "not the host toolchain", but in the case where 113# we're targeting the host it's true then as well. We do require current_os to 114# match target_os so that for example we avoid considering Android as a target 115# toolchain when targeting CrOS. 116is_a_target_toolchain = 117 (current_toolchain != host_toolchain || 118 default_toolchain == host_toolchain) && current_os == target_os 119