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

Enable LTO on the release profile #175

Closed
sorairolake opened this issue Sep 11, 2021 · 3 comments
Closed

Enable LTO on the release profile #175

sorairolake opened this issue Sep 11, 2021 · 3 comments

Comments

@sorairolake
Copy link
Contributor

This makes the binary smaller and may also improve performance.

  • .rwxr-xr-x 16,163,864 root 11 Sep 18:37 target/release/xh # disabled (about 15 MiB)
  • .rwxr-xr-x 11,236,416 root 11 Sep 18:42 target/release/xh # enalbed (about 11 MiB)

Add to Cargo.toml:

[profile.release]
lto = true
@blyxxyz
Copy link
Collaborator

blyxxyz commented Sep 11, 2021

Wow, that's a big improvement! Seems like a good idea.

What's the difference after also stripping debug symbols?

@sorairolake
Copy link
Contributor Author

sorairolake commented Sep 11, 2021

@blyxxyz I also tried when stripping, it was smaller than when LTO is disabled.

  • 8.5 MiB (strip only)
  • 7.2 MiB (LTO and strip)

@ducaale
Copy link
Owner

ducaale commented Sep 15, 2021

@sorairolake a 15% reduction in binary size is still an improvement. Would you mind creating a PR for it? Thanks

On a slightly related note, there is a nightly cargo feature that can automate stripping binaries. Once that stabilizes, we can remove the Strip release binary (linux and macOS) step from .github/workflows/release.yaml.

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

No branches or pull requests

3 participants