adafruit / circuitpython

CircuitPython - a Python implementation for teaching coding with microcontrollers
https://circuitpython.org
Other
4.13k stars 1.22k forks source link

Consider using clang/llvm in the long run #3180

Open dhalbert opened 4 years ago

dhalbert commented 4 years ago

clang/llvm is progressing, and might be considered as a replacement for gcc. Clang/llvm has helpful semantic analysis tools available via the tool chain that are not available via gcc. Better code formatting is also available: see #1012.

Historical background: https://medium.com/@alitech_2017/gcc-vs-clang-llvm-an-in-depth-comparison-of-c-c-compilers-899ede2be378

ARM's paid toolchain is now based on clang/llvm.

May 2020 article mostly about static analysis: https://interrupt.memfault.com/blog/arm-cortexm-with-llvm-clang

2018 article about code size comparisons on Cortex-M4; a few versions old: https://higaski.at/gcc-vs-clang-cortex-m4-benchmarks/

tannewt commented 2 years ago

I looked into this this afternoon. -Oz without LTO is still too large on SAMD21. It's not possible to -Oz with LTO and lld.

Relevant talk about LTO and sections: https://www.youtube.com/watch?v=hhaPAKUt35E

Changes for it are here: https://github.com/tannewt/circuitpython/tree/clang13

Build of feather_m0_express from dc5565a5c is 65664 bytes free in flash. With clang -Oz no lto, 12824 bytes are free.

-Oz not supported in the linker: https://reviews.llvm.org/D63976