Add rust.frame-pointers config option

This is very helpful for profiling. I've hacked this in many times, so
let's add it properly.
This commit is contained in:
Nilstrieb 2024-02-16 22:11:19 +01:00
parent 8a497723e3
commit 09e6043483
6 changed files with 23 additions and 0 deletions

View file

@ -612,6 +612,10 @@
# Indicates whether symbols should be stripped using `-Cstrip=symbols`.
#strip = false
# Forces frame pointers to be used with `-Cforce-frame-pointers`.
# This can be helpful for profiling at a small performance cost.
# frame-pointers = false
# Indicates whether stack protectors should be used
# via the unstable option `-Zstack-protector`.
#

View file

@ -23,3 +23,6 @@ incremental = true
backtrace-on-ice = true
# Make the compiler and standard library faster to build, at the expense of a ~20% runtime slowdown.
lto = "off"
# Forces frame pointers to be used with `-Cforce-frame-pointers`.
# This can be helpful for profiling at a small performance cost.
frame-pointers = true

View file

@ -14,6 +14,9 @@ incremental = true
backtrace-on-ice = true
# Make the compiler and standard library faster to build, at the expense of a ~20% runtime slowdown.
lto = "off"
# Forces frame pointers to be used with `-Cforce-frame-pointers`.
# This can be helpful for profiling at a small performance cost.
frame-pointers = true
[llvm]
# Will download LLVM from CI if available on your platform.

View file

@ -1870,6 +1870,10 @@ fn cargo(
rustflags.arg("-Wrustc::internal");
}
if self.config.rust_frame_pointers {
rustflags.arg("-Cforce-frame-pointers=true");
}
// If Control Flow Guard is enabled, pass the `control-flow-guard` flag to rustc
// when compiling the standard library, since this might be linked into the final outputs
// produced by rustc. Since this mitigation is only available on Windows, only enable it

View file

@ -256,6 +256,7 @@ pub struct Config {
pub rust_split_debuginfo: SplitDebuginfo,
pub rust_rpath: bool,
pub rust_strip: bool,
pub rust_frame_pointers: bool,
pub rust_stack_protector: Option<String>,
pub rustc_parallel: bool,
pub rustc_default_linker: Option<String>,
@ -1083,6 +1084,7 @@ struct Rust {
musl_root: Option<String> = "musl-root",
rpath: Option<bool> = "rpath",
strip: Option<bool> = "strip",
frame_pointers: Option<bool> = "frame-pointers",
stack_protector: Option<String> = "stack-protector",
verbose_tests: Option<bool> = "verbose-tests",
optimize_tests: Option<bool> = "optimize-tests",
@ -1561,6 +1563,7 @@ fn get_table(option: &str) -> Result<TomlConfig, toml::de::Error> {
download_rustc,
lto,
validate_mir_opts,
frame_pointers,
stack_protector,
strip,
lld_mode,
@ -1609,6 +1612,7 @@ fn get_table(option: &str) -> Result<TomlConfig, toml::de::Error> {
set(&mut config.codegen_tests, codegen_tests);
set(&mut config.rust_rpath, rpath);
set(&mut config.rust_strip, strip);
set(&mut config.rust_frame_pointers, frame_pointers);
config.rust_stack_protector = stack_protector;
set(&mut config.jemalloc, jemalloc);
set(&mut config.test_compare_mode, test_compare_mode);

View file

@ -119,4 +119,9 @@ pub fn find_recent_config_change_ids(current_id: usize) -> Vec<ChangeInfo> {
severity: ChangeSeverity::Info,
summary: "New option `target.<triple>.codegen-backends` added to config.toml.",
},
ChangeInfo {
change_id: 121203,
severity: ChangeSeverity::Info,
summary: "A new `rust.frame-pointers` option has been introduced and made the default in the compiler and codegen profiles.",
},
];