-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Optimize for size #32296
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
Comments
As far as I know, yes, this isn't a thing. |
I believe both GCC and Clang support the |
Give this a try:
I guess static linking of libstd is "to blame" for the output size rather than the optimization level. By the way, Rust FAQ must have an item on the issue of "huge" binary size. |
Embedded systems don't usually include |
@engstad, the idea of So yeah, that would be a welcome addition with benchmarking in mind. |
@engstad Are you working on an embedded system already without libstd, and the output binary size is still that important? Well, I tend to agree that smaller binaries are faster to load... FYI, when I compiled GNU Make with Clang 4.8 x86_64 -Ofast and -Os, the stripped binary sizes were 192 KB vs 175 KB, 10 % difference. |
@nodakai Yes, indeed. My two chips have 4 KiB (http://www.nxp.com/products/microcontrollers-and-processors/arm-processors/lpc-cortex-m-mcus/lpc-cortex-m0-plus-m0/lpc800-series/low-cost-32-bit-microcontroller-mcu-based-on-arm-cortex-m0-plus-core:LPC810M021FN8) and 32 KiB total ROM (http://www.nxp.com/products/microcontrollers-and-processors/arm-processors/lpc-cortex-m-mcus/lpc-cortex-m0-plus-m0/lpc1100-series/32kb-flash-4kb-sram-dip28-package:LPC1114FN28), so memory size is quite important. |
…imum size options. Closes rust-lang#32296
Add CodeGen options to optimize for size. Add CodeGen options to annotate functions with the attributes OptimizeSize and/or MinSize used by LLVM to reduce .text size. Closes #32296
@engstad @nodakai I've been looking for up to date information in regards to using Rust with embedded systems such as the Cortex M range of MCU that do not run Linux OS due to lack of resources. Is there any reference/information you can refer me to? I'm aware of Zinc.rs but that is not quite ready yet from what I understand. Are you able to interact with Arduino or mbed libraries? Are you using Rust freestanding/bare metal or with an RTOS like FreeRTOS/ChibiOS/Zephyr? I've read that for MCU to have Rust working we must avoid using the std lib, @nodakai gives me the impression that higher end MCU do not have to avoid this? |
It seems that the compiler doesn't understand -Os (optimize for size):
The text was updated successfully, but these errors were encountered: