Skip to content

Conversation

klensy
Copy link
Contributor

@klensy klensy commented Jan 13, 2025

Reduces binary size using panic_immediate_abort by removing strings used by rtprintpanic!.

for main.rs

fn main() {
    println!("Hello, world!");
}

with Cargo.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

@rustbot
Copy link
Collaborator

rustbot commented Jan 13, 2025

r? @Mark-Simulacrum

rustbot has assigned @Mark-Simulacrum.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Jan 13, 2025
@Mark-Simulacrum
Copy link
Member

Seems OK; the cfg is unstable and is documented to not format output.

@bors r+

@bors
Copy link
Collaborator

bors commented Jan 19, 2025

📌 Commit 3a0554a has been approved by Mark-Simulacrum

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jan 19, 2025
@bors bors merged commit e5b8503 into rust-lang:master Jan 20, 2025
6 checks passed
@rustbot rustbot added this to the 1.86.0 milestone Jan 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-libs Relevant to the library team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants