From c671a7cf5cae42b61991d9b72e53d9d8a6ace84e Mon Sep 17 00:00:00 2001 From: Ying Wang Date: Mon, 20 Jul 2015 18:40:18 -0700 Subject: [PATCH] Split [CC|CXX]_WRAPPER from [TARGET|HOST]_[CC|CXX] - Don't overwrite [TARGET|HOST]_[CC|CXX] with the [CC|CXX]_WRAPPER prefix, so that we can disable the wrapper per module. - Disable ccache on a module when FDO is enabled. Bug: 22612634 Change-Id: Ibc04a4742d589955066c7eceb43a0da9a2b893bc --- core/binary.mk | 7 +++++++ core/ccache.mk | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++ core/combo/select.mk | 59 ---------------------------------------------------- core/config.mk | 2 ++ core/java.mk | 2 +- 5 files changed, 67 insertions(+), 60 deletions(-) create mode 100644 core/ccache.mk diff --git a/core/binary.mk b/core/binary.mk index d7b2c6e4b..b8003d711 100644 --- a/core/binary.mk +++ b/core/binary.mk @@ -44,7 +44,9 @@ my_ldflags := $(LOCAL_LDFLAGS) my_ldlibs := $(LOCAL_LDLIBS) my_asflags := $(LOCAL_ASFLAGS) my_cc := $(LOCAL_CC) +my_cc_wrapper := $(CC_WRAPPER) my_cxx := $(LOCAL_CXX) +my_cxx_wrapper := $(CXX_WRAPPER) my_c_includes := $(LOCAL_C_INCLUDES) my_generated_sources := $(LOCAL_GENERATED_SOURCES) my_native_coverage := $(LOCAL_NATIVE_COVERAGE) @@ -226,6 +228,9 @@ ifneq ($(filter true always, $(LOCAL_FDO_SUPPORT)),) my_cflags += $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_FDO_OPTIMIZE_CFLAGS) my_fdo_build := true endif + # Disable ccache (or other compiler wrapper). + my_cc_wrapper := + my_cxx_wrapper := endif ########################################################### @@ -336,6 +341,7 @@ ifeq ($(strip $(my_cc)),) else my_cc := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)CC) endif + my_cc := $(my_cc_wrapper) $(my_cc) endif ifneq ($(LOCAL_NO_STATIC_ANALYZER),true) my_cc := $(SYNTAX_TOOLS_PREFIX)/ccc-analyzer $(my_syntax_arch) "$(my_cc)" @@ -352,6 +358,7 @@ ifeq ($(strip $(my_cxx)),) else my_cxx := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)CXX) endif + my_cxx := $(my_cxx_wrapper) $(my_cxx) endif ifneq ($(LOCAL_NO_STATIC_ANALYZER),true) my_cxx := $(SYNTAX_TOOLS_PREFIX)/cxx-analyzer $(my_syntax_arch) "$(my_cxx)" diff --git a/core/ccache.mk b/core/ccache.mk new file mode 100644 index 000000000..34e5e1c38 --- /dev/null +++ b/core/ccache.mk @@ -0,0 +1,57 @@ +# +# Copyright (C) 2015 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +ifneq ($(USE_CCACHE),) + # The default check uses size and modification time, causing false misses + # since the mtime depends when the repo was checked out + export CCACHE_COMPILERCHECK := content + + # See man page, optimizations to get more cache hits + # implies that __DATE__ and __TIME__ are not critical for functionality. + # Ignore include file modification time since it will depend on when + # the repo was checked out + export CCACHE_SLOPPINESS := time_macros,include_file_mtime,file_macro + + # Turn all preprocessor absolute paths into relative paths. + # Fixes absolute paths in preprocessed source due to use of -g. + # We don't really use system headers much so the rootdir is + # fine; ensures these paths are relative for all Android trees + # on a workstation. + export CCACHE_BASEDIR := / + + # Workaround for ccache with clang. + # See http://petereisentraut.blogspot.com/2011/09/ccache-and-clang-part-2.html + export CCACHE_CPP2 := true + + CCACHE_HOST_TAG := $(HOST_PREBUILT_TAG) + # If we are cross-compiling Windows binaries on Linux + # then use the linux ccache binary instead. + ifeq ($(HOST_OS)-$(BUILD_OS),windows-linux) + CCACHE_HOST_TAG := linux-$(HOST_PREBUILT_ARCH) + endif + ccache := prebuilts/misc/$(CCACHE_HOST_TAG)/ccache/ccache + # Check that the executable is here. + ccache := $(strip $(wildcard $(ccache))) + ifdef ccache + ifndef CC_WRAPPER + CC_WRAPPER := $(ccache) + endif + ifndef CXX_WRAPPER + CXX_WRAPPER := $(ccache) + endif + ccache = + endif +endif diff --git a/core/combo/select.mk b/core/combo/select.mk index 01f93226f..df12e7e38 100644 --- a/core/combo/select.mk +++ b/core/combo/select.mk @@ -47,62 +47,3 @@ $(combo_var_prefix)STATIC_LIB_SUFFIX := .a # Now include the combo for this specific target. include $(BUILD_COMBOS)/$(combo_target)$(combo_os_arch).mk - -ifneq ($(USE_CCACHE),) - # The default check uses size and modification time, causing false misses - # since the mtime depends when the repo was checked out - export CCACHE_COMPILERCHECK := content - - # See man page, optimizations to get more cache hits - # implies that __DATE__ and __TIME__ are not critical for functionality. - # Ignore include file modification time since it will depend on when - # the repo was checked out - export CCACHE_SLOPPINESS := time_macros,include_file_mtime,file_macro - - # Turn all preprocessor absolute paths into relative paths. - # Fixes absolute paths in preprocessed source due to use of -g. - # We don't really use system headers much so the rootdir is - # fine; ensures these paths are relative for all Android trees - # on a workstation. - export CCACHE_BASEDIR := / - - # Workaround for ccache with clang. - # See http://petereisentraut.blogspot.com/2011/09/ccache-and-clang-part-2.html - export CCACHE_CPP2 := true - - CCACHE_HOST_TAG := $(HOST_PREBUILT_TAG) - # If we are cross-compiling Windows binaries on Linux - # then use the linux ccache binary instead. - ifeq ($(HOST_OS)-$(BUILD_OS),windows-linux) - CCACHE_HOST_TAG := linux-$(HOST_PREBUILT_ARCH) - endif - ccache := prebuilts/misc/$(CCACHE_HOST_TAG)/ccache/ccache - # Check that the executable is here. - ccache := $(strip $(wildcard $(ccache))) - ifdef ccache - ifndef CC_WRAPPER - CC_WRAPPER := $(ccache) - endif - ifndef CXX_WRAPPER - CXX_WRAPPER := $(ccache) - endif - ccache = - endif -endif - -# Stash the original values of CC and CXX so we can still use the non-wrapped -# values later. -$(combo_2nd_arch_prefix)CC_BARE := $($(combo_var_prefix)CC) -$(combo_2nd_arch_prefix)CXX_BARE := $($(combo_var_prefix)CXX) - -# The C/C++ compiler can be wrapped by setting the CC/CXX_WRAPPER vars. -ifdef CC_WRAPPER - ifneq ($(CC_WRAPPER),$(firstword $($(combo_var_prefix)CC))) - $(combo_var_prefix)CC := $(CC_WRAPPER) $($(combo_var_prefix)CC) - endif -endif -ifdef CXX_WRAPPER - ifneq ($(CXX_WRAPPER),$(firstword $($(combo_var_prefix)CXX))) - $(combo_var_prefix)CXX := $(CXX_WRAPPER) $($(combo_var_prefix)CXX) - endif -endif diff --git a/core/config.mk b/core/config.mk index ba8f31030..3e527a87a 100644 --- a/core/config.mk +++ b/core/config.mk @@ -257,6 +257,8 @@ combo_2nd_arch_prefix := $(TARGET_2ND_ARCH_VAR_PREFIX) include $(BUILD_SYSTEM)/combo/select.mk endif +include $(BUILD_SYSTEM)/ccache.mk + ifdef TARGET_PREFER_32_BIT TARGET_PREFER_32_BIT_APPS := true TARGET_PREFER_32_BIT_EXECUTABLES := true diff --git a/core/java.mk b/core/java.mk index b3712895d..0ff59fc90 100644 --- a/core/java.mk +++ b/core/java.mk @@ -253,7 +253,7 @@ endif $(rs_compatibility_jni_libs): $(RenderScript_file_stamp) $(RS_PREBUILT_CLCORE) \ $(rs_support_lib) $(rs_support_io_lib) $(rs_jni_lib) $(rs_compiler_rt) $(rs_compatibility_jni_libs): $(BCC_COMPAT) -$(rs_compatibility_jni_libs): PRIVATE_CXX := $(TARGET_CXX) +$(rs_compatibility_jni_libs): PRIVATE_CXX := $(CXX_WRAPPER) $(TARGET_CXX) $(rs_compatibility_jni_libs): $(renderscript_intermediate)/librs.%.so: \ $(renderscript_intermediate.bc_folder)%.bc $(transform-bc-to-so) -- 2.11.0