Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d7914635 authored by Ying Wang's avatar Ying Wang Committed by Dan Albert
Browse files

Support "LOCAL_FDO_SUPPORT := always".

"LOCAL_FDO_SUPPORT := always" enables FDO without user specifying
"BUILD_FDO_OPTIMIZE := true", i.e. it turns on FDO for a
module in any build configuration.

Change-Id: I05d8db2edb2b3f5db073fa14d5bf1083a04571c0
(cherry picked from commit 45d0143a)
parent 95a543c9
Loading
Loading
Loading
Loading
+13 −17
Original line number Diff line number Diff line
@@ -213,10 +213,15 @@ endif
## Please note that we will do option filtering during FDO build.
## i.e. Os->O2, remove -fno-early-inline and -finline-limit.
##################################################################
ifeq ($(strip $(LOCAL_FDO_SUPPORT)), true)
  ifeq ($(strip $(LOCAL_IS_HOST_MODULE)),)
    my_cflags += $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_FDO_CFLAGS)
    my_ldflags += $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_FDO_LDFLAGS)
my_fdo_build :=
ifneq ($(filter true always, $(LOCAL_FDO_SUPPORT)),)
  ifeq ($(BUILD_FDO_INSTRUMENT),true)
    my_cflags += $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_FDO_INSTRUMENT_CFLAGS)
    my_ldflags += $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_FDO_INSTRUMENT_LDFLAGS)
    my_fdo_build := true
  else ifneq ($(filter true,$(BUILD_FDO_OPTIMIZE))$(filter always,$(LOCAL_FDO_SUPPORT)),)
    my_cflags += $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_FDO_OPTIMIZE_CFLAGS)
    my_fdo_build := true
  endif
endif

@@ -1045,20 +1050,11 @@ my_asflags := $(call $(LOCAL_2ND_ARCH_VAR_PREFIX)convert-to-$(my_host)clang-flag
my_ldflags := $(call $(LOCAL_2ND_ARCH_VAR_PREFIX)convert-to-$(my_host)clang-flags,$(my_ldflags))
endif

ifeq ($(LOCAL_FDO_SUPPORT), true)
  build_with_fdo := false
  ifeq ($(BUILD_FDO_INSTRUMENT), true)
    build_with_fdo := true
  endif
  ifeq ($(BUILD_FDO_OPTIMIZE), true)
    build_with_fdo := true
  endif
  ifeq ($(build_with_fdo), true)
ifeq ($(my_fdo_build), true)
  my_cflags := $(patsubst -Os,-O2,$(my_cflags))
    fdo_incompatible_flags=-fno-early-inlining -finline-limit=%
  fdo_incompatible_flags := -fno-early-inlining -finline-limit=%
  my_cflags := $(filter-out $(fdo_incompatible_flags),$(my_cflags))
endif
endif

$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_YACCFLAGS := $(LOCAL_YACCFLAGS)
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ASFLAGS := $(my_asflags)
+11 −17
Original line number Diff line number Diff line
@@ -18,22 +18,16 @@

$(combo_2nd_arch_prefix)TARGET_FDO_CFLAGS:=

ifeq ($(strip $(BUILD_FDO_INSTRUMENT)), true)
# Set BUILD_FDO_INSTRUMENT=true to turn on FDO instrumentation.
# The profile will be generated on /sdcard/fdo_profile on the device.
  $(combo_2nd_arch_prefix)TARGET_FDO_CFLAGS := -fprofile-generate=/sdcard/fdo_profile -DANDROID_FDO
  $(combo_2nd_arch_prefix)TARGET_FDO_LDFLAGS := -lgcov -lgcc
else
  ifeq ($(strip $(BUILD_FDO_OPTIMIZE)), true)
$(combo_2nd_arch_prefix)TARGET_FDO_INSTRUMENT_CFLAGS := -fprofile-generate=/sdcard/fdo_profile -DANDROID_FDO
$(combo_2nd_arch_prefix)TARGET_FDO_INSTRUMENT_LDFLAGS := -lgcov -lgcc

# Set TARGET_FDO_PROFILE_PATH to set a custom profile directory for your build.
ifeq ($(strip $($(combo_2nd_arch_prefix)TARGET_FDO_PROFILE_PATH)),)
  $(combo_2nd_arch_prefix)TARGET_FDO_PROFILE_PATH := vendor/google_data/fdo_profile
endif

    ifneq ($(strip $(wildcard $($(combo_2nd_arch_prefix)TARGET_FDO_PROFILE_PATH)/$(PRODUCT_OUT))),)
      $(combo_2nd_arch_prefix)TARGET_FDO_CFLAGS := -fprofile-use=$($(combo_2nd_arch_prefix)TARGET_FDO_PROFILE_PATH) -DANDROID_FDO -fprofile-correction -Wcoverage-mismatch -Wno-error
    else
      $(warning Profile directory $($(combo_2nd_arch_prefix)TARGET_FDO_PROFILE_PATH)/$(PRODUCT_OUT) does not exist. Turn off FDO.)
    endif
  endif
endif
$(combo_2nd_arch_prefix)TARGET_FDO_OPTIMIZE_CFLAGS := \
    -fprofile-use=$($(combo_2nd_arch_prefix)TARGET_FDO_PROFILE_PATH) \
    -DANDROID_FDO -fprofile-correction -Wcoverage-mismatch -Wno-error