summaryrefslogtreecommitdiff
path: root/zephyr/cmake/compiler/clang/compiler_flags.cmake
blob: 2fffd4b7556dfec87af7ceb31b885bdbc8ca405c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# Copyright 2020 The ChromiumOS Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

include("${ZEPHYR_BASE}/cmake/compiler/clang/compiler_flags.cmake")

# Disable -fno-freestanding.
set_compiler_property(PROPERTY hosted)

# Disable position independent code.
if ("${ARCH}" STREQUAL "posix" OR "${ARCH}" STREQUAL "unit_testing")
  add_compile_options(-fPIC)
else()
  add_compile_options(-fno-PIC)
endif()

# When testing, look for stack smashing
add_compile_option_ifdef(CONFIG_ZTEST -fstack-protector-all)

if(DEFINED CONFIG_COMPILER_WARNINGS_AS_ERRORS)
  check_set_compiler_property(APPEND PROPERTY warning_extended -Wunused-variable
    -Werror=unused-variable -Werror=missing-braces
    -Werror=sometimes-uninitialized -Werror=unused-function
    -Werror=array-bounds)
endif()

# clang flags for coverage generation
set_property(TARGET compiler PROPERTY coverage --coverage -fno-inline)