Add rust.lto
config option
This commit is contained in:
parent
32238ce1e2
commit
cba16819a1
4 changed files with 39 additions and 2 deletions
|
@ -638,6 +638,11 @@ changelog-seen = 2
|
||||||
# If an explicit setting is given, it will be used for all parts of the codebase.
|
# If an explicit setting is given, it will be used for all parts of the codebase.
|
||||||
#new-symbol-mangling = true|false (see comment)
|
#new-symbol-mangling = true|false (see comment)
|
||||||
|
|
||||||
|
# Select LTO mode that will be used for compiling rustc. By default, thin local LTO (LTO within a
|
||||||
|
# single crate) is used. You can also select "thin" or "fat" to apply Thin/Fat LTO on the
|
||||||
|
# `rustc_driver` dylib.
|
||||||
|
#lto = thin-local
|
||||||
|
|
||||||
# =============================================================================
|
# =============================================================================
|
||||||
# Options for specific targets
|
# Options for specific targets
|
||||||
#
|
#
|
||||||
|
|
|
@ -21,7 +21,7 @@ use serde::Deserialize;
|
||||||
use crate::builder::Cargo;
|
use crate::builder::Cargo;
|
||||||
use crate::builder::{Builder, Kind, RunConfig, ShouldRun, Step};
|
use crate::builder::{Builder, Kind, RunConfig, ShouldRun, Step};
|
||||||
use crate::cache::{Interned, INTERNER};
|
use crate::cache::{Interned, INTERNER};
|
||||||
use crate::config::{LlvmLibunwind, TargetSelection};
|
use crate::config::{LlvmLibunwind, RustcLto, TargetSelection};
|
||||||
use crate::dist;
|
use crate::dist;
|
||||||
use crate::native;
|
use crate::native;
|
||||||
use crate::tool::SourceType;
|
use crate::tool::SourceType;
|
||||||
|
|
|
@ -158,6 +158,7 @@ pub struct Config {
|
||||||
pub rust_new_symbol_mangling: Option<bool>,
|
pub rust_new_symbol_mangling: Option<bool>,
|
||||||
pub rust_profile_use: Option<String>,
|
pub rust_profile_use: Option<String>,
|
||||||
pub rust_profile_generate: Option<String>,
|
pub rust_profile_generate: Option<String>,
|
||||||
|
pub rust_lto: RustcLto,
|
||||||
pub llvm_profile_use: Option<String>,
|
pub llvm_profile_use: Option<String>,
|
||||||
pub llvm_profile_generate: bool,
|
pub llvm_profile_generate: bool,
|
||||||
pub llvm_libunwind_default: Option<LlvmLibunwind>,
|
pub llvm_libunwind_default: Option<LlvmLibunwind>,
|
||||||
|
@ -319,6 +320,28 @@ impl SplitDebuginfo {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// LTO mode used for compiling rustc itself.
|
||||||
|
#[derive(Default)]
|
||||||
|
pub enum RustcLto {
|
||||||
|
#[default]
|
||||||
|
ThinLocal,
|
||||||
|
Thin,
|
||||||
|
Fat
|
||||||
|
}
|
||||||
|
|
||||||
|
impl std::str::FromStr for RustcLto {
|
||||||
|
type Err = String;
|
||||||
|
|
||||||
|
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||||
|
match s {
|
||||||
|
"thin-local" => Ok(RustcLto::ThinLocal),
|
||||||
|
"thin" => Ok(RustcLto::Thin),
|
||||||
|
"fat" => Ok(RustcLto::Fat),
|
||||||
|
_ => Err(format!("Invalid value for rustc LTO: {}", s)),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Copy, Clone, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
#[derive(Copy, Clone, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||||
pub struct TargetSelection {
|
pub struct TargetSelection {
|
||||||
pub triple: Interned<String>,
|
pub triple: Interned<String>,
|
||||||
|
@ -726,6 +749,7 @@ define_config! {
|
||||||
profile_use: Option<String> = "profile-use",
|
profile_use: Option<String> = "profile-use",
|
||||||
// ignored; this is set from an env var set by bootstrap.py
|
// ignored; this is set from an env var set by bootstrap.py
|
||||||
download_rustc: Option<StringOrBool> = "download-rustc",
|
download_rustc: Option<StringOrBool> = "download-rustc",
|
||||||
|
lto: Option<String> = "lto",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1173,6 +1197,13 @@ impl Config {
|
||||||
config.rust_profile_use = flags.rust_profile_use.or(rust.profile_use);
|
config.rust_profile_use = flags.rust_profile_use.or(rust.profile_use);
|
||||||
config.rust_profile_generate = flags.rust_profile_generate.or(rust.profile_generate);
|
config.rust_profile_generate = flags.rust_profile_generate.or(rust.profile_generate);
|
||||||
config.download_rustc_commit = download_ci_rustc_commit(&config, rust.download_rustc);
|
config.download_rustc_commit = download_ci_rustc_commit(&config, rust.download_rustc);
|
||||||
|
|
||||||
|
config.rust_lto = rust
|
||||||
|
.lto
|
||||||
|
.as_deref()
|
||||||
|
.map(RustcLto::from_str)
|
||||||
|
.map(|v| v.expect("invalid value for rust.lto"))
|
||||||
|
.unwrap_or_default();
|
||||||
} else {
|
} else {
|
||||||
config.rust_profile_use = flags.rust_profile_use;
|
config.rust_profile_use = flags.rust_profile_use;
|
||||||
config.rust_profile_generate = flags.rust_profile_generate;
|
config.rust_profile_generate = flags.rust_profile_generate;
|
||||||
|
|
|
@ -78,7 +78,8 @@ ENV RUST_CONFIGURE_ARGS \
|
||||||
--set llvm.thin-lto=true \
|
--set llvm.thin-lto=true \
|
||||||
--set llvm.ninja=false \
|
--set llvm.ninja=false \
|
||||||
--set rust.jemalloc \
|
--set rust.jemalloc \
|
||||||
--set rust.use-lld=true
|
--set rust.use-lld=true \
|
||||||
|
--set rust.lto=thin
|
||||||
ENV SCRIPT ../src/ci/pgo.sh python3 ../x.py dist \
|
ENV SCRIPT ../src/ci/pgo.sh python3 ../x.py dist \
|
||||||
--host $HOSTS --target $HOSTS \
|
--host $HOSTS --target $HOSTS \
|
||||||
--include-default-paths \
|
--include-default-paths \
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue