Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Function-Level Linking (/Gy switch in VC++) - What is it good for?

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.

like image 954
Assaf Lavie Avatar asked Mar 10 '09 12:03

Assaf Lavie


1 Answers

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.

like image 141
mwigdahl Avatar answered Oct 29 '22 12:10

mwigdahl