From a3da2e9086c04b121763d24b299fdc76ee1bbd09 Mon Sep 17 00:00:00 2001 From: Redfire Date: Wed, 6 Dec 2023 00:50:52 +0800 Subject: [PATCH] Added LTO for Linux Release Build CI --- .github/workflows/release.yml | 25 ++++++++++++++++++------- Cargo.toml | 4 ++++ 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0c7bc06f..03b18e89 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -15,7 +15,6 @@ jobs: fail-fast: false matrix: os: [windows-latest, ubuntu-latest, macos-13] - rust: [stable, beta] include: - os: windows-latest id: windows @@ -33,11 +32,22 @@ jobs: steps: - uses: actions/checkout@v4 + - name: Install Rust Toolchain + uses: dtolnay/rust-toolchain@master + with: + toolchain: stable + + - name: Install LLVM + if: matrix.id == 'linux' + uses: KyleMayes/install-llvm-action@v1 + with: + version: "17.0" + - name: Setup Dependencies uses: ./.github/actions/setup with: os: ${{ matrix.id }} - cache-id: ${{ matrix.id }} + cache-id: release-${{ matrix.id }} - name: Build Windows if: matrix.id == 'windows' @@ -47,7 +57,6 @@ jobs: CXX: clang-cl AR: llvm-lib LINKER: lld-link - RUSTFLAGS: -Clto=fat -Cembed-bitcode=true -Clinker=lld-link run: | just build-release -v --target $env:TARGET Rename-Item -Path .\target\$env:TARGET\release\cli.exe -NewName spiderfire.exe @@ -58,7 +67,6 @@ jobs: CC: clang CXX: clang++ RUSTC_WRAPPER: sccache - RUSTFLAGS: -Clto=fat -Cembed-bitcode=true run: | just build-release -v --target $TARGET mv ./target/$TARGET/release/cli ./target/$TARGET/release/spiderfire @@ -66,17 +74,20 @@ jobs: - name: Build Linux if: matrix.id == 'linux' env: + MOZ_LTO: full CC: clang + CFLAGS: -flto -fuse-ld=lld CXX: clang++ + CXXFLAGS: -flto -fuse-ld=lld + LDFLAGS: -fuse-ld=lld RUSTC_WRAPPER: sccache - RUSTFLAGS: -Clto=fat -Cembed-bitcode=true -Cstrip=symbols + RUSTFLAGS: -Clinker-plugin-lto -Clinker=clang -Clink-arg=-fuse-ld=lld -Clink-arg=-v run: | - just build-release -v --target $TARGET + just build-release -vv --target $TARGET mv ./target/$TARGET/release/cli ./target/$TARGET/release/spiderfire - name: Upload Executables as Artifacts uses: actions/upload-artifact@v3 - if: matrix.rust == 'stable' with: name: spiderfire-${{ github.sha }}-${{ matrix.id }} path: target/${{ matrix.target }}/release/spiderfire${{ matrix.id == 'windows' && '.exe' || '' }} diff --git a/Cargo.toml b/Cargo.toml index 0339e8f4..fb48578a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -40,3 +40,7 @@ default-features = false [workspace.lints.rust] unsafe_op_in_unsafe_fn = "forbid" + +[profile.release] +lto = "fat" +strip = "symbols" \ No newline at end of file