Skip to main content

bootstrap/core/config/toml/
pgo.rs

1//! This module defines the `Pgo` struct, which represents the `[pgo]` table
2//! in the `bootstrap.toml` configuration file.
3//!
4//! The `[pgo]` table contains options related PGO (Profile-Guided Optimization) of various
5//! components built by bootstrap.
6
7use serde::{Deserialize, Deserializer};
8
9use crate::core::config::Merge;
10use crate::core::config::toml::ReplaceOpt;
11use crate::{HashSet, PathBuf, define_config, exit};
12
13#[derive(Clone, Default, Debug, serde_derive::Deserialize)]
14#[serde(deny_unknown_fields)]
15pub struct PgoConfig {
16    /// Use the given PGO profile to optimize a component.
17    #[serde(default, rename = "use")]
18    pub use_profile: Option<PathBuf>,
19    /// Build a component with PGO instrumentation. Once executed, the profiles will be stored
20    /// into this path.
21    #[serde(default, rename = "generate")]
22    pub generate_profile: Option<PathBuf>,
23}
24
25define_config! {
26    #[derive(Default)]
27    struct Pgo {
28        rustc: Option<PgoConfig> = "rustc",
29        rustdoc: Option<PgoConfig> = "rustdoc",
30        cargo: Option<PgoConfig> = "cargo",
31        llvm: Option<PgoConfig> = "llvm",
32    }
33}