build: use -O2 instead of -Os for ARC with SDK 0.9

This is intended as a temporary fix for ZEP-1882.
Investigation for this bug has shown that the current SDK 0.9 compiler
for ARC generates incorrect code under -Os optimization level.

Kuo-Lang Tseng found out that SDK 0.8.2 does not have this issue, and
that lowering optimization level to -O2 fixes the issue with SDK 0.9.
Juro Bystricky is working on an updated SDK with ARC GCC 6.3.0, but
there are still problems with it, so he also suggested to use -O2 in
the meantime.

Instead of blindly setting -O2 for all toolchains and architectures,
let Makefile.toolchain.zephyr make the decision for ARC and 0.9 only.
Tested with hello_world, CONFIG_ADC=y and BOARD=arduino_101_sss.

Jira: ZEP-1882
Change-Id: Ifde2e3950c9d93eed8982149805acfda9d13a94f
Signed-off-by: Patrice Buriez <patrice.buriez@intel.com>
This commit is contained in:
Patrice Buriez 2017-04-09 02:44:48 +02:00 committed by Anas Nashif
commit 49a8de7ae3
2 changed files with 15 additions and 2 deletions

View file

@ -599,9 +599,9 @@ ARCH = $(subst $(DQUOTE),,$(CONFIG_ARCH))
export ARCH
ifeq ($(CONFIG_DEBUG),y)
KBUILD_CFLAGS += -Og
KBUILD_CFLAGS_OPTIMIZE := -Og
else
KBUILD_CFLAGS += -Os
KBUILD_CFLAGS_OPTIMIZE := -Os
endif
ifdef ZEPHYR_GCC_VARIANT
@ -613,6 +613,9 @@ $(if $(CROSS_COMPILE),, \
endif
endif
# Let Makefile.toolchain adjust optimization level
KBUILD_CFLAGS += $(KBUILD_CFLAGS_OPTIMIZE)
-include $(srctree)/ext/Makefile
-include $(srctree)/lib/Makefile

View file

@ -36,6 +36,16 @@ ifeq ($(SDK_VERSION),0.8.2)
TOOLCHAIN_ARCH := i686
endif
# TODO remove once we have a replacement for 0.9 that fixes ZEP-1882
# See https://jira.zephyrproject.org/browse/ZEP-1882
ifeq ($(SDK_VERSION),0.9)
ifeq ($(ARCH),arc)
ifneq ($(CONFIG_DEBUG),y)
KBUILD_CFLAGS_OPTIMIZE := -O2
endif
endif
endif
ifeq ($(HOST_OS),MINGW)
TOOLCHAIN_HOME = ${ZEPHYR_SDK_INSTALL_DIR}/sysroots/i686-pokysdk-mingw32
else