Mick
Mick

Reputation: 7957

Diagnose slow link

I have a project (x64) which is taking a long time to link.

I set the link to VERBOSE then watched assorted text flash by, then it says...

1>  Finished searching libraries
1>
1>  Finished pass 1
1>
1>  Generating code

This is where it remains for up a to a minute. I am wondering, could it be taking its time because its trying some fancy optimisation... or could it be that I have a large amount of static data? Are there any linker settings that may help speed things up?

BTW, I have a i7 PC with 16GB RAM and and the compiler and project are all stored on a Solid State Drive.

Edit: it links 10x faster with a debug build, but I need to work with the release version because otherwise the program runs too slowly.

Edit: Below you can see the optimisation settings dialog from the (fast) debug configuration. The selections for enable COMDAT folding, function order and link time code generation are all blank... I have no idea what "blank" means. I can't set enable COMDAT folding, function order and link time code generation to blank in the release configuration, the dropdown menu's for each of them does not have blank as an option and I don't know what to set them to in order to give the linker the least amount of work to do.

enter image description here

Edit: There doesn't seem to be a way to disable link time code generation! It's not an option when in the release configuration!

Upvotes: 0

Views: 767

Answers (1)

Justin R.
Justin R.

Reputation: 24091

In addition to disabling link-time optimization, you might also want to try disabling whole-program optimization (in options at 'C/C++ -> Optimization -> Whole Program Optimization').

Screenshot

Some additional options from the C++ team:

  1. /incremental (linker)
  2. /Zc:inline (compiler)
  3. /debug:FASTLINK (linker)
  4. /LTCG:incremental (linker)

Note that you can find all of the linker options in VS under 'Configuration Properties > Linker > All Options'. There you can search for e.g. 'Link Time Code Generation'.

Upvotes: 2

Related Questions