Linker Problem

Hey all. I've been using Arduino on and off for a number of years and recently got back into it again. I'm using the Arduino IDE 1.8.1 on Windows 10. I've run into a weird linker issue. Sometimes when I compile my sketch I get the following error:

collect2.exe: error: ld returned 5 exit status

exit status 1
Error compiling for board Arduino/Genuino Uno.

This is, of course, after invoking avr-gcc with

avr-gcc" -Wall -Wextra -Os -g -flto -fuse-linker-plugin -Wl,--gc-sections -mmcu=atmega328p -o "C:\Users\radicchio\AppData\Local\Temp\arduino_build_543240/sketch_jan09a.ino.elf" "C:\Users\radicchio\AppData\Local\Temp\arduino_build_543240\sketch\sketch_jan09a.ino.cpp.o" "C:\Users\radicchio\AppData\Local\Temp\arduino_build_543240/core\core.a" "-LC:\Users\radicchio\AppData\Local\Temp\arduino_build_543240" -lm

I'm able to fix the problem by setting the Board field to a different target (i.e. Mini, Nano, Yun... etc.) I will continue to get this error sometimes but after a few tries I get it to compile successfully for a different board. I then switch the target back to Uno (board I'm using) and it compiles just fine (most of the time, occasionally have to repeat the process). All without any alterations to my code.

I can only assume that something is being improperly cached during the linking or compilation phases, but I'm not totally sure. It probably isn't even the IDE's fault. I'm wondering if anyone has run into a similar issue, and how you resolved it.

I suspect you're encountering this issue:

The developers think they have the issue fixed and there is a test build here:

if you want to try it out. If so, please report your results.