Rules to enable LTO for Adreno GFX driver.
This patch controls rules when LTO is enabled for Adreno GFX driver.
Change-Id: I45bd163889ffd3e0237d5451adaca0fc411b14f8
diff --git a/build/core/sdllvm-lto-defs.mk b/build/core/sdllvm-lto-defs.mk
new file mode 100644
index 0000000..74fa49d
--- /dev/null
+++ b/build/core/sdllvm-lto-defs.mk
@@ -0,0 +1,30 @@
+ifeq ($(LOCAL_MODULE_CLASS), STATIC_LIBRARIES)
+# For STATIC_LIBRARIES we need to use SD LLVM's archiver and archiver flags.
+
+AR := $(SDCLANG_PATH)/llvm-ar
+ARFLAGS := crsD
+
+# For 32 bit
+$(LOCAL_BUILT_MODULE) : $(combo_2nd_arch_prefix)TARGET_AR := $(AR)
+$(LOCAL_BUILT_MODULE) : $(combo_var_prefix)GLOBAL_ARFLAGS := $(ARFLAGS)
+
+# For 64 bit
+intermediates := $(call local-intermediates-dir,,$(LOCAL_2ND_ARCH_VAR_PREFIX))
+LOCAL_BUILT_MODULE_64 := $(intermediates)/$(my_built_module_stem)
+
+$(LOCAL_BUILT_MODULE_64) : TARGET_AR := $(AR)
+$(LOCAL_BUILT_MODULE_64) : TARGET_GLOBAL_ARFLAGS := $(ARFLAGS)
+
+else
+# For SHARED_LIBRARIES and EXECUTABLES we need to filter out flags not
+# needed/understood by SD LLVM's Linker.
+
+linked_module_32 := $(intermediates)/LINKED/$(my_built_module_stem)
+intermediates := $(call local-intermediates-dir,,$(LOCAL_2ND_ARCH_VAR_PREFIX))
+linked_module_64 := $(intermediates)/LINKED/$(my_built_module_stem)
+
+FLAGS_TO_BE_FILTERED := -Wl,--icf=safe -Wl,--no-undefined-version -Wl,--fix-cortex-a53-843419 -fuse-ld=gold
+$(linked_module_32) : PRIVATE_TARGET_GLOBAL_LDFLAGS := $(filter-out $(FLAGS_TO_BE_FILTERED),$(PRIVATE_TARGET_GLOBAL_LDFLAGS))
+$(linked_module_64) : PRIVATE_TARGET_GLOBAL_LDFLAGS := $(filter-out $(FLAGS_TO_BE_FILTERED),$(PRIVATE_TARGET_GLOBAL_LDFLAGS))
+
+endif
diff --git a/build/envsetup.sh b/build/envsetup.sh
index d10c54b..5ad75f7 100644
--- a/build/envsetup.sh
+++ b/build/envsetup.sh
@@ -953,7 +953,7 @@
*)
export SDCLANG=true
export SDCLANG_PATH=$(gettop)/prebuilts/snapdragon-llvm/toolchains/llvm-Snapdragon_LLVM_for_Android_3.8/prebuilt/linux-x86_64/bin
- export SDCLANG_LTO_DEFS=$(gettop)/device/qcom/common/sdllvm-lto-defs.mk
+ export SDCLANG_LTO_DEFS=$(gettop)/vendor/lineage/build/core/sdllvm-lto-defs.mk
;;
esac
fi