1 # SPDX-License-Identifier: BSD-3-Clause
2 # Copyright(c) 2010-2014 Intel Corporation
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)
14 KERNELCC = $(CROSS)gcc
16 # for now, we don't use as but nasm.
21 OBJCOPY = $(CROSS)objcopy
22 OBJDUMP = $(CROSS)objdump
24 READELF = $(CROSS)readelf
27 ifeq ("$(origin CC)", "command line")
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")
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
52 ifeq ($(RTE_DEVEL_BUILD),y)
53 WERROR_FLAGS += -Werror
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
63 include $(RTE_SDK)/mk/toolchain/$(RTE_TOOLCHAIN)/rte.toolchain-compat.mk
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
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
74 HOST_WERROR_FLAGS := $(WERROR_FLAGS)
76 ifeq ($(shell test $(HOST_GCC_VERSION) -gt 70 && echo 1), 1)
77 # Tell GCC only to error for switch fallthroughs without a suitable comment
78 HOST_WERROR_FLAGS += -Wimplicit-fallthrough=2
79 # Ignore errors for snprintf truncation
80 HOST_WERROR_FLAGS += -Wno-format-truncation
83 ifeq ($(shell test $(GCC_VERSION) -gt 70 && echo 1), 1)
84 # Tell GCC only to error for switch fallthroughs without a suitable comment
85 WERROR_FLAGS += -Wimplicit-fallthrough=2
86 # Ignore errors for snprintf truncation
87 WERROR_FLAGS += -Wno-format-truncation
90 # disable packed member unalign warnings
91 WERROR_FLAGS += -Wno-address-of-packed-member
93 export CC AS AR LD OBJCOPY OBJDUMP STRIP READELF
94 export TOOLCHAIN_CFLAGS TOOLCHAIN_LDFLAGS TOOLCHAIN_ASFLAGS