Commit graph zephyr/cmake
Author SHA1 Message Date
Anas Nashif
373496795b cmake: sca: eclair: deviate Rule 16.1 for allowed terminal statements
ECLAIR's well-formed-switch check (Rule 16.1) reports a violation for any
non-empty switch clause that does not end with an explicit break, even when
the clause ends with another statement that unconditionally transfers
control. This is the case for the very common return-per-case lookup idiom
(e.g. TC_RESULT_TO_STR(), get_friendly_phase_name()), where adding a break
after the return would only create unreachable code.

Rule 16.3 already treats break, continue, goto, return and calls to
no-return functions as "allowed terminal statements" via the
r16_3_allowed_terminal selector. Reuse that same selector for Rule 16.1 so
the two rules agree on what terminates a switch clause.

Assisted-by: GitHub Copilot:claude-sonnet-4.6
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2026-08-05 13:54:03 +01:00
Anas Nashif
ee44d2ef77 cmake: sca: eclair: deviate four low-volume MISRA rules
Add deliberate/safe deviations for constructs that are intentional and
cannot or should not be changed:

  - Rule 8.12: CBPRINTF_PACKAGE_ARG_TYPE_COUNT is a deliberate readable
    alias of the implicit CBPRINTF_PACKAGE_ARG_TYPE_MAX bound, so the two
    enumeration constants intentionally share a value.

  - Rule 8.14: the POSIX headers must declare functions with the POSIX
    mandated signatures, which use the 'restrict' qualifier.

  - Rule 16.4: the switch statements in the fnmatch helpers are controlled
    by the RANGE_ERROR/RANGE_MATCH/RANGE_NOMATCH result of
    rangematch()/rangematch_cc(); all values are handled, so a default
    clause would be unreachable.

  - Rule 18.1: z_rb_foreach_next() indexes the iterator stack, which is
    bounded by the tree depth (<= Z_MAX_RBTREE_DEPTH) even though the
    analyser cannot prove it.

Assisted-by: GitHub Copilot:claude-sonnet-4.6
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2026-08-05 13:54:03 +01:00
Anas Nashif
12abeb9018 cmake: sca: eclair: deviate Rule 11.9 for deliberate null-pointer idioms
ECLAIR reports MISRA C:2012 Rule 11.9 (the macro NULL shall be the only
permitted form of integer null pointer constant) against several
deliberate constructs in core headers. The reports are smeared across
every call site that expands the macros, but the constructs are safe:

  - Z_ARGIFY(arg) uses '(0) ? 0 : (arg)' as a universal compatible-zero
    so it yields an rvalue of any argument type (integers, floating
    types, bitfields and opaque struct pointers). When arg is a pointer
    the 0 acts as a null pointer constant. This is required to keep the
    cbprintf argument packaging type-generic.

  - CONTAINER_OF_VALIDATE probes a field type with '((type *)0)->field'
    inside a BUILD_ASSERT. The expression is only used by
    __builtin_types_compatible_p / __typeof__ in an unevaluated context
    and the null pointer is never dereferenced.

  - K_MEM_VIRT_RAM_START expands to '((uint8_t
    *)CONFIG_KERNEL_VM_BASE)'.  On configurations where
    CONFIG_KERNEL_VM_BASE is 0 the constant denotes the base address of
    the kernel virtual memory region, not a null pointer.
    K_MEM_VIRT_RAM_END is defined in terms of it and is covered too.

Add deliberate deviations for all three, following the existing
__ACCESS_ONCE Rule 11.9 deviation.

Assisted-by: GitHub Copilot:claude-sonnet-4.6
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2026-08-05 13:54:03 +01:00
Anas Nashif
b7c7abb8cb cmake: sca: eclair: deviate Rule 18.3 for iterable-section iteration
Iterating over a Zephyr iterable linker section compares the iterator
against the section boundary markers (the generated _<type>_list_start and
_<type>_list_end symbols, also produced by STRUCT_SECTION_FOREACH, which
itself uses a relational comparison). The markers delimit a single
contiguous array, so the relational comparison is well defined even though
the analyser treats the two markers as pointers into separate objects.

Deviate Rule 18.3 for relational comparisons against the section end
marker. This covers both the STRUCT_SECTION_FOREACH macro and the
hand-rolled section loops (e.g. in the ztest runner). Unrelated Rule 18.3
reports (such as those from DEVICE_API_GET) are intentionally not covered.

Assisted-by: GitHub Copilot:claude-sonnet-4.6
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2026-08-05 13:54:03 +01:00
Benjamin Cabé
dfafa1f4f9 build: cmake: deprecate zephyr_file_copy()
zephyr_file_copy() only existed because file(COPY_FILE ...) was not
available with CMake 3.20. With the minimum required CMake version now
being 3.28.3, call the native command directly everywhere in-tree and
deprecate the wrapper, which is kept for out-of-tree users.

Assisted-by: Claude:fable-5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2026-08-03 15:03:35 -04:00
Benjamin Cabé
1a91c6bb9f build: cmake: remove checks obsoleted by CMake 3.28.0 requirement
Now that the minimum required CMake version is 3.28.0, remove version
checks and workarounds that can no longer trigger:

- the PyPI CMake 3.22.1 / 3.22.2 cmake_path() bug detection
- the CMakeError.log fallback name for the configure log, which has
  been CMakeConfigureLog.yaml since CMake 3.26
- the armclang generator check for CMake < 3.21

Assisted-by: Claude:fable-5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2026-08-03 15:03:35 -04:00
Benjamin Cabé
a119dbf957 build: bump minimum CMake version to 3.28.0
Raise the minimum required CMake version from 3.20.0 (documented as
3.20.5) to 3.28.0, which is satisfied by the CMake 3.28.3 package
shipped in the Ubuntu 24.04 LTS repositories. Ubuntu 24.04 is the
current Ubuntu LTS release targeted by the Zephyr getting started
guide, and by the time of the next Zephyr release, Ubuntu 22.04 will be
within months of its end of standard support. Users of distributions
shipping an older CMake can use the Kitware APT repository or a
pip-installed CMake, as the documentation already suggests.

Raising the floor to 3.28 unlocks a range of modern CMake features for
the build system, among which the cmake_file_api() command (3.27),
file(COPY_FILE) (3.21), block()/endblock() (3.25), and allows removal
of several version-conditional workarounds.

The tree-wide cmake_minimum_required() occurrences in samples, tests
and boards are updated accordingly, together with the documentation
and the sysbuild CMake presets. The IAR C-STAT integration keeps its
own higher requirement (4.1.0).

Assisted-by: Claude:fable-5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2026-08-03 15:03:35 -04:00
Zhiyuan Tang
2fbdc93cc9 cmake: gcc: fix double-precision FP codegen on single-precision Cortex-M55
commit 6612580d9e introduced PRECISION_TOKEN to pass -mfpu=fpv5-sp-d16
to GCC for Cortex-M55 SoCs with a single-precision-only FPU.

commit 570ef09d0f reverted FPU_FOR_cortex-m55 back to "auto" in the
shared gcc-m-fpu.cmake to fix a clang regression (clang treats an
explicit -mfpu= as a capability override, which silently disables
mve.fp).  However, GCC derives MVE capability from -mcpu alone and is
not affected by -mfpu=fpv5-sp-d16, so the revert was too broad: GCC
now also sees "auto" and assumes the full double-precision default
implied by -mcpu=cortex-m55, ignoring the SoC's actual hardware.

Fix this in the GCC-specific target_arm.cmake: when GCC_M_FPU is
"auto" and CPU_HAS_FPU_DOUBLE_PRECISION is not set, pass
-mfpu=fpv5-sp-d16 explicitly.  The clang and armclang paths already
skip -mfpu= for "auto" (commits 570ef09d0f and f30235f56a
respectively) and are unaffected.

Co-Authored-By: Claude <noreply@anthropic.com>
Signed-off-by: Zhiyuan Tang <zhiyuan_tang@realsil.com.cn>
2026-08-03 15:02:13 -04:00
Ashish Mahanth
68078955f7 cmake: toolchain: add XC32 toolchain configuration files
Add the XC32 toolchain configuration files needed for Zephyr
to detect and use the Microchip compiler toolchain with the
expected compile/link defaults.

Signed-off-by: Ashish Mahanth <ashish.mahanth@microchip.com>
2026-07-17 14:42:46 -05:00
Daniel DeGrasse
5a48d77ab7 cmake: add qemu support for pflash launch arguments
Add support for launching qemu with pflash.

Signed-off-by: Daniel DeGrasse <daniel.degrasse@analog.com>
2026-07-16 14:33:34 +02:00
Joel Holdsworth
8e6010a1bd cmake: emu: qemu: only add CAN bus when QEMU CAN hardware is needed
The previous condition (CONFIG_CAN && !CONFIG_SOC_LEON3) would add the
CAN bus QEMU object for any board with CAN enabled, even when the CAN
controller is not a QEMU-emulated device. This caused QEMU startup
failures on boards without QEMU CAN support.

Only add the CAN bus object when Kvaser PCI emulation or a SocketCAN
interface name is configured, which are the actual indicators that
QEMU-emulated CAN hardware is in use.

Signed-off-by: Joel Holdsworth <jholdsworth@nvidia.com>
2026-07-14 16:41:44 -04:00
Joel Holdsworth
81b6e13b36 arch: openrisc: add LLEXT ELF relocation support
Implement arch_elf_relocate() for the OpenRISC architecture to enable
the LLEXT (Linkable Loadable Extensions) subsystem.

Supported relocation types:
- R_OR1K_32, R_OR1K_32_PCREL (data)
- R_OR1K_INSN_REL_26 (26-bit PC-relative branch/jump)
- R_OR1K_HI_16_IN_INSN, R_OR1K_LO_16_IN_INSN (address pair)
- R_OR1K_AHI16 (adjusted high, sign-compensated)
- R_OR1K_SLO16 (split-immediate store encoding)
- R_OR1K_PCREL_PG21, R_OR1K_LO13, R_OR1K_SLO13 (page-relative)
- R_OR1K_TLS_LE_HI16, R_OR1K_TLS_LE_LO16, R_OR1K_TLS_LE_AHI16,
  R_OR1K_TLS_LE_SLO16, R_OR1K_TLS_TPOFF (TLS local-exec)

Signed-off-by: Joel Holdsworth <jholdsworth@nvidia.com>
2026-07-14 16:41:44 -04:00
Joel Holdsworth
5aa4def94c cmake: gcc: add target_openrisc.cmake to suppress RWX segment warning
OpenRISC runs code from RAM (non-XIP), so the single LOAD segment
legitimately needs RWX permissions. Add --no-warn-rwx-segments to
prevent ld >= 2.39 from turning this into an error under
--fatal-warnings.

Signed-off-by: Joel Holdsworth <jholdsworth@nvidia.com>
2026-07-14 16:41:44 -04:00
Evan Chen
a7214779d1 cmake: linker_script: arm: skip duplicate chosen ITCM region
Skip the ARM-specific chosen ITCM linker group when
the chosen node is already represented through
zephyr,memory-region.

This avoids generating duplicate ITCM execution
regions under armlink for boards that model the same
memory both ways.

Assisted-by: GitHub Copilot:GPT-5.4 [apply_patch] [run_in_terminal]
Signed-off-by: Evan Chen <bugena123@gmail.com>
2026-07-13 16:16:13 -05:00
Alberto Escolar Piedras
94f0908052 Revert "cmake: modules: hwm_v2: Narrowly load a SoC target"
This reverts commit cf15ee1fa6.

Unfortunately this commit has revealed quite a few issues in the tree.
Some are trivial to fix properly, but some are not.
Let's revert it to stabilize main while the issues are fixed.
After it can be merged back.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2026-07-13 18:06:00 +02:00
Jamie McCrae
cf15ee1fa6 cmake: modules: hwm_v2: Narrowly load a SoC target
This changes from loading all SoCs from python into CMake to just
loading the one that the user is using.

When configuring hello_world using sysbuild for
nrf52840dk/nrf52840, this results in a whole 1.7 second speed-up
on the system used for testing (12%)

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2026-07-13 16:40:01 +02:00
Anil Ozrenk
880b2cc6f5 cmake: toolchain: cross-compile: support per-board CROSS_COMPILE
Use zephyr_get() with VAR fallback to resolve CROSS_COMPILE and
CROSS_COMPILE_TOOLCHAIN_PATH per board target, falling back to the
global variable. This follows the same pattern used by XTENSA_CORE
in xcc/common.cmake.

Users can now set CROSS_COMPILE_<normalized_board_target> to specify
different toolchain prefixes for different boards without changing
the global CROSS_COMPILE between builds.

Signed-off-by: Anil Ozrenk <anil.ozrenk@analog.com>
2026-07-09 11:21:12 +01:00
Chao Liu
307d662344 cmake: generate module env files without west
Write the empty module environment fragments in the no-west path. This
keeps direct CMake builds from depending on files that are only produced
when west discovers modules.

Signed-off-by: Chao Liu <chao.liu@processmission.com>
2026-07-08 17:14:24 +01:00
Torsten Rasmussen
c04d206509 cmake: move gcov detection from generic.cmake to target.cmake files
gcov belongs in target.cmake and not generic.cmake.
generic.cmake are for generic tools that are needed during build system
generation, before the arch is known, for example for Kconfig
pre-processing.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2026-07-07 17:26:16 +01:00
Jamie McCrae
31da142a93 scripts: dts: gen_defines: Fix ZEPHYR_BASE output
Fixes this missing output, which helps with repducible build
debugging, to use the zephyr prefix when the bindings are located
there irrespective of if the (long deprecated) environmental value
is set

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2026-07-07 09:52:35 +02:00
Anas Nashif
6f268b6983 kernel: introduce kernel-internal init hooks
Add a lean, kernel-only initialization model to replace the kernel's
internal use of SYS_INIT. Kernel init order is fixed at compile time, so
these hooks drop the SYS_INIT level/priority machinery: a subsystem
registers a parameterless init function that the boot path runs at one of
two fixed phases.

  K_KERNEL_INIT_PRE(fn)   run in z_cstart() before PRE_KERNEL device init
  K_KERNEL_INIT_POST(fn)  run in bg_thread_main() before POST_KERNEL
                          device init

Each entry is a single function pointer placed, via an iterable section,
in the registering subsystem's own translation unit. The linker pulls
that unit (and the entry) into the image only when the subsystem is
otherwise referenced, so an init runs only when its subsystem is actually
linked. This preserves the pay-per-use linkage that SYS_INIT provided
while halving the per-entry size (one pointer versus init_entry's two) and
removing the level/priority sort. The boot-path walks reference only the
section bounds, so they never force a subsystem to be linked.

Assisted-by: Claude:claude-opus-4-8
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2026-07-06 15:10:55 -04:00
Anas Nashif
b2f233ed6a llext: add grouping linker script for relocatable partial link
lld's bare -r (--relocatable) places sections in encounter order without
grouping them by type, so a .TEXT.funcname section from one compilation
unit can end up between .text and .data sections from another unit in the
output file.

The LLEXT loader computes one contiguous file-offset region per
llext_mem type by spanning the min->max offsets of all sections of that
type.  Interleaved sections cause two regions' file-offset spans to
overlap, making the loader reject the ELF with -ENOEXEC.

GNU ld's internal default script implicitly groups *(.text .text.*) etc.
together during -r, so this is lld-specific.  Fix it by supplying an
explicit grouping linker script (-T) to the partial link step, selected
via the toolchain LINKER variable.  The script collects all text, rodata,
data, bss and init-array sections into contiguous output sections;
sections not mentioned (RELA tables, debug info, .riscv.attributes, etc.)
become orphans at the end and are ignored by the loader.

The loader classifies sections into regions by ELF flags rather than by
name, so custom-named sections created via Z_GENERIC_SECTION() must also
be grouped next to the matching type.  Sections that the tests inspect by
name (.my_rodata, .detach, .llext.rodata.noreloc) are given their own
output sections adjacent to that type group, so their identity survives
the link while keeping the region file-offset spans contiguous.

Assisted-by: Claude:Claude Opus 4.8
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2026-07-04 11:41:23 -04:00
Jamie McCrae
961b7a8019 cmake: yaml: Switch to JSON schema
Moves from the deprecated pykwalify to JSON schema

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2026-07-02 13:02:57 +01:00
Jinming Zhao
217e2913a1 lib: heap: kasan: lightweight heap write sanitizer for sys_heap
Lightweight write sanitizer for sys_heap.  Uses
-fsanitize=kernel-address compiler instrumentation combined with a
per-heap shadow bitarray (one bit per granule) to detect buffer
overflows, underflows, and use-after-free on write accesses.

Ships its own lightweight sanitizer runtime (__asan_store* callbacks);
does not depend on an external ASAN library and supports debugging on
real embedded targets.

Instrumentation is opt-in per CMake target via
zephyr_target_enable_heap_kasan(), or per directory via
zephyr_heap_kasan_enable_directory().  Only writes are checked
(-asan-instrument-reads=0).  Bulk-write library calls (memset,
memcpy, str*, printf family) are redirected to checked wrappers at
compile time via -Dfoo=__asan_foo, requiring no source changes in
application code.

Heap tracking is likewise opt-in: register each heap with
SYS_HEAP_KASAN_ENABLE() / K_HEAP_KASAN_ENABLE(), or enable
CONFIG_SYS_HEAP_KASAN_MALLOC / CONFIG_SYS_HEAP_KASAN_SYSTEM for the
common libc malloc and kernel system heaps.

Usage:

  CONFIG_SYS_HEAP_KASAN=y
  CONFIG_SYS_HEAP_KASAN_MALLOC=y   # auto-track malloc/free
  CONFIG_SYS_HEAP_KASAN_SYSTEM=y   # auto-track k_malloc/k_free

  # Instrument all sources of <target> (CMakeLists.txt)
  zephyr_target_enable_heap_kasan(app)
  # Or instrument sources under <dir>
  zephyr_heap_kasan_enable_directory(src/mymodule)

  /* Opt-in tracking for a custom heap */
  K_HEAP_DEFINE(my_heap, 4096);
  K_HEAP_KASAN_ENABLE(my_heap, 4096);

Signed-off-by: Jinming Zhao <jinmzhao@qti.qualcomm.com>
2026-07-01 05:21:22 -04:00
Liu Qian
ab0c08a6ce arch: riscv: add Zk and Zks ISA extension support
Add RISCV_ISA_EXT_ZK (Scalar Cryptography) and RISCV_ISA_EXT_ZKS
(ShangMi Suite) Kconfig options, and append them to the GCC march
flag when enabled.

Signed-off-by: Liu Qian <liuqian.andy@picoheart.com>
2026-06-29 13:56:59 -05:00
Jamie McCrae
9197ece1e8 scripts/cmake: Add monitoring for dts bindings being changed
Generates a new file for use by the build system which lists all
the paths to dts bindings used in a build, then from CMake adds a
dependency to these files so that if they are modified, CMake will
re-run.

This has been implemented by adding support to edtlib to output
details on bindings and binding paths inside of the python code

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2026-06-29 11:28:16 +02:00
Evan Chen
e84eb101c2 cmake: armlink: emit lowercase region symbol aliases
Generate lowercase aliases for region-derived
symbols when armlink creates names from uppercase
devicetree memory-region identifiers.

This provides symbols such as __itcm_start,
__itcm_load_start, and __itcm_size alongside the
uppercase forms expected by armlink.

Assisted-by: GitHub Copilot:GPT-5.4 [apply_patch] [run_in_terminal]
Signed-off-by: Evan Chen <bugena123@gmail.com>
2026-06-24 07:39:12 -04:00
Anas Nashif
63d9258505 cmake: sca: add include-what-you-use (IWYU) support
Add an SCA variant that enables include-what-you-use analysis via
CMake's built-in CMAKE_C_INCLUDE_WHAT_YOU_USE and
CMAKE_CXX_INCLUDE_WHAT_YOU_USE properties. The tool runs alongside the
compiler for each translation unit and reports unused includes and
includes that should be added.

The integration locates the include-what-you-use binary and forwards an
optional IWYU_OPTS list to the tool, prefixing each option with -Xiwyu as
required by the compiler-driven invocation.

Assisted-by: Claude:claude-opus-4-8
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2026-06-23 21:16:24 -04:00
Anas Nashif
30f52a744c cmake: fix various typos
Fix various typos under cmake/

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2026-06-23 09:12:58 -04:00
Nicolas Pitre
97fac4b782 kernel: mmu: remove LINKER_USE_PINNED_SECTION and __pinned_* tagging
CONFIG_LINKER_USE_PINNED_SECTION is the second half of the selective
kernel-pinning model removed in issue #108773. With the kernel image
now always resident at boot (previous commit), the __pinned_*
attribute family is a no-op: every page they would have segregated is
already pinned by z_mem_manage_init()'s whole-image loop, so the
tagging contract neither adds safety nor remains maintainable.

Drop it.

Mechanical removals:

* All ~219 in-tree uses of __pinned_text, __pinned_rodata,
  __pinned_data, __pinned_bss, __pinned_noinit, and __pinned_func
  across arch/x86, drivers/interrupt_controller, drivers/timer,
  arch/common, kernel, lib/libc, subsys/portability/posix, tests, and
  the syscall code generator (scripts/build/gen_syscalls.py).

* The assembly aliases PINNED_TEXT/RODATA/DATA/BSS/NOINIT used in
  arch/x86/core/ia32/*.S and drivers/interrupt_controller/
  intc_loapic_spurious.S become plain TEXT/RODATA/DATA/BSS/NOINIT.

* K_KERNEL_PINNED_STACK_DEFINE, K_KERNEL_PINNED_STACK_ARRAY_DEFINE,
  K_KERNEL_PINNED_STACK_ARRAY_DECLARE, K_THREAD_PINNED_STACK_DEFINE,
  and K_THREAD_PINNED_STACK_ARRAY_DEFINE are removed. The few
  in-tree callers (kernel/init.c, arch/arm/core/cortex_a_r/smp.c,
  arch/arm64/core/fatal.c, arch/rx/core/prep_c.c,
  arch/x86/core/prep_c.c, kernel/include/kernel_internal.h,
  tests/bluetooth/hci_uart_async) move to the corresponding
  non-pinned macros.

Machinery removals:

* Kconfig.zephyr drops CONFIG_LINKER_USE_PINNED_SECTION.
  qemu_x86_tiny and qemu_x86_atom_virt drop their =y overrides.

* include/zephyr/linker/section_tags.h drops the __pinned_* macro
  definitions (both arms). __isr collapses to an empty macro since
  its only purpose was to alias __pinned_func.

* include/zephyr/linker/sections.h drops PINNED_TEXT_SECTION_NAME,
  PINNED_BSS_SECTION_NAME, etc. and the bare PINNED_TEXT/RODATA/etc.
  forwarders, plus the _APP_SMEM_PINNED_SECTION_NAME constant.

* include/zephyr/linker/linker-defs.h drops the lnkr_pinned_*
  externs, the _app_smem_pinned_* externs, and the lnkr_is_pinned()
  / lnkr_is_region_pinned() inline helpers.

* include/zephyr/linker/utils.h drops the lnkr_pinned_rodata branch
  in linker_is_in_rodata().

* include/zephyr/linker/app_smem_pinned{,_aligned,_unaligned}.ld
  are deleted; cmake/linker/ld/target_configure.cmake stops
  configuring them.

* boards/qemu/x86/qemu_x86_tiny.ld and
  include/zephyr/arch/x86/ia32/linker.ld drop their pinned-section
  blocks and the now-redundant #ifndef CONFIG_LINKER_USE_PINNED_SECTION
  conditionals throughout the body. The
  LIB_KERNEL_IN_SECT / LIB_ARCH_X86_IN_SECT / LIB_ZEPHYR_IN_SECT /
  LIB_C_IN_SECT / LIB_DRIVERS_IN_SECT / LIB_SUBSYS_LOGGING_IN_SECT /
  LIB_ZEPHYR_OBJECT_FILE_IN_SECT / ZEPHYR_KERNEL_FUNCS_IN_SECT macros
  in qemu_x86_tiny.ld are deleted; they existed only to feed the
  pinned text/rodata/data/bss/noinit sections.

* kernel/mmu.c drops the mark_linker_section_pinned(lnkr_pinned_start,
  ...) call. The mark_linker_section_pinned() helper survives but is
  now gated only on CONFIG_LINKER_USE_BOOT_SECTION.

* arch/common/init.c and include/zephyr/arch/common/init.h drop
  arch_bss_zero_pinned(); arch/x86/core/ia32/crt0.S drops the call
  to it.

* arch/x86/core/userspace.c drops the eager k_mem_page_in() of the
  thread's privileged stack on user-mode entry. With the kernel
  image fully resident the stack is already mapped.

* arch/x86/gen_mmu.py drops map_region("lnkr_pinned") and the
  set_region_perms() calls for lnkr_pinned_text / lnkr_pinned_rodata.

* CMakeLists.txt drops the LINKER_USE_PINNED_SECTION block that
  generated APP_SMEM_PINNED_* variables and the
  pinned_partitions target property feeding gen_app_partitions.py.
  cmake/modules/extensions.cmake removes the PINNED_RODATA /
  PINNED_RAM_SECTIONS / PINNED_DATA_SECTIONS zephyr_linker_sources()
  location keywords and their snippet files.
  scripts/build/gen_app_partitions.py drops --pinoutput /
  --pinpartitions arguments and the pinned-output branch.
  subsys/testsuite/coverage/CMakeLists.txt drops its
  CONFIG_DEMAND_PAGING-conditional fork.

* scripts/build/gen_kobject_list.py drops the
  app_smem_pinned_start / _end fallback for kobject placement
  validation.

* tests/arch/x86/pagetables and tests/kernel/mem_protect/userspace
  drop their lnkr_pinned_text / lnkr_pinned_rodata branches.

* include/zephyr/arch/x86/ia32/arch.h folds IRQSTUBS_TEXT_SECTION
  to the unconditional ".text.irqstubs" form.

* tests/subsys/llext/src/syscalls_ext.c drops a stale comment about
  syscalls landing in .pinned_text.

Targeted retentions:

* arch/x86/core/bootargs.c keeps multiboot_cmdline and efi_bootargs
  in .noinit (was __pinned_noinit, which decayed to __noinit when
  LINKER_USE_PINNED_SECTION was unset). The multiboot and zefi loader
  paths write these buffers before Zephyr's BSS-zero step, so
  zeroing them at boot loses the cmdline.

* arch/x86/core/ia32/fatal.c keeps _df_esf and _df_stack in .noinit.
  They are scratch space written by the double-fault handler and have
  no zero-init requirement; keeping them in .noinit also preserves
  the historical post-noinit alignment that gen_mmu.py relies on
  (z_mapped_size is computed before CMake-injected iterable sections
  are appended to the linker script, so the post-noinit page padding
  is what keeps those sections within the mapped region).

* include/zephyr/arch/x86/ia32/syscall.h and
  include/zephyr/arch/x86/arch.h wrap the per-arch
  arch_syscall_invoke* / arch_is_user_context / arch_k_cycle_get_*
  implementations in @cond INTERNAL_HIDDEN. The public Doxygen
  contract lives on the prototypes in
  include/zephyr/arch/arch_interface.h; the per-arch implementations
  are internal. Without this, removing the __pinned_func attribute
  exposes the implementations to the doxygen-coverage delta check
  as 10 newly-undocumented APIs.

Documentation updates are deferred to a separate commit.

Issue: #108773

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2026-06-23 09:11:08 -04:00
Omar Naffaa
0bbd981df0 arch: riscv: Add support for Smaia and Ssaia extensions
As a part of the AIA specification two new extensions were introduced:
Smaia (Supervisor Machine AIA) and Ssaia (Supervisor Software AIA).
Support is added for these 2 extensions

Signed-off-by: Omar Naffaa <onaffaa@qti.qualcomm.com>
2026-06-22 15:48:32 +02:00
Evan Chen
13d1b5c8c1 cmake: armclang: fix C++ header search and AEABI flags
Avoid exporting the ARMClang builtin header path ahead of
libc++ for C++ builds, and restrict
_AEABI_PORTABILITY_LEVEL=1 to C and ASM.

This restores the expected C++ standard library include
behavior and avoids applying C-only AEABI portability
handling to libc++.

Assisted-by: GitHub Copilot:GPT-5.4 [apply_patch] [run_in_terminal]
Signed-off-by: Evan Chen <bugena123@gmail.com>
2026-06-19 11:10:42 +02:00
Anas Nashif
fe0dd27db9 cmake: clang: Fix no_global_merge flag compatibility
The -mno-global-merge flag is not recognized by Clang. Since GCC also
sets this property to an empty string, update Clang to match for
cross-platform compatibility. This fixes RISC-V builds with Clang.

Fixes build error on qemu_riscv32e with LLVM:
clang: error: argument unused during compilation: '-mno-global-merge'

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2026-06-17 10:14:59 -04:00
Nicolas Pitre
386df1e719 cmake: emu: armfvp: move board-specific firmware args out of generic runner
The generic armfvp.cmake assembled firmware loading arguments
(bp.secureflashloader, bp.flashloader0, cluster0.cpu0 --data) for
CONFIG_BUILD_WITH_TFA and CONFIG_ARMV8_A_NS that are specific to the
Base FVP model topology.  Other FVP models (e.g. Corstone-1000) with
different firmware loading schemes could not use these parameters.

Move these bp.* arguments to fvp_base_revc_2xaem/board.cmake where
they actually apply.  The generic runner now only falls back to the
"-a <elf>" application loading when the board hasn't set up its own
firmware arguments via CONFIG_BUILD_WITH_TFA or CONFIG_ARMV8_A_NS.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2026-06-17 12:00:17 +02:00
Daniel DeGrasse
b8b6d98c90 cmake: mcuboot: use mcuboot,image-ram for ram load address when present
Use mcuboot,image-ram for the ram load address when the property is
present as a chosen node for a given board.

Signed-off-by: Daniel DeGrasse <daniel.degrasse@analog.com>
2026-06-16 12:55:26 -05:00
Anas Nashif
ddb3225099 cmake: clang: Fix stack protector guard flag compatibility
Clang doesn't support -mstack-protector-guard flags that are used by
GCC.  These flags are particularly problematic on RISC-V where they
cause compilation failures.

Override the security_canaries properties in Clang to only include the
base -fstack-protector variants, removing the unsupported
-mstack-protector-guard flags inherited from GCC.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2026-06-16 17:47:15 +02:00
Siratul Islam
05d87c0fb9 fido2: add FIDO2/CTAP2 authenticator subsystem Kconfig
Add the subsys directory structure and Kconfig symbols

Signed-off-by: Siratul Islam <email@sirat.me>
2026-06-15 18:32:42 -04:00
Anas Nashif
dca09f5d7a ztest: add value-parameterized test infrastructure
Introduce a first-class value-parameterized test mechanism (ZTEST_P)
that works like GoogleTest TEST_P / INSTANTIATE_TEST_SUITE_P:

- A test body declared with ZTEST_P is executed once per registered
  parameter value; inside the body the current value is obtained
  through ztest_get_current_param() / ZTEST_GET_PARAM(type).

- The suite fixture returned by setup() is passed as the 'data'
  argument and is completely independent from the parameter; it is
  never overwritten (root cause of the previous misuse of ZTEST_P).

New public API in ztest_test.h:

  struct ztest_param_values    -- describes a typed value array
  struct ztest_param_inst      -- links a value set to a (suite, test) pair

  ZTEST_DEFINE_PARAM_VALUES(name, type, ...)
    Declare a static value set from literal values.

  ZTEST_DEFINE_PARAM_VALUES_ARRAY(name, array)
    Declare a static value set from an existing array.

  ZTEST_INSTANTIATE_TEST_SUITE_P(inst, suite, fn, values)
    Register a ztest_param_inst entry in the ztest_param_inst
    linker section; the runner dispatches once per value.

  ztest_get_current_param()        const void *  current value
  ZTEST_GET_PARAM_PTR(type)        const type *  typed pointer
  ZTEST_GET_PARAM(type)            type          typed value
  ztest_get_current_param_index()  size_t        zero-based index
  ztest_get_current_param_size()   size_t        element size
  ztest_has_current_param()        bool          is a param active?

New internals in ztest.c:

  struct z_ztest_param_ctx  -- per-invocation parameter context global
  z_ztest_find_param_inst() -- O(n) lookup over ztest_param_inst section
  z_ztest_run_test_dispatch() -- per-test dispatch; loops over values

The fixture-overwrite path ("if (param != NULL) { data = param; }")
is removed; the legacy 'param' argument of z_ztest_run_test_suite
and related internal functions is kept for ABI compatibility but
marked ARG_UNUSED.

The linker script gains Z_LINK_ITERABLE(ztest_param_inst) so the
start/end symbols required by STRUCT_SECTION_FOREACH are emitted.

Assisted-by: GitHub Copilot:claude-sonnet-4-5
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2026-06-15 12:17:37 -04:00
Carlo Caione
570589b2f7 cmake: qemu: keep host cursor visible with virtio input
An absolute pointing device makes QEMU hide the host cursor over the
guest display, but the guest does not draw one.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2026-06-15 10:24:27 +02:00
Anas Nashif
c05e59bd1f compiler: clang: Override LTO flags with Clang-compatible forms
Clang does not support the GCC-specific -flto=auto and -flto=1
flag forms, causing build failures when LTO is enabled with the
LLVM toolchain:

  clang: error: unsupported argument '1' to option '-flto='

Override optimization_lto and optimization_lto_st in the Clang
compiler flags to use the Clang-supported equivalents:

  - optimization_lto:    -flto=thin  (parallel, replaces -flto=auto)
  - optimization_lto_st: -flto=full  (single-threaded, replaces -flto=1)

Assisted-by: GitHub Copilot:claude-sonnet-4.6
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2026-06-12 15:33:09 +02:00
Anas Nashif
d030dea26d cmake: fix ARM llext module loading with clang
Define ARM-specific LLEXT compile flags for the clang toolchain
configuration to match GCC behavior.

This adds long-call code generation for extension objects and disables
unwind table emission in llext builds.

Also strip ARM unwind metadata sections from packaged .llext files so
the loader does not encounter relocations against non-loaded unwind
sections (.ARM.exidx/.ARM.extab and related rel sections).

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2026-06-12 07:53:32 +02:00
Anas Nashif
6bb0c37c55 cmake: compiler: fix cmake style issue
Remove space before '(' in if() statements.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2026-06-10 13:13:12 +02:00
Anas Nashif
570ef09d0f cmake: clang: fix MVE FP disabled on Cortex-M55 with -mfpu=fpv5-sp-d16
Two related problems caused clang/LLVM to disable MVE floating-point
(-mve.fp) when targeting Cortex-M55:

1. cmake/gcc-m-fpu.cmake set FPU_FOR_cortex-m55 to fpv5-sp-d16 (commit
   6612580d9e) to allow precision selection via PRECISION_TOKEN. For
   GCC this is harmless because GCC derives MVE capability from -march.
   For clang, -mfpu=fpv5-sp-d16 explicitly overrides the CPU's default
   FPU capabilities, which disables mve.fp:

     clang -mcpu=cortex-m55 -mfpu=fpv5-sp-d16 -> +nomve.fp  (wrong)
     clang -mcpu=cortex-m55                    -> +mve.fp    (correct)

   restore FPU_FOR_cortex-m55 to "auto". The +nomve.fp, +nomve and
   +nodsp variants keep fpv5-sp-d16 because they explicitly restrict FPU
   capabilities.

2. cmake/compiler/clang/target_arm.cmake unconditionally passed
   -mfpu=${GCC_M_FPU} when CONFIG_FPU is set, with no guard for "auto".
   The equivalent armclang fix was applied in commit f30235f56a but was
   never ported to the standalone clang toolchain path.

   add the same NOT "auto" guard as armclang/target.cmake.

Fixes #109009

Assisted-by: GitHub Copilot:claude-sonnet-4.6
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2026-06-10 13:13:12 +02:00
Anas Nashif
78f078f9d8 cmake: sca: fix Unix Makefiles generator byproduct dependency
With the Unix Makefiles generator, BYPRODUCTS declared in
add_custom_command(TARGET ... POST_BUILD ...) are not registered as
Make rules. The clang and codechecker SCA targets depended on sentinel
files (clang-sca.ready, codechecker.ready) that were byproducts of the
zephyr ELF POST_BUILD step, causing:

  No rule to make target 'sca/clang/clang-sca.ready'

Replace the sentinel file mechanism with cmake_language(DEFER CALL ...)
to add a direct add_dependencies() on logical_target_for_zephyr_elf
after it is defined. This works correctly with both the Ninja and Unix
Makefiles generators and preserves the same ordering guarantee: SCA
analysis runs only after the full ELF build completes.

Fixes #104755

Assisted-by: GitHub Copilot:claude-sonnet-4.6
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2026-06-10 13:13:03 +02:00
Torsten Rasmussen
82990ecb7b cmake: improve genex stripping from flags
Move `string(GENEX_STRIP ...)` before the loop.

We want to strip generator expressions from INTERFACE_COMPILE_OPTIONS.
This needs to be done before looping the list so that a compile  option
list like this: `--arg1;$<1:--genarg1;--genarg2>;--arg2` are correctly
processed as a list of
- --arg1
- --arg2

and not an invalid list of
- --arg1
- $<1:--genarg1
- --genarg2>
- --arg2

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2026-06-09 19:56:28 +02:00
Torsten Rasmussen
558fbe1579 cmake: add FindCcache.cmake as ccache.cmake replacement
Add FindCcache.cmake.

FindCcache.cmake allows Zephyr to use `find_package(Ccache <version>)`.
This provides a uniform way to lookup ccache and support ccache version
handling.

Minimum required ccache version is set to 4.12, as this version supports
the `--specs` argument properly.
47248c4

As part of this improvement, RULE_LAUNCH_COMPILE/LINK has been replaced
by the corresponding CMAKE_<lang>_COMPILER/LINKER_LAUNCHER.

To support existing system which might be setting CCACHE_IGNOREOPTIONS
in environment, the ccache v4.12 requirement is relaxed when this
environment setting is detected.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2026-06-09 10:29:11 +02:00
Silesh C V
ad249444a5 arch: arm: add support for Cortex-A32
Add support for the Cortex-A32 processor. The Cortex-A32 processor
is built on the ARMv8-A architecture and supports only the AArch32
execution state.

Signed-off-by: Silesh C V <silesh@alifsemi.com>
2026-06-09 08:41:24 +02:00
Jjateen Gundesha
b249bd7d34 cmake: extensions: disable LTO for code-relocated files
LTO changes section names in object files (e.g. .text becomes
.gnu.debuglto_.text), which breaks the section name parsing in
gen_relocate_app.py when CONFIG_CODE_DATA_RELOCATION=y.

Fix this by applying -fno-lto to any source files or libraries
registered via zephyr_code_relocate(), using the existing
compiler prohibit_lto property.

Remove the workaround filter from tests/kernel/common/testcase.yaml
that excluded kernel.common.lto and kernel.common.lto.singlethreaded
when CONFIG_CODE_DATA_RELOCATION was enabled.

Fixes #69730

Signed-off-by: Jjateen Gundesha <jjateen97@gmail.com>
2026-06-08 18:59:43 +02:00
Camille BAUD
04b060f83d arch: riscv: Add xthead extension support
Add support for xthead extension usage

Signed-off-by: Camille BAUD <mail@massdriver.space>
2026-06-08 13:56:38 +02:00
Muhammad Waleed Badar
75b002916e cmake: qemu: decouple display backend selection from ramfb
Enable SDL/Cocoa display backend for any CONFIG_DISPLAY target, not
only those using CONFIG_QEMU_RAMFB_DISPLAY. This allows boards with
their own display drivers (e.g. BCM2711 framebuffer) to get a QEMU
GUI window without requiring ramfb, while ramfb-specific flags remain
gated on CONFIG_QEMU_RAMFB_DISPLAY.

Signed-off-by: Muhammad Waleed Badar <walid.badar@gmail.com>
2026-06-08 09:10:03 +02:00