You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@impala.apache.org by ta...@apache.org on 2018/05/08 22:29:45 UTC

[5/5] impala git commit: IMPALA-6974: Use CMAKE_POSITION_INDEPENDENT_CODE in backend

IMPALA-6974: Use CMAKE_POSITION_INDEPENDENT_CODE in backend

Compilation of individual c++ files are only slightly
different between static and shared compilation. First,
CMake adds -D${LIBRARY_NAME}_EXPORTS to each compilation.
Second, CMake sets CMAKE_POSITION_INDEPENDENT_CODE, which
adds an -fPIC/-fPIE flag automatically. The extra define
is not used by our code, so preprocessing results in
identical code. However, we currently add a global -fPIC
to all compilation whether static or shared. This
introduces a second -fPIC flag on shared where static
only has one. This prevents a hit in ccache, even after
preprocessing.

Switching a global -fPIC to CMAKE_POSITION_INDEPENDENT_CODE
eliminates the difference between shared and static
compilation (apart from the added define). This allows
a ccache hit after preprocessing.

There is a slight difference in some of the compile
commands. CMAKE_POSITION_INDEPENDENT_CODE will add
an -fPIC or a -fPIE depending on whether the C++ file
is going to be an executable. For example,
daemon-main.cc gets -fPIE whereas hdfs-scan-node.cc
gets -fPIC. Previously, everything had an -fPIC.

This saves about an hour on all-build-options-ub1604
due to a higher ccache hit rate.

Before:
cache hit (direct)                  1523
cache hit (preprocessed)              61
cache miss                         12690

After:
cache hit (direct)                  1513
cache hit (preprocessed)            5575
cache miss                          7186

Change-Id: Id37bb5afa6a9b7909bb4efe1390a67f7d1469544
Reviewed-on: http://gerrit.cloudera.org:8080/10267
Reviewed-by: Dan Hecht <dh...@cloudera.com>
Reviewed-by: Tim Armstrong <ta...@cloudera.com>
Tested-by: Impala Public Jenkins <im...@cloudera.com>


Project: http://git-wip-us.apache.org/repos/asf/impala/repo
Commit: http://git-wip-us.apache.org/repos/asf/impala/commit/96c9dac2
Tree: http://git-wip-us.apache.org/repos/asf/impala/tree/96c9dac2
Diff: http://git-wip-us.apache.org/repos/asf/impala/diff/96c9dac2

Branch: refs/heads/master
Commit: 96c9dac287f5b1db305f4ce9b77a92a4f5f68eff
Parents: ab2fc5c
Author: Joe McDonnell <jo...@cloudera.com>
Authored: Tue May 1 11:51:21 2018 -0700
Committer: Impala Public Jenkins <im...@cloudera.com>
Committed: Tue May 8 22:23:13 2018 +0000

----------------------------------------------------------------------
 be/CMakeLists.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/impala/blob/96c9dac2/be/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/be/CMakeLists.txt b/be/CMakeLists.txt
index 8e4f8bd..cc5a597 100644
--- a/be/CMakeLists.txt
+++ b/be/CMakeLists.txt
@@ -311,7 +311,7 @@ set(CLANG_INCLUDE_FLAGS
 )
 
 # allow linking of static libs into dynamic lib
-add_definitions(-fPIC)
+set(CMAKE_POSITION_INDEPENDENT_CODE ON)
 
 # set compile output directory
 if ("${CMAKE_BUILD_TYPE}" STREQUAL "DEBUG" OR