Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

security: Add compiler static analysis support #64595

Merged
merged 1 commit into from
Jan 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions cmake/sca/gcc/sca.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# SPDX-License-Identifier: Apache-2.0
#
# Copyright (c) 2024 Intel Corporation

list(APPEND TOOLCHAIN_C_FLAGS -fanalyzer)
18 changes: 18 additions & 0 deletions doc/develop/sca/gcc.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
.. _gcc:

GCC static analysis support
###########################

Static analysis was introduced in `GCC <https://gcc.gnu.org/>`__ 10 and it is enabled
with the option ``-fanalyzer``. This option performs a much more expensive and thorough
analysis of the code than traditional warnings.

Run GCC static analysis
***********************

To run GCC static analysis, :ref:`west build <west-building>` should be
called with a ``-DZEPHYR_SCA_VARIANT=gcc`` parameter, e.g.

.. code-block:: shell

west build -b qemu_x86 samples/userspace/hello_world_user -- -DZEPHYR_SCA_VARIANT=gcc
1 change: 1 addition & 0 deletions doc/develop/sca/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,4 @@ The following is a list of SCA tools natively supported by Zephyr build system.

codechecker
sparse
gcc