Optimizing Link Times

I'm trying to merge our multi-dll project into a single EXE to get more advantage out of LTCG. The problem I'm having is that making this change has taken link times from 20-30 seconds up to 2:20, without enabling LTCG (in a debug build). I have incremental linking and use library dependancy inputs enabled, and with the uber-verbose output, it appears to be functioning. My final exe size in debug is 38 MB, and my .ilk file is 127 MB. Are there any optimizations I'm missing that could get my link times back to a reasonable speed, or is this about what I should expect for this size project

Thanks,
Chris


Answer this question

Optimizing Link Times

  • crbentle

    You have to know that with LTCG the main compilation process is done during link time.

    The Compile process with /GL just creates an intermidiate code. So the main compile process and optimization is done during LINK time. Thats the reason why linking time explodes with LTCG. There is no way arround it!



  • Daniel W

    Sorry if I wasn't clear, but I'm seeing the slow builds without enabling LTCG, with incremental linking apparently working (it's checked on, I get no warning, and a verbose link output shows it's going to .objs, not .libs). The motivation for the merge is to get LTCG for Release builds, but at the point, it doesn't look practical, since it takes our Debug builds from 20 seconds to 2:20. If this doesn't work out, I plan to make multiple build targets, one that builds to dlls, and one that builds to one exe, but that's a lot of work I was hoping to avoid by getting the exe link to go faster.

  • Manolis P

    Please read before you reply!

    This poor "journey" has stated his case clearly but still you fail to reply to the question, assuming he does something wrong. Now read carefully:

    Link time of 20 s was in a DLL scenario

    This increased to 2:20 just by going to static linkning in preparation for LTCG, which had not yet been turned on.

    Incremental linking was in effect.

    My own experience is that link times are intolerable for large exes for vcc >= 7.0. The time is consumed creating the PDB file and the reason is that the /PDBTYPE:SEPT was removed for 7.0. This has made our company stick with 6.0 until now, but it is getting increasingly difficult for other reasons...



  • Jordi Rambla

    With LTCG you can not do incremental linking, so that may be one effect you're seeing.  Additionally, LTCG simply takes longer to build.  It's a function of several things such as the size of the project, the amount of memory on the machine, the number of functions, etc...    The time deltas you report are not unexpected.  For that reason you shouldn't use LTCG for your typical builds as you're debugging, but rather for the less frequent builds. 

     



  • Camonra

    OK, gotcha. Let me just make sure I understand what you're comparing:

    20s debug builds are full builds, and 2:20 builds are also full builds Or are they both incremental builds, with the same chance in both projects

    Thanks,



  • Optimizing Link Times