Commit graph

1860 commits

Author SHA1 Message Date
Carles Cufi
4ea89d0ada cmake: clang: Enable -Waddress-of-packed-member
Several years ago we started enabling the -Waddress-of-packed-member
warning in commit cf111962e0 for GCC.

Do the same for Clang, since there is no reason not to and the warning
is very useful, especially in protocol stacks.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2025-06-27 18:28:09 -05:00
Tu Nguyen Van
c68d0b9630 doc: correct python minimum required
Fixes #92059

Update getting started guide, migration-guide and
python.cmake to use Python 3.12.1 as minimum supported
version

Signed-off-by: Tu Nguyen Van <tu.nguyenvan@nxp.com>
2025-06-27 09:15:42 -10:00
Tim Pambor
a8a4a5a60c cmake: sca: codechecker: Support output to console and export
Enable parsed results to be printed to the console in addition
to being exported, rather than requiring one or the other.

Signed-off-by: Tim Pambor <tim.pambor@codewrights.de>
2025-06-27 10:02:54 -05:00
Tim Pambor
159ad42b2b cmake: sca: codechecker: Finish export before exiting
If exporting to multiple formats (e.g., HTML and JSON), do not stop
after the first format when errors are found. Instead, continue
exporting to all specified formats and only exit afterwards.

Signed-off-by: Tim Pambor <tim.pambor@codewrights.de>
2025-06-27 10:02:54 -05:00
Marcin Szymczyk
496cb0f46e cmake: add option to force raw instruction mnemonics
Some architectures use pseudo instructions in assembly.
Introduce an option that allows forcing raw instruction mnemonics.
Currently implemented for GNU binutils.

Signed-off-by: Marcin Szymczyk <marcin.szymczyk@nordicsemi.no>
2025-06-27 10:01:11 -05:00
Anas Nashif
5ac9cd119b cmake: targets: support overriding puncover host and port
Allow overriding puncover default host and port. Using
PUNCOVER_HOST/PUNCOVER_PORT it is possible now to set the host and port
to something else other than the default.

example:

export PUNCOVER_HOST=10.0.1.1
export PUNCOVER_PORT=8088

will start puncover on 10.0.1.1:8088 and make it available over the
local network.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2025-06-27 09:59:30 -05:00
Simon Maurer
cb982d16ef soc: xlnx: zynq7000: add FPU support
According to its datasheet the Zynq 7000 has a VFPv3 FPU

Signed-off-by: Simon Maurer <mail@maurer.systems>
2025-06-27 09:50:43 -05:00
Tomasz Bursztyka
49a96f67a2 cmake: Add service section to commo-rom linker generator
struct init_entry may point to a struct device or a struct service,
each ones belonging to device or service iterable section.
Service section being newly added, handling it in cmake relevantly.

Signed-off-by: Tomasz Bursztyka <tobu@bang-olufsen.dk>
2025-06-27 14:13:58 +02:00
Pieter De Gendt
ba905d045b cmake: extensions: Check no arguments are given to zephyr_library
The zephyr_library macro does not expect any arguments, add a check for
that and similar for zephyr_library_named for no unexpected additional
arguments.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2025-06-27 10:59:22 +02:00
Pieter De Gendt
775696c297 cmake: extensions: Add macro helper for functions to have no arguments
Add zephyr_check_no_arguments that macros and functions can call to check
that no arguments are given.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2025-06-27 10:59:22 +02:00
Keith Packard
0463827f92 compiler/gcc: Add rx compiler flags to linker too
Many of these affect the library search path.

Signed-off-by: Keith Packard <keithp@keithp.com>
2025-06-26 14:07:03 +02:00
Robin Kastberg
e572e8f491 iar: linker_script: fix bug with alphabetical order
Having alphabetical order on an init block causes a linker error.
So it is one of the things replaced when translating a block to its
corresponding init block.
The recent changes in ff8b24b6bd caused
iterable sections having ONLY alphabetical order as an attribute,
triggering a bug in this regexp.

Signed-off-by: Robin Kastberg <robin.kastberg@iar.com>
2025-06-25 15:53:01 -10:00
Carles Cufi
892ac07a4a cmake: Add a new no_deprecation_warning compiler flag
Commit be40d854c2ccacf14ca3fcfb01bffdc9b075c6c9 introduced the ability
of building Zephyr with deprecation warnings enabled, by making
COMPILER_WARNINGS_AS_ERRORS depend on the newly added DEPRECATION_TEST
Kconfig option. This has the downside of disabling **all** warnings, not
only the deprecation ones.

This patch instead makes DEPRECATION_TEST disable only the deprecation
warning, but leaves COMPILER_WARNINGS_AS_ERRORS enabled.
This has the advantage of being able to see other unrelated warnings
(and fail if they appear) but has the disadvantage of not printing out
the deprecation warnings themselves (since they are disabled).

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2025-06-23 12:38:07 -07:00
Tim Pambor
c8ef91fdb7 cmake: llvm: Use '=' for --config to improve compatibility
Replaces space with an equal sign when assigning the clang configuration
file to the --config parameter. This change improves compatibility with
tools that parse the compilation database and expect compiler arguments
to be separated by space.

Signed-off-by: Tim Pambor <tim.pambor@codewrights.de>
2025-06-20 16:23:16 +02:00
Guennadi Liakhovetski
a3089c1ffc llext: xtensa: strip the .xtensa.info section
.xtensa.info section isn't large so it was ignored in the beginning,
but its contents can differ depending on the build platform even if
the sources and the toolchain are the same. Strip the section to
restore binary reproducibility.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
2025-06-19 13:59:15 +02:00
Benjamin Cabé
043bb58488 doc: ci: Zephyr now requires Python 3.12 or higher
Update getting started guide, release notes, CI actions and
Python version compliance check to use Python 3.12 as
minimum supported version.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2025-06-19 13:56:59 +02:00
Anas Nashif
bffb3f63fe sca: eclair: add Xen deviations
Import some useful Xen deviations that apply to Zephyr as well.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2025-06-18 17:48:03 -04:00
Björn Bergman
a9ed11c3f6 toolchain: iar: Implement MIN_SIZE and MAX_SIZE for IAR linker
Implement the MIN_SIZE and MAX_SIZE options to
zephyr_linker_section_configurefor the IAR icf linker file
generator

Signed-off-by: Björn Bergman <bjorn.bergman@iar.com>
2025-06-18 09:10:46 -04:00
Robin Kastberg
fc7079185c cmake: linker_script: fix __exidx_start
This makes c++ sample
`sample.libraries.hash_map.newlib.cxx_unordered_map.djb2`
start working on gcc w. `CMAKE_LINKER_GENERATOR=y`.

Signed-off-by: Robin Kastberg <robin.kastberg@iar.com>
2025-06-18 09:10:36 -04:00
Joel Holdsworth
f2c8a5acc4 cmake: linker: ld: Use "-Map <mapfile>" for legacy compatibility
The build system currently generates mapfiles by invoking ld with the
"-Map=<mapfile>" command line argument. This variant of the flag was
introduced in GNU binutils 2.20.

To enable compatibility with legacy versions of the GNU ld, the argument
has been replaced with the "-Map <mapfile>" variant.

Signed-off-by: Joel Holdsworth <jholdsworth@nvidia.com>
2025-06-18 09:09:50 -04:00
Richard Hughes
3c97bf1014 cmake: kconfig: regenerate .config when Kconfig sources are updated
The existing logic caused a regeneration when any of the .conf files
changed, but modifying the Kconfig files can also cause the .config file
to become out of date e.g. by adding a new config option or by changing
the default value of a config option (when that default is not
overridden by a .conf).

Without this change, an incremental build wouldn't pick up the new value
and would require the user to notice that and manually do a clean build.

Signed-off-by: Richard Hughes <rhughes@xilinx.com>
2025-06-18 09:08:52 -04:00
Richard Hughes
3aaa68faad cmake: kconfig: rename variable to correct naming convention
Variables used only internally in the module should have lowercase
names.

Signed-off-by: Richard Hughes <rhughes@xilinx.com>
2025-06-18 09:08:52 -04:00
Björn Bergman
4b3cd02e6a toolchain: iar: Put KEEP on init-blocks
To circumvent peculiarities in the linker, the _init blocks
(as well as their content) needs to be tagged with keep.

Signed-off-by: Björn Bergman <bjorn.bergman@iar.com>
2025-06-18 11:20:58 +01:00
Björn Bergman
dff0dbaf34 toolchain: iar: use zephyr_linker_generate_linker_settings_file() to ilink
Use the standard function to generate the input file to the linker
generator.

Signed-off-by: Björn Bergman <bjorn.bergman@iar.com>
2025-06-18 11:20:35 +01:00
Keith Packard
97f96afbd7 linker_script: Remove all SUBALIGN usage for iterable sections
SUBALIGN forces alignment to the specified value, even if the object
requires stricter alignment. This causes mis-aligned access when accessing
the resulting value.

Signed-off-by: Keith Packard <keithp@keithp.com>
2025-06-17 16:06:21 +02:00
Keith Packard
ff8b24b6bd cmake/modules: Make SUBALIGN parameter to zephyr_iterable_sections optional
Most uses of this macro should *not* include SUBALIGN as that can reduce
the alignment requirement for data and cause unaligned access faults in
the processor. Leave support for this in place in case there are
still uses for it.

Signed-off-by: Keith Packard <keithp@keithp.com>
2025-06-17 16:06:21 +02:00
Marcin Szymczyk
ab750eab5f cmake: compiler: gcc: riscv: remove spurious Zmmul
Zmmul is a subset of M extension.
No need to enable Zmmul redundantly if M is already present.

Reference:
449cd0c79a/src/m.tex (L173)
https://github.com/riscv/riscv-isa-manual/issues/869

Signed-off-by: Marcin Szymczyk <marcin.szymczyk@nordicsemi.no>
2025-06-13 10:13:37 -07:00
Daniel Leung
146e22fca4 cmake: xcc/xt-clang: fix for proper system include paths
Although xt-clang is based on clang, for some reason, it still
lists xcc system include path as the first search path (e.g.
for stddef.h), and the clang system include path as last. This
creates a big issue when the code starts to use any standards
past C89 (since xcc is based on GCC 4.2). We can use compiler
property nostdin_include to add -isystem to compiler options.
However, some modules (e.g. picolibcs) somehow ignore this.
So we also need to forcibly do add_compile_options() to make
sure the clang system include path is placed before the xcc
system include path.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2025-06-11 16:10:53 -07:00
Daniel Leung
f7b314347e cmake: compiler/gcc: skip nostdinc property for xt-clang
Xtensa toolchain xt-clang needs similar treatment to xcc in
terms of nostdinc and nostdinc_include, so add it to the if
block to exclude these by default.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2025-06-11 16:10:53 -07:00
Keith Packard
5890c73087 linker: Place .tbss section in RAM, not FLASH
If this section is placed in FLASH, the section gets marked
as writable even though .tbss values will never be stored there.

Signed-off-by: Keith Packard <keithp@keithp.com>
2025-06-10 22:13:09 +02:00
Luca Ciucci
24f9ca7178 sca: add HTML summary and full report options to ECLAIR configuration
Introduce ECLAIR_SUMMARY_HTML and ECLAIR_FULL_HTML CMake options to
enable the generation of HTML reports.

Signed-off-by: Luca Ciucci <luca.ciucci@bugseng.com>
2025-06-10 12:53:59 -04:00
Luca Ciucci
d8b86f1ac7 doc: update ECLAIR documentation
Added prerequisites section, fixed some typos and added
ECLAIR_RULESET_ZEPHYR_GUIDELINES option.
Also updated dead doc string links in ECLAIR configuration files.

Signed-off-by: Luca Ciucci <luca.ciucci@bugseng.com>
2025-06-10 12:53:59 -04:00
Luca Ciucci
c56a8049ed sca: add ECLAIR configuration for main Coding Guidelines rules
Added the main rules from the conding guidelines selection listed in
/doc/contribute/coding_guidelines/index.rst to the zephyr_guidelines
configuration.

Signed-off-by: Luca Ciucci <luca.ciucci@bugseng.com>
2025-06-10 12:53:59 -04:00
Luca Ciucci
8eaf6aebc6 sca: enforce selection of a single ECLAIR_RULESET in configuration
This check prevents misconfigurations where more than one ruleset is
selected, ensuring that the analysis is not silently performed with
an unintended configuration.

Signed-off-by: Luca Ciucci <luca.ciucci@bugseng.com>
2025-06-10 12:53:59 -04:00
Nicola Vetrini
91dde769f7 sca: eclair: improve ECLAIR integration
Various improvements to the integration files in order to obtain correct
static analysis results:
- variable `ECLAIR_WORKSPACE' is set to the build output directory, to
  allow multiple ECLAIR analyses running in parallel on the same machine
  without conflicts;
- fix the evaluation order of rulesets to allow a user-provided ruleset to
  be selected without a cmake options file that undefines other
  ECLAIR_RULESET_* variables;
- add a clean-only frame to initiate the analysis and a project
  frame to end it.

Signed-off-by: Nicola Vetrini <nicola.vetrini@bugseng.com>
2025-06-10 12:53:59 -04:00
Kesavan Yogeswaran
d5fc087690 cmake: Fix warning if a Zephyr library is created in app-mode
zephyr_append_cmake_library attempts to warn the user if a user calls it
to create a Zephyr library while the build is in application mode. At
that stage of the build, the list of Zephyr libraries has already been
processed so the function is effectively a no-op.

This heuristic used to determine if the build was in kernel mode or
application mode checked for the presence of the zephyr_prebuilt target.
This check was broken by a previous commit that renamed this target.

This commit fixes the heuristic by checking for the zephyr_pre0 target.

This was tested by calling zephyr_append_cmake_library from some
application build files, building the application, and seeing the
warning only for the call I added. No warnings were printed for any
Zephyr internal libraries.

Link: https://github.com/zephyrproject-rtos/zephyr/pull/35887
Link: https://github.com/zephyrproject-rtos/zephyr/pull/39959

Signed-off-by: Kesavan Yogeswaran <hikes@google.com>
2025-06-09 15:02:01 -07:00
Robin Kastberg
0fc490956b iar: linker: Do --whole_archive linking
Instead of getting names of all object files, link
against libraries using `--whole_archive`
Signed-off-by: Robin Kastberg <robin.kastberg@iar.com>
2025-06-09 14:37:05 -07:00
Luca Burelli
8e765b78a2 cmake: add_llext_target: fix command expansion
This fixes the invocation of the 'elfconvert' and 'slid_inject' commands
in the `add_llext_target` function by ensuring that the arguments are
expanded correctly before passing them to the shell.

Signed-off-by: Luca Burelli <l.burelli@arduino.cc>
2025-06-06 11:52:31 +02:00
Tom Hughes
b6766aeb6b cmake: compiler: Remove -fshort-enums
"-fshort-enums" changes the ABI. It's not enabled for gcc, so it's not
clear why it's enabled for clang (only ARM) and armclang, other than it
looks like some users of these toolchains may be linking against code
that is compiled with "-fshort-enums".

As an example, when compiling with clang, CONFIG_LTO, and a toolchain
built without "-fshort-enums", the linker warns:

ld.lld: error: linking module flags 'min_enum_size': IDs have
conflicting values in
'/usr/armv7m-cros-eabi/usr/lib/libc++_static.a(string.cpp.o at 784090)'
and 'ld-temp.o'

Signed-off-by: Tom Hughes <tomhughes@chromium.org>
2025-06-06 11:52:22 +02:00
Yuval Peress
d17956a074 build: Support SYSROOT_DIR in native_sim and clang
When running naive sim builds using clang, respect user passed
SYSROOT_DIR values. Additionally, allow overriding the archive tool
when calling Make for the native simulator.

Add the sysroot (if available) to the native_simulator target and
TOOLCHAIN_C_FLAGS and TOOLCHAIN_LD_FLAGS. Additionally pass CMAKE_AR
to NSI_AR.

Signed-off-by: Yuval Peress <peress@google.com>
2025-06-06 10:11:49 +02:00
Björn Bergman
bb797ab421 cmake: Fix compilation options for kobject_hash*.c
Rework how the compilation-options for the gperf generated
kobject_hash*.c files are put together to fix problems with SHELL:
and cmake-list separators handling.

zephyr_get_compile_options_for_lang_as_string() returns the set of
options as a cmake generator expression string which is cumbersome to
edit. This caused the command line for the IAR toolchain to have broken
SHELL: entries, and other some command line entries being postfixed by
"gnu".

This also adds CMake compiler properties for no_function_sections and
no_data_sections options

Signed-off-by: Björn Bergman <bjorn.bergman@iar.com>
2025-05-31 07:02:36 -04:00
Björn Bergman
01d3316810 linker generator: Handle .last_section
Add  cmake linker generator things for .last_section.

Follow up to #88970. Fixes bug #89719, for gcc/ld & iar

Signed-off-by: Björn Bergman <bjorn.bergman@iar.com>
2025-05-26 14:17:21 +02:00
Anas Nashif
b8f3263df0 toolchain: clang: compiler opt: -Ofast -> -O3 -ffast-math
clang 20 does not like -Ofast.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2025-05-23 17:41:40 -04:00
Alex Fabre
219fae6946 sca: llvm: add support for clang static analyzer
This commit brings a convenient way to run clang static analyzer on a
project with 'analyze-build' llvm utility.

Signed-off-by: Alex Fabre <alex.fabre@rtone.fr>
2025-05-23 17:40:36 -04:00
Benjamin Cabé
66fda826e1 shields: scripts: cmake: use list_shields.py in shields.cmake
The logic to "guess" shield names/dirs was duplicated between
list_shields.py (which is used by e.g. west shields) and shields.cmake.
This commit moves the logic to list_shields.py, and updates
shields.cmake to call the script and process its JSON output.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2025-05-23 17:19:58 +02:00
Duy Nguyen
f77e258cb9 cmake: Set RX build use 64bit doubles as default
The RX floating-point hardware only works on 32-bit values
so default gcc will build doubles as 32-bit, this make many
test fail on RX build test.
This commit force the build for RX arch to use 64-bit doubles
FPU will be supported later on this arch

Signed-off-by: Duy Nguyen <duy.nguyen.xa@renesas.com>
2025-05-22 23:57:26 +02:00
Grzegorz Swiderski
da197fe9ef sysbuild: Import image devicetrees
Make the image devicetrees available to sysbuild for advanced use cases.

This is done by calling `zephyr_dt_import` on each image target. The DT
target properties are all expected to be prefixed with `DT_`, so there
should be no conflicts.

Thus, the DT contents of a given `<image>` can be retrieved using e.g.:

    dt_nodelabel(<var> NODELABEL <label> TARGET <image>)

as noted in `extensions.cmake`.

Signed-off-by: Grzegorz Swiderski <grzegorz.swiderski@nordicsemi.no>
2025-05-22 13:44:18 +02:00
Grzegorz Swiderski
7cddb2a5e5 cmake: extensions: Add TARGET arguments to the dt_* API
The CMake dt_* API is backed by target properties. By default, it uses
the target named `devicetree_target` that is initialized in `dts.cmake`.

We should be able to customize this, now that we have a function for
loading those properties into a different target. For example:

    zephyr_dt_import(EDT_PICKLE_FILE /path/to/edt.pickle TARGET target)

    dt_nodelabel(node NODELABEL label TARGET target)

This would make it possible to reference multiple devicetrees in the
same build system, particularly sysbuild.

Signed-off-by: Grzegorz Swiderski <grzegorz.swiderski@nordicsemi.no>
2025-05-22 13:44:18 +02:00
Grzegorz Swiderski
468db18389 cmake: modules: Add zephyr_dt_import
Extract the part of `dts.cmake` that invokes `gen_dts_cmake.py`, then
generalize it into a CMake extension, which can be reused by sysbuild.

The Python script itself is also updated, so that the generated CMake
file can accept an input variable DEVICETREE_TARGET, which comes from
the `zephyr_dt_import(TARGET ...)` argument.

Signed-off-by: Grzegorz Swiderski <grzegorz.swiderski@nordicsemi.no>
2025-05-22 13:44:18 +02:00
Anas Nashif
e80d86ab85 sca: eclair: substitute deprecated service STD.emptrecd
The ECLAIR service STD.emptrecd (which checks for empty structures) is now
deprecated.
Use STD.anonstct (which checks for structures with no named
members, an UB in C99)

Based on a change by Nicola Vetrini in the Xen project:

https://lists.xenproject.org/archives/html/xen-changelog/2024-12/msg00125.html

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2025-05-22 04:52:56 +02:00