Skip to content

Commit afd8d39

Browse files
committed
Split release profile into release and release-opt
In `Cargo.toml`: - Add thin LTO to `release` profile. - Create `release-opt` profile with fat LTO and other slow optimizations, as well as stripping all symbols. - Remove some old commented out configuration that has been superseded by more granular configuration (separate from the above changes) In the `release.yml` CI workflow: - Build `release-opt` rather than `release` workflow. - Use an environment variable to name the `release-opt` profile so it is easy to change and identify (and make the style in which long options are passed more consistent). - Remove explicit stripping of debug symbols, since `release-opt` does that. - *Temporarily* disable the step that takes the release from draft to published, to avoid publishing more "DO-NOT-USE" releases than necessary when testing the workflow (since, for example, it is possible for them to appear in users' "Home" feeds on GitHub). This change must be undone, so the workflow will really publish.
1 parent 29898e3 commit afd8d39

File tree

2 files changed

+17
-28
lines changed

2 files changed

+17
-28
lines changed

.github/workflows/release.yml

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ jobs:
139139
TARGET: ${{ matrix.target }}
140140
TARGET_FLAGS: --target=${{ matrix.target }}
141141
TARGET_DIR: target/${{ matrix.target }}
142+
PROFILE: release-opt
142143

143144
steps:
144145
- name: Checkout repository
@@ -171,23 +172,9 @@ jobs:
171172
echo "target flag is: $TARGET_FLAGS"
172173
echo "target dir is: $TARGET_DIR"
173174
174-
- name: Build release binary
175+
- name: Build release binary (with extra optimizations)
175176
run: |
176-
"$CARGO" build --verbose --release "$TARGET_FLAGS" --no-default-features --features "$FEATURE"
177-
178-
- name: Strip release binary (x86-64 Linux, and all macOS)
179-
if: matrix.target == 'x86_64-unknown-linux-musl' || matrix.os == 'macos-latest'
180-
run: strip "$TARGET_DIR"/release/{ein,gix}
181-
182-
- name: Strip release binary (ARM Linux)
183-
if: matrix.target == 'arm-unknown-linux-gnueabihf'
184-
run: |
185-
docker run --rm -v \
186-
"$PWD/target:/target:Z" \
187-
rustembedded/cross:arm-unknown-linux-gnueabihf \
188-
arm-linux-gnueabihf-strip \
189-
/target/arm-unknown-linux-gnueabihf/release/ein \
190-
/target/arm-unknown-linux-gnueabihf/release/gix
177+
"$CARGO" build --verbose --profile="$PROFILE" "$TARGET_FLAGS" --no-default-features --features="$FEATURE"
191178
192179
- name: Determine archive basename
193180
run: echo "ARCHIVE=gitoxide-$FEATURE-$VERSION-$TARGET" >> "$GITHUB_ENV"
@@ -200,8 +187,8 @@ jobs:
200187
- name: Build archive (Windows)
201188
if: matrix.os == 'windows-latest'
202189
run: |
203-
file -- "$TARGET_DIR"/release/{ein,gix}.exe
204-
cp -- "$TARGET_DIR"/release/{ein,gix}.exe "$ARCHIVE/"
190+
file -- "$TARGET_DIR/$PROFILE"/{ein,gix}.exe
191+
cp -- "$TARGET_DIR/$PROFILE"/{ein,gix}.exe "$ARCHIVE/"
205192
7z a "$ARCHIVE.zip" "$ARCHIVE"
206193
/usr/bin/core_perl/shasum --algorithm=256 --binary "$ARCHIVE.zip" > "$ARCHIVE.zip.sha256"
207194
echo "ASSET=$ARCHIVE.zip" >> "$GITHUB_ENV"
@@ -210,8 +197,8 @@ jobs:
210197
- name: Build archive (Unix)
211198
if: matrix.os != 'windows-latest'
212199
run: |
213-
file -- "$TARGET_DIR"/release/{ein,gix}
214-
cp -- "$TARGET_DIR"/release/{ein,gix} "$ARCHIVE/"
200+
file -- "$TARGET_DIR/$PROFILE"/{ein,gix}
201+
cp -- "$TARGET_DIR/$PROFILE"/{ein,gix} "$ARCHIVE/"
215202
tar czf "$ARCHIVE.tar.gz" "$ARCHIVE"
216203
shasum --algorithm=256 --binary "$ARCHIVE.tar.gz" > "$ARCHIVE.tar.gz.sha256"
217204
echo "ASSET=$ARCHIVE.tar.gz" >> "$GITHUB_ENV"
@@ -346,7 +333,8 @@ jobs:
346333
env:
347334
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
348335

349-
- name: Publish the release
336+
- name: Publish the release # FIXME: Reenable this.
337+
if: false
350338
run: gh release --repo="$REPOSITORY" edit "$VERSION" --draft=false
351339
env:
352340
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Cargo.toml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -206,17 +206,18 @@ sha1_smol = { opt-level = 3 }
206206

207207
[profile.release]
208208
overflow-checks = false
209-
#lto = "fat"
210-
# this bloats files but assures destructors are called, important for tempfiles. One day I hope we
209+
lto = "thin"
210+
# This bloats files but assures destructors are called, important for tempfiles. One day I hope we
211211
# can wire up the 'abrt' signal handler so tempfiles will be removed in case of panics.
212-
panic = 'unwind'
213-
#codegen-units = 1
212+
panic = "unwind"
214213
incremental = false
215214
build-override = { opt-level = 0 }
216215

217-
# It's not quite worth building dependencies with more optimizations yet. Let's keep it here for later.
218-
#[profile.dev.package."*"]
219-
#opt-level = 2
216+
[profile.release-opt]
217+
inherits = "release"
218+
lto = "fat"
219+
codegen-units = 1
220+
strip = "symbols"
220221

221222
[workspace]
222223
members = [

0 commit comments

Comments
 (0)