none
Compiling with "Whole Program Optimization" but linker says no code generation required

    Question

  • Hello,

    I have an MFC application which uses "Whole Program Optimization" (/GL) and "Link time code generation" (/LTCG). The application contains files built with CLR support (/clr) making it mixed-mode. When using Visual Studio 2010, the linker happily generates code (saying "Generating code" and "Finished generating code". After upgrading the solution and projects included to Visual Studio 2013 the linker says:

    "LTCG specified but no code generation required; remove /LTCG from the link command line to improve linker performance"

    Looking at the compiler settings I can see that /GL is still specified so nothing has changed there. While compiling I observe that the compiler seems to generate code since it regularly says "Generating code". In Visual Studio 2010 this does not happen.

    I cannot figure out why "Whole Program Optimization" (/GL) does not seem to have any effect. So my question is: Does anyone know if new funcationality/options/situations in VS 2013 can cause /GL to be ignored?

    Thanks in advance!

    Johan

    Sunday, April 27, 2014 3:29 PM

Answers

  • Thank you for your answer!

    I managed to figure out that having /clr:nostdlib as an additional compiler option caused this problem. Removing that option caused /GM and /LTCG to work as I expect them to.

    /Johan

    Monday, April 28, 2014 2:14 PM

All replies

  • Hi Johan,

    Did you build in debug mode or release mode? I guess you may have compiled some of your files in release mode in VS2010 and now you compiled them in debug mode in VS2013.

    As far as I know, Visual Studio 2013 out of the box ships with Whole Program Optimization (WPO) enabled (/GL or /LTCG build flags) for 'release' build configurations. More about this, you can refer to the link below:

    Performance++ with Visual C++ 2013

    If you need to turn on optimization in a Debug build configuration, please see here.

    Hope this is helpful for you.

    May


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, April 28, 2014 9:03 AM
  • Thank you for your answer!

    I managed to figure out that having /clr:nostdlib as an additional compiler option caused this problem. Removing that option caused /GM and /LTCG to work as I expect them to.

    /Johan

    Monday, April 28, 2014 2:14 PM
  • Hi Johan,

    Thanks for sharing solution with us. This will help many other members who meet this kind of issue. Thanks!

    May


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, May 02, 2014 1:44 AM