1# Overview of used compiler properties for gcc / g++ compilers.
2#
3# Define the flags your toolchain support, and keep the unsupported flags empty.
4
5#####################################################
6# This section covers flags related to optimization #
7#####################################################
8set_compiler_property(PROPERTY no_optimization)
9
10set_compiler_property(PROPERTY optimization_debug)
11
12set_compiler_property(PROPERTY optimization_speed)
13
14set_compiler_property(PROPERTY optimization_size)
15
16set_compiler_property(PROPERTY optimization_size_aggressive)
17
18set_compiler_property(PROPERTY optimization_fast)
19
20#######################################################
21# This section covers flags related to warning levels #
22#######################################################
23
24# Property for standard warning base in Zephyr, this will always bet set when compiling.
25set_compiler_property(PROPERTY warning_base)
26
27# GCC options for warning levels 1, 2, 3, when using `-DW=[1|2|3]`
28# Property for warning levels 1, 2, 3 in Zephyr when using `-DW=[1|2|3]`
29set_compiler_property(PROPERTY warning_dw_1)
30
31set_compiler_property(PROPERTY warning_dw_2)
32
33set_compiler_property(PROPERTY warning_dw_3)
34
35# Extended warning set supported by the compiler
36set_compiler_property(PROPERTY warning_extended)
37
38# Compiler property that will issue error if a declaration does not specify a type
39set_compiler_property(PROPERTY warning_error_implicit_int)
40
41# Compiler flags to use when compiling according to MISRA
42set_compiler_property(PROPERTY warning_error_misra_sane)
43
44###########################################################################
45# This section covers flags related to C or C++ standards / standard libs #
46###########################################################################
47
48# Compiler flags for C standard. The specific standard must be appended by user.
49# For example, gcc specifies this as: set_compiler_property(PROPERTY cstd -std=)
50set_compiler_property(PROPERTY cstd)
51
52# Compiler flags for disabling C standard include and instead specify include
53# dirs in nostdinc_include to use.
54set_compiler_property(PROPERTY nostdinc)
55set_compiler_property(PROPERTY nostdinc_include)
56
57# Compiler flags for disabling C++ standard include.
58set_property(TARGET compiler-cpp PROPERTY nostdincxx)
59
60# Required C++ flags when compiling C++ code
61set_property(TARGET compiler-cpp PROPERTY required)
62
63# Compiler flags to use for specific C++ dialects
64set_property(TARGET compiler-cpp PROPERTY dialect_cpp98)
65set_property(TARGET compiler-cpp PROPERTY dialect_cpp11)
66set_property(TARGET compiler-cpp PROPERTY dialect_cpp14)
67set_property(TARGET compiler-cpp PROPERTY dialect_cpp17)
68set_property(TARGET compiler-cpp PROPERTY dialect_cpp2a)
69set_property(TARGET compiler-cpp PROPERTY dialect_cpp20)
70set_property(TARGET compiler-cpp PROPERTY dialect_cpp2b)
71set_property(TARGET compiler-cpp PROPERTY dialect_cpp23)
72
73# Flag for disabling strict aliasing rule in C and C++
74set_compiler_property(PROPERTY no_strict_aliasing)
75
76# Extra warnings options for twister run
77set_property(TARGET compiler PROPERTY warnings_as_errors)
78set_property(TARGET asm PROPERTY warnings_as_errors)
79
80set_property(TARGET compiler PROPERTY no_deprecation_warning)
81set_property(TARGET asm PROPERTY no_deprecation_warning)
82
83# Flag for disabling exceptions in C++
84set_property(TARGET compiler-cpp PROPERTY no_exceptions)
85
86# Flag for disabling rtti in C++
87set_property(TARGET compiler-cpp PROPERTY no_rtti)
88
89# Flag for disabling optimizations around printf return value
90set_compiler_property(PROPERTY no_printf_return_value)
91
92###################################################
93# This section covers all remaining C / C++ flags #
94###################################################
95
96# Flags for coverage generation
97set_compiler_property(PROPERTY coverage)
98
99# Security canaries flags.
100set_compiler_property(PROPERTY security_canaries)
101set_compiler_property(PROPERTY security_canaries_strong)
102set_compiler_property(PROPERTY security_canaries_all)
103set_compiler_property(PROPERTY security_canaries_explicit)
104
105set_compiler_property(PROPERTY security_fortify_compile_time)
106set_compiler_property(PROPERTY security_fortify_run_time)
107
108# Flag for a hosted (no-freestanding) application
109set_compiler_property(PROPERTY hosted)
110
111# gcc flag for a freestanding application
112set_compiler_property(PROPERTY freestanding)
113
114# Flag to include debugging symbol in compilation
115set_compiler_property(PROPERTY debug)
116
117# Flags to save temporary object files
118set_compiler_property(PROPERTY save_temps)
119
120# Flag to specify linker script
121set_compiler_property(PROPERTY linker_script)
122
123set_compiler_property(PROPERTY no_common)
124
125# Flags for imacros. The specific header must be appended by user.
126set_compiler_property(PROPERTY imacros)
127
128# Compiler flag for turning off thread-safe initialization of local statics
129set_property(TARGET compiler-cpp PROPERTY no_threadsafe_statics)
130
131# Required ASM flags when compiling
132set_property(TARGET asm PROPERTY required)
133
134# GCC compiler flags for imacros. The specific header must be appended by user.
135set_property(TARGET asm PROPERTY imacros)
136
137# Compiler flag for disabling pointer arithmetic warnings
138set_compiler_property(PROPERTY warning_no_pointer_arithmetic)
139
140# Compiler flags for disabling position independent code / executable
141set_compiler_property(PROPERTY no_position_independent)
142
143# Compiler flag to avoid combine more than one global variable into a single aggregate.
144# gen_kobject_list.py is does not understand it and end up identifying objects as if
145# they had the same address.
146set_compiler_property(PROPERTY no_global_merge)
147
148# Compiler flag for warning about shadow variables
149set_compiler_property(PROPERTY warning_shadow_variables)
150# Compiler flag for disabling warning about array bounds
151set_compiler_property(PROPERTY warning_no_array_bounds)
152
153# Compiler flags to avoid recognizing built-in functions
154set_compiler_property(PROPERTY no_builtin)
155set_compiler_property(PROPERTY no_builtin_malloc)
156
157# Compiler flag for defining specs. Used only by gcc, other compilers may keep
158# this undefined.
159set_compiler_property(PROPERTY specs)
160
161# Compiler flag for defining preinclude files.
162set_compiler_property(PROPERTY include_file)
163
164# Compiler flag for trustzone
165set_compiler_property(PROPERTY cmse)
166
167set_property(TARGET asm PROPERTY cmse)
168
169# Compiler flag for not placing functions in their own sections:
170set_compiler_property(PROPERTY no_function_sections)
171
172# Compiler flag for not placing variables in their own sections:
173set_compiler_property(PROPERTY no_data_sections)
174