.NET Framework Developer Center >
.NET Development Forums
>
MSBuild
>
Slow c++ builds with VS2008 / msbuild
Slow c++ builds with VS2008 / msbuild
- I noticed our c++ project builds with either VS2008 / msbuild are 3x to 5x slower than with VS2005. It turns out with that most of our c++ projects are not using precompiled headers (when building with 2008 or with 2005). This appears to be a bug with 2008. Using filemon, you can see lots of STL header file searches in rather odd directories before finding them in the expected location, this occurs for every single .cpp file being built. Enabling precompiled headers solves the problem, the builds go must faster in 2008.
Has anyone seen this before, and better still, is there a workaround that doesn't require enabling precompiled headers?
Many thanks,
-Chris O
Answers
- Hello,
Filemon output for one such header path lookup:
D:\src\srcmain\Base\pshpack1.h FILE NOT FOUND Attributes: Error
D:\src\srcmain\Common\pshpack1.h FILE NOT FOUND Attributes: Error
D:\src\srcmain\Model\pshpack1.h FILE NOT FOUND Attributes: Error
D:\src\srcmain\Image\pshpack1.h FILE NOT FOUND Attributes: Error
D:\src\srcmain\Build\DTK\include\pshpack1.h FILE NOT FOUND Attributes: Error
D:\src\srcmain\Server\Implementation\pshpack1.h FILE NOT FOUND Attributes: Error
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\pshpack1.h FILE NOT FOUND Attributes: Error
C:\Program Files\Microsoft Visual Studio 9.0\VC\atlmfc\include\pshpack1.h FILE NOT FOUND Attributes: Error
C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\pshpack1.h SUCCESS Attributes: A
C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\pshpack1.h SUCCESS Options: Open Access: All
C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\pshpack1.h NOT A DIRECTORY Options: Open Directory Access: All
C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\pshpack1.h SUCCESS Offset: 0 Length: 28672
C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\pshpack1.h SUCCESS
This occurs for *many* sdk headers for each single .cpp file being compiled.
Tools / Options / Projects and Solutions / VC++ Directories / Show directories for: Include files:
$(VCInstallDir)include
$(VCInsallDir)atlmfc\include
$(WindowsSdkDir)\include
$(FrameworkSDKDir)include
The env vars:
VCINSTALLDIR=C:\Program Files\Microsoft Visual Studio 9.0\VC
WindowsSdkDir=C:\Program Files\Microsoft SDKs\Windows\v6.0A\
No FrameworkSDKDir defined as an env var.
So why is cl.exe searching the above d:\src\srcmain\* dirs for SDK headers? That doesn't make any sense according to the 4 include file search paths. But wait a second this is odd (or maybe I'm odd ;-) the above 6 d:\src\srcmain\* dirs exactly match the Additional Include Directories for the vcproj I was building. So cl.exe appears to be searching my Additional Include Directories for Windows SDK headers? This didn't happen with VS2005, I had the same vcproj settings.
Many thanks for your help,
-Chris O- Marked As Answer byHongye SunMSFT, ModeratorSaturday, October 31, 2009 3:32 AM
- Sorry for the delayed response, Chris.
It is strange that VS 2005 doesn't search for Additional Include Directories, because according to MSDN documentation, both the C++ compiler 2.0 and 3.5 will search directories in following orders:-
Directories containing the source file.
-
Directories specified with the /I option, in the order that CL encounters them.
-
Directories specified in the INCLUDE environment variable.
You can change their orders to have a better compile performance.
The directories set in VS options page will be put into Include environment variable when compiling.
Hope it helps.
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.- Marked As Answer byHongye SunMSFT, ModeratorSaturday, October 31, 2009 3:32 AM
-
All Replies
- Hi Chris,
Can you please copy the searched paths from filemon to here?
The header file search paths can be configurable in VS. You can configure it by Tools / Options / Projects and Solutions / VC++ Directories / Show directories for: Include files
You should be able to view a list of file paths. Please let me know what they are.
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework! If you have any feedback, please tell us. - Hello,
Filemon output for one such header path lookup:
D:\src\srcmain\Base\pshpack1.h FILE NOT FOUND Attributes: Error
D:\src\srcmain\Common\pshpack1.h FILE NOT FOUND Attributes: Error
D:\src\srcmain\Model\pshpack1.h FILE NOT FOUND Attributes: Error
D:\src\srcmain\Image\pshpack1.h FILE NOT FOUND Attributes: Error
D:\src\srcmain\Build\DTK\include\pshpack1.h FILE NOT FOUND Attributes: Error
D:\src\srcmain\Server\Implementation\pshpack1.h FILE NOT FOUND Attributes: Error
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\pshpack1.h FILE NOT FOUND Attributes: Error
C:\Program Files\Microsoft Visual Studio 9.0\VC\atlmfc\include\pshpack1.h FILE NOT FOUND Attributes: Error
C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\pshpack1.h SUCCESS Attributes: A
C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\pshpack1.h SUCCESS Options: Open Access: All
C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\pshpack1.h NOT A DIRECTORY Options: Open Directory Access: All
C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\pshpack1.h SUCCESS Offset: 0 Length: 28672
C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\pshpack1.h SUCCESS
This occurs for *many* sdk headers for each single .cpp file being compiled.
Tools / Options / Projects and Solutions / VC++ Directories / Show directories for: Include files:
$(VCInstallDir)include
$(VCInsallDir)atlmfc\include
$(WindowsSdkDir)\include
$(FrameworkSDKDir)include
The env vars:
VCINSTALLDIR=C:\Program Files\Microsoft Visual Studio 9.0\VC
WindowsSdkDir=C:\Program Files\Microsoft SDKs\Windows\v6.0A\
No FrameworkSDKDir defined as an env var.
So why is cl.exe searching the above d:\src\srcmain\* dirs for SDK headers? That doesn't make any sense according to the 4 include file search paths. But wait a second this is odd (or maybe I'm odd ;-) the above 6 d:\src\srcmain\* dirs exactly match the Additional Include Directories for the vcproj I was building. So cl.exe appears to be searching my Additional Include Directories for Windows SDK headers? This didn't happen with VS2005, I had the same vcproj settings.
Many thanks for your help,
-Chris O- Marked As Answer byHongye SunMSFT, ModeratorSaturday, October 31, 2009 3:32 AM
- Sorry for the delayed response, Chris.
It is strange that VS 2005 doesn't search for Additional Include Directories, because according to MSDN documentation, both the C++ compiler 2.0 and 3.5 will search directories in following orders:-
Directories containing the source file.
-
Directories specified with the /I option, in the order that CL encounters them.
-
Directories specified in the INCLUDE environment variable.
You can change their orders to have a better compile performance.
The directories set in VS options page will be put into Include environment variable when compiling.
Hope it helps.
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.- Marked As Answer byHongye SunMSFT, ModeratorSaturday, October 31, 2009 3:32 AM
-
- Hi Chris
Please will you give us your conclusion for this issue? I am also finding that VS2008 builds are slower than VS2005 builds, for my C++ project. Any advice would be appreciated.
David
David - Hi David,
So far no luck, but I was looking for an easy alternative to enabling precompiled headers on the C++ projects. However, for our projects, enabling precompiled headers works for us; we do get the same build times as with VS2005. But there are still 70+ projects (and source files) to go. Certainly doable, but will take a little time.
As far as explaining the difference between 2005 and 2008 compilers, one could try: use the /showIncludes switch on both the 2005 and 2008 projects and see if there is anything obvious.
Hope this helps.
-Chris O - Hi Chris,
we are having the same problem, vc++ 2008 compilation is _really_ slower in our project than vc++ 2005 was. Something like 3 hours vs 10 hours.
We don't use precompiled headers neither.
Let us know if we found something...now I am going to investigate these include folder issues.
Zoltan


