From 2b6efaeed3b263b3be0be46716205152567e854a Mon Sep 17 00:00:00 2001 From: Hadi Brais Date: Sat, 6 Jun 2015 19:18:06 +0530 Subject: build,win: Enables Whole Program Optimization. * Enables whole program optimization for release configuration on Windows. * Fixes all messages "/LTCG specified but no code generation required; remove /LTCG from link command line to improve linker performance" which slow down the build process. * Fixes all messages "MSIL .netmodule or module compiled with /GL found; restarting link with /LTCG; add /LTCG to the link command line to improve linker performance" which slow down the build process. * The previous two fixes work in Release and Debug builds on Windows. Issue-URL: #1086 --- src/dlls/clretwrc/CMakeLists.txt | 13 +++++++++++-- src/dlls/mscordac/CMakeLists.txt | 7 ++++++- src/dlls/mscorrc/CMakeLists.txt | 3 +++ src/pal/tools/gen-buildsys-win.bat | 6 +++--- 4 files changed, 23 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/dlls/clretwrc/CMakeLists.txt b/src/dlls/clretwrc/CMakeLists.txt index e43fcb9665..f4b874d414 100644 --- a/src/dlls/clretwrc/CMakeLists.txt +++ b/src/dlls/clretwrc/CMakeLists.txt @@ -1,5 +1,13 @@ include_directories(${CMAKE_CURRENT_BINARY_DIR}) -set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /NOENTRY") + +if(WIN32) + # remove /ltcg from resource-only libraries + string(REPLACE "/LTCG" "" CMAKE_SHARED_LINKER_FLAGS_RELEASE ${CMAKE_SHARED_LINKER_FLAGS_RELEASE}) + string(REPLACE "/LTCG" "" CMAKE_STATIC_LINKER_FLAGS_RELEASE ${CMAKE_STATIC_LINKER_FLAGS_RELEASE}) + string(REPLACE "/LTCG" "" CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO ${CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO}) + string(REPLACE "/LTCG" "" CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO ${CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO}) + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /NOENTRY") +endif(WIN32) add_definitions(-DFX_VER_INTERNALNAME_STR=clretwrc.dll) @@ -18,6 +26,7 @@ add_custom_command( # add the install targets install (TARGETS clretwrc DESTINATION .) + if(WIN32) -install (FILES ${CMAKE_CURRENT_BINARY_DIR}/$/clretwrc.pdb DESTINATION PDB) + install (FILES ${CMAKE_CURRENT_BINARY_DIR}/$/clretwrc.pdb DESTINATION PDB) endif(WIN32) diff --git a/src/dlls/mscordac/CMakeLists.txt b/src/dlls/mscordac/CMakeLists.txt index 1cb70a52a0..c40c465076 100644 --- a/src/dlls/mscordac/CMakeLists.txt +++ b/src/dlls/mscordac/CMakeLists.txt @@ -68,10 +68,15 @@ if(WIN32) # mscordac.def should be generated before mscordaccore.dll is built add_dependencies(mscordaccore mscordaccore_def) + set(LTCG_FLAG "") + if (CMAKE_BUILD_TYPE STREQUAL Release OR CMAKE_BUILD_TYPE STREQUAL Relwithdebinfo) + set(LTCG_FLAG "/LTCG") + endif() + # Generate export file add_custom_command(TARGET mscordaccore PRE_LINK - COMMAND lib.exe /OUT:${CMAKE_CURRENT_BINARY_DIR}/$/mscordaccore.lib /DEF:${CMAKE_CURRENT_BINARY_DIR}/mscordac.def $ ${STATIC_LIBRARY_FLAGS} ${CMAKE_CURRENT_BINARY_DIR}/mscordaccore.dir/$/mscordac.obj + COMMAND lib.exe ${LTCG_FLAG} /OUT:${CMAKE_CURRENT_BINARY_DIR}/$/mscordaccore.lib /DEF:${CMAKE_CURRENT_BINARY_DIR}/mscordac.def $ ${STATIC_LIBRARY_FLAGS} ${CMAKE_CURRENT_BINARY_DIR}/mscordaccore.dir/$/mscordac.obj COMMENT "Generating mscordaccore.exp export file" VERBATIM ) diff --git a/src/dlls/mscorrc/CMakeLists.txt b/src/dlls/mscorrc/CMakeLists.txt index 47d87ae30b..198fe8deb6 100644 --- a/src/dlls/mscorrc/CMakeLists.txt +++ b/src/dlls/mscorrc/CMakeLists.txt @@ -1,6 +1,9 @@ include_directories("../../pal/prebuilt/corerror") if(WIN32) set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /NOENTRY") + # remove /ltcg from resource-only libraries + string(REPLACE "/LTCG" "" CMAKE_SHARED_LINKER_FLAGS_RELEASE ${CMAKE_SHARED_LINKER_FLAGS_RELEASE}) + string(REPLACE "/LTCG" "" CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO ${CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO}) else() set (RC_TO_CPP ${CMAKE_CURRENT_SOURCE_DIR}/rctocpp.awk) diff --git a/src/pal/tools/gen-buildsys-win.bat b/src/pal/tools/gen-buildsys-win.bat index 56b22f221f..8935e873fd 100644 --- a/src/pal/tools/gen-buildsys-win.bat +++ b/src/pal/tools/gen-buildsys-win.bat @@ -5,7 +5,7 @@ rem This file invokes cmake and generates the build system for windows. set argC=0 for %%x in (%*) do Set /A argC+=1 -if NOT %argC%==2 GOTO :USAGE +if NOT %argC%==3 GOTO :USAGE if %1=="/?" GOTO :USAGE setlocal @@ -24,13 +24,13 @@ if defined CMakePath goto DoGen for /f "delims=" %%a in ('powershell -NoProfile -ExecutionPolicy RemoteSigned "& .\probe-win.ps1"') do %%a :DoGen -"%CMakePath%" "-DCMAKE_USER_MAKE_RULES_OVERRIDE=%basePath%\windows-compiler-override.txt" -G "Visual Studio %__VSString% Win64" %1 +"%CMakePath%" "-DCMAKE_USER_MAKE_RULES_OVERRIDE=%basePath%\windows-compiler-override.txt" "-DCMAKE_BUILD_TYPE=%3" -G "Visual Studio %__VSString% Win64" %1 endlocal GOTO :DONE :USAGE echo "Usage..." - echo "gen-buildsys-win.bat " + echo "gen-buildsys-win.bat " echo "Specify the path to the top level CMake file - /src/NDP" echo "Specify the VSVersion to be used - VS2013 or VS2015" EXIT /B 1 -- cgit v1.2.3