Add rust.lto config option

This commit is contained in:
Jakub Beránek 2022-09-29 16:28:57 +02:00
parent 32238ce1e2
commit cba16819a1
No known key found for this signature in database
GPG key ID: 909CD0D26483516B
4 changed files with 39 additions and 2 deletions

View file

@ -638,6 +638,11 @@ changelog-seen = 2
# If an explicit setting is given, it will be used for all parts of the codebase.
#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
#

View file

@ -21,7 +21,7 @@ use serde::Deserialize;
use crate::builder::Cargo;
use crate::builder::{Builder, Kind, RunConfig, ShouldRun, Step};
use crate::cache::{Interned, INTERNER};
use crate::config::{LlvmLibunwind, TargetSelection};
use crate::config::{LlvmLibunwind, RustcLto, TargetSelection};
use crate::dist;
use crate::native;
use crate::tool::SourceType;

View file

@ -158,6 +158,7 @@ pub struct Config {
pub rust_new_symbol_mangling: Option<bool>,
pub rust_profile_use: Option<String>,
pub rust_profile_generate: Option<String>,
pub rust_lto: RustcLto,
pub llvm_profile_use: Option<String>,
pub llvm_profile_generate: bool,
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)]
pub struct TargetSelection {
pub triple: Interned<String>,
@ -726,6 +749,7 @@ define_config! {
profile_use: Option<String> = "profile-use",
// ignored; this is set from an env var set by bootstrap.py
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_generate = flags.rust_profile_generate.or(rust.profile_generate);
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 {
config.rust_profile_use = flags.rust_profile_use;
config.rust_profile_generate = flags.rust_profile_generate;

View file

@ -78,7 +78,8 @@ ENV RUST_CONFIGURE_ARGS \
--set llvm.thin-lto=true \
--set llvm.ninja=false \
--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 \
--host $HOSTS --target $HOSTS \
--include-default-paths \