summaryrefslogtreecommitdiff
path: root/configure.cmake
diff options
context:
space:
mode:
authorDaniel Podder <dapodd@microsoft.com>2017-03-29 19:01:55 -0700
committerGitHub <noreply@github.com>2017-03-29 19:01:55 -0700
commit926d104068fffb7e7cf867ab4c92082aab968692 (patch)
treea41b9d30e6b8fee46739f8e539f8fe5fd6f552cb /configure.cmake
parentf990ce64c49d268bcaef5a87d5838f5008ff0a30 (diff)
downloadcoreclr-926d104068fffb7e7cf867ab4c92082aab968692.tar.gz
coreclr-926d104068fffb7e7cf867ab4c92082aab968692.tar.bz2
coreclr-926d104068fffb7e7cf867ab4c92082aab968692.zip
Add PGO support for Clang/LLVM on Unix (#10533)
Extend PGO support from VC++ on WIN32 to Clang/LLVM on UNIX as well. * Just like on Windows: if profile data is missing, skip enabling PGO (allows non-PGO builds in branches where we don't publish PGO data). * PGO with LTO requires additional dependencies (namely a discoverable `ld.gold` and `LLVMgold.so`). To protect against broken support and keep the build flexible across a wider array of distros, attempt to detect whether PGO compilation would work (using cmake's `try_compile()`), and fall back to a non-PGO/non-LTO build if the test fails.
Diffstat (limited to 'configure.cmake')
-rw-r--r--configure.cmake12
1 files changed, 12 insertions, 0 deletions
diff --git a/configure.cmake b/configure.cmake
new file mode 100644
index 0000000000..97b4bc6599
--- /dev/null
+++ b/configure.cmake
@@ -0,0 +1,12 @@
+include(CheckCXXSourceCompiles)
+
+# VC++ guarantees support for LTCG (LTO's equivalent)
+if(NOT WIN32)
+ # Function required to give CMAKE_REQUIRED_* local scope
+ function(check_have_lto)
+ set(CMAKE_REQUIRED_FLAGS -flto)
+ set(CMAKE_REQUIRED_LIBRARIES -flto -fuse-ld=gold)
+ check_cxx_source_compiles("int main() { return 0; }" HAVE_LTO)
+ endfunction(check_have_lto)
+ check_have_lto()
+endif(NOT WIN32)