From c989ed08232baf413b99ccdcabefbc42e2f97baf Mon Sep 17 00:00:00 2001 From: Jiahao XU <Jiahao_XU@outlook.com> Date: Tue, 31 May 2022 17:12:15 +1000 Subject: [PATCH 1/8] Optimize release build by enabling lto, setting `codegen-units` to 1 and setting panic behavior to `abort`. On my `aarch64-apple-darwin` with `rustc 1.61.0`, this reduces the size of binary from 7.8M to 4.9M Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com> --- Cargo.toml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Cargo.toml b/Cargo.toml index 4db7ace7..eb13f15f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -44,3 +44,8 @@ zip = "0.6.2" [dev-dependencies] env_logger = "0.9.0" + +[profile.release] +lto = true +codegen-units = 1 +panic = "abort" From 62b5ecbe8373a9d75dea00c62746b0cb1305f5d3 Mon Sep 17 00:00:00 2001 From: Jiahao XU <Jiahao_XU@outlook.com> Date: Tue, 31 May 2022 17:18:51 +1000 Subject: [PATCH 2/8] Set `RUSTFLAGS` to `-Zstrip=symbols` in job `build` Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com> --- .github/workflows/rust.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 9ff74d56..56541de6 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -96,6 +96,8 @@ jobs: command: build args: --target ${{ matrix.target }} --release use-cross: ${{ matrix.use-cross }} + env: + RUSTFLAGS: -Zstrip=symbols - name: Copy and rename utility run: cp target/${{ matrix.target }}/release/${{ matrix.output }} ${{ matrix.output }} From 3411812ee5a300843bfe0f0de73680b9045d02e9 Mon Sep 17 00:00:00 2001 From: Jiahao XU <Jiahao_XU@outlook.com> Date: Tue, 31 May 2022 17:22:17 +1000 Subject: [PATCH 3/8] Revert "Set `RUSTFLAGS` to `-Zstrip=symbols` in job `build`" This reverts commit 62b5ecbe8373a9d75dea00c62746b0cb1305f5d3. --- .github/workflows/rust.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 56541de6..9ff74d56 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -96,8 +96,6 @@ jobs: command: build args: --target ${{ matrix.target }} --release use-cross: ${{ matrix.use-cross }} - env: - RUSTFLAGS: -Zstrip=symbols - name: Copy and rename utility run: cp target/${{ matrix.target }}/release/${{ matrix.output }} ${{ matrix.output }} From 8bdd089775409bc1f0bde482e7e7cd87bcf5b650 Mon Sep 17 00:00:00 2001 From: Jiahao XU <Jiahao_XU@outlook.com> Date: Tue, 31 May 2022 17:23:17 +1000 Subject: [PATCH 4/8] Run `strip` as a separate step in job `build` except on windows. Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com> --- .github/workflows/rust.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 9ff74d56..1070e785 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -100,6 +100,10 @@ jobs: - name: Copy and rename utility run: cp target/${{ matrix.target }}/release/${{ matrix.output }} ${{ matrix.output }} + - name: Strip the executable + if: ${{ matrix.os != 'windows-latest' }} + run: strip ${{ matrix.output }} + - name: Create archive (tgz, linux) if: ${{ matrix.os != 'macos-latest' && matrix.os != 'windows-latest' }} run: tar -czvf cargo-binstall-${{ matrix.target }}.tgz ${{ matrix.output }} From a378be8bc6deb5e6849ed3872d46b4222f378d45 Mon Sep 17 00:00:00 2001 From: Jiahao XU <Jiahao_XU@outlook.com> Date: Tue, 31 May 2022 17:30:50 +1000 Subject: [PATCH 5/8] Revert "Run `strip` as a separate step in job `build`" This reverts commit 8bdd089775409bc1f0bde482e7e7cd87bcf5b650. --- .github/workflows/rust.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 1070e785..9ff74d56 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -100,10 +100,6 @@ jobs: - name: Copy and rename utility run: cp target/${{ matrix.target }}/release/${{ matrix.output }} ${{ matrix.output }} - - name: Strip the executable - if: ${{ matrix.os != 'windows-latest' }} - run: strip ${{ matrix.output }} - - name: Create archive (tgz, linux) if: ${{ matrix.os != 'macos-latest' && matrix.os != 'windows-latest' }} run: tar -czvf cargo-binstall-${{ matrix.target }}.tgz ${{ matrix.output }} From c3c1c97dd394c788fa8d5acf1325385fc444dbca Mon Sep 17 00:00:00 2001 From: Jiahao XU <Jiahao_XU@outlook.com> Date: Tue, 31 May 2022 17:31:59 +1000 Subject: [PATCH 6/8] Set `RUSTFLAGS` to `-Cstrip=symbols` in job `build` Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com> --- .github/workflows/rust.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 9ff74d56..d80cdd3c 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -96,6 +96,8 @@ jobs: command: build args: --target ${{ matrix.target }} --release use-cross: ${{ matrix.use-cross }} + env: + RUSTFLAGS: -Cstrip=symbols - name: Copy and rename utility run: cp target/${{ matrix.target }}/release/${{ matrix.output }} ${{ matrix.output }} From 7b3923972904da59dbfc0546f9054a4eb1cd5945 Mon Sep 17 00:00:00 2001 From: Jiahao XU <Jiahao_XU@outlook.com> Date: Tue, 31 May 2022 17:39:19 +1000 Subject: [PATCH 7/8] Revert "Set `RUSTFLAGS` to `-Cstrip=symbols` in job `build`" This reverts commit c3c1c97dd394c788fa8d5acf1325385fc444dbca. --- .github/workflows/rust.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index d80cdd3c..9ff74d56 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -96,8 +96,6 @@ jobs: command: build args: --target ${{ matrix.target }} --release use-cross: ${{ matrix.use-cross }} - env: - RUSTFLAGS: -Cstrip=symbols - name: Copy and rename utility run: cp target/${{ matrix.target }}/release/${{ matrix.output }} ${{ matrix.output }} From 84d8b9295f327e8f36d23c222d585c851e999ec0 Mon Sep 17 00:00:00 2001 From: Jiahao XU <Jiahao_XU@outlook.com> Date: Tue, 31 May 2022 17:39:33 +1000 Subject: [PATCH 8/8] Set `profile.release.strip` to `symbols` in `Cargo.toml` Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com> --- Cargo.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/Cargo.toml b/Cargo.toml index eb13f15f..943d7ce6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -49,3 +49,4 @@ env_logger = "0.9.0" lto = true codegen-units = 1 panic = "abort" +strip = "symbols"