# Copyright 2013 The Chromium Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import("//build/config/clang/clang.gni")
import("//build/config/compiler/compiler.gni")
import("//build/config/coverage/coverage.gni")
import("//build/config/rust.gni")
import("//build/config/sanitizers/sanitizers.gni")
import("//build/config/sysroot.gni")
import("//build/config/v8_target_cpu.gni")
import("//build/toolchain/cc_wrapper.gni")
import("//build/toolchain/rbe.gni")
import("//build/toolchain/toolchain.gni")

if (is_nacl) {
  # To keep NaCl variables out of builds that don't include NaCl, all
  # variables defined in nacl/config.gni referenced here should be protected by
  # is_nacl conditions.
  import("//build/config/nacl/config.gni")
}

declare_args() {
  # Enables allowlist generation for IDR_ grit defines seen by the compiler.
  # Currently works only on some platforms and enabled by default for official
  # builds. Requires debug info.
  enable_resource_allowlist_generation =
      is_official_build &&
      # Don't enable for Android-on-Chrome OS.
      (target_os == "android" || target_os == "win")

  # Use -MD instead of -MMD for compiler commands. This is useful for tracking
  # the comprehensive set of dependencies.  It's also required when building
  # without the sysroot so that updates to system header files trigger a
  # rebuild (when using the sysroot, the CR_SYSROOT_KEY define takes care of
  # this already).
  system_headers_in_deps = !use_sysroot
}

# When the arg is set via args.gn, it applies to all toolchains. In order to not
# hit the assert in grit_rule.gni, explicitly disable for host toolchains.
if ((is_linux || is_chromeos) && target_os == "android") {
  enable_resource_allowlist_generation = false
}

# Ensure enable_resource_allowlist_generation is enabled only when it will work.
if (enable_resource_allowlist_generation) {
  assert(
      !strip_debug_info,
      "enable_resource_allowlist_generation=true requires strip_debug_info=false")
  assert(
      !is_component_build,
      "enable_resource_allowlist_generation=true requires is_component_build=false")
  assert(
      target_os == "android" || target_os == "win",
      "enable_resource_allowlist_generation=true does not work for target_os=$target_os")
}

# This template defines a toolchain for something that works like gcc
# (including clang).
#
# It requires the following variables specifying the executables to run:
#  - ar
#  - cc
#  - cxx
#  - ld
#
# Optional parameters that control the tools:
#
#  - extra_cflags
#      Extra flags to be appended when compiling C files (but not C++ files).
#  - extra_cppflags
#      Extra flags to be appended when compiling both C and C++ files. "CPP"
#      stands for "C PreProcessor" in this context, although it can be
#      used for non-preprocessor flags as well. Not to be confused with
#      "CXX" (which follows).
#  - extra_cxxflags
#      Extra flags to be appended when compiling C++ files (but not C files).
#  - extra_asmflags
#      Extra flags to be appended when compiling assembly.
#  - extra_ldflags
#      Extra flags to be appended when linking
#
#  - link_outputs
#      The content of this array, if specified, will be added to the list of
#      outputs from the link command. This can be useful in conjunction with
#      the post_link parameter.
#  - use_unstripped_as_runtime_outputs
#      When |strip| is set, mark unstripped executables as runtime deps rather
#      than stripped ones.
#  - post_link
#      The content of this string, if specified, will be run as a separate
#      command following the the link command.
#  - deps
#      Just forwarded to the toolchain definition.
#  - executable_extension
#      If this string is specified it will be used for the file extension
#      for an executable, rather than using no extension; targets will
#      still be able to override the extension using the output_extension
#      variable.
#  - rebuild_define
#      The contents of this string, if specified, will be passed as a #define
#      to the toolchain. It can be used to force recompiles whenever a
#      toolchain is updated.
#  - shlib_extension
#      If this string is specified it will be used for the file extension
#      for a shared library, rather than default value specified in
#      toolchain.gni
#  - strip
#      Location of the strip executable. When specified, strip will be run on
#      all shared libraries and executables as they are built. The pre-stripped
#      artifacts will be put in lib.unstripped/ and exe.unstripped/.
#
# Callers will normally want to invoke "gcc_toolchain" instead, which makes an
# additional toolchain for Rust targets that are build-time artificts such as
# proc macros.
template("single_gcc_toolchain") {
  toolchain(target_name) {
    assert(defined(invoker.ar), "gcc_toolchain() must specify a \"ar\" value")
    assert(defined(invoker.cc), "gcc_toolchain() must specify a \"cc\" value")
    assert(defined(invoker.cxx), "gcc_toolchain() must specify a \"cxx\" value")
    assert(defined(invoker.ld), "gcc_toolchain() must specify a \"ld\" value")

    # This define changes when the toolchain changes, forcing a rebuild.
    # Nothing should ever use this define.
    if (defined(invoker.rebuild_define)) {
      rebuild_string = "-D" + invoker.rebuild_define + " "
    } else {
      rebuild_string = ""
    }

    # GN's syntax can't handle more than one scope dereference at once, like
    # "invoker.toolchain_args.foo", so make a temporary to hold the toolchain
    # args so we can do "invoker_toolchain_args.foo".
    assert(defined(invoker.toolchain_args),
           "Toolchains must specify toolchain_args")
    invoker_toolchain_args = invoker.toolchain_args
    assert(defined(invoker_toolchain_args.current_cpu),
           "toolchain_args must specify a current_cpu")
    assert(defined(invoker_toolchain_args.current_os),
           "toolchain_args must specify a current_os")

    # use_reclient is default to use_remoteexec
    if (!defined(invoker_toolchain_args.use_reclient) &&
        defined(invoker_toolchain_args.use_remoteexec)) {
      invoker_toolchain_args.use_reclient =
          invoker_toolchain_args.use_remoteexec
    }

    # When invoking this toolchain not as the default one, these args will be
    # passed to the build. They are ignored when this is the default toolchain.
    toolchain_args = {
      # Populate toolchain args from the invoker.
      forward_variables_from(invoker_toolchain_args, "*")

      # The host toolchain value computed by the default toolchain's setup
      # needs to be passed through unchanged to all secondary toolchains to
      # ensure that it's always the same, regardless of the values that may be
      # set on those toolchains.
      host_toolchain = host_toolchain

      if (!defined(invoker_toolchain_args.v8_current_cpu)) {
        v8_current_cpu = invoker_toolchain_args.current_cpu
      }
    }

    # When the invoker has explicitly overridden use_remoteexec or
    # cc_wrapper in the toolchain args, use those values, otherwise default
    # to the global one.  This works because the only reasonable override
    # that toolchains might supply for these values are to force-disable them.
    if (defined(toolchain_args.use_reclient)) {
      toolchain_uses_reclient = toolchain_args.use_reclient
    } else {
      toolchain_uses_reclient = use_reclient
    }

    if (defined(toolchain_args.cc_wrapper)) {
      toolchain_cc_wrapper = toolchain_args.cc_wrapper
    } else {
      toolchain_cc_wrapper = cc_wrapper
    }
    assert(!(toolchain_cc_wrapper != "" && toolchain_uses_reclient),
           "re-client and cc_wrapper can't be used together.")

    # When the invoker has explicitly overridden cc_wrapper in the
    # toolchain args, use those values, otherwise default to the global one.
    # This works because the only reasonable override that toolchains might
    # supply for these values are to force-disable them.
    # But if needs_rewrapper_path_arg is set in a Chrome OS build, the
    # toolchain wrapper will have picked up rewrapper via cmd-line arg. So
    # need to prepend rewrapper in that case.
    if (toolchain_uses_reclient &&
        (!defined(invoker.needs_rewrapper_path_arg) ||
         !invoker.needs_rewrapper_path_arg)) {
      if (defined(toolchain_args.reclient_cc_cfg_file)) {
        toolchain_reclient_cc_cfg_file = toolchain_args.reclient_cc_cfg_file
      } else {
        toolchain_reclient_cc_cfg_file = reclient_cc_cfg_file
      }

      # C/C++ (clang) rewrapper prefix to use when use_reclient is true.
      compiler_prefix = "${reclient_bin_dir}/rewrapper -cfg=${toolchain_reclient_cc_cfg_file}${rbe_bug_326584510_missing_inputs} -exec_root=${rbe_exec_root} "
    } else {
      compiler_prefix = "${toolchain_cc_wrapper} "

      # Prevent warning about unused variable since it is not read in the code
      # paths when reclient is not needed.
      not_needed(invoker, [ "needs_rewrapper_path_arg" ])
    }

    # A specific toolchain may wish to avoid coverage instrumentation, so we
    # allow the global "use_clang_coverage" arg to be overridden.
    if (defined(toolchain_args.use_clang_coverage)) {
      toolchain_use_clang_coverage = toolchain_args.use_clang_coverage
    } else {
      toolchain_use_clang_coverage = use_clang_coverage
    }

    # For a coverage build, we use the wrapper script globally so that it can
    # remove coverage cflags from files that should not have them.
    if (toolchain_use_clang_coverage) {
      # "coverage_instrumentation_input_file" is set in args.gn, but it can be
      # overridden by a toolchain config.
      if (defined(toolchain_args.coverage_instrumentation_input_file)) {
        toolchain_coverage_instrumentation_input_file =
            toolchain_args.coverage_instrumentation_input_file
      } else {
        toolchain_coverage_instrumentation_input_file =
            coverage_instrumentation_input_file
      }

      _coverage_wrapper =
          rebase_path("//build/toolchain/clang_code_coverage_wrapper.py",
                      root_build_dir)

      # The wrapper needs to know what OS we target because it uses that to
      # select a list of files that should not be instrumented.
      _coverage_wrapper = _coverage_wrapper + " --target-os=" +
                          invoker_toolchain_args.current_os

      # We want to instrument everything if there is no input file set.
      # If there is a file we need to give it to the wrapper script so it can
      # instrument only those files.
      if (toolchain_coverage_instrumentation_input_file != "") {
        _coverage_wrapper =
            _coverage_wrapper + " --files-to-instrument=" +
            rebase_path(toolchain_coverage_instrumentation_input_file,
                        root_build_dir)
      }
      compiler_prefix =
          "\"$python_path\" ${_coverage_wrapper} " + compiler_prefix
    }

    cc = compiler_prefix + invoker.cc
    cxx = compiler_prefix + invoker.cxx

    # "asm" doesn't support any of toolchain_cc_wrapper and
    # toolchain_uses_reclient. The coverage flags are also nonsensical on
    # assembler runs.
    asm = invoker.cc
    ar = invoker.ar
    ld = invoker.ld
    if (defined(invoker.readelf)) {
      readelf = invoker.readelf
    } else {
      readelf = "readelf"
    }
    if (defined(invoker.nm)) {
      nm = invoker.nm
    } else {
      nm = "nm"
    }
    if (defined(invoker.dwp)) {
      dwp_switch = " --dwp=\"${invoker.dwp}\""
    } else {
      dwp_switch = ""
    }

    if (defined(invoker.shlib_extension)) {
      default_shlib_extension = invoker.shlib_extension
    } else {
      default_shlib_extension = shlib_extension
    }

    if (defined(invoker.default_shlib_subdir)) {
      default_shlib_subdir = invoker.default_shlib_subdir
    } else {
      default_shlib_subdir = ""
    }

    if (defined(invoker.executable_extension)) {
      default_executable_extension = invoker.executable_extension
    } else {
      default_executable_extension = ""
    }

    # Bring these into our scope for string interpolation with default values.
    if (defined(invoker.extra_cflags) && invoker.extra_cflags != "") {
      extra_cflags = " " + invoker.extra_cflags
    } else {
      extra_cflags = ""
    }

    if (defined(invoker.extra_cppflags) && invoker.extra_cppflags != "") {
      extra_cppflags = " " + invoker.extra_cppflags
    } else {
      extra_cppflags = ""
    }

    if (defined(invoker.extra_cxxflags) && invoker.extra_cxxflags != "") {
      extra_cxxflags = " " + invoker.extra_cxxflags
    } else {
      extra_cxxflags = ""
    }

    if (defined(invoker.extra_asmflags) && invoker.extra_asmflags != "") {
      extra_asmflags = " " + invoker.extra_asmflags
    } else {
      extra_asmflags = ""
    }

    if (defined(invoker.extra_ldflags) && invoker.extra_ldflags != "") {
      extra_ldflags = " " + invoker.extra_ldflags
    } else {
      extra_ldflags = ""
    }

    if (system_headers_in_deps) {
      md = "-MD"
    } else {
      md = "-MMD"
    }

    enable_linker_map = defined(invoker.enable_linker_map) &&
                        invoker.enable_linker_map && generate_linker_map

    # These library switches can apply to all tools below.
    lib_switch = "-l"
    lib_dir_switch = "-L"

    # Object files go in this directory.
    object_subdir = "{{target_out_dir}}/{{label_name}}"

    tool("cc") {
      depfile = "{{output}}.d"
      precompiled_header_type = "gcc"
      command = "$cc $md -MF $depfile ${rebuild_string}{{defines}} {{include_dirs}} {{cflags}} {{cflags_c}}${extra_cppflags}${extra_cflags} -c {{source}} -o {{output}}"
      depsformat = "gcc"
      description = "CC {{output}}"
      outputs = [ "$object_subdir/{{source_name_part}}.o" ]
    }

    tool("cxx") {
      depfile = "{{output}}.d"
      precompiled_header_type = "gcc"
      command = "$cxx $md -MF $depfile ${rebuild_string}{{defines}} {{include_dirs}} {{cflags}} {{cflags_cc}}${extra_cppflags}${extra_cxxflags} {{module_deps_no_self}} -c {{source}} -o {{output}}"
      depsformat = "gcc"
      description = "CXX {{output}}"
      outputs = [ "$object_subdir/{{source_name_part}}.o" ]
    }

    tool("cxx_module") {
      depfile = "{{output}}.d"
      command = "$cxx -MD -MF $depfile ${rebuild_string}{{defines}} {{include_dirs}} {{cflags}} {{cflags_cc}}${extra_cppflags}${extra_cxxflags} {{module_deps_no_self}} -fmodule-name={{label_name}} -c -x c++ -Xclang -emit-module {{source}} -o {{output}}"
      depsformat = "gcc"
      description = "CXX_MODULE {{output}}"
      outputs = [ "$object_subdir/{{source_name_part}}.pcm" ]
    }

    tool("asm") {
      # For GCC we can just use the C compiler to compile assembly.
      depfile = "{{output}}.d"
      command = "$asm $md -MF $depfile ${rebuild_string}{{defines}} {{include_dirs}} {{asmflags}}${extra_asmflags} -c {{source}} -o {{output}}"
      depsformat = "gcc"
      description = "ASM {{output}}"
      outputs = [ "$object_subdir/{{source_name_part}}.o" ]
    }

    tool("alink") {
      if (current_os == "aix") {
        # AIX does not support either -D (deterministic output) or response
        # files.
        command = "$ar -X64 {{arflags}} -r -c {{output}} {{inputs}}"
      } else {
        rspfile = "{{output}}.rsp"
        rspfile_content = "{{inputs}}"
        command = "\"$ar\" {{arflags}} -r -c -D {{output}} @\"$rspfile\""
      }

      # Remove the output file first so that ar doesn't try to modify the
      # existing file.
      if (host_os == "win") {
        tool_wrapper_path =
            rebase_path("//build/toolchain/win/tool_wrapper.py", root_build_dir)
        command = "cmd /s /c \"\"$python_path\" $tool_wrapper_path delete-file {{output}} && $command\""
      } else {
        command = "rm -f {{output}} && $command"
      }

      # Almost all targets build with //build/config/compiler:thin_archive which
      # adds -T -S to arflags.
      description = "AR {{output}}"
      outputs = [ "{{output_dir}}/{{target_output_name}}{{output_extension}}" ]

      # Static libraries go in the target out directory by default so we can
      # generate different targets with the same name and not have them collide.
      default_output_dir = "{{target_out_dir}}"
      default_output_extension = ".a"
      output_prefix = "lib"
    }

    tool("solink") {
      soname = "{{target_output_name}}{{output_extension}}"  # e.g. "libfoo.so".
      sofile = "{{output_dir}}/$soname"  # Possibly including toolchain dir.
      rspfile = sofile + ".rsp"

      pool = "//build/toolchain:link_pool($default_toolchain)"

      if (defined(invoker.strip)) {
        unstripped_sofile = "{{root_out_dir}}/lib.unstripped/$soname"
      } else {
        unstripped_sofile = sofile
      }

      # These variables are not built into GN but are helpers that
      # implement (1) linking to produce a .so, (2) extracting the symbols
      # from that file (3) if the extracted list differs from the existing
      # .TOC file, overwrite it, otherwise, don't change it.
      tocfile = sofile + ".TOC"

      soname_flag = ""
      if (current_os != "aix") {
        # -soname flag is not available on aix ld
        soname_flag = "-Wl,-soname=\"$soname\""
      }
      link_command = "$ld -shared $soname_flag {{ldflags}}${extra_ldflags} -o \"$unstripped_sofile\" @\"$rspfile\" {{rlibs}}"

      # Generate a map file to be used for binary size analysis.
      # Map file adds ~10% to the link time on a z620.
      # With target_os="android", libchrome.so.map.gz is ~20MB.
      map_switch = ""
      if (enable_linker_map) {
        map_file = "$unstripped_sofile.map.gz"
        map_switch = " --map-file \"$map_file\""
      }

      assert(defined(readelf), "to solink you must have a readelf")
      assert(defined(nm), "to solink you must have an nm")
      strip_switch = ""
      if (defined(invoker.strip)) {
        strip_switch = "--strip=${invoker.strip} "
      }

      # This needs a Python script to avoid using a complex shell command
      # requiring sh control structures, pipelines, and POSIX utilities.
      # The host might not have a POSIX shell and utilities (e.g. Windows).
      solink_wrapper =
          rebase_path("//build/toolchain/gcc_solink_wrapper.py", root_build_dir)
      solink_extra_flags = ""
      if (current_os == "aix") {
        # to be intercepted by solink_wrapper, so that we exit immediately
        # after linking the shared object, without generating the TOC file
        # (skipped on Aix)
        solink_extra_flags = "--partitioned-library"
      }
      command = "\"$python_path\" \"$solink_wrapper\" --readelf=\"$readelf\" --nm=\"$nm\" $strip_switch$dwp_switch --sofile=\"$unstripped_sofile\" --tocfile=\"$tocfile\"$map_switch --output=\"$sofile\" -- $link_command $solink_extra_flags"

      if (target_cpu == "mipsel" && is_component_build && is_android) {
        rspfile_content = "-Wl,--start-group -Wl,--whole-archive {{inputs}} {{solibs}} -Wl,--no-whole-archive {{libs}} -Wl,--end-group"
      } else if (current_os == "aix") {
        # --whole-archive, --no-whole-archive flags are not available on the aix
        # ld.
        rspfile_content = "{{inputs}} {{solibs}} {{libs}}"
      } else {
        rspfile_content = "-Wl,--whole-archive {{inputs}} {{solibs}} -Wl,--no-whole-archive {{libs}}"
      }

      description = "SOLINK $sofile"

      # Use this for {{output_extension}} expansions unless a target manually
      # overrides it (in which case {{output_extension}} will be what the target
      # specifies).
      default_output_extension = default_shlib_extension

      default_output_dir = "{{root_out_dir}}${default_shlib_subdir}"

      output_prefix = "lib"

      # Since the above commands only updates the .TOC file when it changes, ask
      # Ninja to check if the timestamp actually changed to know if downstream
      # dependencies should be recompiled.
      restat = true

      # Tell GN about the output files. It will link to the sofile but use the
      # tocfile for dependency management.
      outputs = [
        sofile,
        tocfile,
      ]
      if (sofile != unstripped_sofile) {
        outputs += [ unstripped_sofile ]
        if (defined(invoker.use_unstripped_as_runtime_outputs) &&
            invoker.use_unstripped_as_runtime_outputs) {
          runtime_outputs = [ unstripped_sofile ]
        }
      }

      # Clank build will generate DWP files when Fission is used.
      # Other builds generate DWP files outside of the gn link targets, if at
      # all.
      if (defined(invoker.dwp)) {
        outputs += [ unstripped_sofile + ".dwp" ]
        if (defined(invoker.use_unstripped_as_runtime_outputs) &&
            invoker.use_unstripped_as_runtime_outputs) {
          runtime_outputs += [ unstripped_sofile + ".dwp" ]
        }
      }
      if (defined(map_file)) {
        outputs += [ map_file ]
      }
      link_output = sofile
      depend_output = tocfile
    }

    tool("solink_module") {
      soname = "{{target_output_name}}{{output_extension}}"  # e.g. "libfoo.so".
      sofile = "{{output_dir}}/$soname"
      rspfile = sofile + ".rsp"

      pool = "//build/toolchain:link_pool($default_toolchain)"

      if (defined(invoker.strip)) {
        unstripped_sofile = "{{root_out_dir}}/lib.unstripped/$soname"
      } else {
        unstripped_sofile = sofile
      }

      soname_flag = ""
      whole_archive_flag = ""
      no_whole_archive_flag = ""
      if (current_os != "aix") {
        # -soname, --whole-archive, --no-whole-archive flags are not available
        # on aix ld
        soname_flag = "-Wl,-soname=\"$soname\""
        whole_archive_flag = "-Wl,--whole-archive"
        no_whole_archive_flag = "-Wl,--no-whole-archive"
      }
      command = "$ld -shared {{ldflags}}${extra_ldflags} -o \"$unstripped_sofile\" $soname_flag @\"$rspfile\""

      if (defined(invoker.strip)) {
        strip_command = "${invoker.strip} -o \"$sofile\" \"$unstripped_sofile\""
        command += " && " + strip_command
      }
      rspfile_content = "$whole_archive_flag {{inputs}} {{solibs}} $no_whole_archive_flag {{libs}} {{rlibs}}"

      description = "SOLINK_MODULE $sofile"

      # Use this for {{output_extension}} expansions unless a target manually
      # overrides it (in which case {{output_extension}} will be what the target
      # specifies).
      if (defined(invoker.loadable_module_extension)) {
        default_output_extension = invoker.loadable_module_extension
      } else {
        default_output_extension = default_shlib_extension
      }

      default_output_dir = "{{root_out_dir}}${default_shlib_subdir}"

      output_prefix = "lib"

      outputs = [ sofile ]
      if (sofile != unstripped_sofile) {
        outputs += [ unstripped_sofile ]
        if (defined(invoker.use_unstripped_as_runtime_outputs) &&
            invoker.use_unstripped_as_runtime_outputs) {
          runtime_outputs = [ unstripped_sofile ]
        }
      }
    }

    tool("link") {
      exename = "{{target_output_name}}{{output_extension}}"
      outfile = "{{output_dir}}/$exename"
      rspfile = "$outfile.rsp"
      unstripped_outfile = outfile

      pool = "//build/toolchain:link_pool($default_toolchain)"

      # Use this for {{output_extension}} expansions unless a target manually
      # overrides it (in which case {{output_extension}} will be what the target
      # specifies).
      default_output_extension = default_executable_extension

      default_output_dir = "{{root_out_dir}}"

      if (defined(invoker.strip)) {
        unstripped_outfile = "{{root_out_dir}}/exe.unstripped/$exename"
      }

      start_group_flag = ""
      end_group_flag = ""
      if (current_os != "aix") {
        # the "--start-group .. --end-group" feature isn't available on the aix
        # ld.
        start_group_flag = "-Wl,--start-group"
        end_group_flag = "-Wl,--end-group "
      }

      # We need to specify link groups, at least, for single pass linkers. I.e.
      # Rust libraries are alpha-sorted instead of by dependencies so they fail
      # to link if not properly ordered or grouped.
      link_command = "$ld {{ldflags}}${extra_ldflags} -o \"$unstripped_outfile\" $start_group_flag @\"$rspfile\" $end_group_flag {{solibs}} {{libs}} $start_group_flag {{rlibs}} $end_group_flag"

      # Generate a map file to be used for binary size analysis.
      # Map file adds ~10% to the link time on a z620.
      # With target_os="android", libchrome.so.map.gz is ~20MB.
      map_switch = ""
      if (enable_linker_map) {
        map_file = "$unstripped_outfile.map.gz"
        map_switch = " --map-file \"$map_file\""
      }

      strip_switch = ""
      if (defined(invoker.strip)) {
        strip_switch = " --strip=\"${invoker.strip}\" --unstripped-file=\"$unstripped_outfile\""
      }

      link_wrapper =
          rebase_path("//build/toolchain/gcc_link_wrapper.py", root_build_dir)
      command = "\"$python_path\" \"$link_wrapper\" --output=\"$outfile\"$strip_switch$map_switch$dwp_switch -- $link_command"

      description = "LINK $outfile"

      rspfile_content = "{{inputs}}"
      outputs = [ outfile ]
      if (outfile != unstripped_outfile) {
        outputs += [ unstripped_outfile ]
        if (defined(invoker.use_unstripped_as_runtime_outputs) &&
            invoker.use_unstripped_as_runtime_outputs) {
          runtime_outputs = [ unstripped_outfile ]
        }
      }

      # Clank build will generate DWP files when Fission is used.
      # Other builds generate DWP files outside of the gn link targets, if at
      # all.
      if (defined(invoker.dwp)) {
        outputs += [ unstripped_outfile + ".dwp" ]
        if (defined(invoker.use_unstripped_as_runtime_outputs) &&
            invoker.use_unstripped_as_runtime_outputs) {
          runtime_outputs += [ unstripped_outfile + ".dwp" ]
        }
      }
      if (defined(invoker.link_outputs)) {
        outputs += invoker.link_outputs
      }
      if (defined(map_file)) {
        outputs += [ map_file ]
      }
    }

    # These two are really entirely generic, but have to be repeated in
    # each toolchain because GN doesn't allow a template to be used here.
    # See //build/toolchain/toolchain.gni for details.
    tool("stamp") {
      command = stamp_command
      description = stamp_description
    }
    tool("copy") {
      command = copy_command
      description = copy_description
    }

    tool("action") {
      pool = "//build/toolchain:action_pool($default_toolchain)"
    }

    if (toolchain_has_rust) {
      if (!defined(rust_compiler_prefix)) {
        rust_compiler_prefix = ""
      }
      rust_sysroot_relative = rebase_path(rust_sysroot, root_build_dir)
      rustc_bin = "$rust_sysroot_relative/bin/rustc"
      rustc = "$rust_compiler_prefix${rustc_bin}"
      rustc_wrapper =
          rebase_path("//build/rust/rustc_wrapper.py", root_build_dir)

      # RSP manipulation due to https://bugs.chromium.org/p/gn/issues/detail?id=249
      tool("rust_staticlib") {
        libname = "{{output_dir}}/{{target_output_name}}{{output_extension}}"
        rspfile = "$libname.rsp"
        depfile = "$libname.d"

        default_output_extension = ".a"
        output_prefix = "lib"

        # Static libraries go in the target out directory by default so we can
        # generate different targets with the same name and not have them
        # collide.
        default_output_dir = "{{target_out_dir}}"
        description = "RUST(STATICLIB) {{output}}"
        outputs = [ libname ]

        rspfile_content = "{{rustdeps}} {{externs}} SOURCES {{sources}}"
        command = "\"$python_path\" \"$rustc_wrapper\" --rustc=$rustc --depfile=$depfile --rsp=$rspfile -- -Clinker=\"${invoker.cxx}\" $rustc_common_args --emit=dep-info=$depfile,link -o $libname LDFLAGS RUSTENV {{rustenv}}"
        rust_sysroot = rust_sysroot_relative
      }

      tool("rust_rlib") {
        # We must always prefix with `lib` even if the library already starts
        # with that prefix or else our stdlib is unable to find libc.rlib (or
        # actually liblibc.rlib).
        rlibname =
            "{{output_dir}}/lib{{target_output_name}}{{output_extension}}"
        rspfile = "$rlibname.rsp"
        depfile = "$rlibname.d"

        default_output_extension = ".rlib"

        # This is prefixed unconditionally in `rlibname`.
        # output_prefix = "lib"
        # Static libraries go in the target out directory by default so we can
        # generate different targets with the same name and not have them
        # collide.
        default_output_dir = "{{target_out_dir}}"
        description = "RUST {{output}}"
        outputs = [ rlibname ]

        rspfile_content = "{{rustdeps}} {{externs}} SOURCES {{sources}}"
        command = "\"$python_path\" \"$rustc_wrapper\" --rustc=$rustc --depfile=$depfile --rsp=$rspfile -- -Clinker=\"${invoker.cxx}\" $rustc_common_args --emit=dep-info=$depfile,link -o $rlibname LDFLAGS RUSTENV {{rustenv}}"
        rust_sysroot = rust_sysroot_relative
      }

      tool("rust_bin") {
        exename = "{{output_dir}}/{{target_output_name}}{{output_extension}}"
        depfile = "$exename.d"
        rspfile = "$exename.rsp"
        pool = "//build/toolchain:link_pool($default_toolchain)"

        default_output_extension = default_executable_extension
        default_output_dir = "{{root_out_dir}}"
        description = "RUST(BIN) {{output}}"
        outputs = [ exename ]

        rspfile_content = "{{rustdeps}} {{externs}} SOURCES {{sources}}"
        command = "\"$python_path\" \"$rustc_wrapper\" --rustc=$rustc --depfile=$depfile --rsp=$rspfile -- -Clinker=\"${invoker.cxx}\" $rustc_common_args --emit=dep-info=$depfile,link -o $exename LDFLAGS {{ldflags}} ${extra_ldflags} RUSTENV {{rustenv}}"
        rust_sysroot = rust_sysroot_relative
      }

      tool("rust_cdylib") {
        dllname = "{{output_dir}}/{{target_output_name}}{{output_extension}}"
        depfile = "$dllname.d"
        rspfile = "$dllname.rsp"
        pool = "//build/toolchain:link_pool($default_toolchain)"

        default_output_extension = default_shlib_extension
        output_prefix = "lib"
        default_output_dir = "{{root_out_dir}}${default_shlib_subdir}"
        description = "RUST(CDYLIB) {{output}}"
        outputs = [ dllname ]

        rspfile_content = "{{rustdeps}} {{externs}} SOURCES {{sources}}"
        command = "\"$python_path\" \"$rustc_wrapper\" --rustc=$rustc --depfile=$depfile --rsp=$rspfile -- -Clinker=\"${invoker.cxx}\" $rustc_common_args --emit=dep-info=$depfile,link -o $dllname LDFLAGS {{ldflags}} ${extra_ldflags} RUSTENV {{rustenv}}"
        rust_sysroot = rust_sysroot_relative
      }

      tool("rust_macro") {
        dllname = "{{output_dir}}/{{target_output_name}}{{output_extension}}"
        depfile = "$dllname.d"
        rspfile = "$dllname.rsp"
        pool = "//build/toolchain:link_pool($default_toolchain)"

        default_output_extension = default_shlib_extension
        output_prefix = "lib"
        default_output_dir = "{{root_out_dir}}${default_shlib_subdir}"
        description = "RUST(MACRO) {{output}}"
        outputs = [ dllname ]

        rspfile_content = "{{rustdeps}} {{externs}} SOURCES {{sources}}"
        command = "\"$python_path\" \"$rustc_wrapper\" --rustc=$rustc --depfile=$depfile --rsp=$rspfile -- -Clinker=\"${invoker.cxx}\" $rustc_common_args --emit=dep-info=$depfile,link -o $dllname LDFLAGS {{ldflags}} ${extra_ldflags} RUSTENV {{rustenv}}"
        rust_sysroot = rust_sysroot_relative
      }
    }

    forward_variables_from(invoker,
                           [
                             "deps",
                             "propagates_configs",
                           ])
  }
}

# Make an additional toolchain which is used for making tools that are run
# on the host machine as part of the build process (such as proc macros
# and Cargo build scripts). This toolchain uses the prebuilt stdlib that
# comes with the compiler, so it doesn't have to wait for the stdlib to be
# built before building other stuff. And this ensures its proc macro
# outputs have the right ABI to be loaded by the compiler, and it can be
# used to compile build scripts that are part of the stdlib that is built
# for the default toolchain.
template("gcc_rust_host_build_tools_toolchain") {
  single_gcc_toolchain(target_name) {
    assert(defined(invoker.toolchain_args),
           "Toolchains must declare toolchain_args")
    forward_variables_from(invoker,
                           "*",
                           TESTONLY_AND_VISIBILITY + [ "toolchain_args" ])
    toolchain_args = {
      # Populate toolchain args from the invoker.
      forward_variables_from(invoker.toolchain_args, "*")
      toolchain_for_rust_host_build_tools = true

      # The host build tools are static release builds to make the Chromium
      # build faster.
      is_debug = false
      is_component_build = false
      is_official_build = false
      use_clang_coverage = false
      use_sanitizer_coverage = false
      generate_linker_map = false
      use_thin_lto = false
    }

    # When cross-compiling we don't want to use the target platform's file
    # extensions.
    shlib_extension = host_shlib_extension
  }
}

# If PartitionAlloc is part of the build (even as a transitive dependency), then
# it replaces the system allocator. If this toolchain is used, that will be
# overridden and the system allocator will be used regardless. This is important
# in some third-party binaries outside of Chrome.
template("gcc_system_allocator_toolchain") {
  single_gcc_toolchain(target_name) {
    assert(defined(invoker.toolchain_args),
           "Toolchains must declare toolchain_args")
    forward_variables_from(invoker,
                           "*",
                           TESTONLY_AND_VISIBILITY + [ "toolchain_args" ])
    toolchain_args = {
      # Populate toolchain args from the invoker.
      forward_variables_from(invoker.toolchain_args, "*")
      toolchain_allows_use_partition_alloc_as_malloc = false

      # Disable component build so that we can copy the exes to the
      # root_build_dir and support the default_toolchain redirection on Windows.
      # See also the comment in //build/symlink.gni.
      is_component_build = false

      # Only one toolchain can be configured with MSAN support with our current
      # GN setup, or they all try to make the instrumented libraries and
      # collide.
      is_msan = false
    }
  }
}

# Makes a GCC toolchain for the target, and an equivalent toolchain with the
# prebuilt Rust stdlib for building proc macros (and other for-build-use
# artifacts).
template("gcc_toolchain") {
  single_gcc_toolchain(target_name) {
    assert(defined(invoker.toolchain_args),
           "Toolchains must declare toolchain_args")
    forward_variables_from(invoker, "*", TESTONLY_AND_VISIBILITY)

    # No need to forward visibility and test_only as they apply to targets not
    # toolchains, but presubmit checks require that we explicitly exclude them
  }

  gcc_rust_host_build_tools_toolchain(
      "${target_name}_for_rust_host_build_tools") {
    assert(defined(invoker.toolchain_args),
           "Toolchains must declare toolchain_args")
    forward_variables_from(invoker, "*", TESTONLY_AND_VISIBILITY)
  }

  gcc_system_allocator_toolchain("${target_name}_host_with_system_allocator") {
    assert(defined(invoker.toolchain_args),
           "Toolchains must declare toolchain_args")
    forward_variables_from(invoker, "*", TESTONLY_AND_VISIBILITY)
  }
  gcc_system_allocator_toolchain("${target_name}_with_system_allocator") {
    assert(defined(invoker.toolchain_args),
           "Toolchains must declare toolchain_args")
    forward_variables_from(invoker, "*", TESTONLY_AND_VISIBILITY)
  }
}

# This is a shorthand for gcc_toolchain instances based on the Chromium-built
# version of Clang. Only the toolchain_cpu and toolchain_os variables need to
# be specified by the invoker, and optionally toolprefix if it's a
# cross-compile case. Note that for a cross-compile case this toolchain
# requires a config to pass the appropriate -target option, or else it will
# actually just be doing a native compile.
template("clang_toolchain") {
  gcc_toolchain(target_name) {
    _path = "$clang_base_path/bin"
    _is_path_absolute = get_path_info(_path, "abspath") == _path

    # Preserve absolute paths for tools like distcc.
    if (_is_path_absolute && filter_include([ _path ], [ "//*" ]) == []) {
      prefix = _path
    } else {
      prefix = rebase_path(_path, root_build_dir)
    }

    cc = "${prefix}/clang"
    cxx = "${prefix}/clang++"
    ld = cxx
    readelf = "${prefix}/llvm-readelf"
    ar = "${prefix}/llvm-ar"
    nm = "${prefix}/llvm-nm"

    forward_variables_from(invoker, "*", [ "toolchain_args" ])

    toolchain_args = {
      if (defined(invoker.toolchain_args)) {
        forward_variables_from(invoker.toolchain_args, "*")
      }
      is_clang = true
    }
  }
}
