summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--core/combo/arch/arm/armv7-a-neon.mk24
-rw-r--r--core/combo/arch/arm/armv7-a.mk47
-rw-r--r--core/config.mk3
-rw-r--r--core/linaro_compilerchecks.mk43
4 files changed, 89 insertions, 28 deletions
diff --git a/core/combo/arch/arm/armv7-a-neon.mk b/core/combo/arch/arm/armv7-a-neon.mk
index 32273ff..b5eb3d0 100644
--- a/core/combo/arch/arm/armv7-a-neon.mk
+++ b/core/combo/arch/arm/armv7-a-neon.mk
@@ -1,25 +1,5 @@
# Configuration for Linux on ARM.
# Generating binaries for the ARMv7-a architecture and higher with NEON
#
-ARCH_ARM_HAVE_THUMB_SUPPORT := true
-ARCH_ARM_HAVE_FAST_INTERWORKING := true
-ARCH_ARM_HAVE_64BIT_DATA := true
-ARCH_ARM_HAVE_HALFWORD_MULTIPLY := true
-ARCH_ARM_HAVE_CLZ := true
-ARCH_ARM_HAVE_FFS := true
-ARCH_ARM_HAVE_ARMV7A := true
-ARCH_ARM_HAVE_TLS_REGISTER := true
-ARCH_ARM_HAVE_VFP := true
-ARCH_ARM_HAVE_VFP_D32 := true
-ARCH_ARM_HAVE_NEON := true
-
-# Note: Hard coding the 'tune' value here is probably not ideal,
-# and a better solution should be found in the future.
-#
-arch_variant_cflags := \
- -march=armv7-a \
- -mfloat-abi=softfp \
- -mfpu=neon
-
-arch_variant_ldflags := \
- -Wl,--fix-cortex-a8
+TARGET_ARCH_VARIANT_FPU := neon
+include $(BUILD_COMBOS)/arch/$(TARGET_ARCH)/armv7-a.mk
diff --git a/core/combo/arch/arm/armv7-a.mk b/core/combo/arch/arm/armv7-a.mk
index 220f7ec..ca6f2bb 100644
--- a/core/combo/arch/arm/armv7-a.mk
+++ b/core/combo/arch/arm/armv7-a.mk
@@ -9,15 +9,50 @@ ARCH_ARM_HAVE_CLZ := true
ARCH_ARM_HAVE_FFS := true
ARCH_ARM_HAVE_ARMV7A := true
ARCH_ARM_HAVE_TLS_REGISTER := true
+ifneq ($(strip $(TARGET_ARCH_VARIANT_FPU)),)
ARCH_ARM_HAVE_VFP := true
+else
+ARCH_ARM_HAVE_VFP := false
+endif
+ifeq ($(TARGET_ARCH_VARIANT_FPU), neon)
+ARCH_ARM_HAVE_VFP_D32 := true
+ARCH_ARM_HAVE_NEON := true
+endif
-# Note: Hard coding the 'tune' value here is probably not ideal,
-# and a better solution should be found in the future.
-#
+mcpu-arg = $(shell sed 's/^-mcpu=//' <<< "$(call cc-option,-mcpu=$(1),-mcpu=$(2))")
+
+ifeq ($(TARGET_ARCH_VARIANT_CPU), cortex-a15)
+TARGET_ARCH_VARIANT_CPU := $(call mcpu-arg,cortex-a15,cortex-a9)
+endif
+ifeq ($(TARGET_ARCH_VARIANT_CPU), cortex-a9)
+TARGET_ARCH_VARIANT_CPU := $(call mcpu-arg,cortex-a9,cortex-a8)
+endif
+ifeq ($(TARGET_ARCH_VARIANT_CPU), cortex-a8)
+TARGET_ARCH_VARIANT_CPU := $(call mcpu-arg,cortex-a8,)
+endif
+
+ifneq ($(strip $(TARGET_ARCH_VARIANT_CPU)),)
arch_variant_cflags := \
- -march=armv7-a \
- -mfloat-abi=softfp \
- -mfpu=vfpv3-d16
+ -mcpu=$(strip $(TARGET_ARCH_VARIANT_CPU))
+else
+# fall back on generic tunning if cpu is not specified
+arch_variant_cflags := \
+ -march=armv7-a
+endif
+
+ifneq ($(strip $(TARGET_ARCH_VARIANT_FPU)),)
+arch_variant_cflags += \
+ -mfloat-abi=softfp \
+ -mfpu=$(strip $(TARGET_ARCH_VARIANT_FPU))
+else
+# fall back on soft tunning if fpu is not specified
+arch_variant_cflags += \
+ -mfloat-abi=soft
+endif
+ifeq ($(strip $(TARGET_ARCH_VARIANT_CPU)),cortex-a8)
arch_variant_ldflags := \
-Wl,--fix-cortex-a8
+else
+arch_variant_ldflags :=
+endif
diff --git a/core/config.mk b/core/config.mk
index e383c29..4090759 100644
--- a/core/config.mk
+++ b/core/config.mk
@@ -136,6 +136,9 @@ endif
# are specific to the user's build configuration.
include $(BUILD_SYSTEM)/envsetup.mk
+# Useful macros
+include $(BUILD_SYSTEM)/linaro_compilerchecks.mk
+
# Boards may be defined under $(SRC_TARGET_DIR)/board/$(TARGET_DEVICE)
# or under vendor/*/$(TARGET_DEVICE). Search in both places, but
# make sure only one exists.
diff --git a/core/linaro_compilerchecks.mk b/core/linaro_compilerchecks.mk
new file mode 100644
index 0000000..d172703
--- /dev/null
+++ b/core/linaro_compilerchecks.mk
@@ -0,0 +1,43 @@
+# The try-run, cc-version, cc-ifversion and cc-option macros are inspired
+# by the Linux kernel build system's versions of the macros with the same
+# name.
+#
+# The implementations here are rewritten to avoid license clashes, and
+# they're a lot simpler than their kernel counterparts because, at least
+# for now, we don't need to support all the compilers the kernel supports,
+# and we don't need to be aware of all the details the kernel checks for.
+#
+# Usage examples:
+# echo "GCC version $(cc-version)" [e.g. 46 for 4.6]
+# echo $(call cc-ifversion, -lt, 46, GCC older than 4.6)
+# # Use -mcpu=cortex-a9 if supported, otherwise -mcpu=cortex-a8
+# echo $(call cc-option, -mcpu=cortex-a9, -mcpu=cortex-a8)
+# # Use -mcpu=cortex-a9 if supported, otherwise -mcpu=cortex-a8
+# # if supported, otherwise nothing
+# echo $(call cc-option, -mcpu=cortex-a9, $(call cc-option, -mcpu=cortex-a8))
+#
+
+# We have to do our own version of setting TARGET_CC because we can be
+# included before TARGET_CC is set, but we may want to use cc-option and
+# friends in the same file that sets TARGET_CC...
+
+ifeq ($(strip $(TARGET_TOOLS_PREFIX)),)
+LINARO_COMPILERCHECK_CC := prebuilts/gcc/$(HOST_PREBUILT_TAG)/arm/arm-linux-androideabi-4.6/bin/arm-linux-androideabi-gcc$(HOST_EXECUTABLE_SUFFIX)
+else
+LINARO_COMPILERCHECK_CC := $(TARGET_TOOLS_PREFIX)gcc$(HOST_EXECUTABLE_SUFFIX)
+endif
+
+try-run = $(shell set -e; \
+ if ($(1)) >/dev/null 2>&1; then \
+ echo "$(2)"; \
+ else \
+ echo "$(3)"; \
+ fi)
+
+cc-version = $(shell echo '__GNUC__ __GNUC_MINOR__' \
+ |$(LINARO_COMPILERCHECK_CC) -E -xc - |tail -n1 |sed -e 's, ,,g')
+
+cc-ifversion = $(shell [ $(call cc-version) $(1) $(2) ] && echo $(3))
+
+cc-option = $(call try-run, echo -e "$(1)" \
+ |$(LINARO_COMPILERCHECK_CC) $(1) -c -xc /dev/null -o /dev/null,$(1),$(2))