Commit graph zephyr/cmake
Author SHA1 Message Date
Jukka Rissanen
82d3218a7c cmake: extension: Add support for generating shell aliases
Create generate_shell_aliases_inc_file_for_target() function that
can be used to convert shell aliases file to a format that can be
included in the shell to support aliases.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-05-11 15:30:56 +01:00
Grzegorz Swiderski
ab9ce931fd cmake: kconfig: Skip creating Kconfig target on a variant image
This replaces a workaround in `ExternalZephyrVariantProject_Add()` -
setting KCONFIG_TARGETS-NOTFOUND - which turned out to be incomplete.
For example, it had no way of accounting for EXTRA_KCONFIG_TARGETS
(which could be set on the command line or through something like
`ZephyrBuildConfig.cmake`).

Instead, the creation of `menuconfig` and friends can be gated on
KCONFIG_VARIANT_SOURCE, which is the variable sysbuild uses to forward
the source configuration to the variant image. This way, both lists of
Kconfig targets are excluded reliably.

Signed-off-by: Grzegorz Swiderski <grzegorz.swiderski@nordicsemi.no>
2026-05-11 13:41:35 +02:00
Jamie McCrae
1c65d60a40 cmake: Add support for dts RAM configuration
Allows using the chosen SRAM node for RAM configuration without
using Kconfig values

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2026-05-11 08:45:38 +02:00
Fin Maaß
721f9e7e39 cmake: qemu: virtio: mmio: force non legacy mode
Our virtio driver in the zephyr tree only supports
version 2 and not the legacy one, therefore force it
to be used. Needed for the riscv virt target.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2026-05-07 18:11:21 -05:00
Guðni Már Gilbert
2339819829 cmake: modules: remove edt.pickle.cmake.new
Follow the same logic as in dts.cmake, where after:

zephyr_file_copy(file.new file.old ONLY_IF_DIFFERENT)

the .new file is removed.

Signed-off-by: Guðni Már Gilbert <gudni.m.g@gmail.com>
2026-05-06 07:08:57 +02:00
Christoph Busold
88278fb59f drivers: entropy + random: Add implementations for ARM64 RNG
Add new implementations for entropy driver and random subsystem
based on ARM64 RNDRRS and RNDR instructions.

Signed-off-by: Christoph Busold <cbusold@qti.qualcomm.com>
2026-05-06 07:05:12 +02:00
Luca Burelli
a97b5f221b llext-edk: capture full build properties for EDK export
The current implementation of the LLEXT EDK exports only a partial set
of compiler settings to the EDK build system, specifically only the ones
defined by the Zephyr core (the 'zephyr_interface' target). Extending
this to include application and module-specific settings (from the 'app'
target and its dependencies) is tricky, because:
- while evaluating the main CMakeLists.txt, the 'app' target is not
  fully configured yet, and
- using generator expressions is not possible due to CMake not allowing
  expansion of $<COMPILE_LANGUAGE:...> outside of a proper compile
  context.

To work around this, this change introduces a new CMake subdirectory
(misc/llext_edk) that creates a dummy target which imports the build
configuration from 'app', but overrides the C compile rules to simply
output the resulting properties (defines, include directories, flags)
to text files. The EDK generation script then reads those text files
to get the full set of build properties, and includes them in the EDK
tarball.

Signed-off-by: Luca Burelli <l.burelli@arduino.cc>
2026-05-04 14:53:03 +02:00
Luca Burelli
1ad11e0bcf llext-edk: remove 'llext_filter_zephyr_flags' helper function
This function was introduced when the EDK was first implemented to reuse
the flag filtering code in 'add_llext_target'.

After moving the EDK filtering code to a later stage where simpler regex
eplacements can be used, the helper function is used only in its former
location and is no longer needed. Remove the otherwise-unused public
function to simplify the codebase.

This is a revert of commit dc8d7ada19
("cmake/modules: Extract flags filtering code to a function") with
minimal code style cleanups.

Signed-off-by: Luca Burelli <l.burelli@arduino.cc>
2026-05-04 14:53:03 +02:00
Luca Burelli
b367b34bb9 llext-edk: (refact) filter flags in post-processing step
This changes the LLEXT EDK flag filtering to be done after the main
Zephyr build is completed. Instead of filtering the flags via genexes,
the full set is passed to the script along with the set of filters to be
applied, and the filter is applied later.

No functional change is intended.

Signed-off-by: Luca Burelli <l.burelli@arduino.cc>
2026-05-04 14:53:03 +02:00
Torsten Rasmussen
db3f25dd2e cmake: support printing of variables in package_helper
Using package helper for running CMake for Zephyr.
This commit provides to option to also print the value of a Zephyr CMake
variable when Zephyr modules have been loaded.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2026-04-27 14:18:43 +02:00
Jamie McCrae
730b44f422 sysbuild: Add variant image CMake module file
Adds variant image handling CMake code which re-uses parts of the
original dts CMake module code but applies variant-specific parts

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2026-04-27 14:14:35 +02:00
Jason Yu
ad827a78ca lib: libc: iar: Fix build error when IAR_LIBC enabled.
Export the resolved K_HEAP_MEM_POOL_SIZE value to the
linker generator and evaluate it while generating the
IAR command file.

Fixes: #107234

Signed-off-by: Jason Yu <zejiang.yu@nxp.com>
2026-04-25 08:21:27 +02:00
Luca Ciucci
3930e5f9ee sca: update ECLAIR configuration hierarchy
Users may want to use a custom toolchain configuration. Moving this
inclusion to `zephyr_common_config.ecl` allows user-defined rulesets
to control this aspect.

Signed-off-by: Luca Ciucci <luca.ciucci@bugseng.com>
2026-04-24 10:29:51 -04:00
Roberto Bagnara
5d91d11c50 sca: fix toolchain.ecl and stick to C18
The "used_compiler" variable name was erroneously used as a pattern
instead of being expanded and concatenated in the file_tag matcher.

Some configurations were inconsistently matching C99 and C18 standards.
With this change, the generic "c" matcher is used. References to the
standard are updated to C18 ("C_STD").

Signed-off-by: Roberto Bagnara <roberto.bagnara@bugseng.com>
Signed-off-by: Luca Ciucci <luca.ciucci@bugseng.com>
2026-04-24 10:29:51 -04:00
Luca Ciucci
84f513e053 sca: sca_options.cmake should always be included
sca_options.cmake defines the ECLAIR-related options, so it should
always be included.
Consistency checks on these options are moved to sca.cmake. This way
they are applied after the conditional inclusion of the
ECLAIR_OPTIONS_FILE.

Signed-off-by: Luca Ciucci <luca.ciucci@bugseng.com>
2026-04-24 10:29:51 -04:00
Luca Ciucci
4c3a21a570 sca: fix typo in ECLAIR option name
The typo prevented HTML output from being generated.

Signed-off-by: Luca Ciucci <luca.ciucci@bugseng.com>
2026-04-24 10:29:51 -04:00
Luca Ciucci
6581f720db sca: fix target dependency
The analysis directory setup should happen before the project analysis.

This missing dependency would otherwise cause non-deterministic
failures of the analysis, as the directory could be removed while
ECLAIR is producing analysis frame files.

Signed-off-by: Luca Ciucci <luca.ciucci@bugseng.com>
2026-04-24 10:29:51 -04:00
Luca Ciucci
0aef104c82 sca: fix ECLAIR options file inclusion
The options set in ECLAIR_OPTIONS_FILE would be overwritten by the
subsequent "set" commands (e.g. `set(ECLAIR_ENV_ADDITIONAL_OPTIONS "")`).

By moving the inclusion of the options file below these commands, we
avoid this unwanted behavior.

Signed-off-by: Luca Ciucci <luca.ciucci@bugseng.com>
2026-04-24 10:29:51 -04:00
Luca Ciucci
40ef43feed sca: fix passing of ECLAIR_ENV_ADDITIONAL_OPTIONS
ECLAIR_ENV_ADDITIONAL_OPTIONS is a semicolon-separated list. Expanding
the variable directly would produce an invalid option for ECLAIR.

By joining the list with spaces, ECLAIR will receive the arguments
separately as expected.

Signed-off-by: Luca Ciucci <luca.ciucci@bugseng.com>
2026-04-24 10:29:51 -04:00
Luca Ciucci
10959ff526 sca: fix toolchain aliases in ECLAIR configuration
This change disables ECLAIR's default toolchain aliases and sets them
to the exact toolchain paths that are used in the build.

This also simplifies ECLAIR analyses on MacOS systems, where using
ECLAIR's default path-based trap would require additional setup.

Signed-off-by: Luca Ciucci <luca.ciucci@bugseng.com>
2026-04-24 10:29:51 -04:00
Jamie McCrae
709e9e4709 cmake: modules: dts: Rework functions into module
Reworks this to use modular code which can be used from other
modules

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2026-04-20 18:03:09 +02:00
Jamie McCrae
526f124f06 cmake: modules: zephyr_default: Add init calls
Allows calling an init function/macro inside of zephyr module
files, this allows for making it easier to reuse/override module
CMake code

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2026-04-20 18:03:09 +02:00
Yves Wang
2b20b92e53 scripts: dashboard: serve via http server instead of opening file path
The previous webbrowser.open(file_path) approach fails under WSL
because Windows cannot open files via UNC paths. Use a local HTTP
server instead, which works reliably across more platforms.

Also add USES_TERMINAL to the CMake dashboard target so that log
output is visible.

Signed-off-by: Yves Wang <zhengjia.wang@nxp.com>
2026-04-16 10:14:44 +02:00
Pete Johanson
ca53d65386 cmake: Handle multiple shield when running menuconfig, etc targets
Don't use COMMAND_EXPAND_LISTS for the targets added for menuconfig,
guiconfig, etc. so the list of shields is properly quoted when including
multiples with a semicolon separator.

Signed-off-by: Pete Johanson <pete.johanson@analog.com>
2026-04-14 22:35:28 -04:00
Gaetan Perrot
c215bb17a6 cmake: fix typos in comments and documentation
Fix multiple spelling mistakes and typos in CMake
and ECL files, including:

- "warnigs" -> "warnings"
- "tihs" -> "this"
- "provied" -> "provided"
- "singlular" -> "singular"
- "exchangable" -> "exchangeable"
- "desciption" -> "description"
- "initalizer" -> "initializer"
- "Identifers" -> "Identifiers"

These changes improve readability and maintain
consistency in documentation without affecting
functionality.

Signed-off-by: Gaetan Perrot <gaetan.perrot@spacecubics.com>
2026-04-14 22:26:24 -04:00
Jason Yu
6d789dd9cd cmake: toolchain: Update iar toolchain for Zephyr SDK 1.0.0
The iar toolchain fails to build after the update to the
1.0.0 Zephyr SDK. The path to the gnu toolchains
was updated to '${ZEPHYR_SDK_INSTALL_DIR}/gnu/'
in order to be compatible with the 1.0.0 SDK.

Signed-off-by: Jason Yu <zejiang.yu@nxp.com>
2026-04-07 11:44:06 -05:00
Christopher Turner
5f856e68af cmake: toolchain: Update arcmwdt toolchain for Zephyr SDK 1.0.0
The arcmwdt toolchain fails to build after the update to the
1.0.0 Zephyr SDK. The path to the generic.cmake in the toolchain
was updated to '${ZEPHYR_SDK_INSTALL_DIR}/cmake/zephyr/gnu/target.cmake'
in order to be compatible with the 1.0.0 SDK. This commit also
sets the required zephyr SDK to 1.0 as the SDK is no longer backwards
compatible and will fail to build with any version less than 1.0.

Signed-off-by: Christopher Turner <christopher.g.turner@intel.com>
2026-03-23 17:40:07 -05:00
Graham Roff
22c8923263 scripts: Add script to generate an HTML dashboard
This change adds a script to generate an HTML dashboard, invoked via
west, providing a consolidated and user-friendly view of various build
artifacts and metrics. This includes footprint information (as both
tables and plots), configuration tracing, sys init levels, an interactive
devicetree browser, and more.

Signed-off-by: Graham Roff <grahamr@qti.qualcomm.com>
Signed-off-by: Martí Bolívar <mbolivar@oss.qualcomm.com>
2026-03-23 13:57:34 -04:00
Tony Han
7cffa7d563 cmake: gcc-m-cpu: add compile option -mcpu=arm926ej-s for ARM926EJ-S
Add "-mcpu=arm926ej-s" to the compile option when building for
ARM926EJ-S CPUs.

Signed-off-by: Tony Han <tony.han@microchip.com>
2026-03-23 12:27:55 -05:00
Daniel Leung
2fe13e53ab cmake: emu: add support to run whisper
This adds the bits to support running whisper as simulator
so that we can do west build with debug and run targets.
The simulator is used for simulating SweRV SoCs.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2026-03-23 08:56:34 -04:00
Joel Holdsworth
eb19e96291 cmake: emu: qemu: Add binary suffix for or1k architecture
The Qemu emulator executable for the OpenRISC 1000 (or1k) architecture is
named qemu-or1k. This patch adds this information to the qemu architecture
suffix list.

Signed-off-by: Joel Holdsworth <jholdsworth@nvidia.com>
2026-03-21 07:50:57 -05:00
Henrik Brix Andersen
092485f407 toolchain: add support for verilog memory hex dump output
Add support for producing a zephyr.mem binary in Verilog memory hex dump
output format. This requires binutils v2.40 or newer.

Signed-off-by: Henrik Brix Andersen <henrik@brixandersen.dk>
2026-03-21 00:49:20 +00:00
Jamie McCrae
96137acb4c cmake: linker_script: arm: Add support for zephyr,mapped-partition
Adds support for using this new binding

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2026-03-20 09:54:59 -05:00
Maximilian Zimmermann
7205044c7c drivers: display: add new driver for qemu ramfb
The driver implements the QEMU ramfb as a framebuffer-based display.
It only implements the basic capabilities necessary (ARGB8888) with
resolution configurable via DTS. For initialization it uses the fwcfg
driver.

Signed-off-by: Maximilian Zimmermann <gitmz@posteo.de>
2026-03-20 18:19:54 +09:00
Duy Nguyen
66d3edce9b compiler: gcc: Update build config for RX board
ZephyrSDK v1.0.0 is updated to support RXv2 and RXv3 instruction
this update the gcc cmake configuration for RX build on Zephyr SDK
for RXv2 and RXv3 MCU

Signed-off-by: Duy Nguyen <duy.nguyen.xa@renesas.com>
2026-03-19 15:27:18 +09:00
Sylvio Alves
d8215fe289 cmake: remove deprecated espressif toolchain variant
The espressif toolchain variant (ZEPHYR_TOOLCHAIN_VARIANT=espressif)
has not been used for years. Espressif targets are now built using the
Zephyr SDK, which bundles the required Xtensa and RISC-V toolchains.

Remove the cmake/toolchain/espressif/ directory containing generic.cmake,
target.cmake, and Kconfig files that implemented this variant. Also
clean up references in the coredump xtensa gdb stubs, removing the
ESPRESSIF toolchain enum value and related handling code.

Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
2026-03-18 15:25:03 -05:00
Stephanos Ioannidis
d204d24876 cmake: Set minimum required Zephyr SDK version to 1.0
This commit updates the minimum required Zephyr SDK version to 1.0.

This is mandated by the new SDK directory layout scheme as well as the dual
(GNU and LLVM) compiler support in the SDK.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2026-03-17 15:43:52 -04:00
Keith Packard
8a6ef440c5 cmake: Support both toolchain directory layouts
Until https://github.com/zephyrproject-rtos/sdk-ng/pull/936 is merged,
SDK 0.18 is incompatible with previous versions as the paths to
find the cmake bits is different.

Deal with that by checking for files in the wrong place as well as the
right one.

Signed-off-by: Keith Packard <keithp@keithp.com>
2026-03-17 15:43:52 -04:00
Anas Nashif
bfdce6d25f cmake: toolchain: support multiple compiler types for Zephyr SDK
Support specifying compiler type for Zephyr SDK in the
ZEPHYR_TOOLCHAIN_VARIANT variable.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2026-03-17 15:43:52 -04:00
Anas Nashif
180f667812 cmake: toolchain: combine host variants
Combine toolchains provided by the host into one variant. This includes
both gcc and llvm installation typically coming from the distribution
(on Linux).

Both gcc and llvm are now part of the 'host' variant, the default is the
gnu compiler, so setting

	ZEPHYR_TOOLCHAIN_VARIANT=host

Will select the gnu compiler. To select llvm or any other compuler
provided in this variant, use the follwoing format:

	ZEPHYR_TOOLCHAIN_VARIANT=<variant>/<compiler>

The following will select llvm:

	ZEPHYR_TOOLCHAIN_VARIANT=host/llvm

Although gnu is the default, it can also be selected using the above
syntax:

	ZEPHYR_TOOLCHAIN_VARIANT=host/gnu

This commit removes the llvm variant for now, it should be deperecated
in another commit to follow.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2026-03-17 15:43:52 -04:00
Stephanos Ioannidis
0f33efdd9e cmake: clang: Override -Wno-volatile with -Wno-deprecated-volatile
Override the GCC-specific `-Wno-volatile` flag specified by GCC
`compiler_flags.cmake` with the Clang-equivalent
`-Wno-deprecated-volatile`.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2026-03-17 15:43:52 -04:00
Stephanos Ioannidis
3e2af76f99 cmake: linker: lld: Do not link libc when minimal libc is used
When LLVM linker is used, the toolchain-provided C standard library is
always linked, even when the Zephyr minimal libc is selected, because `c`
is unconditionally specified in `link_order_library`, which causes `-lc` to
be specified in the linker flags.

This commit adds a check to ensure that `-lc` is not specified when the
Zephyr minimal libc is selected because it is a standalone C standard
library and it does not make sense to link two C standard libraries at
once.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2026-03-17 15:43:52 -04:00
Stephanos Ioannidis
7550cc1ae4 cmake: toolchain: Introduce TOOLCHAIN_HAS_LIBCXX
This commit introduces `TOOLCHAIN_HAS_LIBCXX` CMake variable, which is set
to `y` when LLVM C++ Standard Library aka. libc++ is available.

This helps filter libc++-specific Kconfig and tests in a more refined
manner.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2026-03-17 15:43:52 -04:00
Stephanos Ioannidis
d5f8b3032d cmake: toolchain: Introduce TOOLCHAIN_HAS_GLIBCXX
This commit introduces `TOOLCHAIN_HAS_GLIBCXX` CMake variable, which is
set to `y` when GNU C++ Standard Library aka. libstdc++ is available.

This helps filter libstdc++-specific Kconfig and tests in a more refined
manner.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2026-03-17 15:43:52 -04:00
Nicolas Pitre
cdbebacaec cmake: remove underscore prefix on local variables
Address review feedback: avoid _ prefixing local CMake variables
as it conflicts with the convention used for function overloading.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2026-03-16 19:05:49 -05:00
Andy Lin
6cb74ad968 arch: riscv: Add -msave-restore option to reduce code footprint
Add `-msave-restore` option to reduce the code footprint
of function prologue and epilogue.

Signed-off-by: Andy Lin <andylinpersonal@gmail.com>
2026-03-16 10:07:57 -04:00
Martin Lampacher
221650a5c9 cmake: sca: codechecker: Cppcheck integration
Prevent cppcheck-preprocessorErrorDirective failures by
passing includes to both autoconf.h and a generated header file
containing compiler-specific definitions to Cppcheck

Signed-off-by: Martin Lampacher <martin.lampacher@gmail.com>
2026-03-13 09:13:09 +01:00
Nicolas Pitre
dee349919b lib: heap: compute heap sizing constants from actual struct layouts
Z_HEAP_MIN_SIZE and Z_HEAP_MIN_SIZE_FOR were defined in kernel.h as
hardcoded magic numbers gated by a growing tower of #ifdefs — one
per Kconfig option that happened to affect the heap struct layout.
Every internal change required manually recomputing the constants,
duplicating layout knowledge across files, and praying nobody forgot
to update the #ifdef matrix.  This is fragile and unscalable: adding
a single new heap feature (e.g. a chunk canary trailer) would add yet
another dimension to the combinatorial explosion.

Replace this with build-time computation from the actual C structures.
A new lib/heap/heap_constants.c uses GEN_ABSOLUTE_SYM to emit the
correct values into a generated heap_constants.h header via the
zephyr_constants_library() infrastructure.  Z_HEAP_MIN_SIZE is
derived through an iterative fixed-point expansion (3 rounds, always
convergent) that mirrors the runtime logic in sys_heap_init().

Big vs small heap determination uses CONFIG_SYS_HEAP_SMALL_ONLY,
CONFIG_SYS_HEAP_BIG_ONLY, and sizeof(void *), mirroring the
big_heap_chunks() logic in heap.h.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2026-03-11 20:52:01 -04:00
Nicolas Pitre
b703f45ad5 cmake: add DEPENDS support to zephyr_constants_library()
Add an optional DEPENDS parameter to zephyr_constants_library() that
lists other constants libraries whose generated headers must be
produced before this library is compiled.  This creates proper build
ordering through add_dependencies() on the header-generation targets.

A build test with four constants libraries exercising various
dependency patterns (fan-in, fan-out, diamond) validates this.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2026-03-11 20:52:01 -04:00
Nicolas Pitre
1db0458480 cmake: add zephyr_constants_library() for build-time constants
Introduce a reusable CMake function that creates an OBJECT library
from a C source file containing GEN_ABSOLUTE_SYM() declarations and
generates a header file from the resulting symbols.  This encapsulates
the boilerplate needed for the offsets-style pattern: OBJECT library
creation, LTO prohibition, gen_offset_header.py invocation, and
dependency registration.

Convert the existing offsets.h generation to use this new function.

The zephyr_generated_headers target is moved earlier in CMakeLists.txt
so that subsystem CMakeLists.txt files can register generated headers
via zephyr_constants_library().

Also update gen_offset_header.py to derive the include guard from the
output filename instead of hardcoding __GEN_OFFSETS_H__, and remove the
unused input_name parameter.  This allows multiple generated headers to
coexist with distinct include guards.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2026-03-11 20:52:01 -04:00