DivestOS/Patches/LineageOS-14.1/android_build/JustArchis_Optimizations-Original.patch

560 lines
27 KiB
Diff

From 008197ea0e59f1fd277f537dfd133aeccf05da8f Mon Sep 17 00:00:00 2001
From: JustArchi <JustArchi@JustArchi.net>
Date: Sat, 6 Feb 2016 01:01:45 +0100
Subject: [PATCH] JustArchi's ArchiDroid Optimizations V4.1
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
_ _ _ ____ _ _
/ \ _ __ ___| |__ (_) _ \ _ __ ___ (_) __| |
/ _ \ | '__/ __| '_ \| | | | | '__/ _ \| |/ _` |
/ ___ \| | | (__| | | | | |_| | | | (_) | | (_| |
/_/ \_\_| \___|_| |_|_|____/|_| \___/|_|\__,_|
Copyright (C) 2015 Łukasz "JustArchi" Domeradzki
----------------------------------------------------------------------------------------------------------------
This is the squashed commit of countless hours spent on trying to optimize Android to the maximum and push it to the limits.
Please give proper credit if you decide to cherry-pick this commit. It includes countless number of full builds and tests, almost 200 hours (KK), and additional 100 hours (LP) spent on compiling and testing
----------------------------------------------------------------------------------------------------------------
WARNING! These modifcations are pretty DANGEROUS and may cause problems during compiling or running. You may also need to implement some fixes on your own.
----------------------------------------------------------------------------------------------------------------
Pre-requirements:
- GCC 4.8+, both androideabi and armeabi. Fortunately for us, Lollipop already uses GCC 4.8, but it's in outdated versions and has some internal compiler errors with O3 flags this commit applies. Therefore, I suggest:
1. UBERTC 4.9 arm-linux-androideabi -> https://github.com/ArchiDroid/Toolchain/tree/uber-4.9-arm-linux-androideabi
2. ArchiToolchain 4.9 arm-eabi -> https://github.com/ArchiDroid/Toolchain/tree/architoolchain-4.9-arm-linux-gnueabi-generic
(Please notice that ArchiToolchain is available in many variants, you may want to select the one that suits you best, e.g. Cortex A9 onex)
- (Optional) Target user, instead of userdebug. You should build with user variant instead of userdebug, as user variant in general pre-optimizes some parts and disables additional debug modules, i.e. dalvik debugging, procmem/procrank binaries and so.
This can be done by multiple ways, e.g. using proper lunch command (i.e. lunching cm_i9300-user instead of cm_i9300-userdebug) or "brunch device user", such as "brunch i9300 user", if your android_build includes my CM commit -> https://github.com/CyanogenMod/android_build/commit/73db70d928f4a7af1d4a0a255327c6ff5d8ffbc9
----------------------------------------------------------------------------------------------------------------
Important notes:
- This commit has been tested on up-to-date CM-12.1 (Android 5.1.1) and suggested toolchains mentioned above. Other ROMs and toolchains may, or may not, work out of the box with it.
- You can ask for help in such cases in the XDA thread linked on the bottom of the commit.
- You're applying these optimizations at your own risk, I highly suggest to understand what each of the flag does, and not trying to blindly "apply them all" and hope for the best. Also, due to various hacks and issues in various trees and devices, I can't assure you that what works for me, will also work for you.
- Fortunately for you, my test device is Samsung Galaxy S3 with the nightmare Exynos4 SoC, so it's likely that it should work for major of the (better done) devices.
- As pointed in pre-requirements, stock AOSP toolchains are outdated and have many internal compiler errors. This commit probably can work on stock AOSP toolchains, but you'll need to get rid of some flags that are causing those errors on AOSP toolchains (e.g. -O3 for thumb)
- Due to O3 optimization, code is significantly larger and may cause problems with oversized images especially for older devices. For example, I couldn't apply O3 because building TWRP recovery failed due to the fact that it didn't fit on recovery's block in my device. In such case you have two options. You can use my little hack that ignored recovery size, so compiler doesn't yell about that (but you obviously can't flash such images), or you need to go back either to O2 or Os (for thumb), up to you.
----------------------------------------------------------------------------------------------------------------
Important changes:
- Optimized for speed yet more all instructions - ARM and THUMB (-O3)
- Optimized for speed also parts which are compiled with Clang (-O3)
- Turned off all debugging code (lack of -g)
- Eliminated redundant loads that come after stores to the same memory location, both partial and full redundancies (-fgcse-las)
- Ran a store motion pass after global common subexpression elimination. This pass attempts to move stores out of loops (-fgcse-sm)
- Enabled the identity transformation for graphite. For every SCoP we generate the polyhedral representation and transform it back to gimple. We can then check the costs or benefits of the GIMPLE -> GRAPHITE -> GIMPLE transformation. Some minimal optimizations are also performed by the code generator ISL, like index splitting and dead code elimination in loops (-fgraphite -fgraphite-identity)
- Performed interprocedural pointer analysis and interprocedural modification and reference analysis (-fipa-pta)
- Performed induction variable optimizations (strength reduction, induction variable merging and induction variable elimination) on trees (-fivopts)
- Didn't keep the frame pointer in a register for functions that don't need one. This avoids the instructions to save, set up and restore frame pointers; it also makes an extra register available in many functions (-fomit-frame-pointer)
- Attempted to avoid false dependencies in scheduled code by making use of registers left over after register allocation. This optimization most benefits processors with lots of registers (-frename-registers)
- Tried to reduce the number of symbolic address calculations by using shared “anchor” symbols to address nearby objects. This transformation can help to reduce the number of GOT entries and GOT accesses on some targets (-fsection-anchors)
- Performed tail duplication to enlarge superblock size. This transformation simplifies the control flow of the function allowing other optimizations to do a better job (-ftracer)
- Performed loop invariant motion on trees. It also moved operands of conditions that are invariant out of the loop, so that we can use just trivial invariantness analysis in loop unswitching. The pass also includes store motion (-ftree-loop-im)
- Created a canonical counter for number of iterations in loops for which determining number of iterations requires complicated analysis. Later optimizations then may determine the number easily (-ftree-loop-ivcanon)
- Assumed that loop indices do not overflow, and that loops with nontrivial exit condition are not infinite. This enables a wider range of loop optimizations even if the loop optimizer itself cannot prove that these assumptions are valid (-funsafe-loop-optimizations)
- Moved branches with loop invariant conditions out of the loop (-funswitch-loops)
- Constructed webs as commonly used for register allocation purposes and assigned each web individual pseudo register. This allows the register allocation pass to operate on pseudos directly, but also strengthens several other optimization passes, such as CSE, loop optimizer and trivial dead code remover (-fweb)
- Sorted the common symbols by alignment in descending order. This is to prevent gaps between symbols due to alignment constraints (-Wl,--sort-common)
----------------------------------------------------------------------------------------------------------------
For more information, support, troubleshooting and discussion about my optimizations, please refer to my thread on XDA -> http://forum.xda-developers.com/showthread.php?t=2754997
---
core/Makefile | 6 +-
core/archidroid.mk | 144 ++++++++++++++++++++++++++++++++++++++
core/clang/config.mk | 8 +++
core/combo/TARGET_linux-arm.mk | 23 +++---
core/combo/TARGET_linux-arm64.mk | 11 ++-
core/combo/TARGET_linux-mips.mk | 12 +++-
core/combo/TARGET_linux-mips64.mk | 12 +++-
core/combo/TARGET_linux-x86.mk | 10 ++-
core/combo/TARGET_linux-x86_64.mk | 10 ++-
core/combo/select.mk | 5 +-
10 files changed, 220 insertions(+), 21 deletions(-)
create mode 100644 core/archidroid.mk
diff --git a/core/Makefile b/core/Makefile
index 834a56d9f..31fda7f5b 100644
--- a/core/Makefile
+++ b/core/Makefile
@@ -1,5 +1,8 @@
# Put some miscellaneous rules here
+# ArchiDroid
+include $(BUILD_SYSTEM)/archidroid.mk
+
# Build system colors
ifneq ($(BUILD_WITH_COLORS),0)
@@ -1004,7 +1007,8 @@ define build-recoveryimage-target
$(BOOT_SIGNER) /recovery $(1) $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VERITY_SIGNING_KEY).pk8 $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VERITY_SIGNING_KEY).x509.pem $(1))
$(if $(filter true,$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VBOOT)), \
$(VBOOT_SIGNER) $(FUTILITY) $(1).unsigned $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VBOOT_SIGNING_KEY).vbpubk $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VBOOT_SIGNING_KEY).vbprivk $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VBOOT_SIGNING_SUBKEY).vbprivk $(1).keyblock $(1))
- $(hide) $(call assert-max-image-size,$(1),$(BOARD_RECOVERYIMAGE_PARTITION_SIZE))
+ $(if $(filter-out true,$(ARCHIDROID_IGNORE_RECOVERY_SIZE)), \
+ $(hide) $(call assert-max-image-size,$(1),$(BOARD_RECOVERYIMAGE_PARTITION_SIZE)))
@echo -e ${CL_CYN}"Made recovery image: $@"${CL_RST}
endef
diff --git a/core/archidroid.mk b/core/archidroid.mk
new file mode 100644
index 000000000..9ab491877
--- /dev/null
+++ b/core/archidroid.mk
@@ -0,0 +1,144 @@
+# _ _ _ ____ _ _
+# / \ _ __ ___| |__ (_) _ \ _ __ ___ (_) __| |
+# / _ \ | '__/ __| '_ \| | | | | '__/ _ \| |/ _` |
+# / ___ \| | | (__| | | | | |_| | | | (_) | | (_| |
+# /_/ \_\_| \___|_| |_|_|____/|_| \___/|_|\__,_|
+#
+# Copyright 2015-2016 Łukasz "JustArchi" Domeradzki
+# Contact: JustArchi@JustArchi.net
+#
+# 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.
+
+#######################
+### GENERAL SECTION ###
+#######################
+
+# General optimization level
+ARCHIDROID_GCC_CFLAGS_OPTI := -O3
+
+# General optimization level of target ARM compiled with GCC. Default: -O2
+ARCHIDROID_GCC_CFLAGS_ARM := $(ARCHIDROID_GCC_CFLAGS_OPTI)
+
+# General optimization level of target THUMB compiled with GCC. Default: -Os
+ARCHIDROID_GCC_CFLAGS_THUMB := $(ARCHIDROID_GCC_CFLAGS_OPTI)
+
+# Additional flags passed to all C targets compiled with GCC
+ARCHIDROID_GCC_CFLAGS := $(ARCHIDROID_GCC_CFLAGS_OPTI) -pipe -fgcse-las -fgcse-sm -fipa-pta -fivopts -fomit-frame-pointer -frename-registers -fsection-anchors -ftree-loop-im -ftree-loop-ivcanon -ftree-vectorize -funsafe-loop-optimizations -funswitch-loops -fweb
+
+# We also need to disable some warnings to not abort the build - those warning are not critical
+ARCHIDROID_GCC_CFLAGS += -Wno-error=array-bounds -Wno-error=clobbered -Wno-error=maybe-uninitialized -Wno-error=parentheses -Wno-error=strict-overflow -Wno-error=unused-variable
+
+# Flags passed to linker (ld) of all C and C++ targets
+ARCHIDROID_GCC_LDFLAGS := -Wl,-O3 -Wl,--as-needed -Wl,--gc-sections -Wl,--relax -Wl,--sort-common
+
+
+# Flags below are applied to specific targets only, use them if your flag is not compatible for both compilers
+
+# We use GCC 5.3 for arm-linux-androideabi, make sure to remove flags below if you decided to stick with 4.9
+ARCHIDROID_GCC_CFLAGS_32 := -Wno-error=bool-compare -Wno-error=logical-not-parentheses -Wno-error=sizeof-array-argument
+
+# We use GCC 4.9 for aarch64-linux-android, so we don't have any extra flags for it
+ARCHIDROID_GCC_CFLAGS_64 :=
+
+############################
+### EXPERIMENTAL SECTION ###
+############################
+
+# Flags in this section are highly experimental
+# Current setup is based on proposed androideabi toolchain
+# Results with other toolchains may vary
+# Be careful when changing options in this section
+
+# These flags should work in general, but it's likely that the generated code might be in fact slower than without them
+# I suggest to not enable them globally, but they're here for you in case you want to benchmark the OS with and without them
+# ARCHIDROID_GCC_CFLAGS += -ftracer -funroll-loops
+
+# These flags may cause ICEs in some compilers, but work fine in other ones, test carefully
+# ARCHIDROID_GCC_CFLAGS += -fgraphite -fgraphite-identity
+
+# The following flags (-floop) require that your GCC has been configured --with-isl
+# Additionally, applying any of them will most likely cause ICE in your compiler, so they're disabled
+# ARCHIDROID_GCC_CFLAGS += -floop-block -floop-interchange -floop-nest-optimize -floop-parallelize-all -floop-strip-mine
+
+# These flags have been disabled because of assembler errors
+# ARCHIDROID_GCC_CFLAGS += -fmodulo-sched -fmodulo-sched-allow-regmoves
+
+####################
+### MISC SECTION ###
+####################
+
+# Flags passed to GCC preprocessor for C and C++
+ARCHIDROID_GCC_CPPFLAGS := $(ARCHIDROID_GCC_CFLAGS)
+
+#####################
+### CLANG SECTION ###
+#####################
+
+# Flags passed to all C targets compiled with CLANG
+ARCHIDROID_CLANG_CFLAGS := -O3 -Qunused-arguments -Wno-unknown-warning-option
+
+# Flags passed to CLANG preprocessor for C and C++
+ARCHIDROID_CLANG_CPPFLAGS := $(ARCHIDROID_CLANG_CFLAGS)
+
+# Flags passed to linker (ld) of all C and C++ targets compiled with CLANG
+ARCHIDROID_CLANG_LDFLAGS := $(ARCHIDROID_GCC_LDFLAGS)
+
+# Flags that are used by GCC, but are unknown to CLANG. If you get "argument unused during compilation" error, add the flag here
+ARCHIDROID_CLANG_UNKNOWN_FLAGS := \
+ -mvectorize-with-neon-double \
+ -mvectorize-with-neon-quad \
+ -fgcse-after-reload \
+ -fgcse-las \
+ -fgcse-sm \
+ -fgraphite \
+ -fgraphite-identity \
+ -fipa-pta \
+ -fivopts \
+ -floop-block \
+ -floop-interchange \
+ -floop-nest-optimize \
+ -floop-parallelize-all \
+ -ftree-parallelize-loops=2 \
+ -ftree-parallelize-loops=4 \
+ -ftree-parallelize-loops=8 \
+ -ftree-parallelize-loops=16 \
+ -floop-strip-mine \
+ -fmodulo-sched \
+ -fmodulo-sched-allow-regmoves \
+ -frerun-cse-after-loop \
+ -frename-registers \
+ -fsection-anchors \
+ -ftracer \
+ -ftree-loop-im \
+ -ftree-loop-ivcanon \
+ -funsafe-loop-optimizations \
+ -fweb
+
+#####################
+### HACKS SECTION ###
+#####################
+
+# Most of the flags are increasing code size of the output binaries, especially O3 instead of Os for target THUMB
+# This may become problematic for small blocks, especially for boot or recovery blocks (ramdisks), used in older devices
+# For example, i9300 has only 8 MB block for recovery.img, and compiling TWRP for it with above optimizations will fail
+#
+# If you don't care about the size of recovery.img, e.g. you have no use of it, and you want to silence the
+# error "image too large" for recovery.img, use this definition
+#
+# NOTICE: It's better to use device-based flag TARGET_NO_RECOVERY instead, but some devices may have
+# boot + recovery combo (e.g. Sony Xperias), and we must build recovery for them, so we can't set TARGET_NO_RECOVERY globally
+# Therefore, this seems like a safe approach (will only ignore check on recovery.img, without doing anything else)
+# However, if you use compiled recovery.img for your device, please disable this flag (comment or set to false), and lower
+# optimization levels instead, as you need to make sure that recovery.img fits prior to trying to flash it
+# Most (if not all) of the builders have no use of recovery.img, therefore this option is enabled by default
+ARCHIDROID_IGNORE_RECOVERY_SIZE := true
diff --git a/core/clang/config.mk b/core/clang/config.mk
index b887c83d9..e382d1cee 100644
--- a/core/clang/config.mk
+++ b/core/clang/config.mk
@@ -1,5 +1,8 @@
## Clang configurations.
+# ArchiDroid
+include $(BUILD_SYSTEM)/archidroid.mk
+
# WITHOUT_CLANG covers both HOST and TARGET
ifeq ($(WITHOUT_CLANG),true)
WITHOUT_TARGET_CLANG := true
@@ -25,6 +28,10 @@ CLANG_CONFIG_EXTRA_CONLYFLAGS := -std=gnu99
CLANG_CONFIG_EXTRA_CPPFLAGS :=
CLANG_CONFIG_EXTRA_LDFLAGS :=
+CLANG_CONFIG_EXTRA_CFLAGS += $(ARCHIDROID_CLANG_CFLAGS)
+CLANG_CONFIG_EXTRA_CPPFLAGS += $(ARCHIDROID_CLANG_CPPFLAGS)
+CLANG_CONFIG_EXTRA_LDFLAGS += $(ARCHIDROID_CLANG_LDFLAGS)
+
CLANG_CONFIG_EXTRA_CFLAGS += \
-D__compiler_offsetof=__builtin_offsetof
@@ -58,6 +65,7 @@ CLANG_CONFIG_EXTRA_CFLAGS += \
-fcolor-diagnostics
CLANG_CONFIG_UNKNOWN_CFLAGS := \
+ $(ARCHIDROID_CLANG_UNKNOWN_FLAGS) \
-finline-functions \
-finline-limit=64 \
-fno-canonical-system-headers \
diff --git a/core/combo/TARGET_linux-arm.mk b/core/combo/TARGET_linux-arm.mk
index 5020865ea..6b479dd6b 100644
--- a/core/combo/TARGET_linux-arm.mk
+++ b/core/combo/TARGET_linux-arm.mk
@@ -30,6 +30,10 @@
# include defines, and compiler settings for the given architecture
# version.
#
+
+# ArchiDroid
+include $(BUILD_SYSTEM)/archidroid.mk
+
ifeq ($(strip $(TARGET_$(combo_2nd_arch_prefix)ARCH_VARIANT)),)
TARGET_$(combo_2nd_arch_prefix)ARCH_VARIANT := armv5te
endif
@@ -68,14 +72,14 @@ $(combo_2nd_arch_prefix)TARGET_STRIP := $($(combo_2nd_arch_prefix)TARGET_TOOLS_P
$(combo_2nd_arch_prefix)TARGET_NO_UNDEFINED_LDFLAGS := -Wl,--no-undefined
-$(combo_2nd_arch_prefix)TARGET_arm_CFLAGS := -O2 \
+$(combo_2nd_arch_prefix)TARGET_arm_CFLAGS := $(ARCHIDROID_GCC_CFLAGS_ARM) \
-fomit-frame-pointer \
-fstrict-aliasing \
-funswitch-loops
# Modules can choose to compile some source as thumb.
$(combo_2nd_arch_prefix)TARGET_thumb_CFLAGS := -mthumb \
- -Os \
+ $(ARCHIDROID_GCC_CFLAGS_THUMB) \
-fomit-frame-pointer \
-fno-strict-aliasing
@@ -111,15 +115,6 @@ $(combo_2nd_arch_prefix)TARGET_GLOBAL_CFLAGS += \
-include $(android_config_h) \
-I $(dir $(android_config_h))
-# The "-Wunused-but-set-variable" option often breaks projects that enable
-# "-Wall -Werror" due to a commom idiom "ALOGV(mesg)" where ALOGV is turned
-# into no-op in some builds while mesg is defined earlier. So we explicitly
-# disable "-Wunused-but-set-variable" here.
-ifneq ($(filter 4.6 4.6.% 4.7 4.7.% 4.8 4.9, $($(combo_2nd_arch_prefix)TARGET_GCC_VERSION)),)
-$(combo_2nd_arch_prefix)TARGET_GLOBAL_CFLAGS += -fno-builtin-sin \
- -fno-strict-volatile-bitfields
-endif
-
# This is to avoid the dreaded warning compiler message:
# note: the mangling of 'va_list' has changed in GCC 4.4
#
@@ -148,12 +143,16 @@ $(combo_2nd_arch_prefix)TARGET_GLOBAL_CPPFLAGS += -fvisibility-inlines-hidden
# More flags/options can be added here
$(combo_2nd_arch_prefix)TARGET_RELEASE_CFLAGS := \
-DNDEBUG \
- -g \
-Wstrict-aliasing=2 \
-fgcse-after-reload \
-frerun-cse-after-loop \
-frename-registers
+$(combo_2nd_arch_prefix)TARGET_GLOBAL_CFLAGS += $(ARCHIDROID_GCC_CFLAGS)
+$(combo_2nd_arch_prefix)TARGET_GLOBAL_CFLAGS += $(ARCHIDROID_GCC_CFLAGS_32)
+$(combo_2nd_arch_prefix)TARGET_GLOBAL_CPPFLAGS += $(ARCHIDROID_GCC_CPPFLAGS)
+$(combo_2nd_arch_prefix)TARGET_GLOBAL_LDFLAGS += $(ARCHIDROID_GCC_LDFLAGS)
+
libc_root := bionic/libc
libm_root := bionic/libm
diff --git a/core/combo/TARGET_linux-arm64.mk b/core/combo/TARGET_linux-arm64.mk
index 3acddc563..f6f14126a 100644
--- a/core/combo/TARGET_linux-arm64.mk
+++ b/core/combo/TARGET_linux-arm64.mk
@@ -30,6 +30,10 @@
# include defines, and compiler settings for the given architecture
# version.
#
+
+# ArchiDroid
+include $(BUILD_SYSTEM)/archidroid.mk
+
ifeq ($(strip $(TARGET_ARCH_VARIANT)),)
TARGET_ARCH_VARIANT := armv8
endif
@@ -125,12 +129,17 @@ TARGET_GLOBAL_CPPFLAGS += -fvisibility-inlines-hidden
# More flags/options can be added here
TARGET_RELEASE_CFLAGS := \
-DNDEBUG \
- -O2 -g \
+ $(ARCHIDROID_GCC_CFLAGS_OPTI) \
-Wstrict-aliasing=2 \
-fgcse-after-reload \
-frerun-cse-after-loop \
-frename-registers
+TARGET_GLOBAL_CFLAGS += $(ARCHIDROID_GCC_CFLAGS)
+TARGET_GLOBAL_CFLAGS += $(ARCHIDROID_GCC_CFLAGS_64)
+TARGET_GLOBAL_CPPFLAGS += $(ARCHIDROID_GCC_CPPFLAGS)
+TARGET_GLOBAL_LDFLAGS += $(ARCHIDROID_GCC_LDFLAGS)
+
libc_root := bionic/libc
libm_root := bionic/libm
diff --git a/core/combo/TARGET_linux-mips.mk b/core/combo/TARGET_linux-mips.mk
index 29e49fba1..847243a98 100644
--- a/core/combo/TARGET_linux-mips.mk
+++ b/core/combo/TARGET_linux-mips.mk
@@ -30,6 +30,10 @@
# include defines, and compiler settings for the given architecture
# version.
#
+
+# ArchiDroid
+include $(BUILD_SYSTEM)/archidroid.mk
+
ifeq ($(strip $(TARGET_$(combo_2nd_arch_prefix)ARCH_VARIANT)),)
TARGET_$(combo_2nd_arch_prefix)ARCH_VARIANT := mips32r2-fp
endif
@@ -67,7 +71,7 @@ $(combo_2nd_arch_prefix)TARGET_STRIP := $($(combo_2nd_arch_prefix)TARGET_TOOLS_P
$(combo_2nd_arch_prefix)TARGET_NO_UNDEFINED_LDFLAGS := -Wl,--no-undefined
-TARGET_mips_CFLAGS := -O2 \
+TARGET_mips_CFLAGS := $(ARCHIDROID_GCC_CFLAGS_OPTI) \
-fomit-frame-pointer \
-fno-strict-aliasing \
-funswitch-loops
@@ -117,12 +121,16 @@ $(combo_2nd_arch_prefix)TARGET_GLOBAL_CPPFLAGS += -fvisibility-inlines-hidden
# More flags/options can be added here
$(combo_2nd_arch_prefix)TARGET_RELEASE_CFLAGS := \
-DNDEBUG \
- -g \
-Wstrict-aliasing=2 \
-fgcse-after-reload \
-frerun-cse-after-loop \
-frename-registers
+$(combo_2nd_arch_prefix)TARGET_GLOBAL_CFLAGS += $(ARCHIDROID_GCC_CFLAGS)
+$(combo_2nd_arch_prefix)TARGET_GLOBAL_CFLAGS += $(ARCHIDROID_GCC_CFLAGS_32)
+$(combo_2nd_arch_prefix)TARGET_GLOBAL_CPPFLAGS += $(ARCHIDROID_GCC_CPPFLAGS)
+$(combo_2nd_arch_prefix)TARGET_GLOBAL_LDFLAGS += $(ARCHIDROID_GCC_LDFLAGS)
+
libc_root := bionic/libc
libm_root := bionic/libm
diff --git a/core/combo/TARGET_linux-mips64.mk b/core/combo/TARGET_linux-mips64.mk
index b34b7a640..7220ead69 100644
--- a/core/combo/TARGET_linux-mips64.mk
+++ b/core/combo/TARGET_linux-mips64.mk
@@ -30,6 +30,10 @@
# include defines, and compiler settings for the given architecture
# version.
#
+
+# ArchiDroid
+include $(BUILD_SYSTEM)/archidroid.mk
+
ifeq ($(strip $(TARGET_ARCH_VARIANT)),)
TARGET_ARCH_VARIANT := mips64r6
endif
@@ -67,7 +71,7 @@ TARGET_STRIP := $(TARGET_TOOLS_PREFIX)strip$(HOST_EXECUTABLE_SUFFIX)
TARGET_NO_UNDEFINED_LDFLAGS := -Wl,--no-undefined
-TARGET_mips_CFLAGS := -O2 \
+TARGET_mips_CFLAGS := $(ARCHIDROID_GCC_CFLAGS_OPTI) \
-fomit-frame-pointer \
-fno-strict-aliasing \
-funswitch-loops
@@ -120,12 +124,16 @@ TARGET_GLOBAL_CPPFLAGS += -fvisibility-inlines-hidden
# More flags/options can be added here
TARGET_RELEASE_CFLAGS := \
-DNDEBUG \
- -g \
-Wstrict-aliasing=2 \
-fgcse-after-reload \
-frerun-cse-after-loop \
-frename-registers
+TARGET_GLOBAL_CFLAGS += $(ARCHIDROID_GCC_CFLAGS)
+TARGET_GLOBAL_CFLAGS += $(ARCHIDROID_GCC_CFLAGS_64)
+TARGET_GLOBAL_CPPFLAGS += $(ARCHIDROID_GCC_CPPFLAGS)
+TARGET_GLOBAL_LDFLAGS += $(ARCHIDROID_GCC_LDFLAGS)
+
libc_root := bionic/libc
libm_root := bionic/libm
libthread_db_root := bionic/libthread_db
diff --git a/core/combo/TARGET_linux-x86.mk b/core/combo/TARGET_linux-x86.mk
index 340f3067a..5b21778bd 100644
--- a/core/combo/TARGET_linux-x86.mk
+++ b/core/combo/TARGET_linux-x86.mk
@@ -17,6 +17,9 @@
# Configuration for Linux on x86 as a target.
# Included by combo/select.mk
+# ArchiDroid
+include $(BUILD_SYSTEM)/archidroid.mk
+
# Provide a default variant.
ifeq ($(strip $(TARGET_$(combo_2nd_arch_prefix)ARCH_VARIANT)),)
TARGET_$(combo_2nd_arch_prefix)ARCH_VARIANT := x86
@@ -68,6 +71,11 @@ endif
$(combo_2nd_arch_prefix)TARGET_NO_UNDEFINED_LDFLAGS := -Wl,--no-undefined
+$(combo_2nd_arch_prefix)TARGET_GLOBAL_CFLAGS += $(ARCHIDROID_GCC_CFLAGS)
+$(combo_2nd_arch_prefix)TARGET_GLOBAL_CFLAGS += $(ARCHIDROID_GCC_CFLAGS_32)
+$(combo_2nd_arch_prefix)TARGET_GLOBAL_CPPFLAGS += $(ARCHIDROID_GCC_CPPFLAGS)
+$(combo_2nd_arch_prefix)TARGET_GLOBAL_LDFLAGS += $(ARCHIDROID_GCC_LDFLAGS)
+
libc_root := bionic/libc
libm_root := bionic/libm
@@ -78,7 +86,7 @@ KERNEL_HEADERS := $(KERNEL_HEADERS_COMMON) $(KERNEL_HEADERS_ARCH)
android_config_h := $(call select-android-config-h,target_linux-x86)
$(combo_2nd_arch_prefix)TARGET_GLOBAL_CFLAGS += \
- -O2 \
+ $(ARCHIDROID_GCC_CFLAGS_OPTI) \
-Wa,--noexecstack \
-Werror=format-security \
-D_FORTIFY_SOURCE=2 \
diff --git a/core/combo/TARGET_linux-x86_64.mk b/core/combo/TARGET_linux-x86_64.mk
index 53b0572cf..e90873331 100644
--- a/core/combo/TARGET_linux-x86_64.mk
+++ b/core/combo/TARGET_linux-x86_64.mk
@@ -17,6 +17,9 @@
# Configuration for Linux on x86_64 as a target.
# Included by combo/select.mk
+# ArchiDroid
+include $(BUILD_SYSTEM)/archidroid.mk
+
# Provide a default variant.
ifeq ($(strip $(TARGET_ARCH_VARIANT)),)
TARGET_ARCH_VARIANT := x86_64
@@ -68,6 +71,11 @@ endif
TARGET_NO_UNDEFINED_LDFLAGS := -Wl,--no-undefined
+TARGET_GLOBAL_CFLAGS += $(ARCHIDROID_GCC_CFLAGS)
+TARGET_GLOBAL_CFLAGS += $(ARCHIDROID_GCC_CFLAGS_64)
+TARGET_GLOBAL_CPPFLAGS += $(ARCHIDROID_GCC_CPPFLAGS)
+TARGET_GLOBAL_LDFLAGS += $(ARCHIDROID_GCC_LDFLAGS)
+
libc_root := bionic/libc
libm_root := bionic/libm
@@ -76,7 +84,7 @@ KERNEL_HEADERS_ARCH := $(libc_root)/kernel/uapi/asm-x86 # x86 covers both x86
KERNEL_HEADERS := $(KERNEL_HEADERS_COMMON) $(KERNEL_HEADERS_ARCH)
TARGET_GLOBAL_CFLAGS += \
- -O2 \
+ $(ARCHIDROID_GCC_CFLAGS_OPTI) \
-Wa,--noexecstack \
-Werror=format-security \
-D_FORTIFY_SOURCE=2 \
diff --git a/core/combo/select.mk b/core/combo/select.mk
index df12e7e38..856b28fc0 100644
--- a/core/combo/select.mk
+++ b/core/combo/select.mk
@@ -21,6 +21,9 @@
# combo_2nd_arch_prefix -- it's defined if this is loaded for the 2nd arch.
#
+# ArchiDroid
+include $(BUILD_SYSTEM)/archidroid.mk
+
# Build a target string like "linux-arm" or "darwin-x86".
combo_os_arch := $($(combo_target)OS)-$($(combo_target)$(combo_2nd_arch_prefix)ARCH)
@@ -34,7 +37,7 @@ $(combo_var_prefix)AR := $(AR)
$(combo_var_prefix)STRIP := $(STRIP)
$(combo_var_prefix)GLOBAL_CFLAGS := -fno-exceptions -Wno-multichar
-$(combo_var_prefix)RELEASE_CFLAGS := -O2 -g -fno-strict-aliasing
+$(combo_var_prefix)RELEASE_CFLAGS := $(ARCHIDROID_GCC_CFLAGS_OPTI) -fno-strict-aliasing
$(combo_var_prefix)GLOBAL_CPPFLAGS :=
$(combo_var_prefix)GLOBAL_LDFLAGS :=
$(combo_var_prefix)GLOBAL_ARFLAGS := crsPD
--
2.16.0