From 460ba718d48b84aa2a9f4f42f4e6262e0d6f63c8 Mon Sep 17 00:00:00 2001 From: Bo Chen Date: Thu, 19 Jan 2023 09:59:27 -0800 Subject: [PATCH] github,Cargo.toml: Strip release binaries using toolchain From Rust 1.59, the cargo command is now able to strip a binary [1]. This can be enabled in Cargo.toml by adding a `strip = "true"` to the `[profile.release]` section. Adding such binary stripping support in Cargo.toml of the project, also change the stripping process in the release workflow to the one using toolchain, so that the AArch64 release binaries can also be stripped. Fixes: https://github.com/cloud-hypervisor/cloud-hypervisor/issues/4916 [1] https://doc.rust-lang.org/beta/cargo/reference/profiles.html#strip Signed-off-by: Henry Wang (cherry picked from commit 1ff0191b305a91ee4c1c0bf2e5e8ac93207ca269) Signed-off-by: Bo Chen --- .github/workflows/release.yaml | 4 +--- Cargo.toml | 1 + 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 5e49600ff..fdf243eb4 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -10,7 +10,7 @@ jobs: - name: Code checkout uses: actions/checkout@v2 - name: Install musl-gcc - run: sudo apt install -y musl-tools + run: sudo apt install -y musl-tools - name: Create release directory run: rsync -rv --exclude=.git . ../cloud-hypervisor-${{ github.event.ref }} - name: Install Rust toolchain (x86_64-unknown-linux-gnu) @@ -35,8 +35,6 @@ jobs: toolchain: "1.62" command: build args: --all --release --target=x86_64-unknown-linux-musl - - name: Strip cloud-hypervisor binaries - run: strip target/*/release/cloud-hypervisor - name: Install Rust toolchain (aarch64-unknown-linux-musl) uses: actions-rs/toolchain@v1 with: diff --git a/Cargo.toml b/Cargo.toml index ffd5efa64..854c70a77 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,6 +16,7 @@ rust-version = "1.60" lto = true codegen-units = 1 opt-level = "s" +strip = true [dependencies] anyhow = "1.0.66"