@@ -3,33 +3,15 @@ include(${ZEPHYR_BASE}/cmake/compiler/gcc/compiler_flags.cmake)
33
44# Now, let's overwrite the flags that are different in clang.
55
6- # No property flag, clang doesn't understand fortify at all
7- set_compiler_property(PROPERTY security_fortify_compile_time)
8- set_compiler_property(PROPERTY security_fortify_run_time)
9- set_compiler_property(PROPERTY optimization_fast -O3 -ffast-math)
10-
11- # No printf-return-value optimizations in clang
12- set_compiler_property(PROPERTY no_printf_return_value)
13-
14- # No property flag, this is used by the POSIX arch based targets when building with the host libC,
15- # But clang has problems compiling these with -fno-freestanding.
16- check_set_compiler_property(PROPERTY hosted)
17-
18- # clang flags for coverage generation
19- if (CONFIG_COVERAGE_NATIVE_SOURCE)
20- set_compiler_property(PROPERTY coverage -fprofile-instr-generate -fcoverage-mapping)
21- else ()
22- set_compiler_property(PROPERTY coverage --coverage -fno-inline)
23- endif ()
24-
25- # clang flag for colourful diagnostic messages
26- set_compiler_property(PROPERTY diagnostic -fcolor-diagnostics)
6+ ########################################################
7+ # Setting compiler properties for gcc / g++ compilers. #
8+ ########################################################
279
28- # clang flag to save temporary object files
29- set_compiler_property(PROPERTY save_temps -save-temps)
10+ #####################################################
11+ # This section covers flags related to optimization #
12+ #####################################################
3013
31- # clang doesn't handle the -T flag
32- set_compiler_property(PROPERTY linker_script -Wl,-T)
14+ set_compiler_property(PROPERTY optimization_fast -O3 -ffast-math)
3315
3416#######################################################
3517# This section covers flags related to warning levels #
@@ -115,6 +97,41 @@ set_compiler_property(PROPERTY warning_error_coding_guideline
11597 -Woverride-init
11698)
11799
100+ ###########################################################################
101+ # This section covers flags related to C or C++ standards / standard libs #
102+ ###########################################################################
103+
104+ # No printf-return-value optimizations in clang
105+ set_compiler_property(PROPERTY no_printf_return_value)
106+
107+ ###################################################
108+ # This section covers all remaining C / C++ flags #
109+ ###################################################
110+
111+ # clang flags for coverage generation
112+ if (CONFIG_COVERAGE_NATIVE_SOURCE)
113+ set_compiler_property(PROPERTY coverage -fprofile-instr-generate -fcoverage-mapping)
114+ else ()
115+ set_compiler_property(PROPERTY coverage --coverage -fno-inline)
116+ endif ()
117+
118+ # No property flag, clang doesn't understand fortify at all
119+ set_compiler_property(PROPERTY security_fortify_compile_time)
120+ set_compiler_property(PROPERTY security_fortify_run_time)
121+
122+ # No property flag, this is used by the POSIX arch based targets when building with the host libC,
123+ # But clang has problems compiling these with -fno-freestanding.
124+ check_set_compiler_property(PROPERTY hosted)
125+
126+ # clang flag to save temporary object files
127+ set_compiler_property(PROPERTY save_temps -save-temps)
128+
129+ # clang doesn't handle the -T flag
130+ set_compiler_property(PROPERTY linker_script -Wl,-T)
131+
132+ # clang flag for colourful diagnostic messages
133+ set_compiler_property(PROPERTY diagnostic -fcolor-diagnostics)
134+
118135set_compiler_property(PROPERTY no_global_merge "-mno-global-merge" )
119136
120137set_compiler_property(PROPERTY specs)
0 commit comments