The syscall generation phase parses all header files to look
for potential syscalls, and emits all the relevant files to
enable syscalls. However, this results in all the syscall
marshalling functions being included in the final binary.
This is due to these functions being referred to inside
the dispatch list, resulting in ineffective garbage
collection during linking. Previous commits allows each
drivers and subsystems to specify which header files
containing syscalls are relevant. So this commit changes
the syscall generation to only include the syscalls needed
for the build in the syscall dispatch list and removing
various bits related to that. This allows the linker to
garbage collect unused syscall related function, and thus
reducing final binary size.
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
This adds a new cmake function zephyr_syscall_header() which
will be used in the future to limit the scope of syscalls
in the built binary. Currently this is just an empty stub
so that add zephyr_syscall_header() to kernel, subsys, etc.
without breaking the build.
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
Fixes: #57139
Snippets provides the possibility of defining EXTRA_DTC_OVERLAY_FILE and
EXTRA_CONF_FILE in snippets.
Snippets must co-exist with existing infrastructure of
EXTRA_DTC_OVERLAY_FILE and EXTRA_CONF_FILE, and a user specifying a
snippet must be able to specify extra files for adjusting the snippet.
This means that if the following is specified:
`-DSNIPPET=some_snippet -DEXTRA_CONF_FILE=extra.conf`
then `extra.conf` may contain adjustments to the snippet.
Similar to sysbuild. Imagine a sysbuild controlled image uses a default
snippet for building, by ensuring that any extra
`-D<image>_EXTRA_CONF_FILE=extra.conf` arguments takes precedence over
the snippet we allow users to make adjustments if they need.
This commit introduces a snippets scope where snippet scoped variables
can be set with `zephyr_set()` and then `zephyr_get()` will take the
snippet scoped variables into consideration before returning.
Adjust calls to `zephyr_get(EXTRA_DTC_OVERLAY_FILE)` and
`zephyr_get(EXTRA_CONF_FILE)` to use `MERGE` to ensure all scopes are
considered.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
zephyr_get() supports multiple scopes when returning variables.
Variables are returned based on the scope's priority.
To facilitate creation of more scopes in Zephyr for variable handling
additional functions are introduced.
- zephyr_create_scope(<scope>)
creates a new scope
- zephyr_set(<var> <val>... SCOPE <scope>)
set the value of a variable in the specified scope.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
Adding the possibility to have the list returned in reversed order when
using `zephyr_get(... MERGE).
`zephyr_get(... MERGE)` creates a list which populates the content based
on variable settings in the following scopes, in this order:
sysbuild, cache, environment, local.
This works well for lists where content first in list has highest
precedence, such as ROOTs settings.
However, for settings where the value last in the list will overwrite
values earlier in the list, we want the list to be reversed, examples
of such can be CONF_FILE, OVERLAY_CONFIG, DTC_OVERLAY_FILE, where the
content of the file last in the list will overrule the content from an
earlier file.
So to ensure that a DTC_OVERLAY_FILE defined as cache takes precedence
over an env or local scope variable the possibility of reversing the
list must be available.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
This commit extends zephyr_get() to support multiple variable names to
be fetched into a single variable.
Example:
zephyr_get(FOO VAR FOO_A FOO_B FOO_C)
will lookup each FOO_A, FOO_B, FOO_C for supported scopes and return
the value in FOO of the first scope encountered having one of the
variables defined.
If MERGE is specified, then all scopes for all vars are looped and the
variable values are merged into FOO and returned.
This functionality will allow to deprecate user-facing settings while
ensuring that both the new and deprecated variables are considered
in zephyr_get() and also taking into consideration the scope with
highest precedence.
This allows Zephyr CMake to do:
zephyr_get(FOO VAR FOO DEPRECATED_FOO)
zephyr_get(BAR MERGE VAR BAR DEPRECATED_BAR)
This allows support of old and new setting for a given number of
releases.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
Fixes a string comparison which is missing quotes, this works
on the first invocation but fails on the second if quotes are
not present.
Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
Add a new flag to zephyr_iterable_section, NUMERIC, that configures
sorting to be numeric (up to 2 digits), that is, 2 comes before e.g. 10.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
The 2c98a001a4 (#57597) cause
regression with ARC MWDT toolchain.
Restore CREATE_OBJ_LEVEL wildcard pattern to be suitable for
both GNU and MWDT toolchains. We return asterisk symbol which
was dropped in 2c98a001a4
(but keep rest of the changes to wildcard pattern).
Signed-off-by: Evgeniy Paltsev <PaltsevEvgeniy@gmail.com>
Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
Fixes an issue where variables like BOARD_ROOT would be provided
to sysbuild but would then be lost on target images.
Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
Cleanup RAM layout so that the RAM_REGION is now in the RAM memory
region. Put .bss in RAM_REGION.
This means we have a proper program header for the RAM region.
As part of this extend zephyr_linker_symbol to allow it to take
an OBJECT paramater to specify the region to associate a symbol to.
Signed-off-by: Kumar Gala <kumar.gala@intel.com>
This function allows subsystems to define libraries which get added to the
link command after all other libraries and modules. It's useful when using
a toolchain library, like libc or libgcc, as those can get added when
processing the 'lib' directory, before any module libraries and hence might
not get used to resolve symbols from modules.
Signed-off-by: Keith Packard <keithp@keithp.com>
Follow-up fixes to 64c7f50229
("cmake: extensions: fix zephyr_dt_preprocess() CPP handling") that
weren't urgent enough for the hotfix, or didn't get noticed:
- error out on missing CPP argument again (this regression was
introduced in 64c7f50229)
- use a UNIX manpage style argument arity format (formatting issues
were present when the function was introduced)
- fix incorrect signature comment: the CPP arguments are the
preprocessor and its arguments, not CMAKE_DTS_PREPROCESSOR
(this was present when the function was introduced)
Fixes: 64c7f50229
Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
This option argument needs to be able to accept a list of arguments.
One use case is the way CMAKE_DTS_PREPROCESSOR is set in
cmake/compiler/armclang/generic.cmake.
Reported-by: Kumar Gala <kumar.gala@intel.com>
Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
Tighten up the interface boundaries by adding an extension function
that separates *how* we preprocess the DTS from *what* DTS files we
are preprocessing. This involves a functional change to the pre_dt
module.
This is useful cleanup but is also groundwork for relying on this
helper function when adding system devicetree support.
Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
This list processing procedure will be useful elsewhere, so prep for
not repeating ourselves. Put it in a new zephyr_list() function whose
signature has room to grow if we keep adding list processing
extensions.
Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
The name of each commented section should match the name in the "table
of contents", for consistency and so people can jump from contents to
implementations more easily with their editors' search functions.
Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
This commit provides a number of helper macros for verifying arguments
passing to function:
- zephyr_check_flags_required
- zephyr_check_arguments_required
- zephyr_check_arguments_required_all
- zephyr_check_flags_exclusive
- zephyr_check_arguments_exclusive
which facilitates checking whether a required argument or flag has been
given or if mutual exclusive arguments are given.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
Fixes: #55490
Follow-up: #53124
Prefix local version of the return variable before calling
`zephyr_check_compiler_flag_hardcoded()`.
This ensures that there will never be any naming collision between named
return argument and the variable name used in later functions when
PARENT_SCOPE is used.
The issue #55490 provided description of situation where the double
de-referencing was not working correctly.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
Follow-up: #53124
The PR#53124 fixed an issue where the variable `check` was not properly
dereferenced into the correct variable name for return value storage.
This was corrected in 04a27651ea.
However, some code was passing a return argument as:
`zephyr_check_compiler_flag(... ${check})`
but checking the result like:
`if(${check})`
thus relying on a faulty behavior of code updating `check` and not the
`${check}` variable.
Fix this by updating to use `${${check}}` as that will point to the
correct return value.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
Fixes: #53124
Fix de-referencing of check and exists function arguments by correctly
de-referencing the argument references using `${<var>}`.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
Update API for zephyr_code_relocate to support cmake generator expressions,
as well as relocating libraries.
zephyr_code_relocate can now accept a target name to the LIBRARY argument,
which will be converted into a set of source files from that
target to relocate.
Alternatively, files can be passed as a space separated list
or CMake generator expression. This allows users more
flexibility when relocating files. Glob matching functionality is still
available, although the preferred method to do this would now be:
file(GLOB relocate_sources "src/*.c")
zephyr_code_relocate(FILES ${relocate_sources} LOCATION <location>)
Note! This commit breaks support for zephyr_code_relocate until in tree
usages of the API are updated to the new format.
Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
This commit updates all in-tree code to use `CONFIG_CPP` instead of
`CONFIG_CPLUSPLUS`, which is now deprecated.
Signed-off-by: Stephanos Ioannidis <stephanos.ioannidis@nordicsemi.no>
The boards, shields, and zephyr_module CMake modules have some issues
in their comments that can be trivially fixed up.
Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
The table of contents at the top of the file has 'Devicetree
extensions' as the name of the section containing... those things.
The actual place in the file where they are defined has a different
title, though, defeating searching in the file for that section name.
Fix it.
Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
"Populate" is ambiguous here: does that mean set, or append? The
answer is "append", so use that to be clearer. Be extra clear where
we're looking in as well.
Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
Load image kconfig setting into image target properties.
This allows sysbuild to evaluate and check image configuration as part
of CMake invocation.
sysbuild_get() is updated to support reading of CMake cache or Kconfig
settings for an image.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
The signature of import_kconfig() take two mandatory arguments and one
optional:
> import_kconfig(<prefix> <kconfig_fragment> [<keys>])
but has been implemented in such a way that it loops all arguments after
the two mandatory args and sets the same list on those.
Fix this error by only setting the created variables on the third and
optional argument if it exists.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
Introduce a `test_sysbuild()` function.
This function is intended to be used by samples that are dependent on
sysbuild. This function allows such samples to test if sysbuild was used
in the build process, and when sysbuild is not used, then print a
warning to the user, or even fail the build.
This is useful for samples that have two parts to function properly, for
example samples that needs to be build and flash on two or more cores.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
Fixes: #47588
Kitware decided to fail compiler tests of single options if the
compiler reported only a warning and not an error:
github.com/Kitware/CMake/commit/f745e0497ee71d35fd1b3524b1636a72da76c266
which affects CMake 3.23.0 and 3.23.1
This change was later reverted in CMake >=3.23.2 and >=3.24.0
github.com/Kitware/CMake/commit/4941887d7defecb3016d2bd94d3a45754251ca56
Although the immediate issue is related to CMake, and has been fixed
reverted in later releases, then it still makes sense to be able to
group compiler options together that generally are depending on each
other to function correctly.
This commit introduces the possibility to group compiler options which
must be tested together.
It uses same approach as
> add_compile_options("SHELL:<option1> <option2> ...")
Usage:
> check_set_compiler_property(PROPERTY <property>
> "SHELL:<option1> <option2> ..."
> )
Will test the option together.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
Enhance sysbuild controlled configurations.
The current scheme of passing settings using `-D` on the CMake
invocation is vulnerable to quoting and lists.
With `zephyr_get()` in place as a uniform way of handling user
controlled settings (CMake cache / environment / CMake local variable)
we have a mechanism in place for a cleaner handling of sysbuild
controlled settings.
This improves the robustness of variable passing and add the same cleans
up and simplifies the logic in sysbuild.
The Kconfig Zephyr CMake module has been updated accordingly so that
CONFIG settings are taken from the sysbuild shadow cache when sysbuild
is used as higher level build system.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
A cache variable specified by the user as `-DVAR=value` will have the
type UNINITIALIZED in the CMake cache.
Later CMake re-runs will execute the line:
set(${variable} ${CACHED_${variable}} CACHE STRING
"Selected ${variable_text}" FORCE)
This will update the cache type from UNINITIALIZED to STRING and thus
may be picked up by other tools as a change.
To ensure the type is initialized to string, this is added:
set(${variable} ${${variable}} CACHE STRING "Selected ${variable_text}")
This code will not change the value of an existing CMake cache variable
because there is no FORCE, but what it will do is to update the cache
variable type to STRING.
As part of this, include the existing parent scope setting of variable
inside the `if(DEFINED ...)` as there is no reason to clear a variable
there is not having a value.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
Fixes: #40389
This commit implements zephyr_get(<variable>).
The purpose of zephyr_get(<variable>) is to ensure a uniform way to
handle variables which can be defined as:
- CMake cache variable, for example `-D<var>=<value>`.
- Environment variable
- Locally in CMakeLists.txt file before `find_package(Zephyr)`
It furthermore ensures that if an environment setting hides a local
setting then a warning is printed.
using
zephyr_get(<var>)
removes the need for constructs like:
set_ifndef(<var> "$ENV{<var>}")
set(<var> ${<var>} CACHE PATH "")
if(NOT DEFINED <var>)
set(<var> $ENV{<var>})
endif()
if (NOT DEFINED ENV{<var>})
message(FATAL_ERROR <error>)
endif()
and also ensures identical preference order for variables used in Zephyr
1. cache
2. environment
3. local scope var
It also ensures the variables supported through environment can also be
set using `-D<var>=<value>`
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
Place vector sections after ROM_START sections.
Also add init.ld script that will prevent overlapping .init sections
in telink_b91 SoC.
Fixes#49036.
Signed-off-by: Mateusz Sierszulski <msierszulski@antmicro.com>
This PR allows the user to add symbols to the nocache
section. The use for this could be as follows
zephyr_linker_sources_ifdef(CONFIG_NOCACHE_MEMORY
NOCACHE_SECTION
nocache.ld
)
nocache.ld (as shown below) can define additional
symbols to go into the nocache section
. = ALIGN(4);
KEEP(*(NonCacheable))
Signed-off-by: Mahesh Mahadevan <mahesh.mahadevan@nxp.com>
Move scripts needed by the build system and not designed to be run
individually or standalone into the build subfolder.
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
zephyr_library_compile_options() was attempting to create
unique hashes for compile options in order to prevent creating
them multiple times. However, it was only using the first
argument to create the hash, so if multiple libraries had
different compile options but the first line was the same,
the second set would be mistaken for the first set and would
actually be passed the first set during compilation instead
of its own set.
The fix should be to use the entire compile options argument
list to create the hash so they should only match if the entire
options list is exactly the same.
This is a continued fix for #43835
Signed-off-by: Nicholas Lowell <nlowell@lexmark.com>
This PR allows the user to add symbols to the ramfunc
section. The use for this could be as follows:
zephyr_linker_sources_ifdef(CONFIG_ARCH_HAS_RAMFUNC_SUPPORT
RAMFUNC_SECTION
quick_access_code.ld
)
quick_access_code.ld (as shown below) can define additional
symbols to go into the ramfunc section
. = ALIGN(4);
KEEP(*(CodeQuickAccess))
Signed-off-by: Mahesh Mahadevan <mahesh.mahadevan@nxp.com>
This patch is doing two things:
- it is removing the fallback on the path. This is not possible anymore
since the DT binding file is now actually requiring the
'zephyr,memory-region' property to be present from which the region
name is obtained.
- it is sanitizing the name when CONFIG_CMAKE_LINKER_GENERATOR is used
or not.
Signed-off-by: Carlo Caione <ccaione@baylibre.com>
COPY/NOCOPY flag was added to the end of the string with ':'
as separators. The python script then split the line on ':'
which breaks on Windows build because the string was
[MEM]:[FILE]:[COPY]
In windows you will have 'c:\' in the file path so the
line.split() in script will split on the 'c:'.
Move the COPY/NOCOPY to:
[MEM]:[COPY/NOCOPY]:[FILE]
Note that the comments at top of gen_relocate_app.py also
indicates this format.
Fixes#43950
Signed-off-by: David Leach <david.leach@nxp.com>
Currently when a node has a 'zephyr,memory-region' compatible and a
'zephyr,memory-region' string property, a new memory region is created
in the linker script.
Having a memory region without a section to place variables in could be
not that useful. With this patch we extend the memory-region mechanism
to also create sections.
The user can then place variables in the sections as usual by using for
example the GCC attributes.
Signed-off-by: Carlo Caione <ccaione@baylibre.com>
Fixes: #43835
In zephyr_library_compile_options() the existence of the compile
options interface library is checked and function returns if it already
exists. This results in #43835 meaning two libraries cannot add the
same option.
This commit fixes this by re-using the already created unique interface
library and link this to the Zephyr library.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>