https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117598
--- Comment #6 from Sam James <sjames at gcc dot gnu.org> --- https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html#index-flto says > To use the link-time optimizer, -flto and optimization options should be > specified at compile time and during the final link. It is recommended that > you compile all the files participating in the same link with the same > options and also specify those options at link time. But really, you should pass as many of the same options as possible. It is not just about optimisation, but e.g. -Werror needs to be repeated (because of late warnings, I fixed that in Meson a little while ago). We don't stream every single option and it would waste time/memory/disk to do that, and it may even cause issues if people deliberately don't want to do something at link-time when testing or similar. Note that you're not using the native CMake support for LTO which is INTERPROCEDURAL_OPTIMIZATION. If that is enabled, maybe it handles this properly for you. If not, please file a CMake bug (and link it here).