I'm working on a project where I've added support for the ATtiny13 to Arduino IDE, including many of the "Arduino functions".
Right now I'm working on improving the pulseIn() function, and I've gotten quite far I think. I've been using a DDS signal generator as a clock source and pulse generator, and I've tuned the code to measure the pulse length of the signal quite accurate (compared with my oscilloscope). This timing sensitive function works great when LTO is enabled, but measures the pulse length incorrectly when LTO is disabled. Since this Arduino add-on project may be compiled with and without LTO enabled, I'd like to implement the pulseIn() function in assembly to make sure it's always accurate.
What I want to do is to compile the function with LTO enabled, and used the compiled output to make an assembly implementation. An example of where this is done can be found in the official Arduino repo (Wiring_pulse.S) (Wiring_pulse.c). The easiest way for my current setup would be to edit the platform.txt file. Question is, which flags should I add (and where) in order for avr-gcc to compile the pulseIn function and output a usable .S file?