Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 6114941

Browse files
authoredJan 20, 2025
Unrolled build for rust-lang#135446
Rollup merge of rust-lang#135446 - klensy:panic_immediate_abort_ext, r=Mark-Simulacrum further improve panic_immediate_abort by removing rtprintpanic! messages Reduces binary size using `panic_immediate_abort` by removing strings used by `rtprintpanic!`. for `main.rs` ```rust fn main() { println!("Hello, world!"); } ``` with `Cargo.toml` ```toml [package] name = "tst" version = "0.1.0" edition = "2024" [dependencies] [profile.release] lto = true codegen-units = 1 panic = "abort" ``` and build with `RUSTFLAGS="-Zlocation-detail=none -Zfmt-debug=none" cargo +stage-1 b -r -Z build-std=std,panic_abort -Z build-std-features=optimize_for_size,panic_immediate_abort` for `x86_64-unknown-linux-gnu` This reduces size: | before | after | type | | - | - | - | | 25256 | 21880 | unstripped | | 18072 | 15288 | stripped |
2 parents 9a1d156 + 3a0554a commit 6114941

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed
 

‎library/std/src/rt.rs

+5
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,14 @@ use crate::{mem, panic, sys};
3232
// - nothing (so this macro is a no-op)
3333
macro_rules! rtprintpanic {
3434
($($t:tt)*) => {
35+
#[cfg(not(feature = "panic_immediate_abort"))]
3536
if let Some(mut out) = crate::sys::stdio::panic_output() {
3637
let _ = crate::io::Write::write_fmt(&mut out, format_args!($($t)*));
3738
}
39+
#[cfg(feature = "panic_immediate_abort")]
40+
{
41+
let _ = format_args!($($t)*);
42+
}
3843
}
3944
}
4045

0 commit comments

Comments
 (0)
Failed to load comments.