Skip to content

Commit a2c55e0

Browse files
JaagupAverinnashif
authored andcommitted
llvm: Reorganize clang/compiler_flags.cmake
Since this overrides values from gcc/compiler_flags.cmake, they should ideally have the same structure and order. Signed-off-by: Jaagup Averin <[email protected]>
1 parent c2575c5 commit a2c55e0

File tree

1 file changed

+42
-25
lines changed

1 file changed

+42
-25
lines changed

cmake/compiler/clang/compiler_flags.cmake

Lines changed: 42 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
118135
set_compiler_property(PROPERTY no_global_merge "-mno-global-merge")
119136

120137
set_compiler_property(PROPERTY specs)

0 commit comments

Comments
 (0)