1*6777b538SAndroid Build Coastguard Worker# Copyright 2023 The Chromium Authors 2*6777b538SAndroid Build Coastguard Worker# Use of this source code is governed by a BSD-style license that can be 3*6777b538SAndroid Build Coastguard Worker# found in the LICENSE file. 4*6777b538SAndroid Build Coastguard Worker 5*6777b538SAndroid Build Coastguard Worker# Provides per-crate and overall configuration options to gnrt. 6*6777b538SAndroid Build Coastguard Worker# 7*6777b538SAndroid Build Coastguard Worker# Most commonly needed configuration options can be found in the top-level doc 8*6777b538SAndroid Build Coastguard Worker# comment in //third_party/rust/chromium_crates_io/gnrt_config.toml. As a 9*6777b538SAndroid Build Coastguard Worker# fallback, one may also read the doc comments in 10*6777b538SAndroid Build Coastguard Worker# `//tools/crates/gnrt/lib/config.rs` (e.g. `CrateConfig`'s fields correspond 11*6777b538SAndroid Build Coastguard Worker# to per-crate options). 12*6777b538SAndroid Build Coastguard Worker 13*6777b538SAndroid Build Coastguard Worker[resolve] 14*6777b538SAndroid Build Coastguard Worker# There is a virtual "sysroot" crate that includes all sysroot libraries as 15*6777b538SAndroid Build Coastguard Worker# dependencies. 16*6777b538SAndroid Build Coastguard Workerroot = "sysroot" 17*6777b538SAndroid Build Coastguard Worker 18*6777b538SAndroid Build Coastguard Worker# Workaround for Cargo issue: hashbrown's Cargo.toml uses an unstable Cargo 19*6777b538SAndroid Build Coastguard Worker# feature that leads to incorrect `cargo metadata` output. 20*6777b538SAndroid Build Coastguard Worker# 21*6777b538SAndroid Build Coastguard Worker# TODO(https://github.com/rust-lang/cargo/issues/10801): remove workaround once 22*6777b538SAndroid Build Coastguard Worker# issue is fixed. 23*6777b538SAndroid Build Coastguard Workerremove_crates = ['allocator-api2'] 24*6777b538SAndroid Build Coastguard Worker 25*6777b538SAndroid Build Coastguard Worker[gn] 26*6777b538SAndroid Build Coastguard Workerbuild_file_template = "BUILD.gn.hbs" 27*6777b538SAndroid Build Coastguard Worker 28*6777b538SAndroid Build Coastguard Worker[all-crates] 29*6777b538SAndroid Build Coastguard Worker# std crates should have metadata applied to them. This would avoid any symbol 30*6777b538SAndroid Build Coastguard Worker# conflicts between std dependencies and third_party/rust crates. 31*6777b538SAndroid Build Coastguard Worker# 32*6777b538SAndroid Build Coastguard Worker# However, we can't apply it yet. GN can't automatically clean old artifacts, 33*6777b538SAndroid Build Coastguard Worker# nor can we delete and rebuild the sysroot on every build. 34*6777b538SAndroid Build Coastguard Worker# 35*6777b538SAndroid Build Coastguard Worker# TODO(crbug.com/1245714): set up GN rules to rebuilt the sysroot only when 36*6777b538SAndroid Build Coastguard Worker# needed. Then set this metadata. 37*6777b538SAndroid Build Coastguard Worker# 38*6777b538SAndroid Build Coastguard Worker# rustc_metadata = "libstd" 39*6777b538SAndroid Build Coastguard Worker 40*6777b538SAndroid Build Coastguard Workerextra_kv = { include_coverage = true } 41*6777b538SAndroid Build Coastguard Worker 42*6777b538SAndroid Build Coastguard Worker[crate.compiler_builtins] 43*6777b538SAndroid Build Coastguard Worker# Dependencies of profiler_builtins must have instrumentation disabled 44*6777b538SAndroid Build Coastguard Worker# The build script conditionally generates a file; it's simplest to just paste 45*6777b538SAndroid Build Coastguard Worker# raw GN into the output. (crbug.com/1470653) 46*6777b538SAndroid Build Coastguard Workerextra_kv = { include_coverage = false, raw_gn = 'if (current_cpu == "arm64") { build_script_outputs = ["outlined_atomics.rs"] }' } 47*6777b538SAndroid Build Coastguard Worker 48*6777b538SAndroid Build Coastguard Worker# compiler_builtins depends on libm on windows crbug.com/1472681 49*6777b538SAndroid Build Coastguard Workerextra_src_roots = ['../libm'] 50*6777b538SAndroid Build Coastguard Worker 51*6777b538SAndroid Build Coastguard Worker[crate.core] 52*6777b538SAndroid Build Coastguard Worker# Dependencies of profiler_builtins must have instrumentation disabled 53*6777b538SAndroid Build Coastguard Workerextra_kv = { include_coverage = false, immediate_abort = true } 54*6777b538SAndroid Build Coastguard Workerextra_src_roots = ['../../portable-simd/crates/core_simd', '../../stdarch/crates/core_arch'] 55*6777b538SAndroid Build Coastguard Worker 56*6777b538SAndroid Build Coastguard Worker[crate.hashbrown] 57*6777b538SAndroid Build Coastguard Worker# Workaround for Cargo issue: hashbrown's Cargo.toml uses an unstable Cargo 58*6777b538SAndroid Build Coastguard Worker# feature that leads to incorrect `cargo metadata` output. 59*6777b538SAndroid Build Coastguard Worker# 60*6777b538SAndroid Build Coastguard Worker# TODO(https://github.com/rust-lang/cargo/issues/10801): remove workaround once 61*6777b538SAndroid Build Coastguard Worker# issue is fixed. 62*6777b538SAndroid Build Coastguard Workerremove_deps = ['allocator-api2'] 63*6777b538SAndroid Build Coastguard Worker 64*6777b538SAndroid Build Coastguard Worker[crate.libc] 65*6777b538SAndroid Build Coastguard Worker# This target is #[no_core] when included by std, which is incompatible with 66*6777b538SAndroid Build Coastguard Worker# profiling. 67*6777b538SAndroid Build Coastguard Worker# 68*6777b538SAndroid Build Coastguard Worker# Suppress link directives since we specify the deps in GN configs. 69*6777b538SAndroid Build Coastguard Workerextra_kv = { include_coverage = false, no_link_directives = true } 70*6777b538SAndroid Build Coastguard Worker 71*6777b538SAndroid Build Coastguard Worker[crate.profiler_builtins] 72*6777b538SAndroid Build Coastguard Worker# The build script is used to compile a profiler-rt library, but we get 73*6777b538SAndroid Build Coastguard Worker# the profiler rt library from clang, so we skip this. 74*6777b538SAndroid Build Coastguard Worker# 75*6777b538SAndroid Build Coastguard Worker# profiler_builtins cannot depend on itself, which it would if build with 76*6777b538SAndroid Build Coastguard Worker# instrumentation. 77*6777b538SAndroid Build Coastguard Workerextra_kv = { include_coverage = false, skip_build_rs = true } 78*6777b538SAndroid Build Coastguard Worker 79*6777b538SAndroid Build Coastguard Worker[crate.rustc-std-workspace-alloc] 80*6777b538SAndroid Build Coastguard Worker# This target is #[no_core] which is incompatible with profiling. 81*6777b538SAndroid Build Coastguard Workerextra_kv = { include_coverage = false } 82*6777b538SAndroid Build Coastguard Worker 83*6777b538SAndroid Build Coastguard Worker[crate.rustc-std-workspace-core] 84*6777b538SAndroid Build Coastguard Worker# Dependencies of profiler_builtins must have instrumentation disabled 85*6777b538SAndroid Build Coastguard Workerextra_kv = { include_coverage = false } 86*6777b538SAndroid Build Coastguard Worker 87*6777b538SAndroid Build Coastguard Worker[crate.std] 88*6777b538SAndroid Build Coastguard Workerextra_src_roots = ['../../backtrace/src', '../../portable-simd/crates/std_float/src', '../../core/src/primitive_docs.rs'] 89*6777b538SAndroid Build Coastguard Workerextra_input_roots = [ '../../portable-simd/crates/core_simd/src', '../../stdarch/crates/core_arch/src', '../../core/src'] 90*6777b538SAndroid Build Coastguard Worker 91*6777b538SAndroid Build Coastguard Worker# Remove this from std. It will be depended on directly when needed. 92*6777b538SAndroid Build Coastguard Workerexclude_deps_in_gn = ['profiler_builtins'] 93*6777b538SAndroid Build Coastguard Worker 94*6777b538SAndroid Build Coastguard Workerextra_kv = { immediate_abort = true } 95*6777b538SAndroid Build Coastguard Worker 96*6777b538SAndroid Build Coastguard Worker[crate.test] 97*6777b538SAndroid Build Coastguard Worker# test only depends on proc_macro as an internal detail of the Rust build, so 98*6777b538SAndroid Build Coastguard Worker# it's implicitly included with std/test. However, we list the std crates and 99*6777b538SAndroid Build Coastguard Worker# construct the sysroot explicitly. We don't need this, and we don't even want 100*6777b538SAndroid Build Coastguard Worker# it during cross-compiles (since we will only build host proc_macro crates). 101*6777b538SAndroid Build Coastguard Workerexclude_deps_in_gn = ['proc_macro'] 102*6777b538SAndroid Build Coastguard Worker 103*6777b538SAndroid Build Coastguard Worker[crate.unwind] 104*6777b538SAndroid Build Coastguard Worker# The build script is used to set up the link directives which we skip below. 105*6777b538SAndroid Build Coastguard Worker# It uses `cc` to run a compiler to do so, which we don't support in build 106*6777b538SAndroid Build Coastguard Worker# scripts. 107*6777b538SAndroid Build Coastguard Worker# 108*6777b538SAndroid Build Coastguard Worker# Suppress link directives since we specify the deps in GN configs. 109*6777b538SAndroid Build Coastguard Workerextra_kv = { skip_build_rs = true, no_link_directives = true } 110