Rahix / avr-hal-template

cargo-generate template for avr-hal projects
Apache License 2.0
130 stars 28 forks source link

Update Cargo.toml. Remove debug info from release build #27

Closed antonio-sc66 closed 8 months ago

antonio-sc66 commented 8 months ago

Debug information uses a lot of space for the binary file, which might result in simple binaries having bigger sizes than the Flash of the device.

In release mode, the program should be as compact as it can be in order to upload it to the microcontroller and use it as a final program/product.

If somebody needs the debug information that should be during developing and testing, for those situations, development profile should be used instead

Rahix commented 8 months ago

Hi,

debug information is never written to flash when uploading code to your microcontroller. It only lives in the ELF file that's produced when compiling the project. When calling avrdude, only the actual code and data sections of the ELF are written to the MCU's flash.

Generally, this means that there is no reason to not produce debug information in embedded microcontroller projects like these here.

antonio-sc66 commented 8 months ago

Ok, Thank you for the acclaration!

I had a wrong understanding of how many symbols were being introduced and thought more infomation was being added when debug is enabled.

I understand your point, but having smaller elf files with stripped information still has other small advantages and generally, nobody will expect extra information to be there in a release profile.

If you prefer to leave it like it is I can close the PR. Please tell me.

Rahix commented 8 months ago

The motivation for explicitly enabling debug in release was this: When you deploy a firmware (release build) and then later notice a crash on production hardware, you'll want to be able to attach a debugger and take a closer look where it is crashing. You can only do that if you built the release firmware with debug information back when the release was made. So it's a saner default in my eyes to have the release info enabled than having it disabled...