Skip to content

Commit 09e6043

Browse files
committed
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.
1 parent 8a49772 commit 09e6043

File tree

6 files changed

+23
-0
lines changed

6 files changed

+23
-0
lines changed

Diff for: config.example.toml

+4
Original file line numberDiff line numberDiff line change
@@ -612,6 +612,10 @@
612612
# Indicates whether symbols should be stripped using `-Cstrip=symbols`.
613613
#strip = false
614614

615+
# Forces frame pointers to be used with `-Cforce-frame-pointers`.
616+
# This can be helpful for profiling at a small performance cost.
617+
# frame-pointers = false
618+
615619
# Indicates whether stack protectors should be used
616620
# via the unstable option `-Zstack-protector`.
617621
#

Diff for: src/bootstrap/defaults/config.codegen.toml

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

Diff for: src/bootstrap/defaults/config.compiler.toml

+3
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ incremental = true
1414
backtrace-on-ice = true
1515
# Make the compiler and standard library faster to build, at the expense of a ~20% runtime slowdown.
1616
lto = "off"
17+
# Forces frame pointers to be used with `-Cforce-frame-pointers`.
18+
# This can be helpful for profiling at a small performance cost.
19+
frame-pointers = true
1720

1821
[llvm]
1922
# Will download LLVM from CI if available on your platform.

Diff for: src/bootstrap/src/core/builder.rs

+4
Original file line numberDiff line numberDiff line change
@@ -1870,6 +1870,10 @@ impl<'a> Builder<'a> {
18701870
rustflags.arg("-Wrustc::internal");
18711871
}
18721872

1873+
if self.config.rust_frame_pointers {
1874+
rustflags.arg("-Cforce-frame-pointers=true");
1875+
}
1876+
18731877
// If Control Flow Guard is enabled, pass the `control-flow-guard` flag to rustc
18741878
// when compiling the standard library, since this might be linked into the final outputs
18751879
// produced by rustc. Since this mitigation is only available on Windows, only enable it

Diff for: src/bootstrap/src/core/config/config.rs

+4
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,7 @@ pub struct Config {
256256
pub rust_split_debuginfo: SplitDebuginfo,
257257
pub rust_rpath: bool,
258258
pub rust_strip: bool,
259+
pub rust_frame_pointers: bool,
259260
pub rust_stack_protector: Option<String>,
260261
pub rustc_parallel: bool,
261262
pub rustc_default_linker: Option<String>,
@@ -1083,6 +1084,7 @@ define_config! {
10831084
musl_root: Option<String> = "musl-root",
10841085
rpath: Option<bool> = "rpath",
10851086
strip: Option<bool> = "strip",
1087+
frame_pointers: Option<bool> = "frame-pointers",
10861088
stack_protector: Option<String> = "stack-protector",
10871089
verbose_tests: Option<bool> = "verbose-tests",
10881090
optimize_tests: Option<bool> = "optimize-tests",
@@ -1561,6 +1563,7 @@ impl Config {
15611563
download_rustc,
15621564
lto,
15631565
validate_mir_opts,
1566+
frame_pointers,
15641567
stack_protector,
15651568
strip,
15661569
lld_mode,
@@ -1609,6 +1612,7 @@ impl Config {
16091612
set(&mut config.codegen_tests, codegen_tests);
16101613
set(&mut config.rust_rpath, rpath);
16111614
set(&mut config.rust_strip, strip);
1615+
set(&mut config.rust_frame_pointers, frame_pointers);
16121616
config.rust_stack_protector = stack_protector;
16131617
set(&mut config.jemalloc, jemalloc);
16141618
set(&mut config.test_compare_mode, test_compare_mode);

Diff for: src/bootstrap/src/utils/change_tracker.rs

+5
Original file line numberDiff line numberDiff line change
@@ -119,4 +119,9 @@ pub const CONFIG_CHANGE_HISTORY: &[ChangeInfo] = &[
119119
severity: ChangeSeverity::Info,
120120
summary: "New option `target.<triple>.codegen-backends` added to config.toml.",
121121
},
122+
ChangeInfo {
123+
change_id: 121203,
124+
severity: ChangeSeverity::Info,
125+
summary: "A new `rust.frame-pointers` option has been introduced and made the default in the compiler and codegen profiles.",
126+
},
122127
];

0 commit comments

Comments
 (0)