did I break avr-gcc? plugin needed to handle lto object

Go To Last Post
2 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

This is an advanced question, but I figured I'd try posting here as there are a couple gurus that read avrfreaks with whom I don't communicate directly.

I've been writing ArduinoShrink, a library which transparently replaces Arduino functions with smaller & faster versions. It's coded mostly in asm, and relies on the linker finding the symbols for standard Arduino functions in my library before it searches the core.a.  Instead of using the standard avr-libc ABI, I like to use a custom ABI with inline asm in order to reduce register pressure when my asm functions don't use all 12 registers specified in the avr-libc ABI.  However whenever I try to call micros_raw with inline asm (from an inline function in ArduinoShrink.h), I get the error "millis.c.o: plugin needed to handle lto object".

https://github.com/nerdralph/Ard...

 

I can work around the error by defining micros() in millis.c instead of in ArduinoShrink.h (and avr-gcc will still inline it due to LTO).  I suspect the issue has something to do with trying to make micros() an inline function, and therefore the code "call micros_raw" is built into the sketch .o instead of being built into the millis .o which is archived into ArduinoShrink.a.

 

Even though I have a way to make it work, I like to have a complete as possible understanding of the build system, so I would like to figure out the reason behind this error.

 

I have no special talents.  I am only passionately curious. - Albert Einstein

 

Last Edited: Wed. Jul 15, 2020 - 01:24 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

This is interesting!

 

Are you trying to use inline assembler in an inline function with gcc?

 

I did try that not so long ago with the gcc ( 5.4.0 ) that ships with Atmel-Studio ... with out any luck what so ever -> compiler error!?!

Had to revert to using macros instead :(

 

Concerning LTO i do not remember issues with object files but with static link libraries and the archiver not loading the LTO plugin ...

See my post here https://www.avrfreaks.net/forum/using-link-time-optimizer-flto-static-library for details!

 

Edit:

Oh, wow.

I just tried again to use inline assembler in an inline function ... what should i say, it worked!

I was absolutely sure i have tried it and it would not compile ... very strange!

 

Edit2:

Ah, never mind ... my memory did not server me well ...

It was not the combination of of inline function with inline asm that was not possible but naked inline functions!

 

Bertolt

Last Edited: Fri. Jul 17, 2020 - 08:47 AM