Link Time Code Generation (LTGC) by default, for Release configurations of Visual Studio projects?

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Link Time Code Generation (LTGC) by default, for Release configurations of Visual Studio projects?

Niels Dekker
When a Visual C++ project is created within Visual Studio (by File menu,
New, Project...), it has Link Time Code Generation (LTGC) by default,
for its Release configurations: Compiler option /GL and linker option
/LTCG. However, when the Visual C++ project is generated by CMake, it
does not have LTGC, by default. LTCG looks like a very useful feature to
me. I think it's worth enabling the feature by default, for Release
configurations. What do you think?


Some details:

I created a "dummy" Visual C++ project in Visual Studio 2017 (Version
15.5.4), by File menu, New, Project..., and I also generated one by
CMake (version 3.10.2), using a very minimal CMakeLists.txt

The Visual C++ project created by Visual Studio 2017 has the following
compile options, by default, for Release (x64):

/permissive- /GS /GL /W3 /Gy /Zc:wchar_t /Zi /Gm- /O2 /sdl
/Fd"x64\Release\vc141.pdb" /Zc:inline /fp:precise /D "_MBCS"
/errorReport:prompt /WX- /Zc:forScope /Gd /Oi /MD /Fa"x64\Release\"
/EHsc /nologo /Fo"x64\Release\" /Fp"x64\Release\MyVS2015Project.pch"
/diagnostics:classic

And the following linker options:

/OUT:"F:\X\Src\MyProject\MyVS2015Project\x64\Release\MyVS2015Project.exe"
/MANIFEST /LTCG:incremental /NXCOMPAT
/PDB:"F:\X\Src\MyProject\MyVS2015Project\x64\Release\MyVS2015Project.pdb"
/DYNAMICBASE "kernel32.lib" "user32.lib" "gdi32.lib" "winspool.lib"
"comdlg32.lib" "advapi32.lib" "shell32.lib" "ole32.lib" "oleaut32.lib"
"uuid.lib" "odbc32.lib" "odbccp32.lib" /DEBUG:FULL /MACHINE:X64 /OPT:REF
/PGD:"F:\X\Src\MyProject\MyVS2015Project\x64\Release\MyVS2015Project.pgd"
/MANIFESTUAC:"level='asInvoker' uiAccess='false'"
/ManifestFile:"x64\Release\MyVS2015Project.exe.intermediate.manifest"
/OPT:ICF /ERRORREPORT:PROMPT /NOLOGO /TLBID:1

The vcxproj file created by Visual Studio has
"<WholeProgramOptimization>true</WholeProgramOptimization>" for its
Release configurations.


The Visual C++ project generated by CMake (Generator: Visual Studio 15
2017 Win64) has the following compile options, for its Release
configuration:

/GS /TP /W3 /Zc:wchar_t /Gm- /O2 /Ob2
/Fd"MyExecutable.dir\Release\vc141.pdb" /Zc:inline /fp:precise /D
"WIN32" /D "_WINDOWS" /D "NDEBUG" /D "CMAKE_INTDIR=\"Release\"" /D
"_MBCS" /errorReport:prompt /WX- /Zc:forScope /GR /Gd /MD /Fa"Release/"
/EHsc /nologo /Fo"MyExecutable.dir\Release\"
/Fp"MyExecutable.dir\Release\MyExecutable.pch" /diagnostics:classic

And the following linker options:

/OUT:"F:\X\Bin\vc141-64\MyProject\Release\MyExecutable.exe" /MANIFEST
/NXCOMPAT /PDB:"F:/X/Bin/vc141-64/MyProject/Release/MyExecutable.pdb"
/DYNAMICBASE "kernel32.lib" "user32.lib" "gdi32.lib" "winspool.lib"
"shell32.lib" "ole32.lib" "oleaut32.lib" "uuid.lib" "comdlg32.lib"
"advapi32.lib"
/IMPLIB:"F:/X/Bin/vc141-64/MyProject/Release/MyExecutable.lib"
/MACHINE:X64 /INCREMENTAL:NO
/PGD:"F:\X\Bin\vc141-64\MyProject\Release\MyExecutable.pgd"
/SUBSYSTEM:CONSOLE /MANIFESTUAC:"level='asInvoker' uiAccess='false'"
/ManifestFile:"MyExecutable.dir\Release\MyExecutable.exe.intermediate.manifest"
/ERRORREPORT:PROMPT /NOLOGO /TLBID:1

The vcxproj file generated by CMake does not have a
"<WholeProgramOptimization>" tag.


I hope you can consider adding LTCG to Release configurations of Visual
C++ projects generated by CMake, by default.


Kind regards, Niels
--
Niels Dekker
Scientific programmer
LKEB, Leiden University Medical Center
--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: Link Time Code Generation (LTGC) by default, for Release configurations of Visual Studio projects?

Cristian Adam
Hi,

I had a quick check to see if CMake 3.10 for which compilers it has support for Interprocedural Optimization (IPO, or LTCG as known on Visual C++).

Modules/Compiler had only for GNU, Clang and PGI the following:
set(_CMAKE_${lang}_IPO_MAY_BE_SUPPORTED_BY_COMPILER YES)

QNX with QCC didn't have it set to YES even though nowdays QNX comes with GCC 5.4.0 on QNX 7.0, which should be just fine.

It would be nice if CMake would have support for IPO on Visual C++.

The steps would be to set the right variables into Modules/Compiler/MSVC-CXX.cmake, change the CheckIPOSupported module, change some flags in some places,update tests, documentation, and so on.

Shouldn't be hard to add this feature.

Cheers,
Cristian.



On Wed, Jan 24, 2018 at 9:06 PM, Niels Dekker <[hidden email]> wrote:
When a Visual C++ project is created within Visual Studio (by File menu, New, Project...), it has Link Time Code Generation (LTGC) by default, for its Release configurations: Compiler option /GL and linker option /LTCG. However, when the Visual C++ project is generated by CMake, it does not have LTGC, by default. LTCG looks like a very useful feature to me. I think it's worth enabling the feature by default, for Release configurations. What do you think?


Some details:

I created a "dummy" Visual C++ project in Visual Studio 2017 (Version 15.5.4), by File menu, New, Project..., and I also generated one by CMake (version 3.10.2), using a very minimal CMakeLists.txt

The Visual C++ project created by Visual Studio 2017 has the following compile options, by default, for Release (x64):

/permissive- /GS /GL /W3 /Gy /Zc:wchar_t /Zi /Gm- /O2 /sdl /Fd"x64\Release\vc141.pdb" /Zc:inline /fp:precise /D "_MBCS" /errorReport:prompt /WX- /Zc:forScope /Gd /Oi /MD /Fa"x64\Release\" /EHsc /nologo /Fo"x64\Release\" /Fp"x64\Release\MyVS2015Project.pch" /diagnostics:classic

And the following linker options:

/OUT:"F:\X\Src\MyProject\MyVS2015Project\x64\Release\MyVS2015Project.exe" /MANIFEST /LTCG:incremental /NXCOMPAT /PDB:"F:\X\Src\MyProject\MyVS2015Project\x64\Release\MyVS2015Project.pdb" /DYNAMICBASE "kernel32.lib" "user32.lib" "gdi32.lib" "winspool.lib" "comdlg32.lib" "advapi32.lib" "shell32.lib" "ole32.lib" "oleaut32.lib" "uuid.lib" "odbc32.lib" "odbccp32.lib" /DEBUG:FULL /MACHINE:X64 /OPT:REF /PGD:"F:\X\Src\MyProject\MyVS2015Project\x64\Release\MyVS2015Project.pgd" /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /ManifestFile:"x64\Release\MyVS2015Project.exe.intermediate.manifest" /OPT:ICF /ERRORREPORT:PROMPT /NOLOGO /TLBID:1

The vcxproj file created by Visual Studio has "<WholeProgramOptimization>true</WholeProgramOptimization>" for its Release configurations.


The Visual C++ project generated by CMake (Generator: Visual Studio 15 2017 Win64) has the following compile options, for its Release configuration:

/GS /TP /W3 /Zc:wchar_t /Gm- /O2 /Ob2 /Fd"MyExecutable.dir\Release\vc141.pdb" /Zc:inline /fp:precise /D "WIN32" /D "_WINDOWS" /D "NDEBUG" /D "CMAKE_INTDIR=\"Release\"" /D "_MBCS" /errorReport:prompt /WX- /Zc:forScope /GR /Gd /MD /Fa"Release/" /EHsc /nologo /Fo"MyExecutable.dir\Release\" /Fp"MyExecutable.dir\Release\MyExecutable.pch" /diagnostics:classic

And the following linker options:

/OUT:"F:\X\Bin\vc141-64\MyProject\Release\MyExecutable.exe" /MANIFEST /NXCOMPAT /PDB:"F:/X/Bin/vc141-64/MyProject/Release/MyExecutable.pdb" /DYNAMICBASE "kernel32.lib" "user32.lib" "gdi32.lib" "winspool.lib" "shell32.lib" "ole32.lib" "oleaut32.lib" "uuid.lib" "comdlg32.lib" "advapi32.lib" /IMPLIB:"F:/X/Bin/vc141-64/MyProject/Release/MyExecutable.lib" /MACHINE:X64 /INCREMENTAL:NO /PGD:"F:\X\Bin\vc141-64\MyProject\Release\MyExecutable.pgd" /SUBSYSTEM:CONSOLE /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /ManifestFile:"MyExecutable.dir\Release\MyExecutable.exe.intermediate.manifest" /ERRORREPORT:PROMPT /NOLOGO /TLBID:1

The vcxproj file generated by CMake does not have a "<WholeProgramOptimization>" tag.


I hope you can consider adding LTCG to Release configurations of Visual C++ projects generated by CMake, by default.


Kind regards, Niels
--
Niels Dekker
Scientific programmer
LKEB, Leiden University Medical Center
--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake


--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: Link Time Code Generation (LTGC) by default, for Release configurations of Visual Studio projects?

Mueller-Roemer, Johannes Sebastian

This would be a great feature! Currently I override my release flags by setting CMAKE_<LANG>_FLAGS_RELEASE_INIT and CMAKE_<TYPE>_LINKER_FLAGS_RELEASE_INIT in a CMAKE_USER_MAKE_RULES_OVERRIDE script. Direct support for /GL and /LTCG in CMake would be great. Fewer target specifics to worry about…

 

Fraunhofer-Institut für Graphische Datenverarbeitung IGD

Fraunhoferstr. 5  |  64283 Darmstadt  |  Germany

Tel +49 6151 155-606  |  Fax +49 6151 155-139

[hidden email] | www.igd.fraunhofer.de

 

From: CMake [mailto:[hidden email]] On Behalf Of Cristian Adam
Sent: Wednesday, January 24, 2018 21:42
To: Niels Dekker <[hidden email]>
Cc: cmake <[hidden email]>
Subject: Re: [CMake] Link Time Code Generation (LTGC) by default, for Release configurations of Visual Studio projects?

 

Hi,

 

I had a quick check to see if CMake 3.10 for which compilers it has support for Interprocedural Optimization (IPO, or LTCG as known on Visual C++).

 

Modules/Compiler had only for GNU, Clang and PGI the following:

set(_CMAKE_${lang}_IPO_MAY_BE_SUPPORTED_BY_COMPILER YES)

 

QNX with QCC didn't have it set to YES even though nowdays QNX comes with GCC 5.4.0 on QNX 7.0, which should be just fine.

 

It would be nice if CMake would have support for IPO on Visual C++.

 

The steps would be to set the right variables into Modules/Compiler/MSVC-CXX.cmake, change the CheckIPOSupported module, change some flags in some places,update tests, documentation, and so on.

 

Shouldn't be hard to add this feature.

 

Cheers,

Cristian.

 

 

 

On Wed, Jan 24, 2018 at 9:06 PM, Niels Dekker <[hidden email]> wrote:

When a Visual C++ project is created within Visual Studio (by File menu, New, Project...), it has Link Time Code Generation (LTGC) by default, for its Release configurations: Compiler option /GL and linker option /LTCG. However, when the Visual C++ project is generated by CMake, it does not have LTGC, by default. LTCG looks like a very useful feature to me. I think it's worth enabling the feature by default, for Release configurations. What do you think?


Some details:

I created a "dummy" Visual C++ project in Visual Studio 2017 (Version 15.5.4), by File menu, New, Project..., and I also generated one by CMake (version 3.10.2), using a very minimal CMakeLists.txt

The Visual C++ project created by Visual Studio 2017 has the following compile options, by default, for Release (x64):

/permissive- /GS /GL /W3 /Gy /Zc:wchar_t /Zi /Gm- /O2 /sdl /Fd"x64\Release\vc141.pdb" /Zc:inline /fp:precise /D "_MBCS" /errorReport:prompt /WX- /Zc:forScope /Gd /Oi /MD /Fa"x64\Release\" /EHsc /nologo /Fo"x64\Release\" /Fp"x64\Release\MyVS2015Project.pch" /diagnostics:classic

And the following linker options:

/OUT:"F:\X\Src\MyProject\MyVS2015Project\x64\Release\MyVS2015Project.exe" /MANIFEST /LTCG:incremental /NXCOMPAT /PDB:"F:\X\Src\MyProject\MyVS2015Project\x64\Release\MyVS2015Project.pdb" /DYNAMICBASE "kernel32.lib" "user32.lib" "gdi32.lib" "winspool.lib" "comdlg32.lib" "advapi32.lib" "shell32.lib" "ole32.lib" "oleaut32.lib" "uuid.lib" "odbc32.lib" "odbccp32.lib" /DEBUG:FULL /MACHINE:X64 /OPT:REF /PGD:"F:\X\Src\MyProject\MyVS2015Project\x64\Release\MyVS2015Project.pgd" /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /ManifestFile:"x64\Release\MyVS2015Project.exe.intermediate.manifest" /OPT:ICF /ERRORREPORT:PROMPT /NOLOGO /TLBID:1

The vcxproj file created by Visual Studio has "<WholeProgramOptimization>true</WholeProgramOptimization>" for its Release configurations.


The Visual C++ project generated by CMake (Generator: Visual Studio 15 2017 Win64) has the following compile options, for its Release configuration:

/GS /TP /W3 /Zc:wchar_t /Gm- /O2 /Ob2 /Fd"MyExecutable.dir\Release\vc141.pdb" /Zc:inline /fp:precise /D "WIN32" /D "_WINDOWS" /D "NDEBUG" /D "CMAKE_INTDIR=\"Release\"" /D "_MBCS" /errorReport:prompt /WX- /Zc:forScope /GR /Gd /MD /Fa"Release/" /EHsc /nologo /Fo"MyExecutable.dir\Release\" /Fp"MyExecutable.dir\Release\MyExecutable.pch" /diagnostics:classic

And the following linker options:

/OUT:"F:\X\Bin\vc141-64\MyProject\Release\MyExecutable.exe" /MANIFEST /NXCOMPAT /PDB:"F:/X/Bin/vc141-64/MyProject/Release/MyExecutable.pdb" /DYNAMICBASE "kernel32.lib" "user32.lib" "gdi32.lib" "winspool.lib" "shell32.lib" "ole32.lib" "oleaut32.lib" "uuid.lib" "comdlg32.lib" "advapi32.lib" /IMPLIB:"F:/X/Bin/vc141-64/MyProject/Release/MyExecutable.lib" /MACHINE:X64 /INCREMENTAL:NO /PGD:"F:\X\Bin\vc141-64\MyProject\Release\MyExecutable.pgd" /SUBSYSTEM:CONSOLE /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /ManifestFile:"MyExecutable.dir\Release\MyExecutable.exe.intermediate.manifest" /ERRORREPORT:PROMPT /NOLOGO /TLBID:1

The vcxproj file generated by CMake does not have a "<WholeProgramOptimization>" tag.


I hope you can consider adding LTCG to Release configurations of Visual C++ projects generated by CMake, by default.


Kind regards, Niels
--
Niels Dekker
Scientific programmer
LKEB, Leiden University Medical Center
--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake

 


--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: Link Time Code Generation (LTGC) by default, for Release configurations of Visual Studio projects?

Niels Dekker
Thank you for your encouraging replies, Johannes and Cristian.

In the meantime I created "default" Visual C++ projects on Visual Studio
2008, Visual Studio 2010, Visual Studio 2013, Visual Studio 2015 and
Visual Studio 2017 (from within the IDE, without using CMake). It
appears that each of these Visual Studio versions hast Link Time Code
Generation by default, for Release configurations.

I don't have access to a machine with Visual Studio 2005. Can someone
tell me whether this version also has Link Time Code Generation by
default, for Release configurations?

Kind regards, Niels


On 2018-01-25 14:54, Mueller-Roemer, Johannes Sebastian wrote:

> This would be a great feature! Currently I override my release flags
> by setting CMAKE_<LANG>_FLAGS_RELEASE_INIT and
> CMAKE_<TYPE>_LINKER_FLAGS_RELEASE_INIT in a
> CMAKE_USER_MAKE_RULES_OVERRIDE script. Direct support for /GL and
> /LTCG in CMake would be great. Fewer target specifics to worry
> about…
>
>
> FROM: Cristian Adam
> SENT: Wednesday, January 24, 2018 21:42
> TO: Niels Dekker
> CC: cmake <[hidden email]>
> SUBJECT: Re: [CMake] Link Time Code Generation (LTGC) by default, for
> Release configurations of Visual Studio projects?
>
> Hi,
>
> I had a quick check to see if CMake 3.10 for which compilers it has
> support for Interprocedural Optimization  (IPO, or LTCG as known on
> Visual C++).
>
> Modules/Compiler had only for GNU, CLANG and PGI the following:
>
> set(_CMAKE_${lang}_IPO_MAY_BE_SUPPORTED_BY_COMPILER YES)
>
> QNX with QCC didn't have it set to YES even though nowdays QNX comes
> with GCC 5.4.0 on QNX 7.0, which should be just fine.
>
> It would be nice if CMake would have support for IPO on Visual C++.
>
> The steps would be to set the right variables into
> Modules/Compiler/MSVC-CXX.cmake, change the CheckIPOSupported
> module, change some flags in some places,update tests, documentation,
> and so on.
>
> Shouldn't be hard to add this feature.
>
> Cheers,
>
> Cristian.
>
> On Wed, Jan 24, 2018 at 9:06 PM, Niels Dekker wrote:
>
>> When a Visual C++ project is created within Visual Studio (by File
>> menu, New, Project...), it has Link Time Code Generation (LTGC) by
>> default, for its Release configurations: Compiler option /GL and
>> linker option /LTCG. However, when the Visual C++ project is
>> generated by CMake, it does not have LTGC, by default. LTCG looks
>> like a very useful feature to me. I think it's worth enabling the
>> feature by default, for Release configurations. What do you think?
>>
>> Some details:
>>
>> I created a "dummy" Visual C++ project in Visual Studio 2017
>> (Version 15.5.4), by File menu, New, Project..., and I also
>> generated one by CMake (version 3.10.2), using a very minimal
>> CMakeLists.txt
>>
>> The Visual C++ project created by Visual Studio 2017 has the
>> following compile options, by default, for Release (x64):
>>
>> /permissive- /GS /GL /W3 /Gy /Zc:wchar_t /Zi /Gm- /O2 /sdl
>> /Fd"x64\Release\vc141.pdb" /Zc:inline /fp:precise /D "_MBCS"
>> /errorReport:prompt /WX- /Zc:forScope /Gd /Oi /MD /Fa"x64\Release\"
>> /EHsc /nologo /Fo"x64\Release\" /Fp"x64\Release\MyVS2015Project.pch"
>> /diagnostics:classic
>>
>> And the following linker options:
>>
>>
> /OUT:"F:\X\Src\MyProject\MyVS2015Project\x64\Release\MyVS2015Project.exe"
>> /MANIFEST /LTCG:incremental /NXCOMPAT
>>
> /PDB:"F:\X\Src\MyProject\MyVS2015Project\x64\Release\MyVS2015Project.pdb"
>> /DYNAMICBASE "kernel32.lib" "user32.lib" "gdi32.lib" "winspool.lib"
>> "comdlg32.lib" "advapi32.lib" "shell32.lib" "ole32.lib"
>> "oleaut32.lib" "uuid.lib" "odbc32.lib" "odbccp32.lib" /DEBUG:FULL
>> /MACHINE:X64 /OPT:REF
>>
> /PGD:"F:\X\Src\MyProject\MyVS2015Project\x64\Release\MyVS2015Project.pgd"
>> /MANIFESTUAC:"level='asInvoker' uiAccess='false'"
>>
> /ManifestFile:"x64\Release\MyVS2015Project.exe.intermediate.manifest"
>> /OPT:ICF /ERRORREPORT:PROMPT /NOLOGO /TLBID:1
>>
>> The vcxproj file created by Visual Studio has
>> "<WholeProgramOptimization>true</WholeProgramOptimization>" for its
>> Release configurations.
>>
>> The Visual C++ project generated by CMake (Generator: Visual Studio
>> 15 2017 Win64) has the following compile options, for its Release
>> configuration:
>>
>> /GS /TP /W3 /Zc:wchar_t /Gm- /O2 /Ob2
>> /Fd"MyExecutable.dir\Release\vc141.pdb" /Zc:inline /fp:precise /D
>> "WIN32" /D "_WINDOWS" /D "NDEBUG" /D "CMAKE_INTDIR=\"Release\"" /D
>> "_MBCS" /errorReport:prompt /WX- /Zc:forScope /GR /Gd /MD
>> /Fa"Release/" /EHsc /nologo /Fo"MyExecutable.dir\Release\"
>> /Fp"MyExecutable.dir\Release\MyExecutable.pch" /diagnostics:classic
>>
>> And the following linker options:
>>
>> /OUT:"F:\X\Bin\vc141-64\MyProject\Release\MyExecutable.exe"
>> /MANIFEST /NXCOMPAT
>> /PDB:"F:/X/Bin/vc141-64/MyProject/Release/MyExecutable.pdb"
>> /DYNAMICBASE "kernel32.lib" "user32.lib" "gdi32.lib" "winspool.lib"
>> "shell32.lib" "ole32.lib" "oleaut32.lib" "uuid.lib" "comdlg32.lib"
>> "advapi32.lib"
>> /IMPLIB:"F:/X/Bin/vc141-64/MyProject/Release/MyExecutable.lib"
>> /MACHINE:X64 /INCREMENTAL:NO
>> /PGD:"F:\X\Bin\vc141-64\MyProject\Release\MyExecutable.pgd"
>> /SUBSYSTEM:CONSOLE /MANIFESTUAC:"level='asInvoker' uiAccess='false'"
>> /ManifestFile:"MyExecutable.dir\Release\MyExecutable.exe.int
>> [1]ermediate.manifest" /ERRORREPORT:PROMPT /NOLOGO /TLBID:1
>>
>> The vcxproj file generated by CMake does not have a
>> "<WholeProgramOptimization>" tag.
>>
>> I hope you can consider adding LTCG to Release configurations of
>> Visual C++ projects generated by CMake, by default.
>>
>> Kind regards, Niels

--
Niels Dekker
Scientific programmer
LKEB, Leiden University Medical Center
--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: Link Time Code Generation (LTGC) by default, for Release configurations of Visual Studio projects?

Niels Dekker
Update: I just submitted the issue to
https://gitlab.kitware.com/cmake/cmake/issues/17720

Kind regards, Niels

-------- Previous Message --------
Subject: Re: [CMake] Link Time Code Generation (LTGC) by default, for
Release configurations of Visual Studio projects?
Date: Fri, 26 Jan 2018 17:04:52 +0100
From: Niels Dekker

Thank you for your encouraging replies, Johannes and Cristian.

In the meantime I created "default" Visual C++ projects on Visual
Studio 2008, Visual Studio 2010, Visual Studio 2013, Visual Studio
2015 and Visual Studio 2017 (from within the IDE, without using
CMake). It appears that each of these Visual Studio versions hast Link
Time Code Generation by default, for Release configurations.

I don't have access to a machine with Visual Studio 2005. Can someone
tell me whether this version also has Link Time Code Generation by
default, for Release configurations?

Kind regards, Niels


On 2018-01-25 14:54, Mueller-Roemer, Johannes Sebastian wrote:

>
> This would be a great feature! Currently I override my release flags by setting CMAKE_<LANG>_FLAGS_RELEASE_INIT and CMAKE_<TYPE>_LINKER_FLAGS_RELEASE_INIT in a CMAKE_USER_MAKE_RULES_OVERRIDE script. Direct support for /GL and /LTCG in CMake would be great. Fewer target specifics to worry about…
>
>
> From: CMake On Behalf Of Cristian Adam
> Sent: Wednesday, January 24, 2018 21:42
> To: Niels Dekker
> Cc: cmake
> Subject: Re: [CMake] Link Time Code Generation (LTGC) by default, for Release configurations of Visual Studio projects?
>
> Hi,
>
> I had a quick check to see if CMake 3.10 for which compilers it has support for Interprocedural Optimization (IPO, or LTCG as known on Visual C++).
>
> Modules/Compiler had only for GNU, Clang and PGI the following:
>
> set(_CMAKE_${lang}_IPO_MAY_BE_SUPPORTED_BY_COMPILER YES)
>
>  
>
> QNX with QCC didn't have it set to YES even though nowdays QNX comes with GCC 5.4.0 on QNX 7.0, which should be just fine.
>
> It would be nice if CMake would have support for IPO on Visual C++.
>
> The steps would be to set the right variables into Modules/Compiler/MSVC-CXX.cmake, change the CheckIPOSupported module, change some flags in some places,update tests, documentation, and so on.
>
> Shouldn't be hard to add this feature.
>
> Cheers,
>
> Cristian.
>
> On Wed, Jan 24, 2018 at 9:06 PM, Niels Dekker wrote:
>
>     When a Visual C++ project is created within Visual Studio (by File menu, New, Project...), it has Link Time Code Generation (LTGC) by default, for its Release configurations: Compiler option /GL and linker option /LTCG. However, when the Visual C++ project is generated by CMake, it does not have LTGC, by default. LTCG looks like a very useful feature to me. I think it's worth enabling the feature by default, for Release configurations. What do you think?
>
>
>     Some details:
>
>     I created a "dummy" Visual C++ project in Visual Studio 2017 (Version 15.5.4), by File menu, New, Project..., and I also generated one by CMake (version 3.10.2), using a very minimal CMakeLists.txt
>
>     The Visual C++ project created by Visual Studio 2017 has the following compile options, by default, for Release (x64):
>
>     /permissive- /GS /GL /W3 /Gy /Zc:wchar_t /Zi /Gm- /O2 /sdl /Fd"x64\Release\vc141.pdb" /Zc:inline /fp:precise /D "_MBCS" /errorReport:prompt /WX- /Zc:forScope /Gd /Oi /MD /Fa"x64\Release\" /EHsc /nologo /Fo"x64\Release\" /Fp"x64\Release\MyVS2015Project.pch" /diagnostics:classic
>
>     And the following linker options:
>
>     /OUT:"F:\X\Src\MyProject\MyVS2015Project\x64\Release\MyVS2015Project.exe" /MANIFEST /LTCG:incremental /NXCOMPAT /PDB:"F:\X\Src\MyProject\MyVS2015Project\x64\Release\MyVS2015Project.pdb" /DYNAMICBASE "kernel32.lib" "user32.lib" "gdi32.lib" "winspool.lib" "comdlg32.lib" "advapi32.lib" "shell32.lib" "ole32.lib" "oleaut32.lib" "uuid.lib" "odbc32.lib" "odbccp32.lib" /DEBUG:FULL /MACHINE:X64 /OPT:REF /PGD:"F:\X\Src\MyProject\MyVS2015Project\x64\Release\MyVS2015Project.pgd" /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /ManifestFile:"x64\Release\MyVS2015Project.exe.intermediate.manifest" /OPT:ICF /ERRORREPORT:PROMPT /NOLOGO /TLBID:1
>
>     The vcxproj file created by Visual Studio has "<WholeProgramOptimization>true</WholeProgramOptimization>" for its Release configurations.
>
>
>     The Visual C++ project generated by CMake (Generator: Visual Studio 15 2017 Win64) has the following compile options, for its Release configuration:
>
>     /GS /TP /W3 /Zc:wchar_t /Gm- /O2 /Ob2 /Fd"MyExecutable.dir\Release\vc141.pdb" /Zc:inline /fp:precise /D "WIN32" /D "_WINDOWS" /D "NDEBUG" /D "CMAKE_INTDIR=\"Release\"" /D "_MBCS" /errorReport:prompt /WX- /Zc:forScope /GR /Gd /MD /Fa"Release/" /EHsc /nologo /Fo"MyExecutable.dir\Release\" /Fp"MyExecutable.dir\Release\MyExecutable.pch" /diagnostics:classic
>
>     And the following linker options:
>
>     /OUT:"F:\X\Bin\vc141-64\MyProject\Release\MyExecutable.exe" /MANIFEST /NXCOMPAT /PDB:"F:/X/Bin/vc141-64/MyProject/Release/MyExecutable.pdb" /DYNAMICBASE "kernel32.lib" "user32.lib" "gdi32.lib" "winspool.lib" "shell32.lib" "ole32.lib" "oleaut32.lib" "uuid.lib" "comdlg32.lib" "advapi32.lib" /IMPLIB:"F:/X/Bin/vc141-64/MyProject/Release/MyExecutable.lib" /MACHINE:X64 /INCREMENTAL:NO /PGD:"F:\X\Bin\vc141-64\MyProject\Release\MyExecutable.pgd" /SUBSYSTEM:CONSOLE /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /ManifestFile:"MyExecutable.dir\Release\MyExecutable.exe.intermediate.manifest" /ERRORREPORT:PROMPT /NOLOGO /TLBID:1
>
>     The vcxproj file generated by CMake does not have a "<WholeProgramOptimization>" tag.
>
>
>     I hope you can consider adding LTCG to Release configurations of Visual C++ projects generated by CMake, by default.
>
>
>     Kind regards, Niels

--
Niels Dekker
Scientific programmer
LKEB, Leiden University Medical Center

--
Niels Dekker
Scientific programmer at LKEB, Leiden University Medical Center
--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake