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

[SOL] Optimize rustlib for size #119

Merged
merged 1 commit into from
Mar 6, 2025

Conversation

LucasSte
Copy link
Collaborator

@LucasSte LucasSte commented Mar 6, 2025

When we enable ALU32 with SBPFv2 and SBPFv3, rustc starts inlining more functions than before, since they may be smaller. Such aggressive inning increases program size.

Building the rust lib with the "s" option prevents inlining and loop unrolling.

rust/config.example.toml

Lines 429 to 443 in 08b7341

# Whether or not to optimize when compiling the compiler and standard library,
# and what level of optimization to use.
# WARNING: Building with optimize = false is NOT SUPPORTED. Due to bootstrapping,
# building without optimizations takes much longer than optimizing. Further, some platforms
# fail to build without this optimization (c.f. #65352).
# The valid options are:
# true - Enable optimizations.
# false - Disable optimizations.
# 0 - Disable optimizations.
# 1 - Basic optimizations.
# 2 - Some optimizations.
# 3 - All optimizations.
# "s" - Optimize for binary size.
# "z" - Optimize for binary size, but also turn off loop vectorization.
#optimize = true

@LucasSte LucasSte requested a review from Lichtso March 6, 2025 20:21
@LucasSte LucasSte marked this pull request as ready for review March 6, 2025 20:21
@LucasSte LucasSte merged commit 5ef2155 into anza-xyz:solana-1.79.0 Mar 6, 2025
18 checks passed
@LucasSte LucasSte deleted the bin-size branch March 6, 2025 21:00
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