Fix LTO support

This fixes the CMake setup to be able to do LTO builds using lld and clang. I
was able to successfully enable LTO with this. However, the performance of
clang-3.9 + ThinLTO appeared to still be worse than devtoolset's gcc-4.9.2.

Nevertheless, it seemed like a good thing to commit to replace the currently
bogus flags.

Change-Id: I58a532dec43bd9ed5d7ea6419bc9dfc011f279b6
Reviewed-on: http://gerrit.cloudera.org:8080/6162
Tested-by: Kudu Jenkins
Reviewed-by: Adar Dembo <[email protected]>


Project: http://git-wip-us.apache.org/repos/asf/kudu/repo
Commit: http://git-wip-us.apache.org/repos/asf/kudu/commit/2730f8bd
Tree: http://git-wip-us.apache.org/repos/asf/kudu/tree/2730f8bd
Diff: http://git-wip-us.apache.org/repos/asf/kudu/diff/2730f8bd

Branch: refs/heads/master
Commit: 2730f8bd5a00de9e9f0efa6059607cfae434336a
Parents: 99ed629
Author: Todd Lipcon <[email protected]>
Authored: Sun Feb 26 18:03:40 2017 -0800
Committer: Todd Lipcon <[email protected]>
Committed: Tue Feb 28 05:49:13 2017 +0000

----------------------------------------------------------------------
 CMakeLists.txt | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kudu/blob/2730f8bd/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 72cf219..6ec3917 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -183,7 +183,9 @@ set(CXX_FLAGS_FASTDEBUG "-ggdb -O1 -fno-omit-frame-pointer")
 set(CXX_FLAGS_RELEASE "-O3 -g -DNDEBUG -fno-omit-frame-pointer")
 
 if (NOT "${KUDU_USE_LTO}" STREQUAL "")
-  set(CXX_FLAGS_RELEASE "${CXX_FLAGS_RELEASE} flto -fno-use-linker-plugin")
+  set(CXX_FLAGS_RELEASE "${CXX_FLAGS_RELEASE} -flto -fuse-ld=lld")
+  set(CMAKE_AR "llvm-ar")
+  set(CMAKE_RANLIB "llvm-ranlib")
 endif()
 
 set(CXX_FLAGS_PROFILE_GEN "${CXX_FLAGS_RELEASE} -fprofile-generate")

Reply via email to