HUGE SaberMod update (2/4)
This patch includes:
from SM_vendor:
MOAR SaberMod flags
extra sabermod C flags
Add more optimizations to extra sabermod gcc cflags and kernel flags
Add more clang C flags
enable graphite and -O3 form libwebviewchromium
Add some basic host optimizations
update sm.mk: cleanup graphite flags
sm.mk: Don't add when exporting
sm.mk: Fix device kernel graphite flags not being added
Fix build, create sm_clear_vars.mk and add -pipe
hammerhead: fix compiling on macs (darwin), and update sm_clear_vars.mk
-O3 optimzations: More improvements
SaberMod ARM Mode
Fix bluetooth in SaberMod ARM Mode
export GRAPHITE_UNROLL_AND_JAM to the kernel
sm.mk: more dependency fixes:
small cleanup
from SM_build:
MOAR SaberMod flags
ARM: Enable -fno-builtin-sin and -fno-strict-volatile-bitfields by default
extra sabermod flags binary mode: separate gcc from clang completely
Add some basic host optimizations
Cleanup graphite: LOCAL_CFLAGS will be used for CPP flags
-O3 optimzations: More improvements
Include sm_clear_vars.mk
sm.mk: Bug fix for aosp and strict-aliasing
SaberMod ARM Mode (2/2)
small cleanup
Rewrite SaberMod ARM Mode to fix build for arm64
Find more strict-aliasing flags in arm mode
ARM: Make strict-aliasing optional
ARM: Remove -funswitch-loops from arm mode flags
More flag fixes...
sm.mk: code shrink
strict derp: Make optional for real this time.
Remove extra clang -O3 flags
Create dumpvar.mk
strict: one more fix..
Fix strict-aliasing being enabled thanks to Alessandro
Add a option to disable vectorization flags (2/2)
Update for vendor changes
No optimizations for bluetooth modules
from SM_kernel:
MOAR SaberMod flags
pthread: make the warning more obvious
Use common ld scripts for ld modules
kernel: add support for gcc 5/6
net: netfilter: disable loop-unroll-and-jam where needed
Organize SaberMod edits and add LICENSE
Update for latest rom changes.
One more compatibility patch for graphite
Change-Id: I373fa1102a90704a0fabdd497ffd59cd472e9498
Signed-off-by: noname55804 <marlin2201@gmail.com>
diff --git a/core/O3.mk b/core/O3.mk
deleted file mode 100644
index f9aa54f..0000000
--- a/core/O3.mk
+++ /dev/null
@@ -1,27 +0,0 @@
-# Copyright (C) 2014-2015 The SaberMod Project
-#
-# 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.
-#
-
-ifneq (1,$(words $(filter $(LOCAL_DISABLE_O3),$(LOCAL_MODULE))))
- ifdef LOCAL_CONLYFLAGS
- LOCAL_CONLYFLAGS += $(O3_FLAGS)
- else
- LOCAL_CONLYFLAGS := $(O3_FLAGS)
- endif
- ifdef LOCAL_CPPFLAGS
- LOCAL_CPPFLAGS += $(O3_FLAGS)
- else
- LOCAL_CPPFLAGS := $(O3_FLAGS)
- endif
-endif
diff --git a/core/binary.mk b/core/binary.mk
index d46ea43..1315f68 100644
--- a/core/binary.mk
+++ b/core/binary.mk
@@ -98,60 +98,7 @@
endif
ifneq ($(strip $(USE_OPTIMIZATIONS)),false)
-##########################################################################
-# Copyright (C) 2014-2015 The SaberMod Project
-#
-# 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.
-##########################################################################
-
-# arm thumb, not used on the host compiler.
-ifneq ($(strip $(LOCAL_IS_HOST_MODULE)),true)
- include $(BUILD_SYSTEM)/thumb_interwork.mk
-endif
-
-# O3
-ifeq ($(strip $(O3_OPTIMIZATIONS)),true)
- include $(BUILD_SYSTEM)/O3.mk
-endif
-
-# posix thread (pthread) support
-ifeq ($(strip $(ENABLE_PTHREAD)),true)
- include $(BUILD_SYSTEM)/pthread.mk
-endif
-
-# Do not use graphite on host modules or the clang compiler.
-ifneq ($(strip $(LOCAL_IS_HOST_MODULE)),true)
- ifneq ($(strip $(LOCAL_CLANG)),true)
-
- # If it gets this far enable graphite by default from here on out.
- include $(BUILD_SYSTEM)/graphite.mk
- endif
-endif
-
-# General flags for gcc 4.9 to allow compilation to complete.
-# Many of these are device specific and should be set in device make files.
-# See vendor or device trees for more info. Add more sections below and to vendor/name/configs/sm.mk if need be.
-
-# modules that need -Wno-error=maybe-uninitialized
-ifeq (1,$(words $(filter $(MAYBE_UNINITIALIZED),$(LOCAL_MODULE))))
- ifdef LOCAL_CFLAGS
- LOCAL_CFLAGS += -Wno-error=maybe-uninitialized
- else
- LOCAL_CFLAGS := -Wno-error=maybe-uninitialized
- endif
-endif
-
-#end SaberMod
+include $(BUILD_SYSTEM)/sabermod/sm.mk
endif
# The following LOCAL_ variables will be modified in this file.
diff --git a/core/clear_vars.mk b/core/clear_vars.mk
index bf81ebf..6abb0c9 100644
--- a/core/clear_vars.mk
+++ b/core/clear_vars.mk
@@ -254,3 +254,5 @@
# Leave the current makefile to make sure we don't break anything
# that expects to be able to find the name of the current makefile.
MAKEFILE_LIST := $(lastword $(MAKEFILE_LIST))
+
+include $(BUILD_SYSTEM)/sabermod/clear_vars.mk
diff --git a/core/combo/TARGET_linux-arm.mk b/core/combo/TARGET_linux-arm.mk
index d5d3be2..a2f19b4 100644
--- a/core/combo/TARGET_linux-arm.mk
+++ b/core/combo/TARGET_linux-arm.mk
@@ -38,10 +38,6 @@
ifdef TARGET_NDK_VERSION
$(combo_2nd_arch_prefix)TARGET_NDK_GCC_VERSION := $(TARGET_NDK_VERSION)
else
- $(warning ********************************************************************************)
- $(warning * TARGET_NDK_VERSION not defined.)
- $(warning * Defaulting to 4.8 .)
- $(warning ********************************************************************************)
$(combo_2nd_arch_prefix)TARGET_NDK_GCC_VERSION := 4.8
endif
@@ -75,10 +71,15 @@
$(combo_2nd_arch_prefix)TARGET_NO_UNDEFINED_LDFLAGS := -Wl,--no-undefined
-$(combo_2nd_arch_prefix)TARGET_arm_CFLAGS := -O2 \
- -fomit-frame-pointer \
- -fstrict-aliasing \
- -funswitch-loops
+$(combo_2nd_arch_prefix)TARGET_arm_CFLAGS := -fomit-frame-pointer
+
+ifneq ($(strip $(O3_OPTIMIZATIONS)),true)
+ $(combo_2nd_arch_prefix)TARGET_arm_CFLAGS += -O2 -g
+endif
+
+ifeq ($(strip $(ENABLE_STRICT_ALIASING)),true)
+ $(combo_2nd_arch_prefix)TARGET_arm_CFLAGS += -fstrict-aliasing
+endif
# Modules can choose to compile some source as thumb.
$(combo_2nd_arch_prefix)TARGET_thumb_CFLAGS := -mthumb \
@@ -86,7 +87,6 @@
-fomit-frame-pointer \
-fno-strict-aliasing
-
# Set FORCE_ARM_DEBUGGING to "true" in your buildspec.mk
# or in your environment to force a full arm build, even for
# files that are normally built as thumb; this can make
@@ -123,10 +123,8 @@
# "-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, $($(combo_2nd_arch_prefix)TARGET_GCC_VERSION)),)
$(combo_2nd_arch_prefix)TARGET_GLOBAL_CFLAGS += -fno-builtin-sin \
-fno-strict-volatile-bitfields
- endif
@@ -149,18 +147,18 @@
-Wl,--icf=safe \
$(arch_variant_ldflags)
-$(combo_2nd_arch_prefix)TARGET_GLOBAL_CFLAGS += -mthumb-interwork
-
$(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 \
- -Wstrict-aliasing=2 \
-fgcse-after-reload \
- -frerun-cse-after-loop \
-frename-registers
+ifneq ($(strip $(O3_OPTIMIZATIONS)),true)
+ TARGET_RELEASE_CFLAGS += -O2 -g
+endif
+
libc_root := bionic/libc
libm_root := bionic/libm
libstdc++_root := bionic/libstdc++
diff --git a/core/combo/arch/arm/armv7-a-neon.mk b/core/combo/arch/arm/armv7-a-neon.mk
index 4daedb3..ae61d05 100644
--- a/core/combo/arch/arm/armv7-a-neon.mk
+++ b/core/combo/arch/arm/armv7-a-neon.mk
@@ -11,12 +11,11 @@
krait \
denver
-# arm64 doesn't like cortex-a15
-ifeq (denver,$(TARGET_$(combo_2nd_arch_prefix)CPU_VARIANT))
-# Export cflags and cpu variant to the kernel.
- export kernel_arch_variant_cflags := -march=armv8-a
-endif
ifneq (,$(filter $(CORTEX_A15_TYPE),$(TARGET_$(combo_2nd_arch_prefix)CPU_VARIANT)))
+ # TODO: krait and denver is not a cortex-a15, we set the variant to cortex-a15 so that
+ # hardware divide operations are generated for arm binaries. This should be removed and a
+ # krait CPU variant added to GCC. For clang we specify -mcpu for krait in
+ # core/clang/arm.mk.
arch_variant_cflags := -mcpu=cortex-a15
else
ifeq ($(strip $(TARGET_$(combo_2nd_arch_prefix)CPU_VARIANT)),cortex-a8)
@@ -30,6 +29,12 @@
endif
endif
+# arm64 doesn't like cortex-a15 in the kernel
+ifeq (denver,$(TARGET_$(combo_2nd_arch_prefix)CPU_VARIANT))
+ # Export cflags and cpu variant to the kernel.
+ export kernel_arch_variant_cflags := -march=armv8-a
+endif
+
arch_variant_cflags += \
-mfloat-abi=softfp \
-mfpu=neon
@@ -46,4 +51,4 @@
-mfpu=neon-vfpv4
# Export cflags and cpu variant to the kernel.
export kernel_arch_variant_cflags := $(arch_variant_cflags)
-endif
\ No newline at end of file
+endif
diff --git a/core/dumpvar.mk b/core/dumpvar.mk
index 2758899..a873974 100644
--- a/core/dumpvar.mk
+++ b/core/dumpvar.mk
@@ -102,25 +102,13 @@
else
$(info KERNEL OPTIMIZATIONS=false)
endif
-ifeq ($(strip $(O3_OPTIMIZATIONS)),true)
-$(info O3=true)
-else
-$(info O3=false)
-endif
-ifeq ($(strip $(GRAPHITE)),true)
-$(info Graphite=true)
-else
-$(info Graphite=false)
-endif
-ifeq ($(strip $(ENABLE_PTHREAD)),true)
-$(info Pthread=true)
-else
-$(info Pthread=false)
-endif
+$(info OPTIMIZATION LEVELS=$(GCC_OPTIMIZATION_LEVELS))
$(info ============================================)
+ifeq ($(strip $(USE_OPTIMIZATIONS)),true)
ifneq ($(strip $(TARGET_ARCH)),$(strip $(TARGET_ARCH_2)))
$(error "TARGET_ARCH_2 set in sm.mk does not match your devices TARGET_ARCH")
endif
+endif
endif
diff --git a/core/graphite.mk b/core/graphite.mk
deleted file mode 100644
index 00f7d27..0000000
--- a/core/graphite.mk
+++ /dev/null
@@ -1,35 +0,0 @@
-# Copyright (C) 2014-2015 The SaberMod Project
-#
-# 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.
-#
-
-ifneq (1,$(words $(filter $(LOCAL_DISABLE_GRAPHITE),$(LOCAL_MODULE))))
- ifdef LOCAL_CONLYFLAGS
- LOCAL_CONLYFLAGS += $(GRAPHITE_FLAGS)
- else
- LOCAL_CONLYFLAGS := $(GRAPHITE_FLAGS)
- endif
-
- ifdef LOCAL_CPPFLAGS
- LOCAL_CPPFLAGS += $(GRAPHITE_FLAGS)
- else
- LOCAL_CPPFLAGS := $(GRAPHITE_FLAGS)
- endif
-
- ifndef LOCAL_LDFLAGS
- LOCAL_LDFLAGS := $(GRAPHITE_FLAGS)
- else
- LOCAL_LDFLAGS += $(GRAPHITE_FLAGS)
- endif
-endif
-#####
diff --git a/core/sabermod/O3.mk b/core/sabermod/O3.mk
new file mode 100644
index 0000000..0108976
--- /dev/null
+++ b/core/sabermod/O3.mk
@@ -0,0 +1,45 @@
+##########################################################################
+# Copyright (C) 2015 The SaberMod Project
+#
+# 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.
+##########################################################################
+
+# O3 optimzations
+# LOCAL_O3_OPTIMIZATIONS_MODE is for other flag configurations to use, not for device configurations.
+
+ifeq ($(strip $(O3_OPTIMIZATIONS)),true)
+ ifneq ($(strip $(LOCAL_ARM_MODE))-$(strip $(DISABLE_O3_OPTIMIZATIONS_THUMB)),thumb-true)
+ ifneq (1,$(words $(filter $(LOCAL_DISABLE_O3),$(LOCAL_MODULE))))
+ ifdef LOCAL_CFLAGS
+ LOCAL_CFLAGS += $(O3_FLAGS) -g
+ else
+ LOCAL_CFLAGS := $(O3_FLAGS) -g
+ endif
+ LOCAL_O3_OPTIMIZATIONS_MODE := on
+ else
+ ifneq (1,$(words $(filter $(NO_OPTIMIZATIONS),$(LOCAL_MODULE))))
+ LOCAL_O3_OPTIMIZATIONS_MODE := off
+ ifdef LOCAL_CFLAGS
+ LOCAL_CFLAGS += -O2 -g
+ else
+ LOCAL_CFLAGS := -O2 -g
+ endif
+ endif
+ endif
+ else
+ LOCAL_O3_OPTIMIZATIONS_MODE := off
+ endif
+else
+ LOCAL_O3_OPTIMIZATIONS_MODE := off
+endif
+
diff --git a/core/sabermod/arm.mk b/core/sabermod/arm.mk
new file mode 100644
index 0000000..41ff0c6
--- /dev/null
+++ b/core/sabermod/arm.mk
@@ -0,0 +1,121 @@
+# Copyright (C) 2015 The SaberMod Project
+#
+# 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.
+
+# SABERMOD_ARM_MODE for arm and arm64
+# ARM mode is known to generate better native 32bit instructions on arm targets,
+# instead of the default thumb mode which only generates 16bit code.
+# The code produced is slightly larger, but graphite should shirnk it up when -O3 is enabled.
+# This will disable the clang compiler when possible.
+# And allow more optimizations to take place throughout GCC on target ARM modules.
+# Clang is very limited with options, so kill it with fire.
+# The LOCAL_ARM_COMPILERS_WHITELIST and LOCAL_ARM64_COMPILERS_WHITELIST will disable SaberMod ARM Mode for specified modules.
+# All libLLVM's gets added to the WhiteList automatically.
+# Big thanks to Joe Maples for the arm mode to replace thumb mode, and Sebastian Jena for the unveiling the arm thumb mode.
+
+# ARM
+ifeq ($(strip $(TARGET_ARCH)),arm)
+ ifeq ($(strip $(ENABLE_SABERMOD_ARM_MODE)),true)
+ ifneq ($(strip $(LOCAL_IS_HOST_MODULE)),true)
+ ifneq (1,$(words $(filter libLLVM% $(LOCAL_ARM_COMPILERS_WHITELIST),$(LOCAL_MODULE))))
+ ifneq ($(filter arm thumb,$(LOCAL_ARM_MODE)),)
+ LOCAL_TMP_ARM_MODE := $(filter arm thumb,$(LOCAL_ARM_MODE))
+ LOCAL_ARM_MODE := $(LOCAL_TMP_ARM_MODE)
+ ifeq ($(strip $(LOCAL_ARM_MODE)),arm)
+ ifdef LOCAL_CFLAGS
+ LOCAL_CFLAGS += -marm
+ else
+ LOCAL_CFLAGS := -marm
+ endif
+ endif
+ ifeq ($(strip $(LOCAL_ARM_MODE)),thumb)
+ ifdef LOCAL_CFLAGS
+ LOCAL_CFLAGS += -mthumb-interwork
+ else
+ LOCAL_CFLAGS := -mthumb-interwork
+ endif
+ endif
+ else
+
+ # Set to arm mode
+ LOCAL_ARM_MODE := arm
+ ifdef LOCAL_CFLAGS
+ LOCAL_CFLAGS += -marm
+ else
+ LOCAL_CFLAGS := -marm
+ endif
+ endif
+ ifeq ($(strip $(LOCAL_CLANG)),true)
+ LOCAL_CLANG := false
+ endif
+ else
+
+ # Set the normal arm default back to thumb mode if LOCAL_ARM_MODE is not set.
+ # This is needed for the DISABLE_O3_OPTIMIZATIONS_THUMB function to work.
+ ifndef LOCAL_ARM_MODE
+ LOCAL_ARM_MODE := thumb
+ endif
+ ifeq ($(strip $(LOCAL_ARM_MODE)),arm)
+ ifdef LOCAL_CFLAGS
+ LOCAL_CFLAGS += -marm
+ else
+ LOCAL_CFLAGS := -marm
+ endif
+ endif
+ ifeq ($(strip $(LOCAL_ARM_MODE)),thumb)
+ ifdef LOCAL_CFLAGS
+ LOCAL_CFLAGS += -mthumb-interwork
+ else
+ LOCAL_CFLAGS := -mthumb-interwork
+ endif
+ endif
+ endif
+ endif
+ endif
+
+ # This is needed for the DISABLE_O3_OPTIMIZATIONS_THUMB function to work on arm devices.
+ ifneq ($(strip $(LOCAL_IS_HOST_MODULE)),true)
+ ifndef LOCAL_ARM_MODE
+
+ # Still set the default LOCAL_ARM_MODE to thumb in case ENABLE_SABERMOD_ARM_MODE is not set.
+ LOCAL_ARM_MODE := thumb
+ endif
+ ifdef LOCAL_CFLAGS
+ LOCAL_CFLAGS += -mthumb-interwork
+ else
+ LOCAL_CFLAGS := -mthumb-interwork
+ endif
+ endif
+endif
+
+# ARM64
+ifeq ($(strip $(TARGET_ARCH)),arm64)
+ ifeq ($(strip $(ENABLE_SABERMOD_ARM_MODE)),true)
+ ifneq ($(strip $(LOCAL_IS_HOST_MODULE)),true)
+ ifneq (1,$(words $(filter libLLVM% $(LOCAL_ARM64_COMPILERS_WHITELIST),$(LOCAL_MODULE))))
+ ifneq ($(filter arm arm64 thumb,$(LOCAL_ARM_MODE)),)
+ LOCAL_TMP_ARM_MODE := $(filter arm arm64 thumb,$(LOCAL_ARM_MODE))
+ LOCAL_ARM_MODE := $(LOCAL_TMP_ARM_MODE)
+ else
+
+ # Set to arm64 mode
+ LOCAL_ARM_MODE := arm64
+ endif
+ ifeq ($(strip $(LOCAL_CLANG)),true)
+ LOCAL_CLANG := false
+ endif
+ endif
+ endif
+ endif
+endif
+
diff --git a/core/pthread.mk b/core/sabermod/clear_vars.mk
similarity index 66%
rename from core/pthread.mk
rename to core/sabermod/clear_vars.mk
index a5bb897..1c29e9b 100644
--- a/core/pthread.mk
+++ b/core/sabermod/clear_vars.mk
@@ -11,12 +11,13 @@
# 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.
-#
-# Add pthread flags globally
-ifneq (1,$(words $(filter $(LOCAL_DISABLE_PTHREAD),$(LOCAL_MODULE))))
- ifdef LOCAL_CFLAGS
- LOCAL_CFLAGS += -pthread
- else
- LOCAL_CFLAGS := -pthread
- endif
-endif
+
+###########################################################
+## Clear out values of all variables used by rule templates.
+###########################################################
+
+$(shell unset LOCAL_O3_OPTIMIZATIONS_MODE)
+$(shell unset LOCAL_TMP_ARM_MODE)
+$(shell unset LOCAL_TMP_ARCH)
+
+
diff --git a/core/sabermod/extra.mk b/core/sabermod/extra.mk
new file mode 100644
index 0000000..fd0ae3b
--- /dev/null
+++ b/core/sabermod/extra.mk
@@ -0,0 +1,63 @@
+# Copyright (C) 2015 The SaberMod Project
+#
+# 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.
+
+# Extra SaberMod C flags for gcc and clang
+# Seperated by arch, clang and host
+
+ifneq ($(strip $(LOCAL_IS_HOST_MODULE)),true)
+ ifneq ($(strip $(LOCAL_CLANG)),true)
+ ifdef EXTRA_SABERMOD_GCC_VECTORIZE_CFLAGS
+ ifneq (1,$(words $(filter $(LOCAL_DISABLE_SABERMOD_GCC_VECTORIZE_CFLAGS),$(LOCAL_MODULE))))
+ ifdef LOCAL_CFLAGS
+ LOCAL_CFLAGS += $(EXTRA_SABERMOD_GCC_VECTORIZE_CFLAGS)
+ else
+ LOCAL_CFLAGS := $(EXTRA_SABERMOD_GCC_VECTORIZE_CFLAGS)
+ endif
+ endif
+ endif
+ ifneq ($(strip $(LOCAL_O3_OPTIMIZATIONS_MODE)),off)
+ ifdef LOCAL_CFLAGS
+ LOCAL_CFLAGS += $(EXTRA_SABERMOD_GCC_O3_CFLAGS)
+ else
+ LOCAL_CFLAGS := $(EXTRA_SABERMOD_GCC_O3_CFLAGS)
+ endif
+ endif
+ endif
+endif
+
+ifneq ($(strip $(LOCAL_IS_HOST_MODULE)),true)
+ ifeq ($(strip $(LOCAL_CLANG)),true)
+ ifneq (1,$(words $(filter $(LOCAL_DISABLE_SABERMOD_CLANG_VECTORIZE_CFLAGS),$(LOCAL_MODULE))))
+ ifdef LOCAL_CFLAGS
+ LOCAL_CFLAGS += $(LOCAL_SABERMOD_CLANG_VECTORIZE_CFLAGS)
+ else
+ LOCAL_CFLAGS := $(LOCAL_SABERMOD_CLANG_VECTORIZE_CFLAGS)
+ endif
+ endif
+ endif
+endif
+
+ifeq ($(strip $(LOCAL_IS_HOST_MODULE)),true)
+ ifneq ($(strip $(LOCAL_CLANG)),true)
+ ifdef LOCAL_CFLAGS
+ LOCAL_CFLAGS += $(EXTRA_SABERMOD_HOST_GCC_CFLAGS)
+ else
+ LOCAL_CFLAGS := $(EXTRA_SABERMOD_HOST_GCC_CFLAGS)
+ endif
+ ifeq ($(strip $(LOCAL_O3_OPTIMIZATIONS_MODE)),on)
+ LOCAL_CFLAGS += $(EXTRA_SABERMOD_HOST_GCC_O3_CFLAGS)
+ endif
+ endif
+endif
+
diff --git a/core/sabermod/sm.mk b/core/sabermod/sm.mk
new file mode 100644
index 0000000..cc2f02b
--- /dev/null
+++ b/core/sabermod/sm.mk
@@ -0,0 +1,75 @@
+##########################################################################
+# Copyright (C) 2014-2015 The SaberMod Project
+#
+# 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.
+##########################################################################
+
+include $(BUILD_SYSTEM)/sabermod/arm.mk
+
+include $(BUILD_SYSTEM)/sabermod/O3.mk
+
+# Extra sabermod variables
+include $(BUILD_SYSTEM)/sabermod/extra.mk
+
+# posix thread (pthread) support
+ifneq (1,$(words $(filter $(LOCAL_DISABLE_PTHREAD),$(LOCAL_MODULE))))
+ ifdef LOCAL_CFLAGS
+ LOCAL_CFLAGS += -pthread
+ else
+ LOCAL_CFLAGS := -pthread
+ endif
+endif
+
+# Do not use graphite on host modules or the clang compiler.
+# Also do not bother using on darwin.
+ifeq ($(HOST_OS),linux)
+ ifneq ($(strip $(LOCAL_IS_HOST_MODULE)),true)
+ ifneq ($(strip $(LOCAL_CLANG)),true)
+ ifeq ($(strip $(LOCAL_O3_OPTIMIZATIONS_MODE)),on)
+
+ # If it gets this far enable graphite by default from here on out.
+ ifneq (1,$(words $(filter $(LOCAL_DISABLE_GRAPHITE),$(LOCAL_MODULE))))
+ ifdef LOCAL_CFLAGS
+ LOCAL_CFLAGS += $(GRAPHITE_FLAGS)
+ else
+ LOCAL_CFLAGS := $(GRAPHITE_FLAGS)
+ endif
+ ifdef LOCAL_LDFLAGS
+ LOCAL_LDFLAGS += $(GRAPHITE_FLAGS)
+ else
+ LOCAL_LDFLAGS := $(GRAPHITE_FLAGS)
+ endif
+ endif
+ endif
+ endif
+ endif
+endif
+
+# General flags for gcc 4.9 to allow compilation to complete.
+# Many of these are device specific and should be set in device make files.
+# See vendor or device trees for more info. Add more sections below and to vendor/name/configs/sm.mk if need be.
+
+# modules that need -Wno-error=maybe-uninitialized
+ifdef MAYBE_UNINITIALIZED
+ ifeq (1,$(words $(filter $(MAYBE_UNINITIALIZED),$(LOCAL_MODULE))))
+ ifdef LOCAL_CFLAGS
+ LOCAL_CFLAGS += -Wno-error=maybe-uninitialized
+ else
+ LOCAL_CFLAGS := -Wno-error=maybe-uninitialized
+ endif
+ endif
+endif
+
+include $(BUILD_SYSTEM)/sabermod/strict.mk
+
+#end SaberMod
diff --git a/core/sabermod/strict.mk b/core/sabermod/strict.mk
new file mode 100644
index 0000000..8709371
--- /dev/null
+++ b/core/sabermod/strict.mk
@@ -0,0 +1,62 @@
+# Copyright (C) 2015 The SaberMod Project
+#
+# 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.
+
+# BUGFIX for AOSP
+# Turn all strict-aliasing warnings into errors.
+# strict-aliasing has a long well known history of breaking code when allowed to pass with warnings.
+# AOSP has blindly turned on strict-aliasing in various places locally throughout the source.
+# This causes warnings and should be dealt with, by turning strict-aliasing off to fix the warnings,
+# until AOSP gets around to fixing the warnings locally in the code.
+
+# Warnings and errors are turned on by default if strict-aliasing is set in LOCAL_CFLAGS. Also check for arm mode strict-aliasing.
+# GCC can handle a warning level of 3 and clang a level of 2.
+ifeq ($(strip $(ENABLE_STRICT_ALIASING)),true)
+ ifeq ($(strip $(LOCAL_ARM_MODE)),arm)
+ arm_objects_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)$(arm_objects_mode)_CFLAGS)
+ ifneq ($(strip $(LOCAL_CLANG)),true)
+ ifneq ($(filter -fstrict-aliasing,$(arm_objects_cflags)),)
+ ifdef LOCAL_CFLAGS
+ LOCAL_CFLAGS += -Wstrict-aliasing=3 -Werror=strict-aliasing
+ else
+ LOCAL_CFLAGS := -Wstrict-aliasing=3 -Werror=strict-aliasing
+ endif
+ endif
+ else
+ arm_objects_cflags := $(call $(LOCAL_2ND_ARCH_VAR_PREFIX)convert-to-$(my_host)clang-flags,$(arm_objects_cflags))
+ ifneq ($(filter -fstrict-aliasing,$(arm_objects_cflags)),)
+ ifdef LOCAL_CFLAGS
+ LOCAL_CFLAGS += -Wstrict-aliasing=2 -Werror=strict-aliasing
+ else
+ LOCAL_CFLAGS := -Wstrict-aliasing=2 -Werror=strict-aliasing
+ endif
+ endif
+ endif
+ endif
+endif
+
+
+ifneq ($(strip $(ENABLE_STRICT_ALIASING)),true)
+ LOCAL_CFLAGS += -fno-strict-aliasing
+else
+ ifneq ($(strip $(LOCAL_CLANG)),true)
+ LOCAL_CFLAGS += -Wstrict-aliasing=3 -Werror=strict-aliasing
+ else
+ LOCAL_CFLAGS += -Wstrict-aliasing=2 -Werror=strict-aliasing
+ endif
+ ifeq (1,$(words $(filter $(LOCAL_DISABLE_STRICT_ALIASING),$(LOCAL_MODULE))))
+ LOCAL_CFLAGS += -fno-strict-aliasing
+ endif
+endif
+
+
diff --git a/core/thumb_interwork.mk b/core/thumb_interwork.mk
deleted file mode 100644
index 1008033..0000000
--- a/core/thumb_interwork.mk
+++ /dev/null
@@ -1,41 +0,0 @@
-# Copyright (C) 2014-2015 The SaberMod Project
-#
-# 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.
-#
-
-# Copyright (C) 2014-2015 The SaberMod Project
-#
-# 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.
-#
-
-ifeq ($(strip (TARGET_ARCH)),arm)
- ifneq (1,$(words $(filter $(LOCAL_DISABLE_THUMB_INTERWORK),$(LOCAL_MODULE))))
- ifdef LOCAL_CFLAGS
- LOCAL_CFLAGS += \
- -mthumb-interwork
- else
- LOCAL_CFLAGS := \
- -mthumb-interwork
- endif
- endif
-endif