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 ifeq ($(CONFIG_RTE_ENABLE_LTO),y)
66 # 'fat-lto' is used since pmdinfogen needs to have 'this_pmd_nameX'
67 # exported in symbol table and without this option only internal
68 # representation is present.
69 TOOLCHAIN_CFLAGS += -flto -ffat-lto-objects
70 TOOLCHAIN_LDFLAGS += -flto
71 # workaround for GCC bug 81440
72 ifeq ($(shell test $(GCC_VERSION) -lt 80 && echo 1), 1)
73 WERROR_FLAGS += -Wno-lto-type-mismatch
77 # disable warning for non-initialised fields
78 WERROR_FLAGS += -Wno-missing-field-initializers
79 # workaround GCC bug with warning "may be used uninitialized"
80 ifeq ($(shell test $(GCC_VERSION) -lt 47 && echo 1), 1)
81 WERROR_FLAGS += -Wno-uninitialized
84 HOST_WERROR_FLAGS := $(WERROR_FLAGS)
86 ifeq ($(shell test $(HOST_GCC_VERSION) -gt 70 && echo 1), 1)
87 # Tell GCC only to error for switch fallthroughs without a suitable comment
88 HOST_WERROR_FLAGS += -Wimplicit-fallthrough=2
89 # Ignore errors for snprintf truncation
90 HOST_WERROR_FLAGS += -Wno-format-truncation
93 ifeq ($(shell test $(GCC_VERSION) -gt 70 && echo 1), 1)
94 # Tell GCC only to error for switch fallthroughs without a suitable comment
95 WERROR_FLAGS += -Wimplicit-fallthrough=2
96 # Ignore errors for snprintf truncation
97 WERROR_FLAGS += -Wno-format-truncation
100 # disable packed member unalign warnings
101 WERROR_FLAGS += -Wno-address-of-packed-member
103 export CC AS AR LD OBJCOPY OBJDUMP STRIP READELF
104 export TOOLCHAIN_CFLAGS TOOLCHAIN_LDFLAGS TOOLCHAIN_ASFLAGS