30

What is there to gain from the use of this switch in a large VS solution (200 VC projects)?

From what I understand this mainly affects the size of the resulting binaries; but aside from smaller binaries, could FLL also help in reducing dependencies between projects?

How does FLL usually affect build times?

I'd also appreciate an educated explanation on FLL in VC. MSDN's explanation is pretty brief.

Tim Sylvester
  • 22,897
  • 2
  • 80
  • 94
Assaf Lavie
  • 73,079
  • 34
  • 148
  • 203
  • 2
    To add on to mwigdahl's excellent post: [here](https://ribosome.helixcommunity.org/2005/devdocs/FuncLevelLinking)'s a link that explains how to achieve FLL for g++ -- this may give you some additional insights. – dirkgently Mar 10 '09 at 12:51
  • 2
    The link in the question seems to be changed and leads to some different page. – kiner_shah May 01 '20 at 04:29

1 Answers1

38

Since you linked MSDN's explanation, you know that /Gy ensures that all functions are packaged in their own COMDAT. The main advantage of this is that if you have identical functions the linker can collapse them all down into one actual piece of code ("COMDAT folding"). This can have very large impacts when you have many identical functions, which is often the case when you write modern C++ that is heavy on templates.

Aside from the smaller size of the resulting executable due to COMDAT folding and elimination of unreferenced COMDATs, there's no other effect of /Gy. To be specific, it doesn't help in reducing interproject dependencies.

The cost is a slight increase in compilation time (similar to other optimizer flags). Usually not something you'll notice.

mwigdahl
  • 16,268
  • 7
  • 50
  • 64
  • 1
    if application A references a function F1 in static library B, which resides (without /Gy) in the same COMDAT section with a function F2 in B that references symbol F3 in C, this creates a dependency between A and C which would otherwise not be needed. If A and B do not have a project dependency on C defined, A would not compile even though no code path from A references F3, and this would be prevented by /Gy. Is this wrong? – Pavel Radzivilovsky Aug 01 '10 at 09:20