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