Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: reduce executable size #59

Merged
merged 4 commits into from
May 6, 2024
Merged

feat: reduce executable size #59

merged 4 commits into from
May 6, 2024

Conversation

YOU54F
Copy link
Member

@YOU54F YOU54F commented Apr 25, 2024

Slim executables

[profile.release]
strip = true
opt-level = "z"
codegen-units = 1
lto = true

References

Motivation

Some of our client languages necessitate the inclusion of all supported platform/architecture combinations in a single package distributed to end-users.

Reducing the size of the executables and libraries if preferable, if there is no discernible difference for end user.

The proposed set of changes, opts not to set panic=abort over the default of panic=unwind.

The inclusion of the panic=abort will change behaviour which may lead to changes in how we program (if we are expecting to be able to unwind - maybe more relevant for the ffi?), but leads to smaller binary sizes. To go further than that, we need to build against nightly rust channels, which is probably less than preferable.

I believe these set of options provides the best trade-offs whilst remaining on a stable rust channel.

The strip option as a minimum should be included, it is actually now enabled by default in rust 1.77

- create linux executables linked statically to musl
  - drop gnu (glibc) target, executable will work on alpine & glibc based distros (debian etc)
- create windows aarch64 target
- refactor release script & workflow to match pact-reference
  - builds on pull request to master/main branch, in debug mode

Related epics

- musl all the things
  - pact-foundation/devrel#30
- more supported platforms
- install to ~/.pact/bin
    macos-latest has switched to arm64
    update arduino/setup-protoc@v3 to support arm64
# Slim executables

```toml
[profile.release]
strip = true
opt-level = "z"
codegen-units = 1
lto = true
```

## References
- https://doc.rust-lang.org/stable/rustc/codegen-options/
- https://doc.rust-lang.org/rustc/profile-guided-optimization.html
- https://github.com/johnthagen/min-sized-rust
Copy link

github-actions bot commented Apr 26, 2024

Unit Test Results

6 tests  ±0   6 ✔️ ±0   7s ⏱️ -2s
2 suites ±0   0 💤 ±0 
2 files   ±0   0 ±0 

Results for commit 18dbf5c. ± Comparison against base commit 68a327a.

♻️ This comment has been updated with latest results.

@rholshausen rholshausen merged commit 634026d into main May 6, 2024
49 checks passed
@rholshausen rholshausen deleted the feat/reduce_exe_size branch May 6, 2024 23:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants