View Issue Details [ Jump to Notes ] | [ Print ] | ||||||||
ID | Project | Category | View Status | Date Submitted | Last Update | ||||
0006794 | CMake | CMake | public | 2008-04-11 15:49 | 2011-05-02 14:45 | ||||
Reporter | Luke K | ||||||||
Assigned To | Bill Hoffman | ||||||||
Priority | normal | Severity | major | Reproducibility | always | ||||
Status | closed | Resolution | fixed | ||||||
Platform | OS | OS Version | |||||||
Product Version | |||||||||
Target Version | Fixed in Version | ||||||||
Summary | 0006794: Visual Studio compiler 'WholeProgramOptimization' (/LTCG) | ||||||||
Description | Hi, The cl.exe compiler option /LTCG (i.e. "WholeProgramOptimization") does not seem to be generated correctly into the Visual Studio project file. This error occurs in Visual Studio .NET 2003 (v7.1), and probably occurs in later versions as well. The /LTCG is a whole configuration setting, which should be added to the "Configuration" xml tag in the vcproj file as in the following example: <Configuration Name="Release|Win32" OutputDirectory="Release" . . . WholeProgramOptimization="TRUE"> This should be an easy fix. Please feel free to contact me with any questions you may have. Thanks! Luke | ||||||||
Tags | No tags attached. | ||||||||
Attached Files | |||||||||
Relationships | |
Relationships |
Notes | |
(0013076) Bill Hoffman (manager) 2008-08-19 15:09 |
Committer: Bill Hoffman <bill.hoffman@kitware.com> /cvsroot/CMake/CMake/Source/cmGlobalVisualStudio7Generator.cxx,v <-- cmGlobalVisualStudio7Generator.cxx new revision: 1.101; previous revision: 1.100 BTW, this flag is not supported in VS8 and greater: cl : Command line warning D9002 : ignoring unknown option '/LTGC' |
(0014292) Luke K (reporter) 2008-12-04 18:32 |
This MSVC 7.1 issue is not entirely resolved. I am still seeing numerous warnings when dependent static libraries are built prior to linking the final executable: [ 45%] Building CXX object Util/CMakeFiles/Util-SL.dir/XMLUtil/XMLWriter.cpp.obj XMLWriter.cpp Linking CXX static library ..\build\MT-DLL\Util-SL.lib XMLWriter.cpp.obj : warning LNK4218: non-native module found; restarting link with /LTCG [ 45%] Built target Util-SL The /LTCG option is added to the executable linker line now (in the "AdditionalOptions" linker section), but I think that the above warning is caused by a missing WholeProgramOptimization="TRUE" element in the static library project files (in the Configuration tag). I think the best way to resolve this issue is to detect the /GL compiler flag and insert the WholeProgramOptimization="TRUE" element into the Configuration tag. The compiler flag /GL and linker flag /LTCG are almost synonymous flags that mean "perform whole program optimization". This warning is a result of a discrepancy between the /GL flag and the WholeProgramOptimization element. If /GL is passed as a compiler arg, then it is necessarily true that WholeProgramOptimization element should = "TRUE" (otherwise = "FALSE" or omitted). Thank you for your time and effort. I appreciate the hard work that you have all done to make and keep CMake a high-quality software product. Sincerely, Luke Kucalaba |
(0014294) Luke K (reporter) 2008-12-04 18:50 |
I did some more investigation of this problem, and I think I've nailed it down now. I thought it was the missing WholeProgramOptimization element that was causing the warning, when in fact it is the missing "/LTCG" flag that should be in the Librarian additional command-line options. I realize that for a static library project the linker flags are not included in the generated project file, but this should be an exception case to that rule. As a general rule of thumb, if the /GL compiler flag is passed to a static library project, then the /LTCG flag should be passed to the Librarian AdditionalOptions line. <Tool Name="VCLibrarianTool" AdditionalOptions="/LTCG"> Thanks again, Luke |
(0014314) Luke K (reporter) 2008-12-09 14:44 |
Problem solved! I finally found some time today to checkout the CMake source code and get setup for development. I started the build and found the answer I was looking for in cmLocalVisualStudio7Generator::OutputBuildTool() : const char* tool = "VCLibrarianTool"; fout << "\t\t\t<Tool\n" << "\t\t\t\tName=\"" << tool << "\"\n"; if(const char* libflags = target.GetProperty("STATIC_LIBRARY_FLAGS")) { fout << "\t\t\t\tAdditionalOptions=\"" << libflags << "\"\n"; } Here is the solution that worked for me... if you have a similar problem you can use the same concept for your situation: If(WIN32 AND MSVC71) String(REGEX MATCH "/GL" matchResult "${compilerFlagsDebug}") If(matchResult) Set_Target_Properties("${targetFilenameDebug}" PROPERTIES STATIC_LIBRARY_FLAGS "/LTCG" ) EndIf() String(REGEX MATCH "/GL" matchResult "${compilerFlagsRelease}") If(matchResult) Set_Target_Properties("${targetFilenameRelease}" PROPERTIES STATIC_LIBRARY_FLAGS "/LTCG" ) EndIf() EndIf() Thanks again for everything. Our build system is now completely free of errors and warnings! Luke |
(0024612) David Cole (manager) 2011-01-12 06:40 |
Resolving issue that I accidentally stumbled across... and according to all the notes in the bug, it appears fixed. Please re-open if there is still an issue here. |
(0026329) David Cole (manager) 2011-05-02 14:45 |
Closing resolved issues that have not been updated in more than 3 months. |
Notes |
Issue History | |||
Date Modified | Username | Field | Change |
2008-04-11 15:49 | Luke K | New Issue | |
2008-08-19 15:09 | Bill Hoffman | Status | new => closed |
2008-08-19 15:09 | Bill Hoffman | Note Added: 0013076 | |
2008-08-19 15:09 | Bill Hoffman | Resolution | open => fixed |
2008-12-04 18:32 | Luke K | Note Added: 0014292 | |
2008-12-04 18:32 | Luke K | Status | closed => feedback |
2008-12-04 18:32 | Luke K | Resolution | fixed => reopened |
2008-12-04 18:50 | Luke K | Note Added: 0014294 | |
2008-12-09 14:44 | Luke K | Note Added: 0014314 | |
2008-12-15 10:35 | Bill Hoffman | Status | feedback => assigned |
2008-12-15 10:35 | Bill Hoffman | Assigned To | => Bill Hoffman |
2011-01-12 06:40 | David Cole | Note Added: 0024612 | |
2011-01-12 06:40 | David Cole | Status | assigned => resolved |
2011-01-12 06:40 | David Cole | Resolution | reopened => fixed |
2011-05-02 14:45 | David Cole | Note Added: 0026329 | |
2011-05-02 14:45 | David Cole | Status | resolved => closed |
Issue History |
Copyright © 2000 - 2018 MantisBT Team |