mirror of
https://github.com/Divested-Mobile/DivestOS-Build.git
synced 2024-12-25 15:39:26 -05:00
Remove JustArchi's compiler flag optimizations
While some tasks complete slightly faster overall there are too many downsides - Too large system images - Weird compiler errors - Performance regressions on some devices - General maintenance overhead Maybe a less aggressive variant can be brought back in the future
This commit is contained in:
parent
9cdfc59d5e
commit
994a069deb
@ -1,559 +0,0 @@
|
||||
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
|
||||
|
@ -1,516 +0,0 @@
|
||||
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
|
||||
|
@ -1,516 +0,0 @@
|
||||
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
|
||||
|
@ -68,6 +68,7 @@ buildAll() {
|
||||
brunch lineage_d802-userdebug;
|
||||
brunch lineage_d855-userdebug;
|
||||
brunch lineage_ether-user;
|
||||
brunch lineage_flo-user;
|
||||
brunch lineage_flounder-user;
|
||||
brunch lineage_FP2-user;
|
||||
# brunch lineage_h815-user; - (UPSTREAM) drivers/input/touchscreen/DS5/RefCode_CustomerImplementation.c:147:1: warning: the frame size of 2064 bytes is larger than 2048 bytes
|
||||
@ -75,10 +76,13 @@ buildAll() {
|
||||
brunch lineage_hammerhead-user;
|
||||
brunch lineage_herolte-user;
|
||||
brunch lineage_himaul-user;
|
||||
brunch lineage_i9100-userdebug;
|
||||
brunch lineage_i9305-user;
|
||||
brunch lineage_jfltexx-user;
|
||||
brunch lineage_klte-user;
|
||||
brunch lineage_m8-user;
|
||||
brunch lineage_marlin-user;
|
||||
brunch lineage_n5110-user;
|
||||
brunch lineage_osprey-user;
|
||||
brunch lineage_sailfish-user;
|
||||
brunch lineage_shamu-user;
|
||||
@ -86,16 +90,6 @@ buildAll() {
|
||||
}
|
||||
export -f buildAll;
|
||||
|
||||
buildAllNO3() {
|
||||
brunch lineage_flo-user; #Not affected by size, but breaks: undefined reference to 'mm_jpeg_get_new_session_idx'
|
||||
#Devices incompatible with -O3 due to size constraints
|
||||
#TODO: Consider moving these devices back and simply disabling recovery.img compilation
|
||||
brunch lineage_i9100-userdebug;
|
||||
brunch lineage_i9305-user;
|
||||
brunch lineage_n5110-user;
|
||||
}
|
||||
export -f buildAllNO3;
|
||||
|
||||
patchWorkspace() {
|
||||
source $scripts/Patch.sh;
|
||||
source $scripts/Defaults.sh;
|
||||
|
@ -62,7 +62,6 @@ patch -p1 < $patches"android_bootable_recovery/0001-Squash_Menus.patch"; #What's
|
||||
|
||||
enterAndClear "build"
|
||||
patch -p1 < $patches"android_build/0001-Automated_Build_Signing.patch" #Automated build signing. Disclaimer: From CopperheadOS 13.0
|
||||
patch -p1 < $patches"android_build/JustArchis_Optimizations-Rebased.patch" #JustArchi's Compiler Flags XXX: Breaks some devices, see buildAllNO3()
|
||||
sed -i 's/messaging/Silence/' target/product/*.mk; #Replace AOSP Messaging app with Silence
|
||||
|
||||
enterAndClear "device/qcom/sepolicy"
|
||||
|
@ -58,22 +58,18 @@ export -f buildDevice;
|
||||
buildAll() {
|
||||
#Select devices are userdebug due to SELinux policy issues
|
||||
#TODO: Add victara, griffin, athene, us997, us996, pme, t0lte, hlte
|
||||
brunch lineage_angler-user;
|
||||
brunch lineage_bacon-user;
|
||||
brunch lineage_bullhead-user;
|
||||
brunch lineage_d852-userdebug;
|
||||
brunch lineage_d855-userdebug;
|
||||
brunch lineage_angler-user;
|
||||
brunch lineage_bullhead-user;
|
||||
brunch lineage_flo-user; #Not affected by size, but breaks: undefined reference to 'mm_jpeg_get_new_session_idx'
|
||||
brunch lineage_flounder-user;
|
||||
#brunch lineage_shamu-user;
|
||||
#brunch lineage_hammerhead-user;
|
||||
#brunch lineage_shamu-user;
|
||||
}
|
||||
export -f buildAll;
|
||||
|
||||
buildAllNO3() {
|
||||
brunch lineage_flo-user; #Not affected by size, but breaks: undefined reference to 'mm_jpeg_get_new_session_idx'
|
||||
}
|
||||
export -f buildAllNO3;
|
||||
|
||||
patchWorkspace() {
|
||||
source build/envsetup.sh;
|
||||
repopick 204743 204744;
|
||||
|
@ -58,7 +58,6 @@ echo -e "\n84831b9409646a918e30573bab4c9c91346d8abd" > "$ANDROID_HOME/licenses/a
|
||||
cp -r $patches"Fennec_DOS-Shim" $base"packages/apps/"; #Add a shim to install Fennec DOS without actually including the large APK
|
||||
|
||||
enterAndClear "build/make"
|
||||
#patch -p1 < $patches"android_build/0002-JustArchis_Optimizations.patch" #JustArchi's Compiler Flags XXX: Breaks some devices, see buildAllNO3() TODO: Rebase
|
||||
sed -i 's/messaging/Silence/' target/product/*.mk; #Replace AOSP Messaging app with Silence
|
||||
|
||||
enterAndClear "device/qcom/sepolicy"
|
||||
|
Loading…
Reference in New Issue
Block a user