diff options
author | Daniel Podder <dapodd@microsoft.com> | 2017-06-13 14:51:55 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-06-13 14:51:55 -0700 |
commit | 94788b256bc2aaa930341e27dc5ae3baf3bbf8b5 (patch) | |
tree | dabb4fcaf7e13a048c0cd00ee9af385410aa05c5 | |
parent | 25bc371325b21a4bed9e0337192dd04ad7051b54 (diff) | |
download | coreclr-94788b256bc2aaa930341e27dc5ae3baf3bbf8b5.tar.gz coreclr-94788b256bc2aaa930341e27dc5ae3baf3bbf8b5.tar.bz2 coreclr-94788b256bc2aaa930341e27dc5ae3baf3bbf8b5.zip |
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.
-rw-r--r-- | pgosupport.cmake | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/pgosupport.cmake b/pgosupport.cmake index f3d00b7505..e92923fcb0 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}) |