1# List the warnings that are not supported for C++ compilations 2list(APPEND CXX_EXCLUDED_OPTIONS 3 -Werror=implicit-int 4 -Wold-style-definition 5 ) 6 7################################################### 8# Setting compiler properties for MWDT compilers. # 9################################################### 10 11##################################################### 12# This section covers flags related to optimization # 13##################################################### 14set_compiler_property(PROPERTY no_optimization -O0) 15set_compiler_property(PROPERTY optimization_debug -O0) 16set_compiler_property(PROPERTY optimization_speed -O2) 17set_compiler_property(PROPERTY optimization_size -Os) 18 19####################################################### 20# This section covers flags related to warning levels # 21####################################################### 22 23# options for warnings 24# base options 25set_compiler_property(PROPERTY warning_base 26 -Wformat 27 -Wformat-security 28 -Wno-format-zero-length 29 -Wno-unaligned-pointer-conversion 30 -Wno-incompatible-pointer-types-discards-qualifiers 31 -Wno-typedef-redefinition 32) 33 34# C implicit promotion rules will want to make floats into doubles very easily 35check_set_compiler_property(APPEND PROPERTY warning_base -Wdouble-promotion) 36 37check_set_compiler_property(APPEND PROPERTY warning_base -Wno-pointer-sign) 38 39# Prohibit void pointer arithmetic. Illegal in C99 40check_set_compiler_property(APPEND PROPERTY warning_base -Wpointer-arith) 41 42# level 1 warning options 43set_compiler_property(PROPERTY warning_dw_1 44 -Wextra 45 -Wunused 46 -Wno-unused-parameter 47 -Wmissing-declarations 48 -Wmissing-format-attribute 49) 50 51check_set_compiler_property(APPEND PROPERTY warning_dw_1 52 -Wold-style-definition 53 -Wmissing-prototypes 54 -Wmissing-include-dirs 55 -Wunused-but-set-variable 56 -Wno-missing-field-initializers 57) 58 59# level 2 warning options 60set_compiler_property(PROPERTY warning_dw_2 61 -Waggregate-return 62 -Wcast-align 63 -Wdisabled-optimization 64 -Wnested-externs 65 -Wshadow 66) 67 68check_set_compiler_property(APPEND PROPERTY warning_dw_2 69 -Wlogical-op 70 -Wmissing-field-initializers 71) 72 73# level 3 warning options 74set_compiler_property(PROPERTY warning_dw_3 75 -Wbad-function-cast 76 -Wcast-qual 77 -Wconversion 78 -Wpacked 79 -Wpadded 80 -Wpointer-arith 81 -Wredundant-decls 82 -Wswitch-default 83) 84 85check_set_compiler_property(APPEND PROPERTY warning_dw_3 86 -Wpacked-bitfield-compat 87 -Wvla 88) 89 90# extended warning options 91check_set_compiler_property(PROPERTY warning_extended 92 -Wno-sometimes-uninitialized 93 -Wno-shift-overflow 94 -Wno-missing-braces 95 -Wno-self-assign 96 -Wno-address-of-packed-member 97 -Wno-unused-function 98 -Wno-initializer-overrides 99 -Wno-section 100 -Wno-unknown-warning-option 101 -Wno-unused-variable 102 -Wno-format-invalid-specifier 103 -Wno-gnu 104 # comparison of unsigned expression < 0 is always false 105 -Wno-tautological-compare 106) 107 108check_set_compiler_property(PROPERTY warning_error_implicit_int -Werror=implicit-int) 109 110set_compiler_property(PROPERTY warning_error_misra_sane -Werror=vla) 111 112########################################################################### 113# This section covers flags related to C or C++ standards / standard libs # 114########################################################################### 115 116set_compiler_property(PROPERTY cstd -std=) 117 118if (NOT CONFIG_ARCMWDT_LIBC) 119 set_compiler_property(PROPERTY nostdinc -Hno_default_include -Hnoarcexlib -U__STDC_LIB_EXT1__) 120 set_compiler_property(APPEND PROPERTY nostdinc_include ${NOSTDINC}) 121endif() 122 123# C++ std options 124set_property(TARGET compiler-cpp PROPERTY dialect_cpp98 "-std=c++98") 125set_property(TARGET compiler-cpp PROPERTY dialect_cpp11 "-std=c++11") 126set_property(TARGET compiler-cpp PROPERTY dialect_cpp14 "-std=c++14") 127set_property(TARGET compiler-cpp PROPERTY dialect_cpp17 "-std=c++17") 128 129#no support of C++2a, C++20, C++2b 130set_property(TARGET compiler-cpp PROPERTY dialect_cpp2a "") 131set_property(TARGET compiler-cpp PROPERTY dialect_cpp20 "") 132set_property(TARGET compiler-cpp PROPERTY dialect_cpp2b "") 133 134# Flag for disabling strict aliasing rule in C and C++ 135set_compiler_property(PROPERTY no_strict_aliasing -fno-strict-aliasing) 136 137# Flags for set extra warnigs (ARCMWDT asm can't recognize --fatal-warnings. Skip it) 138set_property(TARGET compiler PROPERTY warnings_as_errors -Werror) 139set_property(TARGET asm PROPERTY warnings_as_errors -Werror) 140 141# Disable exceptions flag in C++ 142set_property(TARGET compiler-cpp PROPERTY no_exceptions "-fno-exceptions") 143 144# Disable rtti in C++ 145set_property(TARGET compiler-cpp PROPERTY no_rtti "-fno-rtti") 146 147################################################### 148# This section covers all remaining C / C++ flags # 149################################################### 150 151# mwdt flag for a freestanding application 152# do not link in supplied run-time startup files 153set_compiler_property(PROPERTY freestanding -Hnocrt) 154 155# Flag to keep DWARF information (enable debug info) 156set_compiler_property(PROPERTY debug -g) 157 158# compile common globals like normal definitions 159set_compiler_property(PROPERTY no_common -fno-common) 160 161# mwdt's coverage mechanism is different with gnu 162# at present, zephyr only support gnu coverage 163set_compiler_property(PROPERTY coverage "") 164 165# mwdt compiler flags for imacros. The specific header must be appended by user. 166set_compiler_property(PROPERTY imacros -imacros) 167 168# Security canaries. 169#no support of -mstack-protector-guard=global" 170set_compiler_property(PROPERTY security_canaries -fstack-protector) 171set_compiler_property(PROPERTY security_canaries_strong -fstack-protector-strong) 172set_compiler_property(PROPERTY security_canaries_all -fstack-protector-all) 173 174#no support of _FORTIFY_SOURCE" 175set_compiler_property(PROPERTY security_fortify_compile_time) 176set_compiler_property(PROPERTY security_fortify_run_time) 177 178# Required C++ flags when using mwdt 179set_property(TARGET compiler-cpp PROPERTY required "-Hcplus" ) 180 181if(CONFIG_ARC) 182 set_property(TARGET compiler-cpp PROPERTY required "-Hoff=Stackcheck_alloca") 183endif() 184 185# Compiler flag for turning off thread-safe initialization of local statics 186set_property(TARGET compiler-cpp PROPERTY no_threadsafe_statics "-fno-threadsafe-statics") 187 188# ARC MWDT does not support -fno-pic and -fno-pie flags, 189# but it has PIE disabled by default - so no extra flags are required here. 190set_compiler_property(PROPERTY no_position_independent "") 191 192set_compiler_property(PROPERTY no_global_merge "") 193 194################################# 195# This section covers asm flags # 196################################# 197 198# Required ASM flags when using mwdt 199set_property(TARGET asm PROPERTY required "-Hasmcpp") 200 201if(CONFIG_ARCMWDT_LIBC) 202 # We rely on the default C/C++ include locations which are provided by MWDT if we do build with 203 # MW C / C++ libraries. However, for that case we still need to explicitly set header directory 204 # to ASM builds (which may use 'stdbool.h'). 205 set_property(TARGET asm APPEND PROPERTY required "-I${NOSTDINC}") 206endif() 207 208# Remove after testing that -Wshadow works 209set_compiler_property(PROPERTY warning_shadow_variables) 210 211set_compiler_property(PROPERTY no_builtin -fno-builtin) 212set_compiler_property(PROPERTY no_builtin_malloc -fno-builtin-malloc) 213