Build_unflags usage confusion

I am using latest Pio and have problems with final linking failing. I have reverted to Python 3.7.7 and it gets further, but not complete. In the error, I saw “lto” mentioned. I inserted build_unflags = -flto. Here is a snip of the final compile, and it looks like the flag was not removed.

avr-g++ -o .pio\build\megaatmega2560\firmware.elf -Os -mmcu=atmega2560 -Wl,--gc-sections -flto -fuse-linker-plugin .pio\build\megaatmega2560\src\CRC32.cpp.o .pio\build\megaatmega2560\src\ContactManagementFunctions.cpp.o .pio\build\megaatmega2560\src\DiagnosticFunctions.cpp.o .pio\build\megaatmega2560\src\GSMFunctions.cpp.o .pio\build\megaatmega2560\src\MegaMaster.cpp.o .pio\build\megaatmega2560\src\MonitoringFunctions.cpp.o .pio\build\megaatmega2560\src\SlaveCommunicationFunctions.cpp.o .pio\build\megaatmega2560\src\Sounds.cpp.o .pio\build\megaatmega2560\src\WatchdogFunctions.cpp.o -L.pio\build\megaatmega2560 -Wl,--start-group .pio\build\megaatmega2560\libe03\libSPI.a .pio\build\megaatmega2560\libf01\libEthernet_ID872.a .pio\build\megaatmega2560\lib421\libSerialGSM.a .pio\build\megaatmega2560\libc98\libSdFat_ID322.a .pio\build\megaatmega2560\liba74\libWire.a .pio\build\megaatmega2560\libFrameworkArduinoVariant.a .pio\build\megaatmega2560\libFrameworkArduino.a -lm -Wl,--end-group
C:\Users\Owner\AppData\Local\Temp\ccVwudPP.ltrans1.ltrans.o: In function `main':
<artificial>:(.text.startup+0x76c): undefined reference to `notifyContactsAlarmResponse(int)'
C:\Users\Owner\AppData\Local\Temp\ccVwudPP.ltrans0.ltrans.o: In function `checkIncomingSMS() [clone .part.1] [clone .lto_priv.76]':
<artificial>:(.text+0x446): undefined reference to `notifyContactsAlarmResponse(int)'
collect2.exe: error: ld returned 1 exit status
*** [.pio\build\megaatmega2560\firmware.elf] Error 1
==================== [FAILED] Took 51.97 seconds ==================== 
PS C:\Users\Owner\Documents\PlatformIO\Projects\Alarm2>

Different project I take it? As I remember you saying that you’d gotten marlin working after the downgrade. Without seeing the platformio.ini complete, I can’t comment, as it could just be a typo, or something else has gone wrong. I’d find it strange if for instance it correctly removed the -flto flag on the Marlin project, but not on another. One thing to double check would be if your python version has sneakily updated itself (although really it shouldn’t - unless you are forcing PlatformIO to use a different version, it should be using it’s own bundled copy… what does python --version from a PIO terminal give you? Any different from a normal system terminal?)… then again… maybe I’m missing out on all the errors as it seems I’m still on Python 2.7 for my install! :laughing:

It is a different project. I can’t guarantee that the build flag worked on the other. I think it was the python change.

python --version Python 3.7.7

Platformio.ini snip
lib_archive = no
lib_compat_mode = strict
lib_ldf_mode = chain+
build_unflags = -flto

Did you end up resolving this?

We’d need to see your source files in order to resolve that.

Doesn’t affect final linker scripts, would need a advanced scripting addition.

1 Like