Skip to content

Commit 550107b

Browse files
author
Jeremy Fitzhardinge
committed
Build with -Zannotate-moves by default (non-stage-0 only)
Build rustc and tools with -Zannotate-moves by default, both to exercise the feature and because could be useful for doing performance measurement on rustc and its tools. This is only added for stage 1 and later. Stage 0 (the bootstrap compiler) doesn't yet support -Zannotate-moves.
1 parent 055d0d6 commit 550107b

File tree

4 files changed

+31
-0
lines changed

4 files changed

+31
-0
lines changed

bootstrap.example.toml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -828,6 +828,17 @@
828828
# If an explicit setting is given, it will be used for all parts of the codebase.
829829
#rust.new-symbol-mangling = true|false (see comment)
830830

831+
# Enable move/copy annotations for profiler visibility. When enabled, compiler-generated
832+
# move and copy operations will be annotated with debug info that makes them visible in
833+
# profilers. This is helpful when profiling to see where expensive copies/moves occur.
834+
# Defaults to true (enabled).
835+
#rust.annotate-moves = true
836+
837+
# Size limit in bytes for move/copy annotations. Only types at or above this size will
838+
# be annotated. If not specified, uses the default limit (65 bytes). Only takes effect
839+
# if annotate-moves is enabled.
840+
#rust.annotate-moves-size-limit = 65
841+
831842
# Select LTO mode that will be used for compiling rustc. By default, thin local LTO
832843
# (LTO within a single crate) is used (like for any Rust crate). You can also select
833844
# "thin" or "fat" to apply Thin/Fat LTO to the `rustc_driver` dylib, or "off" to disable

src/bootstrap/src/core/builder/cargo.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -654,6 +654,16 @@ impl Builder<'_> {
654654
rustflags.arg("-Csymbol-mangling-version=legacy");
655655
}
656656

657+
// Enable move/copy annotations for profiler visibility if configured
658+
// Skip stage 0 since the bootstrap compiler doesn't support this flag yet
659+
if self.config.rust_annotate_moves.unwrap_or(true) && build_compiler_stage >= 1 {
660+
if let Some(limit) = self.config.rust_annotate_moves_size_limit {
661+
rustflags.arg(&format!("-Zannotate-moves={}", limit));
662+
} else {
663+
rustflags.arg("-Zannotate-moves");
664+
}
665+
}
666+
657667
// FIXME: the following components don't build with `-Zrandomize-layout` yet:
658668
// - rust-analyzer, due to the rowan crate
659669
// so we exclude an entire category of steps here due to lack of fine-grained control over

src/bootstrap/src/core/config/config.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,8 @@ pub struct Config {
216216
pub rust_thin_lto_import_instr_limit: Option<u32>,
217217
pub rust_randomize_layout: bool,
218218
pub rust_remap_debuginfo: bool,
219+
pub rust_annotate_moves: Option<bool>,
220+
pub rust_annotate_moves_size_limit: Option<u64>,
219221
pub rust_new_symbol_mangling: Option<bool>,
220222
pub rust_profile_use: Option<String>,
221223
pub rust_profile_generate: Option<String>,
@@ -558,6 +560,8 @@ impl Config {
558560
llvm_libunwind: rust_llvm_libunwind,
559561
control_flow_guard: rust_control_flow_guard,
560562
ehcont_guard: rust_ehcont_guard,
563+
annotate_moves: rust_annotate_moves,
564+
annotate_moves_size_limit: rust_annotate_moves_size_limit,
561565
new_symbol_mangling: rust_new_symbol_mangling,
562566
profile_generate: rust_profile_generate,
563567
profile_use: rust_profile_use,
@@ -1398,6 +1402,8 @@ impl Config {
13981402
reproducible_artifacts: flags_reproducible_artifact,
13991403
reuse: build_reuse.map(PathBuf::from),
14001404
rust_analyzer_info,
1405+
rust_annotate_moves,
1406+
rust_annotate_moves_size_limit,
14011407
rust_break_on_ice: rust_break_on_ice.unwrap_or(true),
14021408
rust_codegen_backends: rust_codegen_backends
14031409
.map(|backends| parse_codegen_backends(backends, "rust"))

src/bootstrap/src/core/config/toml/rust.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ define_config! {
5959
llvm_libunwind: Option<String> = "llvm-libunwind",
6060
control_flow_guard: Option<bool> = "control-flow-guard",
6161
ehcont_guard: Option<bool> = "ehcont-guard",
62+
annotate_moves: Option<bool> = "annotate-moves",
63+
annotate_moves_size_limit: Option<u64> = "annotate-moves-size-limit",
6264
new_symbol_mangling: Option<bool> = "new-symbol-mangling",
6365
profile_generate: Option<String> = "profile-generate",
6466
profile_use: Option<String> = "profile-use",
@@ -363,6 +365,8 @@ pub fn check_incompatible_options_for_ci_rustc(
363365
llvm_libunwind: _,
364366
control_flow_guard: _,
365367
ehcont_guard: _,
368+
annotate_moves: _,
369+
annotate_moves_size_limit: _,
366370
new_symbol_mangling: _,
367371
profile_generate: _,
368372
profile_use: _,

0 commit comments

Comments
 (0)