Skip to content

Commit 60c2cbf

Browse files
Jeremy Fitzhardingejsgf
authored andcommitted
Build with -Zannotate-moves by default
Build rustc and tools with -Zannotate-moves by default. Adds toml config options to set the annotation size limit. This has no measurable effect on output binary size or compile time.
1 parent acda5e9 commit 60c2cbf

File tree

4 files changed

+16
-0
lines changed

4 files changed

+16
-0
lines changed

bootstrap.example.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -828,6 +828,10 @@
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+
# Size limit in bytes for move/copy annotations. Only types at or above this size will
832+
# be annotated. If not specified, uses the default limit (65 bytes).
833+
#rust.annotate-moves-size-limit = 65
834+
831835
# Select LTO mode that will be used for compiling rustc. By default, thin local LTO
832836
# (LTO within a single crate) is used (like for any Rust crate). You can also select
833837
# "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: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -654,6 +654,13 @@ impl Builder<'_> {
654654
rustflags.arg("-Csymbol-mangling-version=legacy");
655655
}
656656

657+
// Always enable move/copy annotations for profiler visibility
658+
if let Some(limit) = self.config.rust_annotate_moves_size_limit {
659+
rustflags.arg(&format!("-Zannotate-moves={}", limit));
660+
} else {
661+
rustflags.arg("-Zannotate-moves");
662+
}
663+
657664
// FIXME: the following components don't build with `-Zrandomize-layout` yet:
658665
// - rust-analyzer, due to the rowan crate
659666
// 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: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,7 @@ pub struct Config {
217217
pub rust_randomize_layout: bool,
218218
pub rust_remap_debuginfo: bool,
219219
pub rust_new_symbol_mangling: Option<bool>,
220+
pub rust_annotate_moves_size_limit: Option<u64>,
220221
pub rust_profile_use: Option<String>,
221222
pub rust_profile_generate: Option<String>,
222223
pub rust_lto: RustcLto,
@@ -559,6 +560,7 @@ impl Config {
559560
control_flow_guard: rust_control_flow_guard,
560561
ehcont_guard: rust_ehcont_guard,
561562
new_symbol_mangling: rust_new_symbol_mangling,
563+
annotate_moves_size_limit: rust_annotate_moves_size_limit,
562564
profile_generate: rust_profile_generate,
563565
profile_use: rust_profile_use,
564566
download_rustc: rust_download_rustc,
@@ -1419,6 +1421,7 @@ impl Config {
14191421
.map(|value| RustcLto::from_str(value).unwrap())
14201422
.unwrap_or_default(),
14211423
rust_new_symbol_mangling,
1424+
rust_annotate_moves_size_limit,
14221425
rust_optimize: rust_optimize.unwrap_or(RustOptimize::Bool(true)),
14231426
rust_optimize_tests: rust_optimize_tests.unwrap_or(true),
14241427
rust_overflow_checks: rust_overflow_checks.unwrap_or(rust_debug == Some(true)),

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ define_config! {
6060
control_flow_guard: Option<bool> = "control-flow-guard",
6161
ehcont_guard: Option<bool> = "ehcont-guard",
6262
new_symbol_mangling: Option<bool> = "new-symbol-mangling",
63+
annotate_moves_size_limit: Option<u64> = "annotate-moves-size-limit",
6364
profile_generate: Option<String> = "profile-generate",
6465
profile_use: Option<String> = "profile-use",
6566
// ignored; this is set from an env var set by bootstrap.py
@@ -364,6 +365,7 @@ pub fn check_incompatible_options_for_ci_rustc(
364365
control_flow_guard: _,
365366
ehcont_guard: _,
366367
new_symbol_mangling: _,
368+
annotate_moves_size_limit: _,
367369
profile_generate: _,
368370
profile_use: _,
369371
download_rustc: _,

0 commit comments

Comments
 (0)