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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
Binutils 2.39 and above print out a warning when `.note.GNU-stack` section
is missing from an object file.
ld.bfd: warning: _thumb1_case_uqi.o: missing .note.GNU-stack section
implies executable stack
ld.bfd: NOTE: This behaviour is deprecated and will be removed in a
future version of the linker
This commit adds `-znoexecstack` when linking bare metal executables to
mark that stack is not executable when `.note.GNU-stack` section is
missing, effectively suppressing the above warning.
Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
The Cortex-M55 is available with single-precision and double-precision
FPUs. However, when setting -mfpu=auto, the compiler always seems to
guess that the CPU supports all features.
In contrast to other Cortex-M cores, there is no extension +nofp.dp
available, which would only disable the use of dual-precision
floating-point instructions. So we need to set the FPU features
explicitly.
See here for GCC docs on CPU extensions and FPU features:
https://gcc.gnu.org/onlinedocs/gcc-15.2.0/gcc/ARM-Options.html#index-mcpu-2
The explicit configuration of the precision also ensures that the Kconfig
CONFIG_CPU_HAS_FPU_DOUBLE_PRECISION is considered. In addition to that,
it matches the IAR settings.
Signed-off-by: Martin Jäger <martin.jaeger@a-labs.io>
Ensure the two BSIM variables BSIM_OUT_PATH and BSIM_COMPONENTS_PATH are
available everywhere also as a cmake variable as quite a few apps use
them. (Some apps try to get them as an environment var, some as a cmake
var).
When the user had them set in the environment, and the BabbleSim module
uses zephyr_get() to try to find them, this also sets them globally.
But otherwise, if we just deduced them in this module, we were only
setting them in the enviroment, so apps which expected them globally
would not build properly.
As bonus, add a cache variable to mark the module as found, so if
find_package(BabbleSim) is called again, we just skip it.
Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
This file is superfluous because it is exactly the same as the
normal bin file without the slot 1 designation, therefore exclude
it to prevent confusion to user
Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
Uses relative paths for the signed images, instead of absolute
paths, to allow transferring test files to other machines
Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
- Add a hidden symbol to indicate variable cleanup attribute support.
- Add a symbol to enable cleanup helper macros.
- Provide a macro for the cleanup attribute in the GCC toolchain.
- Disable IAR toolchain support.
Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
Update getting started guide, release notes, CI actions, ruff,
build system, and Python version compliance check to use Python
3.12 as minimum supported version.
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Compiler-generated FLIX instructions are currently disabled for LLEXT due
to a historic issue with LLEXT feature that appears to be already
resolved. However, another issue with FLIX is now being investigated.
The latter issue is not related to LLEXT but userspace feature.
To mitigate impact of global complier settings, this change adds a kconfig
choice for controlling FLIX generation independently for LLEXT modules.
Signed-off-by: Wojciech Jablonski <wojciech.jablonski@intel.com>
Add a new compiler property warning_no_misleading_indentation to allow
disabling misleading indentation warnings. This is implemented for GCC
with the -Wno-misleading-indentation flag.
Signed-off-by: Zhaoxiang Jin <Zhaoxiang.Jin_1@nxp.com>
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>
Zephyr `<type>_ROOT`s, such as `BOARD_ROOT`, `DTS_ROOT`, `SCA_ROOT`,
are initialed by ROOT settings provided through CMake variable
`<type>_ROOT`, Zephyr base, and root settings specified in Zephyr
module's `zephyr/module.yml` file.
`SNIPPET_ROOT` didn't follow the same pattern as it also included
application source dir.
This commit aligns `SNIPPET_ROOT` to follow same principle for
constructing other Zephyr `<type>_ROOT` lists.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
Enable the ARM_PACBTI Kconfig choice for ARM64 architectures (ARMV8_A
and ARMV9_A) in addition to the existing ARM32 ARMV8_1_M_MAINLINE
support. Add the corresponding -mbranch-protection compiler flags to
both GCC and Clang target files for ARM64.
Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
Zephyr supports CMake 3.20, which doesn't support
`file(COPY ... ONLY_IF_DIFFERENT)` and requires `BRIEF_DOCS` and
`FULL_DOCS` when defining properties.
This commit ensures the build system is CMake 3.20 compliant.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
If CONFIG_ROMSTART_RELOCATION is enabled, create a *separate* load/exec
memory region for the vector table. This must be separate for armlink,
otherwise moving .rom_start changes the LR base and drags .text with it.
Signed-off-by: Sudan Landge <sudan.landge@arm.com>
`armclang` doesn't support picolibc right now so disable it and fix
few issues related to it as below:
```
zephyrproject/zephyr/lib/libc/validate_libc.c:17:14: error: static
assertion failed due to requirement 'sizeof(unsigned int) >= 8': time_t
cannot hold 64-bit values
17 | BUILD_ASSERT(sizeof(time_t) >= 8, "time_t cannot hold 64-bit
values");
```
Signed-off-by: Sudan Landge <sudan.landge@arm.com>
Add system symbols in right region (FLASH) instead of the first
non-empty load section to fix below build errors:
```
Error: L6384E: No Load Execution Region of name ramfunc seen yet at line
11.
Error: L6384E: No Load Execution Region of name bss seen yet at line 13.
Error: L6384E: No Load Execution Region of name bss seen yet at line 17.
```
Signed-off-by: Sudan Landge <sudan.landge@arm.com>
`armlink` does not accept -O* flags so, drop linker optimization flags
to avoid below build error:
```
Fatal error: L3903U: Argument 's' not permitted for option 'O'.
```
Signed-off-by: Sudan Landge <sudan.landge@arm.com>
Remove linker optimization workaround for IAR linker as the new
inheritance scheme allows empty linker values.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
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>
Commit 388725870f introduced thread-local
storage support for the ARM Cortex-M architecture. As part of this commit,
".TEXT.*" was added as input pattern for the `text` output section in the
Cortex-M architecture linker script, even though such a pattern is not
found in any other architecture.
I suspect this was done as a workaround for a bug in the very same commit:
a missing `#include` in __aeabi_read_tp.S results in the eponymous function
being placed in section `.TEXT.__aeabi_read_tp` (notice uppercase) instead
of `.text.__aeabi_read_tp`, which would trigger an "orphan section" linker
warning without the modified linker script. Over time, this workaround has
unfortunately allowed the same bug to appear in at least another file...
Realign Cortex-M with all other architectures and stop accepting ".TEXT.*"
as valid input section name for the `text` output section. This can be done
safely since all non-compliant code (in tree) has been fixed.
Signed-off-by: Mathieu Choplain <mathieu.choplain-ext@st.com>
This adds the compiler flag to instruct xt-clang not to generate
FLIX (Flexible Length Instruction Xtensions) instructions, where
multiple instructions can be fused into one instruction. FLIX
can provide performance and code size advantages.
When userspace is enabled, FLIX may reorder memory access
where memory is accessed before code determines whether
we should perform that memory access. For example,
when guarding memory access via k_is_user_context(), and
some kernel variables can only be accessed via kernel mode,
FLIX may reorder memory access such that these variables are
accessed before k_is_user_context(). This results in access
violation. This turns off FLIX generation by default and
lets the application developers to decide whether to enable
FLIX generation.
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
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>
Added missing section k_timer_observer to linker file generator, to fix
missing section definitions for IAR linker.
Signed-off-by: Lars-Ove Karlsson <lars-ove.karlsson@iar.com>
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>
Use zephyr_custom_target_shared for menuconfig and friends so that
knowledge about those targets are available in through the CMake cache.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
The function zephyr_custom_command_shared extends the CMake
add_custom_command.
Sysbuild maps custom image build targets, such as `menuconfig` to
top-level `<image>_menuconfig`, however this knowledge is built into
sysbuild. Providing `zephyr_custom_command_shared` allows an image build
target to be shared with sysbuild and other external tools to share
information about important build targets available in the image.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
CMake cache persists between CMake runs.
The CMake cache both ensures a setting keeps its value between CMake
re-runs but the CMake cache is also used by external tools, such as
sysbuild and west, to read information about the build system.
The CMake cache has a limitation when handling lists. It's easy to
extend a CMake cache list with extra values, but it's difficult to clear
the list to ensure only values from current CMake run is present in the
list, because cached lists are always initialized with the value from
previous run.
This commit extends `zephyr_set()` with a cache scope.
The cache scope is empty initialized for a given CMake run.
Any write to the CMake scope is mapped into the CMake cache, and thus
the value is shared to external tools.
This removes the CMake cache limitation for list handling.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
The value os board qualifiers in CMake and Kconfig differs.
CMake has a leading '/', as example:
CMake: BOARD_QUALIFIERS=/nrf52840
Kconfig: BOARD_QUALIFIERS=nrf52840
This was also discussed in
https://github.com/zephyrproject-rtos/zephyr/pull/69740
This commit aligns the value of the CMake variable BOARD_QUALIFIERS to
the value of BOARD_QUALIFIERS (CONFIG_BOARD_QUALIFIERS) in Kconfig.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
seperate fpu mabi and march part, also use
the extention for the march part to make it
easier to add Zfinx and Zdinx later.
Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
Introduce the missing flag to compile code with Zbkb extension,
which has already been supported by the GCC 12 in current SDK.
Signed-off-by: Andy Lin <andylinpersonal@gmail.com>
Change the toolchain version resolution order to check for
board-specific TOOLCHAIN_VER_${NORMALIZED_BOARD_TARGET} first,
falling back to the generic TOOLCHAIN_VER if not defined.
Now if we want to use various boards lots of them uses same version
but fewer ones differ. We won't have to define TOOLCHAIN_VER for
every board.
Signed-off-by: Anil Ozrenk <anil.ozrenk@analog.com>
This is the version of the tool that Zephyr infrastructure uses,
and the configuration needs to be adjusted accordingly.
Setting *_ALIASES variables is not necessary anymore.
Signed-off-by: Nicola Vetrini <nicola.vetrini@bugseng.com>
Adds a new experimental Kconfig option to sysbuild which allows
generating a variant image to use with MCUboot in direct-xip mode.
It also includes base sysbuild infrastructure for creating
additional variant images in future (including out-of-tree),
whereby they use the base configuration of an existing image but
modify it, without creating the default zephyr extra targets for
images (e.g. menuconfig) to prevent changing configuration that
should not be changed.
Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
When building for ARMv9-A platforms with CONFIG_ARM64_SVE disabled,
compilers still emit SVE instructions because ARMv9-A includes SVE
by default in the architecture specification.
Add explicit +nosve flag to -march when CONFIG_ARMV9_A=y but
CONFIG_ARM64_SVE=n to prevent SVE instruction emission. This ensures
the compiler respects the SVE configuration and only emits SVE
instructions when explicitly enabled.
Applied to both GCC and Clang/LLVM toolchains.
Signed-off-by: Nicolas Pitre <npitre@baylibre.com>