blob: f99685bbad63ddac1cc26186a75c702314ca007c [file] [log] [blame]
# Copyright 2023 The Chromium Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# Provides per-crate and overall configuration options to gnrt.
#
# Most commonly needed configuration options can be found in the top-level doc
# comment in //third_party/rust/chromium_crates_io/gnrt_config.toml. As a
# fallback, one may also read the doc comments in
# `//tools/crates/gnrt/lib/config.rs` (e.g. `CrateConfig`'s fields correspond
# to per-crate options).
[resolve]
# There is a virtual "sysroot" crate that includes all sysroot libraries as
# dependencies.
root = "sysroot"
# Workaround for Cargo issue: hashbrown's Cargo.toml uses an unstable Cargo
# feature that leads to incorrect `cargo metadata` output.
#
# TODO(https://github.com/rust-lang/cargo/issues/10801): remove workaround once
# issue is fixed.
remove_crates = ['allocator-api2']
[gn]
build_file_template = "BUILD.gn.hbs"
[all-crates]
# std crates should have metadata applied to them. This would avoid any symbol
# conflicts between std dependencies and third_party/rust crates.
#
# However, we can't apply it yet. GN can't automatically clean old artifacts,
# nor can we delete and rebuild the sysroot on every build.
#
# TODO(crbug.com/1245714): set up GN rules to rebuilt the sysroot only when
# needed. Then set this metadata.
#
# rustc_metadata = "libstd"
extra_kv = { include_coverage = true }
[crate.compiler_builtins]
# Dependencies of profiler_builtins must have instrumentation disabled
# The build script conditionally generates a file; it's simplest to just paste
# raw GN into the output. (crbug.com/1470653)
extra_kv = { include_coverage = false, raw_gn = 'if (current_cpu == "arm64") { build_script_outputs = ["outlined_atomics.rs"] }' }
# compiler_builtins depends on libm on windows crbug.com/1472681
extra_src_roots = ['../libm']
[crate.core]
# Dependencies of profiler_builtins must have instrumentation disabled
extra_kv = { include_coverage = false, immediate_abort = true }
extra_src_roots = ['../../portable-simd/crates/core_simd', '../../stdarch/crates/core_arch']
[crate.hashbrown]
# Workaround for Cargo issue: hashbrown's Cargo.toml uses an unstable Cargo
# feature that leads to incorrect `cargo metadata` output.
#
# TODO(https://github.com/rust-lang/cargo/issues/10801): remove workaround once
# issue is fixed.
remove_deps = ['allocator-api2']
[crate.libc]
# This target is #[no_core] when included by std, which is incompatible with
# profiling.
#
# Suppress link directives since we specify the deps in GN configs.
extra_kv = { include_coverage = false, no_link_directives = true }
[crate.profiler_builtins]
# The build script is used to compile a profiler-rt library, but we get
# the profiler rt library from clang, so we skip this.
#
# profiler_builtins cannot depend on itself, which it would if build with
# instrumentation.
extra_kv = { include_coverage = false, skip_build_rs = true }
[crate.rustc-std-workspace-alloc]
# This target is #[no_core] which is incompatible with profiling.
extra_kv = { include_coverage = false }
[crate.rustc-std-workspace-core]
# Dependencies of profiler_builtins must have instrumentation disabled
extra_kv = { include_coverage = false }
[crate.std]
extra_src_roots = ['../../backtrace/src', '../../portable-simd/crates/std_float/src', '../../core/src/primitive_docs.rs']
extra_input_roots = [ '../../portable-simd/crates/core_simd/src', '../../stdarch/crates/core_arch/src', '../../core/src']
# Remove this from std. It will be depended on directly when needed.
exclude_deps_in_gn = ['profiler_builtins']
extra_kv = { immediate_abort = true }
[crate.test]
# test only depends on proc_macro as an internal detail of the Rust build, so
# it's implicitly included with std/test. However, we list the std crates and
# construct the sysroot explicitly. We don't need this, and we don't even want
# it during cross-compiles (since we will only build host proc_macro crates).
exclude_deps_in_gn = ['proc_macro']
[crate.unwind]
# The build script is used to set up the link directives which we skip below.
# It uses `cc` to run a compiler to do so, which we don't support in build
# scripts.
#
# Suppress link directives since we specify the deps in GN configs.
extra_kv = { skip_build_rs = true, no_link_directives = true }