move cflags setting to arch/<arch>/Makefile

Move Zephyr specific CFLAGS that depend on config options to
the Makefile where they can better be managed among other cflag
options.

Change-Id: Ia79a2f2def4f51857f6d661aa78e9fb7eb7a5e22
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
This commit is contained in:
Anas Nashif 2015-10-11 07:22:22 -04:00
commit 1cc1ac4b2f
4 changed files with 19 additions and 11 deletions

View file

@ -605,10 +605,6 @@ KBUILD_CFLAGS += $(call cc-option,-fno-reorder-blocks,) \
$(call cc-option,-fno-partial-inlining)
endif
STACK_CANARIES_FLAG_y = $(call cc-option,-fstack-protector-all,)
STACK_CANARIES_FLAG_ = $(call cc-option,-fno-stack-protector,)
STACK_CANARIES_FLAG = $(STACK_CANARIES_FLAG_$(CONFIG_STACK_CANARIES))
# Handle stack protector mode.
#
# Since kbuild can potentially perform two passes (first with the old
@ -653,12 +649,6 @@ KBUILD_CFLAGS += $(subst $(DQUOTE),,$(CONFIG_COMPILER_OPT))
export LDFLAG_LINKERCMD OUTPUT_FORMAT OUTPUT_ARCH
ARCHFLAGS = $($(SRCARCH)_FLAGS)
KBUILD_CFLAGS += $(SSE_FP_MATH_FLAG) \
$(STACK_CANARIES_FLAG) \
$(ARCHFLAGS)
ifdef CONFIG_DEBUG_INFO_REDUCED
KBUILD_CFLAGS += $(call cc-option, -femit-struct-debug-baseonly) \
$(call cc-option,-fno-var-tracking)
@ -667,7 +657,6 @@ endif
include arch/$(SRCARCH)/Makefile
KBUILD_CFLAGS += $(CFLAGS)
KBUILD_AFLAGS += $(ARCHFLAGS)
KBUILD_AFLAGS += $(CFLAGS)
ifdef CONFIG_FUNCTION_TRACER

View file

@ -3,5 +3,11 @@ arch-$(CONFIG_LTO) = $(call cc-option,-flto,)
arch-$(CONFIG_CPU_ARCEM4) = $(call cc-option,-mARCv2EM) \
$(call cc-option,-mav2em,) $(call cc-option,-mno-sdata)
ifeq ($(CONFIG_STACK_CANARIES),y)
cflags-y += $(call cc-option,-fstack-protector-all,)
else
cflags-y += $(call cc-option,-fno-stack-protector,)
endif
KBUILD_CFLAGS += $(arch-y) $(cflags-y)
KBUILD_AFLAGS += $(arch-y)

View file

@ -9,6 +9,12 @@ arch-$(CONFIG_CPU_CORTEX_M4) += $(call cc-option,-mthumb -mcpu=cortex-m4) \
cflags-$(CONFIG_LTO) = $(call cc-option,-flto,)
ifeq ($(CONFIG_STACK_CANARIES),y)
cflags-y += $(call cc-option,-fstack-protector-all,)
else
cflags-y += $(call cc-option,-fno-stack-protector,)
endif
KBUILD_CFLAGS += $(cflags-y) $(arch-y)
KBUILD_AFLAGS += $(arch-y)

View file

@ -19,6 +19,13 @@ arch-$(CONFIG_CPU_ATOM) += $(call cc-option,-march=atom) \
$(call cc-option,-mtune=atom,$(call cc-option,-mtune=generic))
arch-$(CONFIG_CPU_MINUTEIA) += $(call cc-option,-march=pentium)
ifeq ($(CONFIG_STACK_CANARIES),y)
cflags-y += $(call cc-option,-fstack-protector-all,)
else
cflags-y += $(call cc-option,-fno-stack-protector,)
endif
KBUILD_CFLAGS += $(cflags-y) $(arch-y)
KBUILD_AFLAGS += $(arch-y)