[Solved] Native AVR code linker error in Platformio, not Atmel studio

Really loving Platformio IDE, running into linker error in PlatformIO 2.000-beta3

Throwing linker errors similar to

Linking .pioenvs/native_avr/firmware.elf

 `rx1_buffer' referenced in section `.text' of /var/folders/rv/4zb74pz12t1970l_8mwwv0sr0000gr/T//ccZbpPSV.ltrans1.ltrans.o: defined in discarded section `COMMON' of .pioenvs/native_avr/src/usart.o (symbol from plugin)

Links fine in Atmel Studio 7.0.1417.

platformio.ini is

[env:native_avr]
platform = atmelavr
board = atmega328pb

Any ideas?

Could you provide a simple test project to reproduce this issue?

Looks like this is a gcc linker/version issue, which can be worked around by adding

__attribute__((used))

after the problem variable definition;

eg

char rx0_buffer[RX0_BUFFER_SIZE] ;

becomes

char rx0_buffer[RX0_BUFFER_SIZE] __attribute__((used));

1 Like