diff --git a/Makefile b/Makefile index 98081009cd0..954bd7d4287 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/scripts/Makefile.toolchain.zephyr b/scripts/Makefile.toolchain.zephyr index faea0b1a5d2..8aa81ddae25 100644 --- a/scripts/Makefile.toolchain.zephyr +++ b/scripts/Makefile.toolchain.zephyr @@ -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