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

517 lines
24 KiB
Diff
Raw Normal View History

From b1299e6d90dba5f03c40ee07c9917187dae5aad4 Mon Sep 17 00:00:00 2001
From: JustArchi <JustArchi@JustArchi.net>
Date: Fri, 19 Jan 2018 03:29:47 -0500
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
Change-Id: Ic57c5d9d18b8f8c1efd81505d0c297bc975c547f
---
core/Makefile | 3 +
core/archidroid.mk | 125 ++++++++++++++++++++++++++++++++++++++
core/clang/config.mk | 8 +++
core/combo/TARGET_linux-arm.mk | 14 ++++-
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, 199 insertions(+), 11 deletions(-)
create mode 100644 core/archidroid.mk
diff --git a/core/Makefile b/core/Makefile
index 3fb424733..ab43549b8 100644
--- a/core/Makefile
+++ b/core/Makefile
@@ -1,5 +1,8 @@
# Put some miscellaneous rules here
+# ArchiDroid
+include $(BUILD_SYSTEM)/archidroid.mk
+
# HACK: clear LOCAL_PATH from including last build target before calling
# intermedites-dir-for
LOCAL_PATH := $(BUILD_SYSTEM)
diff --git a/core/archidroid.mk b/core/archidroid.mk
new file mode 100644
index 000000000..b1ff91578
--- /dev/null
+++ b/core/archidroid.mk
@@ -0,0 +1,125 @@
+# _ _ _ ____ _ _
+# / \ _ __ ___| |__ (_) _ \ _ __ ___ (_) __| |
+# / _ \ | '__/ __| '_ \| | | | | '__/ _ \| |/ _` |
+# / ___ \| | | (__| | | | | |_| | | | (_) | | (_| |
+# /_/ \_\_| \___|_| |_|_|____/|_| \___/|_|\__,_|
+#
+# 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 4.9 for arm-linux-androideabi, so we don't have any extra flags for it
+ARCHIDROID_GCC_CFLAGS_32 :=
+
+# 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
diff --git a/core/clang/config.mk b/core/clang/config.mk
index 6cc344637..af6ec2328 100644
--- a/core/clang/config.mk
+++ b/core/clang/config.mk
@@ -1,5 +1,8 @@
## Clang configurations.
+# ArchiDroid
+include $(BUILD_SYSTEM)/archidroid.mk
+
LLVM_PREBUILTS_PATH := $(LLVM_PREBUILTS_BASE)/$(BUILD_OS)-x86/$(LLVM_PREBUILTS_VERSION)/bin
LLVM_RTLIB_PATH := $(LLVM_PREBUILTS_PATH)/../lib64/clang/$(LLVM_RELEASE_VERSION)/lib/linux/
@@ -28,6 +31,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
@@ -64,6 +71,7 @@ CLANG_CONFIG_EXTRA_CFLAGS += \
endif
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 510aae52f..9d0ea1a1f 100644
--- a/core/combo/TARGET_linux-arm.mk
+++ b/core/combo/TARGET_linux-arm.mk
@@ -29,6 +29,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
@@ -71,14 +75,14 @@ endef
$(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
@@ -148,12 +152,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 6a1d8619f..bef38c2dd 100644
--- a/core/combo/TARGET_linux-arm64.mk
+++ b/core/combo/TARGET_linux-arm64.mk
@@ -29,6 +29,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
@@ -128,12 +132,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 186d88f25..39ee5ef4b 100644
--- a/core/combo/TARGET_linux-mips.mk
+++ b/core/combo/TARGET_linux-mips.mk
@@ -29,6 +29,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
@@ -71,7 +75,7 @@ endef
$(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
@@ -119,12 +123,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 3e1f61a0f..a59978afb 100644
--- a/core/combo/TARGET_linux-mips64.mk
+++ b/core/combo/TARGET_linux-mips64.mk
@@ -29,6 +29,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
@@ -71,7 +75,7 @@ endef
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
@@ -125,12 +129,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
diff --git a/core/combo/TARGET_linux-x86.mk b/core/combo/TARGET_linux-x86.mk
index 558ec3b6b..7dd32e711 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
@@ -73,6 +76,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
@@ -82,7 +90,7 @@ KERNEL_HEADERS_ARCH := $(libc_root)/kernel/uapi/asm-x86 # x86 covers both x86
KERNEL_HEADERS := $(KERNEL_HEADERS_COMMON) $(KERNEL_HEADERS_ARCH)
$(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 12166ec47..a96203bc2 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
@@ -73,6 +76,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
@@ -82,7 +90,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 97d62c684..1eddc2219 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 $(BOARD_GLOBAL_CFLAGS)
-$(combo_var_prefix)RELEASE_CFLAGS := -O2 -g -fno-strict-aliasing $(BOARD_RELEASE_CFLAGS)
+$(combo_var_prefix)RELEASE_CFLAGS := $(ARCHIDROID_GCC_CFLAGS_OPTI) -fno-strict-aliasing $(BOARD_RELEASE_CFLAGS)
$(combo_var_prefix)GLOBAL_CPPFLAGS := $(BOARD_GLOBAL_CPPFLAGS)
$(combo_var_prefix)GLOBAL_LDFLAGS :=
$(combo_var_prefix)GLOBAL_ARFLAGS := crsPD
--
2.16.0