Commit graph

544 commits

Author SHA1 Message Date
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
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
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
Jamie McCrae
fa6c04b411 Revert "lib: heap: compute Z_HEAP_MIN_SIZE from actual struct layouts"
This reverts commit 518d8420c9.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2026-03-03 17:55:22 +01:00
Jamie McCrae
976ae48ce9 Revert "cmake: prohibit LTO for heap_constants.c offsets source"
This reverts commit 2d747e55a3.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2026-03-03 17:55:22 +01:00
Nicolas Pitre
2d747e55a3 cmake: prohibit LTO for heap_constants.c offsets source
Commit 518d8420c9 ("lib: heap: compute Z_HEAP_MIN_SIZE from actual
struct layouts") added heap_constants.c to the offsets library, but
did not add the prohibit_lto compile option that offsets.c has.
When LTO is enabled, the compiler optimizes away the absolute symbols
emitted by GEN_ABSOLUTE_SYM, causing them to be missing from the
generated offsets.h.  This breaks builds that use Z_HEAP_MIN_SIZE
(via kernel/mempool.c) with LTO-enabled configurations.

Fix by adding heap_constants.c to the same set_source_files_properties
call that disables LTO for offsets.c.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2026-02-28 10:10:18 +01:00
Nicolas Pitre
518d8420c9 lib: heap: compute Z_HEAP_MIN_SIZE 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 is compiled as part of the offsets
library and uses GEN_ABSOLUTE_SYM to emit the correct values into the
generated offsets.h.  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().  Z_HEAP_MIN_SIZE_FOR overhead and
bucket sizes are also generated, keeping all internal heap layout
knowledge in one place.

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.

kernel.h picks up the generated values via
__has_include(<zephyr/offsets.h>) so there is no circular dependency
with the offsets compilation itself.  The old _Z_HEAP_SIZE manual
sizeof and BUILD_ASSERT scaffolding in heap.c are removed.

gen_offset_header.py is updated to accept multiple input object files
so that the heap constants object can coexist with the per-arch offsets
object in the same offsets library.  COMMAND_EXPAND_LISTS is added to
the offsets generation custom command so that CMake correctly expands
the $<TARGET_OBJECTS:> generator expression into separate arguments
when the offsets library contains more than one object file.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2026-02-27 21:02:45 +00:00
Lauren Murphy
ebf1f9d019 tests: llext: fixes for arcmwdt, gcc
Adds fixes for build and runtime issues using MWDT:

* Rename sections for llext_memblk.c buffers as MWDT cannot initialize
  sys_mem_blocks struct with buffer address when the section name of
  sys_mem_blocks struct (its variable name) is identical to the
  buffer's section name
* Adds --no-check-sections flag for MWDT on final stages of
  linking. Unlike other toolchains, MWDT's default behavior is to
  strictly check and fail on section overlap. Using SLIDs requires
  overlap; see llext-sections.ld
* Modifies inspect test case's ifdef around rodata sections, as
  not all Harvard platforms using MWDT have .rodata_in_data sections -
  their creation is triggered by passing the -Hccm flag to CCAC.
  As an example, nsim/nsim_em doesn't have them and nsim/nsim_vpx5 does
* Removes -Hccm flag when building with CONFIG_LLEXT_RODATA_NO_RELOC
  as it causes CCAC to mark the custom section llext.rodata.noreloc
  writable (SHF_WRITE) though it has only read-only data, making it
  impossible for for LLEXT to recognize it and put it in the
  appropriate region; see llext_load.c's llext_map_sections
* Adds name to unnamed first argument of threads_objects_test_setup,
  removing warning about omitting parameter names being a
  C2x extension

Also fixes a build warning for GCC about pointer arithmetic in
the INSTR_FETCHABLE macro.

Signed-off-by: Lauren Murphy <lauren.murphy@intel.com>
2026-02-20 07:07:52 +01:00
Torsten Rasmussen
f04c9c0093 cmake: improve linker and assembly optimization inheritance
Switch manual linker and assembly inheritance settings from custom
handling of checking and setting linker/assembly optimization settings
based on compiler properties to instead use CMake's property inheritance
mechanism.

This reduces code to maintain as well as allow toolchain infrastructure
to clear optimization property flags when no flag is required or
supported, for example by the linker.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2026-01-30 16:58:13 -06:00
Daniel Leung
8776407309 cmake: compiler: add flags for VLIW generations
This adds to compiler flags template on instructing the compiler
on whether to generate VLIW instructions.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2026-01-29 16:09:13 -06:00
Mathieu Choplain
edbdfcad8c llext: add discarded symbol groups inspector
When the LLEXT subsystem detects that a symbol is marked for export from
the main image, but the symbol group in which the export belongs is not
enabled, add a marker in a special section in addition to not placing the
symbol in the final export table.

Add a post-build script which consumes the special section as post-build to
dump information about all discarded symbols in a build artifact, and also
check for common errors (missing Kconfig symbol / improperly named groups).

Signed-off-by: Mathieu Choplain <mathieu.choplain-ext@st.com>
2026-01-29 13:42:56 +01:00
Torsten Rasmussen
a99311ebc6 cmake: align board qualifiers in CMake with Kconfig
Follow-up to PR# 102385.

Some occurrences of ${BOARD}${BOARD_QUALIFIERS} was missed in the
original alignment PR.

This commit adjusts the remaining occurrences to know include `/`.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2026-01-27 08:41:15 -05:00
Tim Lin
2edece9d58 kernel: Add Kconfig option to disable LTO for kernel sources
Some SoCs require kernel code to be placed in RAM, which makes
link-time optimization (LTO) unsuitable for these files.
Disabling LTO allows the affected code to be linked as separate
objects and placed in specific memory regions.

Running kernel code from RAM can improve execution performance,
especially for timing-critical routines or context switch paths.

Signed-off-by: Tim Lin <tim2.lin@ite.corp-partner.google.com>
2026-01-21 17:04:50 +01:00
Mark Inderhees
234aa30a8f build: Dependency handling for syscall gen for changed API
Fix issue where changing an existing syscall API does not result in
regeneration of syscalls. This causes a build break on incremental
builds. The issue comes from an incorrect assumption that file
modifications result in updates to folder timestamps on Linux. The fix
is to use the same mechanism Windows is using to track file changes,
making explicit deps on header files that have syscalls.

Signed-off-by: Mark Inderhees <markind@meta.com>
2026-01-15 16:40:11 +00:00
Wilfried Chauveau
05dde46c4d build: cmake: print the board's qualifiers in the elf postbuild phase
When building for several cores of the same system it can be hard to
identify which build is currently running.
This addition helps disambiguate the logs.

Signed-off-by: Wilfried Chauveau <wilfried.chauveau@arm.com>
2026-01-14 09:19:39 -06:00
Jamie McCrae
1bbbb286b3 cmake: Remove old deprecated code
Removes code that was deprecated in Zephyr 4.0

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2026-01-08 09:50:19 +01:00
Alberto Escolar Piedras
d74ccc1bdb cmake: Do not warn on deprecated symbols w CONFIG_WARN_DEPRECATED=n
CONFIG_WARN_DEPRECATED is 'y' by default.
When a user actively disables CONFIG_WARN_DEPRECATED, one would expect
that they would stop getting all deprecation warnings, not just the
ones from kconfig.
Otherwise users continue getting tons of these warnings when building
deprecated functionality.

So let's indeed disable them also for symbols and macros.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2025-12-19 07:52:31 -06:00
Carles Cufi
d0547b67cd toolchain: gcc: Add a new LTO_SINGLE_THREADED option for LTO
As described in this issue:
https://github.com/zephyrproject-rtos/sdk-ng/issues/1038
`-flto=auto` fails on some (slower) Windows machines due to an issue with
the Zephyr SDK's GCC toolchain for Windows.
In order to allow users to work around this issue, introduce a new
CONFIG_LTO_SINGLE_THREADED option that switches to `-flto=1`, which
enforces a single thread when processing LTO.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2025-11-28 09:50:04 +00:00
Jamie McCrae
2a09063289 cmake: Allow specifying custom VERSION file dependency
Allows applications and projects to specify their own requirements
for the application VERSION file to be re-generated, this fixes an
issue whereby the application git repository is updated with a new
commit but the old commit is still used by a build, users would
need to add a dependency in their application to the git index file

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2025-10-31 22:41:26 +02:00
Anas Nashif
303af992e5 style: fix 'if (' usage in cmake files
Replace with 'if(' and 'else(' per the cmake style guidelines.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2025-10-29 11:44:13 +02:00
Kevin Townsend
03fcfcd0f2 cmake: compiler: Add func_instrumentation flag
Adds a new compiler flag to enable function instrumentation injection
at compile time for compilers that support it.

Adds support for this flag to GCC when `CONFIG_INSTRUMENTATION` is
enabled, setting the `-finstrument-functions` flag during compilation.

Signed-off-by: Kevin Townsend <kevin.townsend@linaro.org>
Signed-off-by: Gustavo Romero <gustavo.romero@linaro.org>
Signed-off-by: Maciej Sobkowski <msobkowski@antmicro.com>
2025-10-05 06:18:25 -04:00
Pierrick Guillaume
b7eec0fe24 cmake: linker: separate toolchain_ld_options() calls for grouped flags
Fixes #91045

Adding NO_SPLIT in the TOOLCHAIN_LD_FLAGS list caused every flags in the
list to be checked together by the linker. This caused issues where
incompatible flags was passed together, and the result was that none was
propagated to the linker.

By using separate variables, we can achieve the initial goal of NO_SPLIT to
only group a sub-set of flags.

Signed-off-by: Pierrick Guillaume <pguillaume@fymyte.com>
2025-09-30 19:36:37 +02:00
Ederson de Souza
08ec5e89fc cmake: New list for post build commands that should run early
New cmake list, `post_build_patch_elf_commands`, will be prepended to
`post_build_commands` one, effectively making these commands to run just
after the ELF is created. It's particularly useful for operations that
patch the ELF generated, before other representations of it (such as
.bin) are created.

Signed-off-by: Ederson de Souza <ederson.desouza@intel.com>
2025-09-02 07:56:48 +02:00
Dmitrii Sharshakov
8433c491b2 build: uf2: set offset when building RAM images
Follow ROMABLE_REGION from include/.../arm/cortex_m/scripts/linker.ld

This enables UF2 images to be created for RAM-only apps on RP2350.

Signed-off-by: Dmitrii Sharshakov <d3dx12.xx@gmail.com>
2025-09-01 16:40:54 +02:00
Keith Packard
d77b58aacb cmake: Delay computation of linker paths until needed
With inclusion of the optimization flag into the multilib selection
process, we cannot compute the compiler library path when the compiler's
target.cmake is processed as LINKER_OPTIMIZATION_FLAG is not computed until
much later.

Instead, add a function (compiler_file_path) which can be used to locate
the appropriate crtbegin.o and crtend.o files.

Delay computation of lib_include_dir and rt_library until after all
compiler flags have been computed by adding compiler_set_linker_properties
and calling that just before toolchain_linker_finalize is invoked.

Place default implementations of both of these functions in a new file,
cmake/compiler/target_template.cmake, where we assume the compiler works
like gcc or clang and handlers the --print-file-name and
--print-libgcc-file-name options. Compilers needing alternate
implementations can override these functions in their target.cmake files.

These implementations require that no generator expressions are necessary
for the compiler to compute the right library paths.

This mechanism is also used to take any additional compiler options by
adding a new (optional) linker function,
toolchain_linker_add_compiler_options, which maps compiler options to
equivalent linker options, discarding any that aren't applicable.

Signed-off-by: Keith Packard <keithp@keithp.com>
2025-08-13 22:13:24 -04:00
Keith Packard
d29cbf6563 cmake: Pass optimization flag to linker too
The linker may want to know the desired optimization level as when
the multilib configuration includes -Os as a selector.

Adopt the same pattern as the assembler optimization flags by allowing
toolchains to specify linker optimization flags which default to the
compiler optimization flags and the apply those using add_link_options.

Signed-off-by: Keith Packard <keithp@keithp.com>
2025-08-13 22:13:24 -04:00
Daniel Flodin
a4b66f9214 cmake: assembler optimization options
Commit f499ea0 made it so that the compiler optimization flags are also
passed to the assembler. However, this breaks for the IAR toolchain
since it uses the GNU assembler which does not have the same
optimization flags as the IAR compiler.

This commit separates the compiler and assembler optimizations to make
it possible to specify appropriate flags in a toolchains corresponding
`compiler_flags.cmake`

Signed-off-by: Daniel Flodin <daniel.flodin@iar.com>
2025-08-11 12:49:21 +03:00
Kesavan Yogeswaran
9f59461036 cmake: Clarify comment for zephyr_generated_headers library
Clean up the comment around the zephyr_generated_headers CMake library
to make it more accurate, now that the library is an interface library
rather than a custom target.

This is a follow-up to non-blocking feedback from
https://github.com/zephyrproject-rtos/zephyr/pull/92927.

Signed-off-by: Kesavan Yogeswaran <hikes@google.com>
2025-08-06 17:11:21 +03:00
Kesavan Yogeswaran
2aba39d870 cmake: Define zephyr_generated_headers as an interface library
Define `zephyr_generated_headers` as an interface library rather than a
custom target. This allows CMake libraries to depend on this target
AND propagate the dependency if needed using target_link_libraries.

Example:

If some user header includes offsets.h, even transitively, then
offsets.h must be generated before any source file that includes that
header is compiled. This can be captured by defining a library `foo` for
the header with a public link dependency on zephyr_generated_headers
using `target_link_libraries(foo zephyr_generated_headers)`. The
ordering dependency on the generated offsets.h header will then
propagate to `foo` and any libraries that link against `foo`, even
transitively. This was not possible before this CL because one cannot
use custom targets as public link dependencies with
target_link_libraries.

Signed-off-by: Kesavan Yogeswaran <hikes@google.com>
2025-07-31 10:51:43 +01:00
Adrian Bieri
5d42408efa cpp: add kconfig option STD_CPP23 for STD_CPP
to be able to choose c++23 dialect
deprecates c++2b, but we should keep the option c++2b for legacy

Signed-off-by: Adrian Bieri <adrian.bieri@loepfe.com>
2025-07-30 07:27:53 -04:00
Alberto Escolar Piedras
68391f2ecf cmake: Remove NATIVE_APPLICATION support
This mode of building has been removed, so we do not need to support it
in the top level cmake file either.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2025-07-19 09:38:15 +02:00
Daniel Leung
f499ea0a58 cmake: apply optimization flags to assembler
Commit 65471a6095 separated
compiler flags into ASM, C and CXX as those flags may not be
universal to both assembler and compiler. Though, with that
separation, the assembler no longer gets the optimization
flags (e.g. speed/size optimizations). So adds this back so
the assembler can optimize the code if it chooses to. For
example, some instructions can be fused together to result
in small code.

Fixes #92439

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2025-07-11 11:41:29 -10:00
Marcin Szymczyk
496cb0f46e cmake: add option to force raw instruction mnemonics
Some architectures use pseudo instructions in assembly.
Introduce an option that allows forcing raw instruction mnemonics.
Currently implemented for GNU binutils.

Signed-off-by: Marcin Szymczyk <marcin.szymczyk@nordicsemi.no>
2025-06-27 10:01:11 -05:00
Duy Nguyen
8322b22391 CMakeList: Disable gapfill for RX target
Ignore gapfill for RX target as some RX toolchains generate wrong
output image when running gapfill for binary format.

Signed-off-by: Duy Nguyen <duy.nguyen.xa@renesas.com>
2025-06-26 14:07:03 +02:00
Carles Cufi
892ac07a4a cmake: Add a new no_deprecation_warning compiler flag
Commit be40d854c2ccacf14ca3fcfb01bffdc9b075c6c9 introduced the ability
of building Zephyr with deprecation warnings enabled, by making
COMPILER_WARNINGS_AS_ERRORS depend on the newly added DEPRECATION_TEST
Kconfig option. This has the downside of disabling **all** warnings, not
only the deprecation ones.

This patch instead makes DEPRECATION_TEST disable only the deprecation
warning, but leaves COMPILER_WARNINGS_AS_ERRORS enabled.
This has the advantage of being able to see other unrelated warnings
(and fail if they appear) but has the disadvantage of not printing out
the deprecation warnings themselves (since they are disabled).

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2025-06-23 12:38:07 -07:00
Björn Bergman
bb797ab421 cmake: Fix compilation options for kobject_hash*.c
Rework how the compilation-options for the gperf generated
kobject_hash*.c files are put together to fix problems with SHELL:
and cmake-list separators handling.

zephyr_get_compile_options_for_lang_as_string() returns the set of
options as a cmake generator expression string which is cumbersome to
edit. This caused the command line for the IAR toolchain to have broken
SHELL: entries, and other some command line entries being postfixed by
"gnu".

This also adds CMake compiler properties for no_function_sections and
no_data_sections options

Signed-off-by: Björn Bergman <bjorn.bergman@iar.com>
2025-05-31 07:02:36 -04:00
David Schneider
d85ed3212c cmake: fix syscall dependencies
Replace _parse_syscalls_target_ custom target with explicit
dependency management for syscall depending file generation.

Signed-off-by: David Schneider <schneidav81@gmail.com>
2025-05-13 16:23:54 +02:00
Torsten Rasmussen
8f2560cf3e linker: discard eh_frame when C++ exceptions are disabled
Discard the eh_frame section when C++ exceptions are disabled.

In principle the eh_frame may be used for other purposes such as
backtracing when linking C programs, then Zephyr compiles each source
file with '-fno-asynchronous-unwind-tables', thus keeping the eh_frame
in the elf output just takes up space.

When using gcc/ld, then the eh_frame is generally generally discarded
per default, however for clang/lld it will be included but give a
warning that the section is auto-placed.

Some platforms already discards the eh_frame, so unify this for all
targets.

As eh_frame is now discarded in linker scripts then post processing step
of removing the section during hex or bin conversion can also be
removed.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2025-05-08 15:55:40 +02:00
Armin Brauns
d6efbc8af4 cmake: clean up gen_kobject_list.py invocations
cmake/kobj.cmake now provides nice wrappers around the script itself and
common uses.

Signed-off-by: Armin Brauns <armin.brauns@embedded-solutions.at>
2025-05-07 15:10:05 +02:00
Duy Nguyen
5fabd3634a CMake: Add support for .mot binary file format
The Renesas RX support flashing .mot file for binary image
This commit target to add the .mot file output for build and
flash script

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

This patch adds three new compiler properties:

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

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

Signed-off-by: Keith Packard <keithp@keithp.com>
2025-05-02 01:16:18 +02:00
Mirai SHINJO
56cf24e34d cmake: ensure -fstack-protector-explicit is applied to C++ targets
A typo in the top-level CMakeLists.txt prevented C++ targets from
receiving -fstack-protector-explicit when CONFIG_STACK_CANARIES_EXPLICIT=y.

Signed-off-by: Mirai SHINJO <oss@mshinjo.com>
2025-04-25 14:04:51 +02:00
Björn Bergman
128698fd36 cmake: userspace: A stab at USERSPACE + CMAKE_LINKER_GENERATOR
All in all this makes cmake linker generator able to work for at least
most of the kernel tests and samples, on cortex m4.

Make the cmake linker generator have a file-structure more similar to
the ld-skeletons.

Add or edit groups, sections and logic to make the generator reflect
what the ld-skeletons do, esp. for kobjects and APP_SMEM, nonint and
some other details are also effected.

Use the new zephyr_linker_include_generated() and
zephyr_linker_include_var() functions to to handle
${DEVICE_API_LINKER_SECTIONS_CMAKE}, the kobject-prebuilt-*.h files and
APP_SMEM partition. Essentially the output from gen_app_partitions.py,
gen_kobject_placeholders.py.

Add ALIGN_WITH_INPUT on sections being put into DATA_REGION. This makes
the init layout work for ld.

This leverages the updates in gen_app_partitions.py to generate its
output as cmake linker generator sections too, and puts them into a
group defined in linker.cmake

Setup generator variables for alignment of APP_SMEM. Note that this does
not yet handle MPU_ALIGN which depends on the size of the section...

Fix broken k_object_assignment iterable section

Signed-off-by: Björn Bergman <bjorn.bergman@iar.com>
2025-03-27 17:17:03 +01:00
Jamie McCrae
cc453dfed8 cmake: Remove previously deprecated look-ups
Removes functions that would handle deprecated variables and
functionality from CMake within Zephyr that were deprecated in
Zephyr 3.1 onwards but before 3.7

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2025-03-24 07:53:31 +01:00
Robin Kastberg
65471a6095 toolchain: stop C flags from leaking to the assembler
Currently the compiler and assembler shares many
properties. This can be problematic for non-GNU
toolchains that takes different parameters to the
assembler and compiler.

Signed-off-by: Robin Kastberg <robin.kastberg@iar.com>
2025-02-14 19:12:44 +00:00
Luca Burelli
c188dee334 llext-edk: add support for Zstd and Zip formats
This patch adds support for Zstd and Zip formats to the EDK generation
process. The user can now choose between XZ, Zstd, and Zip compression
and output formats for the EDK file.

Signed-off-by: Luca Burelli <l.burelli@arduino.cc>
2025-02-14 13:35:43 +01:00
Luca Burelli
d043a21426 llext-edk: add Kconfig option to enable EDK generation
Add a new Kconfig option to make the generation of an Extension
Development Kit (EDK) for the LLEXT subsystem optional. This
allows to cleanly separate EDK-related configuration and build
steps from the rest of the Zeprhyr build system.

Signed-off-by: Luca Burelli <l.burelli@arduino.cc>
2025-02-14 13:35:43 +01:00
Luca Burelli
5d3fe7e85a llext-edk: import data from build_info.yml and .config
Currently, the llext-edk.cmake script requires a number of variables to
be passed in from the main CMakeLists.txt file as arguments to be able
to customize the generated files.

To improve this rigid approach, the script is modified to read in the
following files in the build directory:

 * 'zephyr/.config', for the final set of Kconfig options used;
 * 'build_info.yml', for the cmake-related variables.

This is more flexible and also easier to maintain, as it doesn't require
manual changes to the main CMakelists.txt file when new variables need
to be referenced.

Signed-off-by: Luca Burelli <l.burelli@arduino.cc>
2025-02-07 17:45:45 +01:00
Jamie McCrae
2e436564a6 cmake: Configure custom linker script Kconfig before usage
Allows having CMake variables inside of this Kconfig to e.g. use a
value that can specify a board directory or path relative to a
CMake file location variable

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2025-01-10 09:50:19 +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