summaryrefslogtreecommitdiff
path: root/examples/build_system/make/toolchain/gcc_common.mk
blob: 42fd01183f69cf80afdc2bb019be3435414b53a8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# ---------------------------------------
# Compiler Flags
# ---------------------------------------
CFLAGS += \
  -MD \
  -ggdb \
  -fdata-sections \
  -ffunction-sections \
  -fno-strict-aliasing \
  -Wall \
  -Wextra \
  -Werror \
  -Wfatal-errors \
  -Wdouble-promotion \
  -Wstrict-prototypes \
  -Wstrict-overflow \
  -Werror-implicit-function-declaration \
  -Wfloat-equal \
  -Wundef \
  -Wshadow \
  -Wwrite-strings \
  -Wsign-compare \
  -Wmissing-format-attribute \
  -Wunreachable-code \
  -Wcast-align \
  -Wcast-function-type \
  -Wcast-qual \
  -Wnull-dereference \
  -Wuninitialized \
  -Wunused \
  -Wreturn-type \
  -Wredundant-decls \

CFLAGS_CLANG += \
  -Wno-error=unknown-warning-option

#  -Wmissing-prototypes \
# conversion is too strict for most mcu driver, may be disable sign/int/arith-conversion
#  -Wconversion

# Size Optimization as default
CFLAGS_OPTIMIZED ?= -Os

# Debugging/Optimization
ifeq ($(DEBUG), 1)
  CFLAGS += -O0
  NO_LTO = 1
else
  CFLAGS += $(CFLAGS_OPTIMIZED)
endif

# ---------------------------------------
# Linker Flags
# ---------------------------------------
LDFLAGS += \
  -Wl,[email protected] \
  -Wl,--cref \
  -Wl,-gc-sections \

# renesas rx does not support --print-memory-usage flags
ifneq ($(FAMILY),rx)
LDFLAGS += -Wl,--print-memory-usage
endif

ifeq ($(TOOLCHAIN),gcc)
CC_VERSION := $(shell $(CC) -dumpversion)
CC_VERSION_MAJOR = $(firstword $(subst ., ,$(CC_VERSION)))

# from version 12
ifeq ($(strip $(if $(CMDEXE),\
               $(shell if $(CC_VERSION_MAJOR) geq 12 (echo 1) else (echo 0)),\
               $(shell expr $(CC_VERSION_MAJOR) \>= 12))), 1)
LDFLAGS += -Wl,--no-warn-rwx-segment
endif
endif