LTCG warning on Visual Studio 2019

I spent some time on this today, but couldn’t figure out the answer, I would appreciate if somebody could chime in!

If I just create a fresh plugin project and compile the release code, I’ll get a warning for all formats:
“Not all modules are compiled with -Gy (function comdat), build without incremental LTCG.”

So the question is, does this mean LTCG is ignored fully, or does this mean it will still use Link Time Code Generation, but not with the Incremental option (Juce adds “/LTCG: incremental” as a linker flag).

I can get rid of this warning by adding “/Gy” by hand as an extra compiler option in Projucer, but if
“/LTCG: incremental” is default in Juce, and it needs the “/Gy” option, then why Projucer is not adding the latter to the projects as default?

Obviously if the warning doesn’t mean that it will totally discard /LTCG, but instead of “”/LTCG: incrememntal" it will fall back to “/LTCG” then all good, it’s just a bit confusing to see a warning there that says LTCG won’t be used.

It seems that enabling WholeProgramOptimization in the configuration properties is setting the incremental LTCG setting for the linker, which is incompatible when the function-level linking (/GY) setting isn’t also enabled, so MSVC falls back to non-incremental LTCG and emits a warning when doing so. Instead of enabling function-level linking which might have other unexpected side effects, we can explicitly disable incremental LTCG to get rid of the warning. We’ve added this to develop in 0335d43 so if you re-build the Projucer with this commit and re-save your projects the warning will be gone.


Thank you Ed for the quick fix!