Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions bootstrap.example.toml
Original file line number Diff line number Diff line change
Expand Up @@ -828,6 +828,17 @@
# If an explicit setting is given, it will be used for all parts of the codebase.
#rust.new-symbol-mangling = true|false (see comment)

# Enable move/copy annotations for profiler visibility. When enabled, compiler-generated
# move and copy operations will be annotated with debug info that makes them visible in
# profilers. This is helpful when profiling to see where expensive copies/moves occur.
# Defaults to true (enabled).
#rust.annotate-moves = true

# Size limit in bytes for move/copy annotations. Only types at or above this size will
# be annotated. If not specified, uses the default limit (65 bytes). Only takes effect
# if annotate-moves is enabled.
#rust.annotate-moves-size-limit = 65

# Select LTO mode that will be used for compiling rustc. By default, thin local LTO
# (LTO within a single crate) is used (like for any Rust crate). You can also select
# "thin" or "fat" to apply Thin/Fat LTO to the `rustc_driver` dylib, or "off" to disable
Expand Down
10 changes: 10 additions & 0 deletions src/bootstrap/src/core/builder/cargo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -654,6 +654,16 @@ impl Builder<'_> {
rustflags.arg("-Csymbol-mangling-version=legacy");
}

// Enable move/copy annotations for profiler visibility if configured
// Skip stage 0 since the bootstrap compiler doesn't support this flag yet
if self.config.rust_annotate_moves.unwrap_or(true) && build_compiler_stage >= 1 {
if let Some(limit) = self.config.rust_annotate_moves_size_limit {
rustflags.arg(&format!("-Zannotate-moves={}", limit));
} else {
rustflags.arg("-Zannotate-moves");
}
}
Comment on lines +657 to +665
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question: hold on, won't this affect stable compiler dist builds too? Or maybe I'm misunderstanding?

Copy link
Contributor Author

@jsgf jsgf Nov 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that should be fine. It will have no functional effect, aside from some extra debug info.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There won't be any debuginfo, we strip it.


// FIXME: the following components don't build with `-Zrandomize-layout` yet:
// - rust-analyzer, due to the rowan crate
// so we exclude an entire category of steps here due to lack of fine-grained control over
Expand Down
6 changes: 6 additions & 0 deletions src/bootstrap/src/core/config/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,8 @@ pub struct Config {
pub rust_thin_lto_import_instr_limit: Option<u32>,
pub rust_randomize_layout: bool,
pub rust_remap_debuginfo: bool,
pub rust_annotate_moves: Option<bool>,
pub rust_annotate_moves_size_limit: Option<u64>,
pub rust_new_symbol_mangling: Option<bool>,
pub rust_profile_use: Option<String>,
pub rust_profile_generate: Option<String>,
Expand Down Expand Up @@ -558,6 +560,8 @@ impl Config {
llvm_libunwind: rust_llvm_libunwind,
control_flow_guard: rust_control_flow_guard,
ehcont_guard: rust_ehcont_guard,
annotate_moves: rust_annotate_moves,
annotate_moves_size_limit: rust_annotate_moves_size_limit,
new_symbol_mangling: rust_new_symbol_mangling,
profile_generate: rust_profile_generate,
profile_use: rust_profile_use,
Expand Down Expand Up @@ -1398,6 +1402,8 @@ impl Config {
reproducible_artifacts: flags_reproducible_artifact,
reuse: build_reuse.map(PathBuf::from),
rust_analyzer_info,
rust_annotate_moves,
rust_annotate_moves_size_limit,
rust_break_on_ice: rust_break_on_ice.unwrap_or(true),
rust_codegen_backends: rust_codegen_backends
.map(|backends| parse_codegen_backends(backends, "rust"))
Expand Down
4 changes: 4 additions & 0 deletions src/bootstrap/src/core/config/toml/rust.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ define_config! {
llvm_libunwind: Option<String> = "llvm-libunwind",
control_flow_guard: Option<bool> = "control-flow-guard",
ehcont_guard: Option<bool> = "ehcont-guard",
annotate_moves: Option<bool> = "annotate-moves",
annotate_moves_size_limit: Option<u64> = "annotate-moves-size-limit",
new_symbol_mangling: Option<bool> = "new-symbol-mangling",
profile_generate: Option<String> = "profile-generate",
profile_use: Option<String> = "profile-use",
Expand Down Expand Up @@ -363,6 +365,8 @@ pub fn check_incompatible_options_for_ci_rustc(
llvm_libunwind: _,
control_flow_guard: _,
ehcont_guard: _,
annotate_moves: _,
annotate_moves_size_limit: _,
new_symbol_mangling: _,
profile_generate: _,
profile_use: _,
Expand Down
Loading