Commit graph

1784 commits

Author SHA1 Message Date
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
Lauren Murphy
7bbe425fe4 llext: basic x86 support
Adds basic x86 support for LLEXT.

Signed-off-by: Lauren Murphy <lauren.murphy@intel.com>
2025-05-21 19:57:20 +02:00
Benjamin Cabé
0c82c3516f Revert "cmake: shields: introduce shield.yml"
This reverts commit 9d5b19710b.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2025-05-21 09:30:30 +02:00
Benjamin Cabé
9d5b19710b cmake: shields: introduce shield.yml
While legacy shields are still supported, this introduces a shield.yml
file similar to board.yml that allows to more explicitly declare a
shield and to set some useful metadata such as vendor and full name.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2025-05-20 15:23:34 +02:00
Ederson de Souza
050b8a915c cmake/emu: Use SIMICS_PROJECT environment variable as working dir
Some simics dependencies live at its own directory, not application's.

Note we need to change it to its absolute path, because relative paths
for `add_custom_target` are relative to the build directory, while
relative SIMICS_PROJECT are more likely to be relative to ZEPHYR_BASE,
from where west or twister are normally run.

Signed-off-by: Ederson de Souza <ederson.desouza@intel.com>
2025-05-20 12:47:25 +02:00
Paul Schaetzle
269799e0e9 cmake: modules: shields: pre_dt_shield.cmake file
Similar to the pre_dt_board.cmake, this is an optional file for
additional arguments that need to get passed to the devicetree compiler.

Signed-off-by: Paul Schaetzle <paulschaetzle@mailbox.org>
2025-05-20 12:47:00 +02:00
Chris Friedt
c32488f97b cmake: kconfig: auto-generate boolean board revision option
Automatically generate a boolean CONFIG_BOARD_REVISION_FOO=y Kconfig
option based on e.g. CONFIG_BOARD_REVISION="foo".

Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
2025-05-16 16:11:48 +02:00
Luca Burelli
c1603b3163 gen_edt: use workspace dir as base for relative paths in comments
This commit allows comments to reference files with paths that are relative
to the Zephyr workspace root. This is done by adding a new argument
'--workspace-dir' to the 'gen_edt.py' script, which is passed to the
'EDT' and 'DT' classes and used instead of the current working directory.

The workspace directory is set to WEST_TOPDIR if West is in use,
otherwise it is set to the parent directory of ZEPHYR_BASE so that
Zephyr files have a 'zephyr/' prefix.

Signed-off-by: Luca Burelli <l.burelli@arduino.cc>
2025-05-16 09:38:35 +02:00
Anas Nashif
d881fb334b boards: qemu_nios2: drop board definition
Remove qemu_nios2, more removals will follow.

Part of #89280

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2025-05-15 20:01:05 -04:00
David Schneider
d85ed3212c cmake: fix syscall dependencies
Replace _parse_syscalls_target_ custom target with explicit
dependency management for syscall depending file generation.

Signed-off-by: David Schneider <schneidav81@gmail.com>
2025-05-13 16:23:54 +02:00
Robin Kastberg
5a92e46c92 iar: toolchain: Implement IAR static init routine
This will implement a way of doing static initialization
the "IAR" way. This is done by calling __iar_data_init3
which handles all static initialization that is mentioned
in the linker file "initialize by copy".

Signed-off-by: Robin Kastberg <robin.kastberg@iar.com>
2025-05-12 19:18:56 +02:00
Sudan Landge
37a0e8c82b cmake: arm: fix ARMFVP_FLAGS for ns variant
Support to run non secure variants with ARMFVP was enabled with
a7122cf5 and fa45bebc
however, the pattern search doesn't work as expected.
This commit fixes that.

Signed-off-by: Sudan Landge <sudan.landge@arm.com>
2025-05-09 15:41:07 +02:00
Anas Nashif
f8647dc94a sca: add coverity as a SCA variant
Add coverity integration as a SCA variant. This is targetting the
service provided by blackduck to open-source projects available on
scan.coverity.com.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2025-05-09 14:01:50 +02:00
Björn Bergman
465f6ba73e userspace: weak defintions for generated k-object lookup functions
Instead of obscure linker-file hacks providing dummy definitions before
we have the proper generated k-object lookup functions, provide weak
definitions  that will be taken out by the real generated implementations
when they are available.

Signed-off-by: Björn Bergman <bjorn.bergman@iar.com>
2025-05-09 12:51:30 +02:00
3468830744 arch: riscv: add support for the zmmul integer multiply extension
The QingKe V2C has an integer multiplier but no divide. Add support
for the corresponding Zmmul extension and, as the extension was added
in GCC 13.0, add a test for the compiler version.

Signed-off-by: Michael Hope <michaelh@juju.nz>
2025-05-09 01:40:22 +02:00
Luca Burelli
dbf00bfca8 yaml: save intermediate files in the build directory
Make sure to provide full paths when saving the intermediate files in
the YAML export, to prevent them from being saved in the source tree.

Signed-off-by: Luca Burelli <l.burelli@arduino.cc>
2025-05-08 19:46:18 +02:00
Armin Brauns
153be1b142 cmake: use external gen_kobject_list binary if available
e.g. https://github.com/arbrauns/gen_kobject_list

Signed-off-by: Armin Brauns <armin.brauns@embedded-solutions.at>
2025-05-07 15:10:05 +02:00
Armin Brauns
d6efbc8af4 cmake: clean up gen_kobject_list.py invocations
cmake/kobj.cmake now provides nice wrappers around the script itself and
common uses.

Signed-off-by: Armin Brauns <armin.brauns@embedded-solutions.at>
2025-05-07 15:10:05 +02:00
Duy Nguyen
65ad2b0883 cmake: Add Renesas RX support
This commit add toolchain command line option for the RX
architecture support

Signed-off-by: Duy Nguyen <duy.nguyen.xa@renesas.com>
2025-05-02 09:18:16 +02:00
Duy Nguyen
5fabd3634a CMake: Add support for .mot binary file format
The Renesas RX support flashing .mot file for binary image
This commit target to add the .mot file output for build and
flash script

Signed-off-by: Duy Nguyen <duy.nguyen.xa@renesas.com>
2025-05-02 09:18:16 +02:00
Keith Packard
2d64237f44 cmake: Enable undefined behavior sanitizer on all targets
GCC and Clang support the undefined behavior sanitizer in any
configuration, the only restriction is that if you want to get nice
messages printed, then you need the ubsan library routines which are only
present for posix architecture or when using picolibc.

This patch adds three new compiler properties:

 * sanitizer_undefined. Enables the undefined behavior sanitizer.
 * sanitizer_undefined_library. Calls ubsan library routines on fault.
 * sanitizer_undefined_trap. Invokes __builtin_trap() on fault.

Overhead for using the trapping sanitizer is fairly low and should be
considered for use in CI once all of the undefined behavior faults in
Zephyr are fixed.

Signed-off-by: Keith Packard <keithp@keithp.com>
2025-05-02 01:16:18 +02:00
Daniel Leung
3cf5b0c8e8 cmake: toolchain/xcc,xt-clang: LD flag for multi-core env vars
When using one set of environment variables for multiple
cores compilation, we also need to supply the core name in
linker flags. So add that to TOOLCHAIN_LD_FLAGS.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2025-04-30 23:02:56 +02:00
Declan Snyder
7962eaeca6 dts: Move vendor-specific dtsi to dedicated folder
Move all the vendor-specific dtsi files that were in dts/common to a
new folder under dts/ designated for vendor-specific files,
since they are not common at all, except for one vendor.

Change MAINTAINERS.yml to reflect the moving of the files.

Update migration guide for this change.

Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
2025-04-29 13:00:03 +02:00
Tom Hughes
78b1ad9a73 cmake clang/compiler_flags.cmake: Re-enable -Wunused-variable for clang
All warnings in the code base have been resolved.

Signed-off-by: Tom Hughes <tomhughes@chromium.org>
2025-04-25 14:03:25 +02:00
Daniel DeGrasse
b84076a192 cmake: arm: linker: remove usage of ld-specific ADDR() function
Remove usage of ld-specific ADDR function within the cmake linker
generator scripting. Since the linker generator scripting doesn't
support MPUs, we can simply set the __ramfunc_region_start symbol to be
equal to __ramfunc_start

Fixes #87200

Signed-off-by: Daniel DeGrasse <ddegrasse@tenstorrent.com>
2025-04-24 16:54:14 +02:00
Ederson de Souza
f968d49232 cmake/emu: Use environment variable value on message about it
A message about not finding simics at SIMICS_PROJECT env var was not
showing the current value of said variable.

Signed-off-by: Ederson de Souza <ederson.desouza@intel.com>
2025-04-24 16:54:00 +02:00
Phi Bang Nguyen
2b46cc0b78 drivers: video: Introduce video device structure
Introduce a new video device structure representing a device in a
video pipeline. Each video device embeds a pointer to its "source"
device and other "video" characteristics.

This structure give the video framework an access to all video features
of the device and a hierachical view of the video pipeline that the
device belongs to.

Signed-off-by: Phi Bang Nguyen <phibang.nguyen@nxp.com>
2025-04-21 20:03:31 +02:00