platformio / platform-atmelavr

Atmel AVR: development platform for PlatformIO
https://registry.platformio.org/platforms/platformio/atmelavr
Apache License 2.0
138 stars 105 forks source link

Change lib_archive default for Arduino framework projects #154

Open joeuser846 opened 5 years ago

joeuser846 commented 5 years ago

The Arduino WiFi101 library fails at runtime when compiled with PIO. I ported working Arduino Mega code from the Arduino IDE to PIO. It compiled and linked without error. However, the WiFi101 library hangs when trying to connect to the AP. The same code works fine when compiled with the Arduino IDE or with Eclipse plus Sloeber plugin.

The reason is the PIO default setting of the lib_archive variable which is wrong if a library uses the "weak" attribute. See here:

"Setting lib_archive = no will instruct PIO Build System to link object files directly (in-line). This could be useful if you need to override weak symbols defined in framework or other libraries."

This bug report is to request that the default setting of lib_archive be changed to "no" for all Arduino framework projects. Any library might be using the "weak" attribute and therefore might fail at runtime with the current PIO defaults. The WiFi101 library uses "weak" but who knows how many others do too? This causes pernicious problems when porting code and likely causes many Arduino users to abandon PIO. Being 100% runtime compatible with the Arduino IDE and toolchain needs to be an essential objective of PIO. At present, it isn't. Changing the lib_archive default will help.