From 88e926e359fa34e557b0c6256a6d5bb8e8b3750e Mon Sep 17 00:00:00 2001 From: Elias Floreteng <18127101+elias123tre@users.noreply.github.com> Date: Sun, 23 Jan 2022 03:27:39 +0100 Subject: [PATCH] Rustc strip flag and cargo strip release date This PR is to update the README before the release of rust version 1.59 on 2022-02-24. When that version is released, issue #33 and PR #34 can be merged and the edits in this PR discarded but and alternative solution is good to have in the meantime. --- README.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/README.md b/README.md index d5ef5e6..302f12f 100644 --- a/README.md +++ b/README.md @@ -49,6 +49,8 @@ $ strip target/release/min-sized-rust Available starting `1.45.0-nightly (2020-05-28)`, [Cargo has `strip` functionality built in](https://doc.rust-lang.org/cargo/reference/unstable.html#profile-strip-option): +> Usage directly with `cargo` will be stabilized with rust [`1.59`](https://github.com/rust-lang/cargo/blob/master/CHANGELOG.md#cargo-159-2022-02-24) + ![Minimum Rust: Nightly](https://img.shields.io/badge/Minimum%20Rust%20Version-nightly%201.45.0-orange.svg) Modify `Cargo.toml` in this way: @@ -60,6 +62,18 @@ cargo-features = ["strip"] strip = true # Automatically strip symbols from the binary. ``` +![Minimum Rust: 1.58](https://img.shields.io/badge/Minimum%20Rust%20Version-1.58-brightgreen.svg) + +To avoid using the nightly, you can add the rustc flag that is now [stabilized](https://github.com/rust-lang/rust/blob/master/RELEASES.md#version-1580-2022-01-13) (since `1.58`). + +Add the following to `.cargo/config`: + +```toml +[build] +rustflags = ["-Cstrip=symbols"] +``` +or build with `RUSTFLAGS='-C strip=symbols' cargo build --release` + # Optimize For Size ![Minimum Rust: 1.28](https://img.shields.io/badge/Minimum%20Rust%20Version-1.28-brightgreen.svg)