Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between /GL and /LTCG in Visual Studio

I tried looking online for the differences but couldn't get a lot. The two options sound related to each other:

/LTCG: https://msdn.microsoft.com/en-us/library/xbf3tbeh.aspx

The /LTCG option tells the linker to call the compiler and perform whole-program optimization.

/GL: https://msdn.microsoft.com/en-us/library/0zza0de8.aspx

Enables whole program optimization.

Does anybody know the exact difference?

like image 595
neerad29 Avatar asked Feb 18 '16 02:02

neerad29


1 Answers

/GL is a compiler option and /LTCG is a linker option. According to the documentation they are closely related to each other. For example:

/LTCG is implied with /GL

However, /LTCG can be employed without using /GL.

The /LTCG option tells the linker to call the compiler and perform whole-program optimization. You can also do profile guided optimization.

How is profile guided optimization enabled? By using the /GL option.

/GL also makes profile guided optimization available; see /LTCG

What is profile guided optimization? Here's a snippet from the start of the profile guided optimization documentation:

Profile-guided optimization lets you optimize an output file, where the optimizer uses data from test runs of the .exe or .dll file. The data represents how the program is likely to perform in a production environment.

like image 137
James Adkison Avatar answered Oct 02 '22 12:10

James Adkison