summaryrefslogtreecommitdiff
path: root/pgosupport.cmake
diff options
context:
space:
mode:
authorDaniel Podder <dapodd@microsoft.com>2017-06-13 21:51:55 (GMT)
committerGitHub <noreply@github.com>2017-06-13 21:51:55 (GMT)
commit94788b256bc2aaa930341e27dc5ae3baf3bbf8b5 (patch)
treedabb4fcaf7e13a048c0cd00ee9af385410aa05c5 /pgosupport.cmake
parent25bc371325b21a4bed9e0337192dd04ad7051b54 (diff)
downloadcoreclr-94788b256bc2aaa930341e27dc5ae3baf3bbf8b5.zip
coreclr-94788b256bc2aaa930341e27dc5ae3baf3bbf8b5.tar.gz
coreclr-94788b256bc2aaa930341e27dc5ae3baf3bbf8b5.tar.bz2
Skip PGO if clang is too old, and add warnings for skipped PGO (#12248)
Clang/LLVM cannot merge profile data generated by a newer version of itself. Training currently requires 3.6, but we don't want to completely break the build for 3.5. I'm adding a version check to allow non-PGO release builds on 3.5, along with a warning message. I'm also updating the LTO detection to print a warning message if it causes PGO to be disabled.
Diffstat (limited to 'pgosupport.cmake')
-rw-r--r--pgosupport.cmake14
1 files changed, 10 insertions, 4 deletions
diff --git a/pgosupport.cmake b/pgosupport.cmake
index f3d00b7..e92923f 100644
--- a/pgosupport.cmake
+++ b/pgosupport.cmake
@@ -42,10 +42,16 @@ function(add_pgo TargetName)
set_property(TARGET ${TargetName} APPEND_STRING PROPERTY LINK_FLAGS_RELWITHDEBINFO " /LTCG /USEPROFILE:PGD=${ProfilePath}")
else(WIN32)
if(UPPERCASE_CMAKE_BUILD_TYPE STREQUAL RELEASE OR UPPERCASE_CMAKE_BUILD_TYPE STREQUAL RELWITHDEBINFO)
- if(HAVE_LTO)
- target_compile_options(${TargetName} PRIVATE -flto -fprofile-instr-use=${ProfilePath} -Wno-profile-instr-out-of-date)
- set_property(TARGET ${TargetName} APPEND_STRING PROPERTY LINK_FLAGS " -flto -fuse-ld=gold -fprofile-instr-use=${ProfilePath}")
- endif(HAVE_LTO)
+ if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.6)
+ if(HAVE_LTO)
+ target_compile_options(${TargetName} PRIVATE -flto -fprofile-instr-use=${ProfilePath} -Wno-profile-instr-out-of-date)
+ set_property(TARGET ${TargetName} APPEND_STRING PROPERTY LINK_FLAGS " -flto -fuse-ld=gold -fprofile-instr-use=${ProfilePath}")
+ else(HAVE_LTO)
+ message(WARNING "LTO is not supported, skipping profile guided optimizations")
+ endif(HAVE_LTO)
+ else(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.6)
+ message(WARNING "PGO is not supported; Clang 3.6 or later is required for profile guided optimizations")
+ endif(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.6)
endif(UPPERCASE_CMAKE_BUILD_TYPE STREQUAL RELEASE OR UPPERCASE_CMAKE_BUILD_TYPE STREQUAL RELWITHDEBINFO)
endif(WIN32)
endif(EXISTS ${ProfilePath})