From f00ae028d5502888ddeccbe0afa396c69d3562fb Mon Sep 17 00:00:00 2001 From: Bas Zalmstra Date: Mon, 26 Jun 2023 14:59:13 +0200 Subject: [PATCH 1/3] fix: lto with flags --- .github/workflows/rust.yml | 23 +++++++++-------------- Cargo.toml | 5 ----- 2 files changed, 9 insertions(+), 19 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 8bf1dc8a7..0e6270e0e 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -161,6 +161,13 @@ jobs: unset IS_RELEASE ; if [[ $GITHUB_REF =~ ^refs/tags/v[0-9].* ]]; then IS_RELEASE='true' ; fi echo "IS_RELEASE=${IS_RELEASE}" >> $GITHUB_OUTPUT + - name: Set release specific compilation flags + if: steps.is-release.outputs.IS_RELEASE + shell: bash + run: | + echo "CARGO_PROFILE_RELEASE_LTO=true" >> $GITHUB_ENV + echo "CARGO_PROFILE_RELEASE_STRIP=true" >> $GITHUB_ENV + - name: Set build options id: build-options shell: bash @@ -171,25 +178,14 @@ jobs: *) CARGO_BUILD_OPTIONS="" ;; esac - if [[ '${{ steps.is-release.outputs.IS_RELEASE }}' == 'true' ]]; then - CARGO_BUILD_OPTIONS="${CARGO_BUILD_OPTIONS} --profile=release-lto" - BUILD_TARGET_FOLDER="release-lto" - else - CARGO_BUILD_OPTIONS="${CARGO_BUILD_OPTIONS} --release" - BUILD_TARGET_FOLDER="release" - fi - - echo "BUILD_TARGET_FOLDER=${BUILD_TARGET_FOLDER}" >> $GITHUB_OUTPUT echo "CARGO_BUILD_OPTIONS=${CARGO_BUILD_OPTIONS}" >> $GITHUB_OUTPUT - name: Build uses: actions-rs/cargo@v1 - env: - BUILD_PROFILE: ${{ steps.is-release.outputs.IS_RELEASE && '--profile release-lto' || '--release' }} with: use-cross: ${{ matrix.job.use-cross }} command: build - args: --locked --target=${{ matrix.job.target }} ${{ steps.build-options.outputs.CARGO_BUILD_OPTIONS}} + args: --locked --release --target=${{ matrix.job.target }} ${{ steps.build-options.outputs.CARGO_BUILD_OPTIONS}} - name: Set binary name & path id: bin @@ -202,9 +198,8 @@ jobs: esac; # Setup paths - BUILD_TARGET_FOLDER="${{ steps.build-options.outputs.BUILD_TARGET_FOLDER }}" BIN_NAME="${{ needs.crate_metadata.outputs.name }}${EXE_SUFFIX}" - BIN_PATH="target/${{ matrix.job.target }}/${BUILD_TARGET_FOLDER}/${BIN_NAME}" + BIN_PATH="target/${{ matrix.job.target }}/release/${BIN_NAME}" # Let subsequent steps know where to find the binary echo "BIN_PATH=${BIN_PATH}" >> $GITHUB_OUTPUT diff --git a/Cargo.toml b/Cargo.toml index 27eebb3f6..bcafc9ae5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -56,8 +56,3 @@ toml_edit = { version = "0.19.10", features = ["serde"] } tracing = "0.1.37" tracing-subscriber = { version = "0.3.17", features = ["env-filter"] } url = "2.4.0" - -[profile.release-lto] -inherits = "release" -lto = true -strip = true From 2e21ea839c8845ed2838393cca49dd2779ebb1e5 Mon Sep 17 00:00:00 2001 From: Bas Zalmstra Date: Mon, 26 Jun 2023 15:01:53 +0200 Subject: [PATCH 2/3] fix: rustflags for windows --- .github/workflows/rust.yml | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 0e6270e0e..eb2604bde 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -76,7 +76,7 @@ jobs: build: name: ${{ matrix.job.name }} runs-on: ${{ matrix.job.os }} - needs: [crate_metadata, clippy] + needs: [ crate_metadata, clippy ] strategy: fail-fast: false matrix: @@ -86,10 +86,7 @@ jobs: - { name: "macOS-x86_64", target: x86_64-apple-darwin, os: macOS-latest } - { name: "macOS-aarch64", target: aarch64-apple-darwin, os: macOS-latest, skip-tests: true } - - { name: "Windows-x86_64", target: x86_64-pc-windows-msvc, os: windows-latest } - include: - - os: windows-latest - rustflags: -C target-feature=+crt-static + - { name: "Windows-x86_64", target: x86_64-pc-windows-msvc, os: windows-latest, rustflags: -C target-feature=+crt-static } env: BUILD_CMD: cargo # The build and test command to use if not overwritten RUSTFLAGS: ${{ matrix.rustflags || '' }} -D warnings From c9237309a008a575cf1835cbdede1354e7b2092e Mon Sep 17 00:00:00 2001 From: Bas Zalmstra Date: Mon, 26 Jun 2023 15:02:17 +0200 Subject: [PATCH 3/3] fix: rustflags per target --- .github/workflows/rust.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index eb2604bde..c086713f2 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -89,7 +89,7 @@ jobs: - { name: "Windows-x86_64", target: x86_64-pc-windows-msvc, os: windows-latest, rustflags: -C target-feature=+crt-static } env: BUILD_CMD: cargo # The build and test command to use if not overwritten - RUSTFLAGS: ${{ matrix.rustflags || '' }} -D warnings + RUSTFLAGS: ${{ matrix.job.rustflags || '' }} -D warnings steps: - name: Checkout source code uses: actions/checkout@v3