-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Add compiler flags -Os
and -Oz
to optimize binary size
#14463
Add compiler flags -Os
and -Oz
to optimize binary size
#14463
Conversation
Co-authored-by: Johannes Müller <straightshoota@gmail.com>
They could be confusing: they're not opt level 4 or 5 but opt size and opt mini size.
Co-authored-by: Sijawusz Pur Rahnama <sija@sija.pl> Co-authored-by: Johannes Müller <straightshoota@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue: The man page also needs an update.
LLVM only added |
I backported the function. It relies on a C++ class (for |
Wonderful, now it looks like the backport is only compatible with LLVM 16 |
Perhaps we could limit support for these new option to LLVM 17+? |
Or keep the legacy pass manager for LLVM < 17? or LLVM < 16 with the backported function. |
I went with a mix of PassManager (legacy) and PassBuilder. While older releases (LLVM <= 12) always use PassManager, and the newest releases (LLVM >= 17) always use PassBuilder, the intermediary releases (LLVM 13 to 16) preferably use PassBuilder but fallback to use the legacy PassManager for Hopefully, that should now compile, and avoid to segment the opt levels to the LLVM version that Crystal happens to have been compiled with (all versions from LLVM 12 to 18 compiled on my local) 🤞
|
Don't remove the types and only up the deprecation to only warn from LLVM 17, even though the feature was removed, in order to keep the documentation, while avoiding a deprecation warning when compiling crystal on LLVM 13 to 16.
-Os
and -Oz
to optimize binary size
Follows LLVM defaults. Tajkes advantage that LLVMRunPasses now handles Os and Oz directly, and manually applies the LLVM defaults for LLVM 13 to 16 (new pas manager). The Oz configuration with the legacy manager (LLVM < 13) don't disable the vectorizations; I'm not sure how to do it or if it's worth implementing.
Maybe we'd like to adjust the inliner thresholds to account for Crystal. For example Rust uses 75 and 25. Clang also keeps the SLP vectorization enabled. I didn't check the impact (yet).
Of course this is related to #14393