Commit a2c55e01 authored by Jaagup Averin's avatar Jaagup Averin Committed by Anas Nashif
Browse files

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: default avatarJaagup Averin <jaagup.averin@gmail.com>
parent c2575c53
Loading
Loading
Loading
Loading
+42 −25
Original line number Diff line number Diff line
@@ -3,33 +3,15 @@ include(${ZEPHYR_BASE}/cmake/compiler/gcc/compiler_flags.cmake)

# Now, let's overwrite the flags that are different in clang.

# No property flag, clang doesn't understand fortify at all
set_compiler_property(PROPERTY security_fortify_compile_time)
set_compiler_property(PROPERTY security_fortify_run_time)
set_compiler_property(PROPERTY optimization_fast -O3 -ffast-math)

# No printf-return-value optimizations in clang
set_compiler_property(PROPERTY no_printf_return_value)

# No property flag, this is used by the POSIX arch based targets when building with the host libC,
# But clang has problems compiling these with -fno-freestanding.
check_set_compiler_property(PROPERTY hosted)

# clang flags for coverage generation
if (CONFIG_COVERAGE_NATIVE_SOURCE)
  set_compiler_property(PROPERTY coverage -fprofile-instr-generate -fcoverage-mapping)
else()
  set_compiler_property(PROPERTY coverage --coverage -fno-inline)
endif()

# clang flag for colourful diagnostic messages
set_compiler_property(PROPERTY diagnostic -fcolor-diagnostics)
########################################################
# Setting compiler properties for gcc / g++ compilers. #
########################################################

# clang flag to save temporary object files
set_compiler_property(PROPERTY save_temps -save-temps)
#####################################################
# This section covers flags related to optimization #
#####################################################

# clang doesn't handle the -T flag
set_compiler_property(PROPERTY linker_script -Wl,-T)
set_compiler_property(PROPERTY optimization_fast -O3 -ffast-math)

#######################################################
# This section covers flags related to warning levels #
@@ -115,6 +97,41 @@ set_compiler_property(PROPERTY warning_error_coding_guideline
                      -Woverride-init
)

###########################################################################
# This section covers flags related to C or C++ standards / standard libs #
###########################################################################

# No printf-return-value optimizations in clang
set_compiler_property(PROPERTY no_printf_return_value)

###################################################
# This section covers all remaining C / C++ flags #
###################################################

# clang flags for coverage generation
if (CONFIG_COVERAGE_NATIVE_SOURCE)
  set_compiler_property(PROPERTY coverage -fprofile-instr-generate -fcoverage-mapping)
else()
  set_compiler_property(PROPERTY coverage --coverage -fno-inline)
endif()

# No property flag, clang doesn't understand fortify at all
set_compiler_property(PROPERTY security_fortify_compile_time)
set_compiler_property(PROPERTY security_fortify_run_time)

# No property flag, this is used by the POSIX arch based targets when building with the host libC,
# But clang has problems compiling these with -fno-freestanding.
check_set_compiler_property(PROPERTY hosted)

# clang flag to save temporary object files
set_compiler_property(PROPERTY save_temps -save-temps)

# clang doesn't handle the -T flag
set_compiler_property(PROPERTY linker_script -Wl,-T)

# clang flag for colourful diagnostic messages
set_compiler_property(PROPERTY diagnostic -fcolor-diagnostics)

set_compiler_property(PROPERTY no_global_merge "-mno-global-merge")

set_compiler_property(PROPERTY specs)