[ 
https://issues.apache.org/jira/browse/IMPALA-6974?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16468054#comment-16468054
 ] 

ASF subversion and git services commented on IMPALA-6974:
---------------------------------------------------------

Commit 96c9dac287f5b1db305f4ce9b77a92a4f5f68eff in impala's branch 
refs/heads/master from [~joemcdonnell]
[ https://git-wip-us.apache.org/repos/asf?p=impala.git;h=96c9dac ]

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 <dhe...@cloudera.com>
Reviewed-by: Tim Armstrong <tarmstr...@cloudera.com>
Tested-by: Impala Public Jenkins <impala-public-jenk...@cloudera.com>


> Static and shared compilation don't have compatible ccache entries
> ------------------------------------------------------------------
>
>                 Key: IMPALA-6974
>                 URL: https://issues.apache.org/jira/browse/IMPALA-6974
>             Project: IMPALA
>          Issue Type: Bug
>          Components: Backend
>    Affects Versions: Impala 2.13.0
>            Reporter: Joe McDonnell
>            Assignee: Joe McDonnell
>            Priority: Major
>
> In be/CMakeLists.txt, we add an -fPIC flag unconditionally:
> {code:java}
> # allow linking of static libs into dynamic lib
> add_definitions(-fPIC)
> {code}
> When building in static mode, every command will have an -fPIC flag. However, 
> when building in shared mode, CMake adds -fPIC (or -fPIE) automatically, so 
> every command will have -fPIC plus another -fPIC added by CMake. These extra 
> flags prevent ccache from sharing entries between static and shared builds 
> even after preprocessing.
>  



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-all-unsubscr...@impala.apache.org
For additional commands, e-mail: issues-all-h...@impala.apache.org

Reply via email to