Mixing LTO and libraries requires the use of gcc-ar instead of ar. See https://gcc.gnu.org/wiki/LinkTimeOptimizationFAQ?action=recall&rev=5#ar.2C_nm_and_ranlib