Skip to content

Commit 9d8f727

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 bc1b9e0 commit 9d8f727

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed

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
#

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

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>,
@@ -1082,6 +1083,7 @@ define_config! {
10821083
musl_root: Option<String> = "musl-root",
10831084
rpath: Option<bool> = "rpath",
10841085
strip: Option<bool> = "strip",
1086+
frame_pointers: Option<bool> = "frame-pointers",
10851087
stack_protector: Option<String> = "stack-protector",
10861088
verbose_tests: Option<bool> = "verbose-tests",
10871089
optimize_tests: Option<bool> = "optimize-tests",
@@ -1559,6 +1561,7 @@ impl Config {
15591561
download_rustc,
15601562
lto,
15611563
validate_mir_opts,
1564+
frame_pointers,
15621565
stack_protector,
15631566
strip,
15641567
lld_mode,
@@ -1607,6 +1610,7 @@ impl Config {
16071610
set(&mut config.codegen_tests, codegen_tests);
16081611
set(&mut config.rust_rpath, rpath);
16091612
set(&mut config.rust_strip, strip);
1613+
set(&mut config.rust_frame_pointers, frame_pointers);
16101614
config.rust_stack_protector = stack_protector;
16111615
set(&mut config.jemalloc, jemalloc);
16121616
set(&mut config.test_compare_mode, test_compare_mode);

0 commit comments

Comments
 (0)