It appears as if the underlying compiler bug was fixed for 8.1 but has not been backported
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69866
And 6.5 was the last release on the g++-6
series a few days ago. LTO is not critical, but there are some benchmarks supporting it
You may be able to install rstan without the -flto
flag but add it back to compile Stan programs at runtime.