Commit graph

1797 commits

Author SHA1 Message Date
Benjamin Cabé
55112d658e Revert "cmake: modules: yaml: Remove debug messages"
This reverts commit 8f48758836.
as it's part of a series of commits causing issues on Windows

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2025-01-29 09:27:31 +01:00
Jamie McCrae
8f48758836 cmake: modules: yaml: Remove debug messages
Some debug output was accidentally  left in, this removes it

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2025-01-28 18:15:51 +01:00
Joel Holdsworth
46e37b00e7 compiler: gcc: Support versions predating include-fixed/limits.h
GCC versions starting from 4.3.0 until 12.4.0 stored the limits.h header in
a directory named include-fixed/ . Before 4.3.0 and after 12.4.0 i.e. from
13.1.0 onward, the header is stored in a directory named include/ .

Previously, target.cmake would only detect if the GCC version was 13.1.0 or
newer. This patch adds a check to also check if it is older than 4.3.0.

Signed-off-by: Joel Holdsworth <jholdsworth@nvidia.com>
2025-01-27 13:24:52 +01:00
Joel Holdsworth
6d63d4d904 cmake: modules/FindGnuLd: support an additional obselete version format
A legacy build of GNU ld emits the following version string:

GNU ld version 2.17.50.0.9 20070103

This patch fixes the regex parsing so that the version number is correctly
extracted from the string.

Signed-off-by: Joel Holdsworth <jholdsworth@nvidia.com>
2025-01-27 13:24:52 +01:00
Joel Holdsworth
8b59dcfd11 cmake: compiler: Check -fno-printf-return-value before using
GCC versions before 7.1.0 do not have the -fno-printf-return-value flag and
give an error if it is used. This patch improves compatibility with older
compilers by making CMake check for the flag's availability before using.

Signed-off-by: Joel Holdsworth <jholdsworth@nvidia.com>
2025-01-27 13:24:52 +01:00
Joel Holdsworth
c7bc47c60d cmake: compiler: Check -fdiagnostics-color=always before using
The -fdiagnostics-color flag is only on GCC versions 4.9.0 and newer.
Previously, CMake only checked that the compiler was not the XCC compiler
before using the flag.

However, given that the flag us unavailable on compilers other than XCC,
e.g. old versions of GCC, this patch replaces the previous logic with a
flag-check using the check_set_compiler_property() CMake function.

Signed-off-by: Joel Holdsworth <jholdsworth@nvidia.com>
2025-01-27 13:24:52 +01:00
Torsten Rasmussen
f24f5288f3 cmake: support array of maps in yaml module
This commit introduce support for maps in a yaml list.

The yaml_set() function has been extended with the following signature:
> yaml_set(NAME <name> KEY <key>...
>          [APPEND] LIST MAP <map1> MAP <map2> MAP ...
> )

where a `MAP <map>` has the form:
`MAP "<key1>: <value1>, <key2>: <value2>, ...`

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2025-01-27 13:24:23 +01:00
Torsten Rasmussen
b1a27a77a2 cmake: store board directories in build_info
The schema for build info already contained a `board:path` sequence tag
definition, but boards.cmake did not populate this in the generated
build_info.yml.

Fix this by correctly populating the `board:path` with list of board
directories.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2025-01-27 13:24:23 +01:00
Luca Burelli
8660020205 llext: group LLEXT output files in a subdirectory
LLEXT-related files are currently scattered in multiple locations in the
build directory. For easier access, this patch groups the outputs in a
subdirectory named 'llext' at the root of the build binaries, alongside
the 'zephyr' directory. This directory will thus contain the generated
debug ELF and the final .llext file for each compiled extension.

Note that this does not affect out-of-tree projects that use LLEXT,
since they already pass the full LLEXT file path to add_llext_target().

Signed-off-by: Luca Burelli <l.burelli@arduino.cc>
2025-01-27 08:54:44 +01:00
Luca Burelli
5b66af8adb llext: build with debug info, strip at packaging time
This patch changes the way extensions are built to allow for debugging
information to be collected. Debug flags are now used when compiling and
linking the extension source code, generating a debuggable ELF file.
The final .llext file is then stripped of unneeded symbols, including
all debugging information, at packaging time.

The debugging flag is still removed from the EDK-exported flags.

Signed-off-by: Luca Burelli <l.burelli@arduino.cc>
2025-01-27 08:54:44 +01:00
Luca Burelli
dda8d776ab cmake: bintools: add --strip-unneeded flag to elfconvert
This flag is used by LLEXT to strip all unreferenced symbols and
debugging information from a binary.

Signed-off-by: Luca Burelli <l.burelli@arduino.cc>
2025-01-27 08:54:44 +01:00
Pieter De Gendt
ab26ecce6e linker: iterable_section: Allow numeric sorting up to 5 numeric characters
This allows using a uint16_t value to sort iterable sections.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2025-01-22 10:40:45 +01:00
Nick Brook
4c1275d63a cmake: Added "-" support to EXTRAVERSION
cmake: Added "-" support to EXTRAVERSION.
Added to the regex and update the documentation.
Also updated the examples in the documentation.

Signed-off-by: Nick Brook <nrbrook@gmail.com>
2025-01-21 15:13:36 +01:00
Nick Brook
0d6b3422c9 cmake: Allow semver style EXTRAVERSION
cmake: Allow semver style EXTRAVERSION

Semver versions are commonly in the form X.X.X-a.1, X.X.X-beta.2, etc.
However, currently EXTRAVERSION cannot include ".". This change allows it.

Signed-off-by: Nick Brook <nrbrook@gmail.com>
2025-01-21 15:13:36 +01:00
Jamie McCrae
8b7beff153 cmake: mcuboot: Use zephyr-discovered imgtool
Uses imgtool which has already been located by zephyr

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2025-01-21 11:10:26 +01:00
Jamie McCrae
6db2c86d3a cmake: modules: Prefer imgtool being in MCUboot directory
Changes the priority of imgtool so that the preferred version is
the one inside of the MCUboot directory

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2025-01-21 11:10:26 +01:00
Benjamin Cabé
4b55a13c6c Revert "cmake clang/compiler_flags.cmake: Re-enable -Wgnu"
This reverts commit 8133f470dd.
Causes issues in pow2.c test

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2025-01-20 20:54:58 +01:00
Tom Hughes
8133f470dd cmake clang/compiler_flags.cmake: Re-enable -Wgnu
All warnings in the code base have been resolved.

Signed-off-by: Tom Hughes <tomhughes@chromium.org>
2025-01-20 16:27:10 +01:00
Jukka Rissanen
e658bc1b2b net: Extend the protocol handling in Ethernet
Allow user to specify protocol extensions when receiving data
from Ethernet network. This means that user can register L3
protocol handler using NET_L3_REGISTER() with the desired
protocol type. Ethernet code will then call the handler if
such a protocol type packet is received. This is currently
only implemented for Ethernet. The original IPv4 and IPv6
handling is left intact even if they can be considered to
be L3 layer protocol. This could be changed in the future
if needed so that IPv4 and IPv6 handling could be made
pluggable protocols.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-01-20 09:21:32 +01:00
Carles Cufi
d3a0e16ede cmake: llvm: Add elfconvert_flag_lma_adjust property
The elfconvert_flag_lma_adjust property is required when using
CONFIG_BUILD_OUTPUT_ADJUST_LMA, but was missing for LLVM.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2025-01-19 19:22:49 +01:00
Stephanos Ioannidis
3bb5c4b264 cmake: toolchain: Remove deprecated 'xtools' toolchain variant
The `xtools` toolchain variant, which was originally introduced to be used
with the Crosstool-NG-based Zephyr SDK toolchains and has been replaced by
the `zephyr` toolchain variant, has been marked as deprecated since Zephyr
v3.3.0.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2025-01-17 10:50:07 +01:00
Tom Hughes
c021c6d5f0 cmake clang/compiler_flags.cmake: Re-enable Wmissing-braces warning
All warnings in the code base have been resolved.

Signed-off-by: Tom Hughes <tomhughes@chromium.org>
2025-01-17 10:42:00 +01:00
Tom Hughes
9ba1f2e170 cmake clang/compiler_flags.cmake: Re-enable -Winvalid-format-specifier
All warnings in the code base have been resolved.

Signed-off-by: Tom Hughes <tomhughes@chromium.org>
2025-01-16 02:39:44 +01:00
Tom Hughes
b9d7b1bdae cmake clang/compiler_flags.cmake: Re-enable -Wunknown-warning-option
All warnings in the code base have been resolved.

Signed-off-by: Tom Hughes <tomhughes@chromium.org>
2025-01-16 02:39:31 +01:00
Tom Hughes
2ae4ad2097 cmake clang/compiler_flags.cmake: Re-enable -Wtautological-compare
All warnings in the code base have been resolved.

Signed-off-by: Tom Hughes <tomhughes@chromium.org>
2025-01-16 02:39:21 +01:00
Tom Hughes
0a71e95c5a cmake clang/compiler_flags.cmake: Re-enable -Wshift-overflow
This warning can be re-enabled without any changes (no warnings are
emitted).

Signed-off-by: Tom Hughes <tomhughes@chromium.org>
2025-01-15 19:05:34 +01:00
Jordan Yates
1556596def cmake: unittest: add -t run support
Add support to run unit tests directly from `west build`, for
environments where `west build -t run-test` (which runs the binary under
valgrind) is inappropriate or unavailable (WSL).

`west build -t run` also has the muscle-memory advantage of being the
same target name as the `native_sim` boards.

Signed-off-by: Jordan Yates <jordan@embeint.com>
2025-01-15 01:39:24 +01:00
Grzegorz Swiderski
a7397affcd cmake: modules: dts: Remove duplicate zephyr.dts log
Recently, the "Generated zephyr.dts" message started being shown twice,
because of some now redundant code that was left behind by commit
fe3287a9ac.

Signed-off-by: Grzegorz Swiderski <grzegorz.swiderski@nordicsemi.no>
2025-01-14 17:56:08 +01:00
Martin Becker
2871f1abef sca: added support for Polyspace tool
Add the cmake files for running static code analysis with the Polyspace
tools in the west build. The analysis leverages the compilation database.
Options for the analysis are documented in doc/develop/sca/polyspace.rst.

Analysis results are printed as command line output and provided as CSV.

Manually tested on v4.0.0 with various sample applications.

Signed-off-by: Martin Becker <mbecker@mathworks.com>
2025-01-07 14:13:13 +01:00
Jamie McCrae
0711f42e3a sysbuild: Add support for snippets
Adds support for sysbuild loading snippets, these can be included
by using e.g.: cmake ... -DSB_SNIPPET=blah for sysbuild
directly or can be used with an application and sysbuild using
-DSNIPPET. Snippets for sysbuild can use SB_EXTRA_CONF_FILE in the
snippet file to specify an extra Kconfig fragment for sysbuild

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2024-12-27 07:18:13 +01:00
Torsten Rasmussen
4e29a35b22 cmake: use GLOBAL property instead TARGET properties for scoping
Targets are not available in script mode.
To support the Zephyr scoping feature used by snippets and yaml module
then this commit moves from using custom targets to use GLOBAL
properties for scopes.

A scope property is prefixed with `<scope>:<property>` to avoid naming
collisions.
A `scope:<scope-name>` global property is used to track created scopes.
Tracking valid scopes ensure that properties are only set on known
scopes and thus catches typos / naming errors.

Add zephyr_scope_exists() and zephyr_get_scoped() to abstract the
implementation details of the scoped property retrieval and refactor
current code to use them.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
Signed-off-by: Luca Burelli <l.burelli@arduino.cc>
2024-12-26 09:31:11 +01:00
Benjamin Cabé
eacd5527aa Revert "cmake: remove enforcement of DWARF v4"
This reverts commit 9d849d92bf that seems to
be causing dozens of basic kernel test failures across various platforms.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2024-12-20 16:05:23 +01:00
Flavio Ceolin
3e75c03cb2 security: Add default stack protection level
STACK_CANARIES was enabling canaries in all functions using the compiler
flag -fstack-protector-all. This became confuse with the addition of the
options STRONG and EXPLICIT.

This commit adds the missing option (default level) and disambiguous the
options mapping them close to the compiler flags.

Now we have the following options:

STACK_CANARIES            -> fstack-protector
STACK_CANARIES_STRONG     -> fstack-protector-strong
STACK_CANARIES_ALL        -> fstack-protector-all
STACK_CANARIES_EXPLICIT   -> fstack-protector-explicit

Note that from now on STACK_CANARIES_ALL is the symbol that adds canaries
for all functions.

Signed-off-by: Flavio Ceolin <flavio.ceolin@gmail.com>
2024-12-20 12:37:20 +01:00
Flavio Ceolin
0236f7c9aa security: Add option for explicit stack canaries
Add option to enable stack canaries only when explicitely
declared. It adds a new function attribute, __stack_protect, that
can be used to enable stack protection in a function.

Signed-off-by: Flavio Ceolin <flavio.ceolin@gmail.com>
2024-12-20 12:37:20 +01:00
Flavio Ceolin
82ace41da4 security: Additional option for stack canaries
Previously, when stack canaries were enabled, Zephyr applied this
protection to all functions. This commit introduces a new option that
allows stack canary protection to be applied selectively to specific
functions based on certain criteria.

Signed-off-by: Flavio Ceolin <flavio.ceolin@gmail.com>
2024-12-20 12:37:20 +01:00
Benedikt Schmidt
9d849d92bf cmake: remove enforcement of DWARF v4
Remove the enforcement of DWARF v4 as pyelftools is able
to parse DWARF v5.

Signed-off-by: Benedikt Schmidt <benedikt.schmidt@embedded-solutions.at>
2024-12-20 12:36:46 +01:00
Flavio Ceolin
292d6885f2 cmake: Remove deprecated code
to_hex() and from_hex() are deprecated since v3.5.0. Time
to remove them.

Signed-off-by: Flavio Ceolin <flavio.ceolin@gmail.com>
2024-12-19 21:53:55 +01:00
Robin Kastberg
742679a928 soc: nordic: make -include a compiler property
CMakeLists.txt uses the C compiler parameter -include,
This is causing issues for other toolchains and needs to generalized.

Signed-off-by: Robin Kastberg <robin.kastberg@iar.com>
2024-12-16 20:51:17 +01:00
Fabio Baltieri
e9b86891e1 unittest: add COMPILER_WARNINGS_AS_ERRORS handling
Add a check to set the warnings_as_errors flags in unit tests if
CONFIG_COMPILER_WARNINGS_AS_ERRORS is specified, this should catch
warnings in unit test twister runs.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2024-12-16 20:48:56 +01:00
Fabio Baltieri
e510275ced unittest: set -Wno-format-zero-length
This flag is set on other compiler as well for normal builds, and
suppresses a warning for empty print, which is apparently quite common.

The unit test build uses its own flags so set it there as well to get
the same behavior as with the rest of the code base.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2024-12-16 20:48:56 +01:00
Cedric Lescop
af9ae5b894 cmake: scripts: add 'winpty' support when available
Some Python scripts need to access to the underlying OS, like
using redirections. These interactions go through TTY interface.
On MinGW, these interactions/interfaces are called 'winpty'.
=> use them when available (harmless on platform *NIX platforms)

Signed-off-by: Cedric Lescop <cedric.lescop@se.com>
2024-12-12 20:00:00 +01:00
Dmitrii Golovanov
c3cb5bd376 boards: intel: ish: Improve Simics support
Improve Simics support for `boards/intel/ish/intel_ish_5_8_0`
for better integration with the simulator.

Signed-off-by: Dmitrii Golovanov <dmitrii.golovanov@intel.com>
2024-12-12 16:22:34 +01:00
TOKITA Hiroshi
624e051372 linker: devicetree_regions: Add support memory region flag setting
Add `zephyr,memory-region-flags` for supporting memory region flags
setting.

For example, when the below node is in the devicetree,

```
    test_sram: sram@20010000 {
        compatible = "zephyr,memory-region", "mmio-sram";
        reg = < 0x20010000 0x1000 >;
        zephyr,memory-region = "FOOBAR";
        zephyr,memory-region-flags = "rw";
    };
```

We get the following line in MEMORY section of linker script.

```
FOOBAR (rw) : ORIGIN = (0x20010000), LENGTH = (0x1000)
```

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
2024-12-05 06:39:46 -05:00
Axel Le Bourhis
841311330b cmake: linker: ld: fix duplicate LINK_FLAGS
Original implementation of `toolchain_linker_finalize` duplicates
the `LINK_FLAGS` in the link command. This can cause some problems
like duplicate definitions when using link options like
`--whole-archive`.

This commit fixes it by removing the duplicate `LINK_FLAGS`.

Fixes #82281

Signed-off-by: Axel Le Bourhis <axel.lebourhis@nxp.com>
2024-12-02 22:08:21 +00:00
Torsten Rasmussen
71fd4d9c98 cmake: clear llvm bintool gapfill property
The llvm-objcopy doesn't support a gap-fill argument, therefore clear
the property to remove the error:
> llvm-objcopy: error: unknown argument '--gap-fill'

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2024-12-02 11:14:09 +01:00
Torsten Rasmussen
971dfa6024 device: export CMake pre-load from device subsystem enumeration script
Extend the device subsystem enumeration script to produce a CMake
pre-load script.

This allow CMake linker generator scripts to create iterable sections
based on output from device subsystem enumeration.

This ensures that same functionality is available in both ld linker
templates and the linker generator.

Update linker generators to support the use of the device subsystem
enumeration CMake pre-load script.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2024-11-27 08:15:22 +01:00
Torsten Rasmussen
0332770e46 cmake: create CMake pre-load file for calling linker script generator
Create a CMake preload file with linker settings which is then passed
to the linker script generator as preload file.

This removes the need for command invocation with long arguments.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2024-11-27 08:15:22 +01:00
Robin Kastberg
a63926d44a cmake: linker_script: update common-ram.cmake
CMAKE_LINKER_GENERATOR common-ram.cmake is out of date.
This updates it to keep it up to date with common-ram.ld

Signed-off-by: Robin Kastberg <robin.kastberg@iar.com>
2024-11-26 14:46:24 +00:00
Simon Hein
61f2b117a9 SCA: Get options file value for sysbuild invokation
Get eclair specific option file variable via zephyr_get.
This is also needed if the sca is invoked with sysbuild so it uses
the intended file.

Signed-off-by: Simon Hein <Shein@baumer.com>
2024-11-26 14:45:09 +00:00
Chris Friedt
d6f32bb339 cmake: flash: update cmake to support rtt target
Add support for the rtt target so that users can run

`west build -p auto -b <board> -t rtt <app>`

similarly to the way that users can now do so with the debug
target, since the rtt target is supposed to be used in a similar
way.

Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
2024-11-21 11:01:55 +00:00