Add the option of lto

Closes #759, continuation of #790.