From 473375ad5fd4492a7314d7f0e55cf507640f56f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Mikrut?= Date: Sun, 11 Feb 2024 08:48:40 +0100 Subject: [PATCH] LTO --- .github/workflows/linux_cli.yml | 4 ++++ .github/workflows/linux_cli_eyra.yml | 4 ++++ .github/workflows/linux_gui.yml | 16 ++++++++++++++++ .github/workflows/mac.yml | 4 ++++ .github/workflows/windows.yml | 6 ++++++ Cargo.toml | 1 + Changelog.md | 1 + 7 files changed, 36 insertions(+) diff --git a/.github/workflows/linux_cli.yml b/.github/workflows/linux_cli.yml index 053f22f..5d9e686 100644 --- a/.github/workflows/linux_cli.yml +++ b/.github/workflows/linux_cli.yml @@ -24,6 +24,10 @@ jobs: - name: Setup rust version run: rustup default ${{ matrix.toolchain }} + - name: Enable LTO + run: sed -i 's/#lto = "fat"/lto = "fat"/g' Cargo.toml + if: ${{ matrix.toolchain == 'release' }} + - name: Build Release run: cargo build --release --bin czkawka_cli if: ${{ (matrix.type == 'release') }} diff --git a/.github/workflows/linux_cli_eyra.yml b/.github/workflows/linux_cli_eyra.yml index 35657f9..736ff98 100644 --- a/.github/workflows/linux_cli_eyra.yml +++ b/.github/workflows/linux_cli_eyra.yml @@ -32,6 +32,10 @@ jobs: echo 'fn main() { println!("cargo:rustc-link-arg=-nostartfiles"); }' > build.rs cd .. + - name: Enable LTO + run: sed -i 's/#lto = "fat"/lto = "fat"/g' Cargo.toml + if: ${{ matrix.toolchain == 'release' }} + - name: Build Release run: cargo build --release --bin czkawka_cli if: ${{ (matrix.type == 'release') }} diff --git a/.github/workflows/linux_gui.yml b/.github/workflows/linux_gui.yml index aca39f5..c8ae516 100644 --- a/.github/workflows/linux_gui.yml +++ b/.github/workflows/linux_gui.yml @@ -21,6 +21,10 @@ jobs: - name: Setup rust version run: rustup default ${{ matrix.toolchain }} + - name: Enable LTO + run: sed -i 's/#lto = "fat"/lto = "fat"/g' Cargo.toml + if: ${{ matrix.toolchain == 'release' }} + - name: Build Release Krokiet run: cargo build --release --bin krokiet if: ${{ (matrix.type == 'release') }} @@ -47,6 +51,10 @@ jobs: - name: Setup rust version run: rustup default ${{ matrix.toolchain }} + - name: Enable LTO + run: sed -i 's/#lto = "fat"/lto = "fat"/g' Cargo.toml + if: ${{ matrix.toolchain == 'release' }} + - name: Build Release Krokiet heif run: cargo build --release --bin krokiet --features "heif,libraw" if: ${{ (matrix.type == 'release') }} @@ -73,6 +81,10 @@ jobs: - name: Setup rust version run: rustup default ${{ matrix.toolchain }} + - name: Enable LTO + run: sed -i 's/#lto = "fat"/lto = "fat"/g' Cargo.toml + if: ${{ matrix.toolchain == 'release' }} + - name: Build Release Heif Libraw run: cargo build --release --bin czkawka_gui --features "heif,libraw" if: ${{ (matrix.type == 'release') }} @@ -111,6 +123,10 @@ jobs: - name: Setup rust version run: rustup default ${{ matrix.toolchain }} + - name: Enable LTO + run: sed -i 's/#lto = "fat"/lto = "fat"/g' Cargo.toml + if: ${{ matrix.toolchain == 'release' }} + - name: Build Release run: cargo build --release --bin czkawka_gui diff --git a/.github/workflows/mac.yml b/.github/workflows/mac.yml index e746fcc..905b8d4 100644 --- a/.github/workflows/mac.yml +++ b/.github/workflows/mac.yml @@ -30,6 +30,10 @@ jobs: - name: Setup rust version run: rustup default ${{ matrix.toolchain }} + - name: Enable LTO + run: sed -i 's/#lto = "fat"/lto = "fat"/g' Cargo.toml + if: ${{ matrix.toolchain == 'release' }} + - name: Build Release run: cargo build --release if: ${{ matrix.type == 'release'}} diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 76cbd91..e100211 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -30,6 +30,9 @@ jobs: run: | rustup target add x86_64-pc-windows-gnu + - name: Enable LTO + run: sed -i 's/#lto = "fat"/lto = "fat"/g' Cargo.toml + - name: Compile Krokiet run: cargo build --release --target x86_64-pc-windows-gnu --bin krokiet @@ -75,6 +78,9 @@ jobs: - name: Setup rust version run: rustup default stable-x86_64-pc-windows-gnu + - name: Enable LTO + run: sed -i 's/#lto = "fat"/lto = "fat"/g' Cargo.toml + - name: Compile Krokiet run: cargo build --release --bin krokiet diff --git a/Cargo.toml b/Cargo.toml index c8806cb..d72e6f1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,6 +18,7 @@ resolver = "2" panic = "unwind" # LTO setting is disabled by default, because release mode is usually needed to develop app and compilation with LTO would take a lot of time +# But it is used to optimize release builds(and probably also in CI, where time is not so important as in local development) #lto = "fat" # Optimize all dependencies except application/workspaces, even in debug builds diff --git a/Changelog.md b/Changelog.md index 1683e22..24b1dc9 100644 --- a/Changelog.md +++ b/Changelog.md @@ -33,6 +33,7 @@ - Decrease a little size of cache by few percents and improve loading/saving speed - [#1159](https://github.com/qarmin/czkawka/pull/1159) - Added ability to remove from scan files with excluded extensions - [#1184](https://github.com/qarmin/czkawka/pull/1102) - Fixed not showing in similar images results, files with same hashes when using reference folders - [#1184](https://github.com/qarmin/czkawka/pull/1102) +- Optimize release binaries with LTO - [#1184](https://github.com/qarmin/czkawka/pull/1102) ## Version 6.1.0 - 15.10.2023r - BREAKING CHANGE - Changed cache saving method, deduplicated, optimized and simplified procedure(all files needs to be hashed again) - [#1072](https://github.com/qarmin/czkawka/pull/1072), [#1086](https://github.com/qarmin/czkawka/pull/1086)