CMAKE_IPO_ISSUE msvc (/LTCG:incremental)

I’ve create a public github to demonstrate this issue.

set(CMAKE_INTERPROCEDURAL_OPTIMIZATION ON)

The code above turns on LTO but not in an always desirable fashion.

It sets /LTCG to be INCREMENTAL. Which isn’t what I want for release configs.

I might want INCREMENTAL for debug, relwithdebinfo, etc. But not release. But it looks like I have no control over it.

1 Like

This issue is Windows MSVC specific.

The options CMake uses for IPO on MSVC can be seen here. It compiles with /GL and links with /INCREMENTAL:NO /LTCG. The Visual Studio generator then sends the flags through this mapping to convert them to the actual .vcxproj content. I think the order of the flags in that mapping may be wrong. You can try hacking that json file in your local installation to switch the two blocks seen in my link.

Please open an issue for this on the CMake Issue Tracker.

After looking at the implementation, the Visual Studio generator is not using those places I linked that list LTCG flags. It is directly implementing the INTERPROCEDURAL_OPTIMIZATION target property by generating .vcxproj settings.

Either way, please open an issue for this.

I’ve created the issue for this.

https://gitlab.kitware.com/cmake/cmake/issues/20484

I’ve also been having this issue.

Thanks hdf89shfdfs :slight_smile:

1 Like