Skip to content

Consider using the circuitpython/lib/libm math library instead of -libm to save space #325

Closed
@dhalbert

Description

@dhalbert

The atmel-samd boards currently use -libm. This is supplied as part of glibc in the arm-none-eabi toolchain. Various functions there such as powf and sqrtf end up using the double-precision float arithmetic routines (__aeabi_dadd, dsub, etc.), which occupy a few thousand bytes.

There is an alternate simpler libm which is in our source tree which does not use doubles and is simpler in other ways. It's used for some other ports, including esp8266. I assume it might be numerically different as well, probably less precise.

When I tested switching atmel-samd to use the libm in our tree instead of -libm, the Gemma M0 firmware got smaller by 8780 bytes (!). This would give us the freedom to add a lot more stuff to the non-Express boards, and completely solves the current space squeeze (e.g., #322).

@tannewt @ladyada Do you have an opinion on this? Should we try to use the same libm across all atmel-samd boards (the size matters less for Express and M4).

The internal libm needs some work to remove compile warnings. Our -Werror errors out on all warnings.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions