I don’t know if it’s the same problem I had both on my main system and on a virtual machine, but I was able to work around it by using clang and disabling the lfto flag (there’s a weird linker problem with clang using this flag):
I use the gcc and I am always using this guide [Home · stan-dev/rstan Wiki · GitHub] to install Rstan.
I add one more CXXFLAGS += -DBOOST_PHOENIX_NO_VARIADIC_EXPRESSION
and it works (for me)