7e4531bab355a0660dd8fcccb47019ed8a300219
[dpdk.git] / mk / toolchain / gcc / rte.vars.mk
1 # SPDX-License-Identifier: BSD-3-Clause
2 # Copyright(c) 2010-2014 Intel Corporation
3
4 #
5 # toolchain:
6 #
7 #   - define CC, LD, AR, AS, ... (overridden by cmdline value)
8 #   - define TOOLCHAIN_CFLAGS variable (overridden by cmdline value)
9 #   - define TOOLCHAIN_LDFLAGS variable (overridden by cmdline value)
10 #   - define TOOLCHAIN_ASFLAGS variable (overridden by cmdline value)
11 #
12
13 CC        = $(CROSS)gcc
14 KERNELCC  = $(CROSS)gcc
15 CPP       = $(CROSS)cpp
16 # for now, we don't use as but nasm.
17 # AS      = $(CROSS)as
18 AS        = nasm
19 AR        = $(CROSS)ar
20 LD        = $(CROSS)ld
21 OBJCOPY   = $(CROSS)objcopy
22 OBJDUMP   = $(CROSS)objdump
23 STRIP     = $(CROSS)strip
24 READELF   = $(CROSS)readelf
25 GCOV      = $(CROSS)gcov
26
27 ifeq ("$(origin CC)", "command line")
28 HOSTCC    = $(CC)
29 else
30 HOSTCC    = gcc
31 endif
32 HOSTAS    = as
33
34 TOOLCHAIN_ASFLAGS =
35 TOOLCHAIN_CFLAGS =
36 TOOLCHAIN_LDFLAGS =
37
38 ifeq ($(CONFIG_RTE_LIBRTE_GCOV),y)
39 TOOLCHAIN_CFLAGS += --coverage
40 TOOLCHAIN_LDFLAGS += --coverage
41 ifeq (,$(findstring -O0,$(EXTRA_CFLAGS)))
42   $(warning "EXTRA_CFLAGS doesn't contains -O0, coverage will be inaccurate with optimizations enabled")
43 endif
44 endif
45
46 WERROR_FLAGS := -W -Wall -Wstrict-prototypes -Wmissing-prototypes
47 WERROR_FLAGS += -Wmissing-declarations -Wold-style-definition -Wpointer-arith
48 WERROR_FLAGS += -Wcast-align -Wnested-externs -Wcast-qual
49 WERROR_FLAGS += -Wformat-nonliteral -Wformat-security
50 WERROR_FLAGS += -Wundef -Wwrite-strings -Wdeprecated
51
52 ifeq ($(RTE_DEVEL_BUILD),y)
53 WERROR_FLAGS += -Werror
54 endif
55
56 # There are many issues reported for strict alignment architectures
57 # which are not necessarily fatal. Report as warnings.
58 ifeq ($(CONFIG_RTE_ARCH_STRICT_ALIGN),y)
59 WERROR_FLAGS += -Wno-error=cast-align
60 endif
61
62 # process cpu flags
63 include $(RTE_SDK)/mk/toolchain/$(RTE_TOOLCHAIN)/rte.toolchain-compat.mk
64
65 # workaround GCC bug with warning "missing initializer" for "= {0}"
66 ifeq ($(shell test $(GCC_VERSION) -lt 47 && echo 1), 1)
67 WERROR_FLAGS += -Wno-missing-field-initializers
68 endif
69 # workaround GCC bug with warning "may be used uninitialized"
70 ifeq ($(shell test $(GCC_VERSION) -lt 47 && echo 1), 1)
71 WERROR_FLAGS += -Wno-uninitialized
72 endif
73
74 ifeq ($(shell test $(GCC_VERSION) -gt 70 && echo 1), 1)
75 # Tell GCC only to error for switch fallthroughs without a suitable comment
76 WERROR_FLAGS += -Wimplicit-fallthrough=2
77 # Ignore errors for snprintf truncation
78 WERROR_FLAGS += -Wno-format-truncation
79 endif
80
81 export CC AS AR LD OBJCOPY OBJDUMP STRIP READELF
82 export TOOLCHAIN_CFLAGS TOOLCHAIN_LDFLAGS TOOLCHAIN_ASFLAGS