Add PGO config for Cranelift

This commit is contained in:
Jakub Beránek
2026-10-02 12:54:37 +02:00
parent 4b9666a948
commit ef2ad40c3e
5 changed files with 14 additions and 0 deletions

View File

@@ -1038,6 +1038,11 @@
# Instrument LLVM, so that when executed, it will gather profiles # Instrument LLVM, so that when executed, it will gather profiles
# Note: for LLVM specifically, this should be a directory, not a file path. # Note: for LLVM specifically, this should be a directory, not a file path.
#pgo.llvm.generate = "/tmp/profiles" #pgo.llvm.generate = "/tmp/profiles"
# Use the following profile to PGO optimize the Cranelift codegen backend.
#pgo.cranelift.use = "/tmp/profiles/foo.profraw"
# Instrument the Cranelift codegen backend, so that when executed, it will gather profiles
# to this path.
#pgo.cranelift.generate = "/tmp/profiles/foo.profraw"
# ============================================================================= # =============================================================================
# Options for specific targets # Options for specific targets

View File

@@ -1796,6 +1796,7 @@ impl CommandLineStep for CraneliftCodegenBackend {
.arg("--manifest-path") .arg("--manifest-path")
.arg(builder.src.join("compiler/rustc_codegen_cranelift/Cargo.toml")); .arg(builder.src.join("compiler/rustc_codegen_cranelift/Cargo.toml"));
apply_dylib_lto(builder, &build_compiler, &mut cargo); apply_dylib_lto(builder, &build_compiler, &mut cargo);
apply_pgo(builder, &mut cargo, build_compiler, &builder.config.cranelift_pgo);
let _guard = builder.msg( let _guard = builder.msg(
Kind::Build, Kind::Build,

View File

@@ -3143,6 +3143,7 @@ impl CommandLineStep for ReproducibleArtifacts {
&builder.config.rustdoc_pgo.use_profile, &builder.config.rustdoc_pgo.use_profile,
&builder.config.cargo_pgo.use_profile, &builder.config.cargo_pgo.use_profile,
&builder.config.clippy_pgo.use_profile, &builder.config.clippy_pgo.use_profile,
&builder.config.cranelift_pgo.use_profile,
]; ];
for profile in pgo_profiles { for profile in pgo_profiles {
if let Some(path) = profile.as_ref() { if let Some(path) = profile.as_ref() {

View File

@@ -229,10 +229,13 @@ pub(crate) struct Config {
pub rust_break_on_ice: bool, pub rust_break_on_ice: bool,
pub rust_parallel_frontend_threads: Option<u32>, pub rust_parallel_frontend_threads: Option<u32>,
pub rust_rustflags: Vec<String>, pub rust_rustflags: Vec<String>,
// Note: modify the ReproducibleArtifacts step when adding new PGO configs here!
pub rust_pgo: PgoConfig, pub rust_pgo: PgoConfig,
pub rustdoc_pgo: PgoConfig, pub rustdoc_pgo: PgoConfig,
pub cargo_pgo: PgoConfig, pub cargo_pgo: PgoConfig,
pub clippy_pgo: PgoConfig, pub clippy_pgo: PgoConfig,
pub cranelift_pgo: PgoConfig,
pub stdlib_semver_baseline: Option<String>, pub stdlib_semver_baseline: Option<String>,
@@ -675,6 +678,7 @@ impl Config {
rustdoc: pgo_rustdoc, rustdoc: pgo_rustdoc,
cargo: pgo_cargo, cargo: pgo_cargo,
clippy: pgo_clippy, clippy: pgo_clippy,
cranelift: pgo_cranelift,
llvm: pgo_llvm, llvm: pgo_llvm,
} = toml_pgo.unwrap_or_default(); } = toml_pgo.unwrap_or_default();
@@ -732,6 +736,7 @@ impl Config {
let pgo_rustdoc = init_pgo(pgo_rustdoc, "rustdoc"); let pgo_rustdoc = init_pgo(pgo_rustdoc, "rustdoc");
let pgo_cargo = init_pgo(pgo_cargo, "cargo"); let pgo_cargo = init_pgo(pgo_cargo, "cargo");
let pgo_clippy = init_pgo(pgo_clippy, "clippy"); let pgo_clippy = init_pgo(pgo_clippy, "clippy");
let pgo_cranelift = init_pgo(pgo_cranelift, "cranelift");
let bootstrap_override_lld = rust_bootstrap_override_lld.unwrap_or_default(); let bootstrap_override_lld = rust_bootstrap_override_lld.unwrap_or_default();
@@ -1426,6 +1431,7 @@ NOTE: Please add `--stage 2` to your command line, or if you're sure you want to
compiletest_diff_tool: build_compiletest_diff_tool, compiletest_diff_tool: build_compiletest_diff_tool,
config: toml_path, config: toml_path,
control_flow_guard: rust_control_flow_guard.unwrap_or(false), control_flow_guard: rust_control_flow_guard.unwrap_or(false),
cranelift_pgo: pgo_cranelift,
datadir: install_datadir.map(PathBuf::from), datadir: install_datadir.map(PathBuf::from),
deny_warnings, deny_warnings,
description: build_description, description: build_description,

View File

@@ -28,5 +28,6 @@ define_config! {
cargo: Option<PgoConfig> = "cargo", cargo: Option<PgoConfig> = "cargo",
clippy: Option<PgoConfig> = "clippy", clippy: Option<PgoConfig> = "clippy",
llvm: Option<PgoConfig> = "llvm", llvm: Option<PgoConfig> = "llvm",
cranelift: Option<PgoConfig> = "cranelift",
} }
} }