From: Ulrich Eckhardt on
Hi!

We're currently looking for a Heisenbug here and one facet we're looking at
is the two features from the topic. Our setup is an MS Windows CE 6,
running on an x86 board. Our code is tompiled using VS2005. A few questions
came up:

1. There is a setting in the "General" tab that says "Whole Program
Optimization". There also is one in the C++ with the same name. Further,
there is one in the linker settings that reads "Link Time Code Generation".
If the one in the C++ tab is set, you get a warning unless you activate the
one for the linker, too. What are the further relations between those
three?

2. We have activated the program database for debugging, which increased the
size of our binary by ~30%. I was under the impression that all additional
info is put into the PDB-file. What additional info is put into the
executable? Also, does this affect optimizations in any way?

Thanks for clarifications!

Uli

--
C++ FAQ: http://parashift.com/c++-faq-lite

Sator Laser GmbH
Geschäftsführer: Thorsten Föcking, Amtsgericht Hamburg HR B62 932
From: Igor Tandetnik on
Ulrich Eckhardt wrote:
> 1. There is a setting in the "General" tab that says "Whole Program
> Optimization". There also is one in the C++ with the same name. Further,
> there is one in the linker settings that reads "Link Time Code Generation".
> If the one in the C++ tab is set, you get a warning unless you activate the
> one for the linker, too. What are the further relations between those
> three?

Whole program optimization requires cooperation between compiler and linker. Very roughly, the compiler dumps a parse tree into the object file rather than the actual machine code. At link time, the linker calls back into the compiler to generate machine code; at this point, the compiler can see the whole program, not just a single translation unit - hence the name.

For this to work, compiler and linker settings have to be set in compatible ways. The property on General tab sets them both correctly. You can also change them independently on C/C++ | Optimization and Linker | Optimization tabs, but then it's your responsibility to have them match (if they don't, you may get a warning).
--
With best wishes,
Igor Tandetnik

With sufficient thrust, pigs fly just fine. However, this is not necessarily a good idea. It is hard to be sure where they are going to land, and it could be dangerous sitting under them as they fly overhead. -- RFC 1925