Quantcast
Channel: Active questions tagged gcc - Stack Overflow
Viewing all articles
Browse latest Browse all 22045

Issues with Link Time Optimization (LTO) on avr-gcc with ATmega328

$
0
0

I’m working on a project with an ATmega328 and using avr-gcc/g++. I'm trying to enable Link Time Optimization (LTO), but I’m encountering issues during linking.

Here's a simplified example:

•   Static Library: libATmega328__T_LIB.a (consists of blink.cpp and blink.cpp.obj)•   Executable: ATmega328__T_ uses the blink() function defined in blink.cpp.obj within main.cpp.

Compiler Flags:

tools.build:cxxflags=['-mmcu=atmega328', '-O2', '-ffunction-sections','-fdata-sections', '-fno-exceptions', '-fno-rtti', '-flto','-fuse-linker-plugin', '-fno-devirtualize']

Linker Flags:

tools.build:exelinkflags=['-Wl,--gc-sections', '-flto']tools.build:sharedlinkflags=['-Wl,--gc-sections', '-flto']

Build Environment:

AR=/opt/avr8-gnu-toolchain-linux_x86_64/bin/avr-arAS=/opt/avr8-gnu-toolchain-linux_x86_64/bin/avr-asRANLIB=/opt/avr8-gnu-toolchain-linux_x86_64/bin/avr-ranlibCC=/opt/avr8-gnu-toolchain-linux_x86_64/bin/avr-gccCXX=/opt/avr8-gnu-toolchain-linux_x86_64/bin/avr-g++STRIP=/opt/avr8-gnu-toolchain-linux_x86_64/bin/avr-strip

When I try to link the project, I get the following errors:

[ 60%] Linking CXX static library libATmega328__T_LIB.a/opt/avr8-gnu-toolchain-linux_x86_64/bin/avr-ar: CMakeFiles/ATmega328__T_LIB.dir/blink.cpp.obj: plugin needed to handle lto object/opt/avr8-gnu-toolchain-linux_x86_64/bin/avr-ranlib: blink.cpp.obj: plugin needed to handle lto object[100%] Linking CXX executable ATmega328__T_/tmp/ccWiGx4b.ltrans0.ltrans.o: In function `main':<artificial>:(.text.startup.main+0x0): undefined reference to `blink()'collect2: error: ld returned 1 exit status

It seems that the plugin for LTO isn’t being used correctly, even though I have specified -flto in the flags. Does anyone have an idea on how to resolve this issue?


Viewing all articles
Browse latest Browse all 22045

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>