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

Simple size optimization flags for Cargo by default #552

Merged
merged 1 commit into from
Jun 20, 2024
Merged

Conversation

alevy
Copy link
Member

@alevy alevy commented Jun 19, 2024

Very simply add three Cargo flags by default that seem to have a reasonable impact on code size in many examples, all used in the kernel as well:

  1. opt-level = "z" is LLVM's -Os, i.e., optimize for size not speed, please. This seems to help in all but very small examples (under 1k)
  2. codegen-units = 1 restricts Cargo from splitting crates up during compilation and in general should improve LTO the cost is slower compile times. In practice, this doesn't seem to make a difference in this repo for now, so this is mostly a forward thinking precaution.
  3. `"-C link-arg=-icf=all" combines identical compiled procedures. Seems to have marginal benefit.

Add a few arguments to Cargo/rustc to optimize better for code size
@alevy alevy added this pull request to the merge queue Jun 20, 2024
Merged via the queue into master with commit 140d7c2 Jun 20, 2024
3 checks passed
@alevy alevy deleted the sizeopt-flags branch June 20, 2024 11:51
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.

2 participants