Commit graph

1784 commits

Author SHA1 Message Date
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
Guennadi Liakhovetski
827909b7b9 LLEXT: Xtensa: don't generate FLIX commands
The LLEXT linker for Xtensa cannot relocate FLIX commands, disable
them in extensions only until we have a solution. Note, that this
only affects extensions, the main Zephyr binary is still built with
FLIX commands.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
2024-11-20 10:17:06 +00:00
Jonathon Penix
2493123758 cmake: lld: Remove duplicate -fuse-ld=lld
-fuse-ld=lld is currently specified twice through the baremetal property
(in cmake/linker/lld/linker_flags.cmake) and TOOLCHAIN_LD_FLAGS (in
cmake/linker/lld/target.cmake). This doesn't really harm anything as
it isn't duplicated on the link line (and specifying it multiple times
wouldn't hurt even if it was), but it also doesn't really help anything.

-fuse-ld isn't baremetal-specific and setting it via TOOLCHAIN_LD_FLAGS
will cover this case anyway, so remove this duplicate.

Signed-off-by: Jonathon Penix <jpenix@quicinc.com>
2024-11-16 15:56:42 -05:00
Torsten Rasmussen
cc488787ea cmake: source dedicated linker library properties for native builds
Native builds uses system libraries per default.
Instead of handling this in each linker_libraries.cmake files, then the
check for native build is moved one level up and for native build a
dedicated linker_libraries_native.cmake is sourced.

This simplifies the linker_libraries.cmake files as they no longer need
to check for native builds.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2024-11-16 15:28:20 -05:00
Torsten Rasmussen
d2896df821 cmake: set minimal C++ linker properties in minimal C++ CMake impl
The property based toolchain integration allows a cleaner design by
letting the toolchain define its properties and values and let CMake
implementation of Zephyr provided C and C++ libraries adjust those
properties when minimal C or C++ libraries are used.

This commit moves handling of C++ linker library properties into
the minimal C++ CMake implementation.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2024-11-16 15:28:20 -05:00
Guennadi Liakhovetski
e2d8daae16 LLEXT: Xtensa: add a Kconfig option to enable -fPIC
Currently when building LLEXT for Xtensa we use the -fPIC compiler
option, but this cannot be used when using detached sections in
extensions. Add a Kconfig option to switch between the two
compilation modes and switch -fPIC off when building relocatable
(partially linked) ELF binaries.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
2024-11-16 15:28:00 -05:00
Simon Hein
d4da23e3c3 sca: Add cmake options file for tool configuration
Add a cmake file which uses the cmake options feature
and include it inot the sca.cmake file to set up and describe
the options for the ECLAIR tool.

Signed-off-by: Simon Hein <Shein@baumer.com>
2024-11-16 15:18:57 -05:00
Simon Hein
e0db9ce948 sca: Add ECLAIR sca cmake implementation
Add the ECLAIR calls for the zephyr cmake environment to call
ECLAIR while the firmware is build by replacing the actual compiler
call and setup the eclair environment and call the compiler through
the eclair.

The Integration accepts a kconfig file for configuring the
analysis and the generation of the reports. The path of the
kconfig file should be provided via the variable ECLAIR_CONFIG.

db_generation.ecl has be created and introduced instead of
reports.ecl because the report generation is handled by the
sca.cmake directly.

Signed-off-by: Simon Hein <Shein@baumer.com>
2024-11-16 15:18:57 -05:00
Simon Hein
4c7d86a8b5 sca: Add ECLAIR SCA configuration files.
Add the Eclair configuration files, which are needed to
configure the static code analysis tool for the zephyr
coding guidelines.

Signed-off-by: Simon Hein <Shein@baumer.com>
2024-11-16 15:18:57 -05:00
Lauren Murphy
99a5236b40 llext: add support for arc
Adds compiler flag(s) and some architecture-specific relocations
for ARC. No userspace support, doesn't support all relocations.

Signed-off-by: Lauren Murphy <lauren.murphy@intel.com>
2024-11-16 15:08:51 -05:00
Mark Inderhees
c9d6c4c744 compiler: for xtensa add libgcc support
In order to compile with C++ exception handling for xtensa, the libgcc
location needs to be known. This change uses the same logic from gcc's
target.cmake to query the compiler for libgcc location and add the lib
to the include list.

Signed-off-by: Mark Inderhees <markind@meta.com>
2024-11-16 14:07:30 -05:00
Daniel DeGrasse
0ea212918f cmake: extensions: use INTERFACE_SOURCES as property for code relocation
In order to enable code relocation, we use a custom target
(code_data_relocation_target), and add files we wish to relocate, as
well as which sections should be relocated to the COMPILE_DEFINITIONS
property for the target.

This approach has been fragile, because COMPILE_DEFINITIONS can also be
added to for all targets using `add_definitions`. This means if another
part of the project uses `add_definitions` and
CONFIG_CODE_DATA_RELOCATION is on, a warning will appear about the
"file" not being found. The "file" of course, is just the definition
added by `add_definitions`.

To work around this, switch to overloading the INTERFACE_SOURCES
property. This property should be a bit more robust, because nobody else
will add sources to the code_data_relocation_target.

However, this approach has the downside that the CMake documentation
pstates targets created with `add_custom_target()` (which the
code_data_relocation_target is) do not have an INTERFACE scope for
their sources- so while this approach works, it is not officially
supported by CMake

Fixes #60220

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
2024-11-16 13:35:36 -05:00
Jamie McCrae
ed8f613e55 cmake: dts: Use temporary file for dts.cmake
Uses a temporary file for dts output then uses CMake to copy to the
correct file if it has changed. This prevents a ping-pong issue when
sysbuild is used of configuring and building cycle when nothing has
changed and there is sysbuild code which loads in the devicetree
data from an image

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2024-11-16 13:31:02 -05:00
Daniel DeGrasse
6023d6a142 arch: common: fix copy for ramfunc region during XIP init
ramfunc region is copied into RAM from FLASH region during XIP init. We
copy from the loadaddr of the region, and were previously loading to the
symbol __ramfunc_start. This is incorrect when using an MPU with
alignment requirements, as the __ramfunc_start symbol may have padding
placed before it in the region. The __ramfunc_start symbol still needs
to be aligned in order to be used by the MPU though, so define a new
symbol __ramfunc_region_start, and use that symbol when copying the
__ramfunc region from FLASH to RAM.

Fixes #75296

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
2024-11-06 10:19:08 -08:00