This commit removes the "-vvv" argument from the SLID generation
scripts' command line when building Zephyr or an extension with
Kconfig CONFIG_LLEXT_EXPORT_BUILTINS_BY_SLID enabled. This removes
a lot of noise in the build log (usually ~250 lines) and is fine to
do because the printed information is also saved in build artifacts.
Signed-off-by: Mathieu Choplain <mathieu.choplain@st.com>
Fix the dictionary database not being generated under some
situations even though CONFIG_LOG_DICTIONARY_DB_TARGET is
disabled. For example, build and run through QEMU via
west build -t run.
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
Improve the SPDX with the current values:
- URL: extracted from `git remote`. If more than one remote, URL is not
set.
- Version: extracted from `git rev-parse` (commit id).
- PURL and CPE for Zephyr: generated from URL and version.
For zephyr, the tag is extracted, if present, and replace the commit id for
the version field.
Since official modules does not have tags, tags are not yet extracted for
modules.
To track vulnerabilities from modules dependencies, a new SBOM,
`modules-deps.spdx` was created. It contains the `external-references`
provided by the modules. It allows to easily track vulnerabilities from
these external dependencies.
Signed-off-by: Thomas Gagneret <thomas.gagneret@hexploy.com>
Both Clang [1] and (recently) GCC [2] support this flag to enable
additional codesize optimizations beyond -Os, possibly at the expense of
performance.
This tradeoff is worthwhile for some (and, Clang's -Oz seems to be
closer to GCC's -Os currently), so add a new abstraction for this flag
so users can select it as appropriate.
[1] https://clang.llvm.org/docs/CommandGuide/clang.html#cmdoption-O0
[2] https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html#index-Oz
Signed-off-by: Jonathon Penix <jpenix@quicinc.com>
When invoking cmake/llext-edk.cmake, CMakeLists.txt was sending the list
of includes as a colon separated list. On Windows, this list was
actually a single item, so it wasn't being parsed properly.
This patch sends the list as a cmake list and uses separate_arguments()
on the receiving side to fix it.
Fixes#73069
Signed-off-by: Ederson de Souza <ederson.desouza@intel.com>
Does not make much sense to ship the project with a config that by
default print a warning for a not-yet-deprecated feature. Let's drop it
for now, we can reintroduce it once the default is changed.
Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
This commit introduces support for an alternate linking method in the
LLEXT subsystem, called "SLID" (short for Symbol Link Identifier),
enabled by the CONFIG_LLEXT_EXPORT_BUILTINS_BY_SLID Kconfig option.
SLID-based linking uses a unique identifier (integer) to identify
exported symbols, instead of using the symbol name as done currently.
This approach provides several benefits:
* linking is faster because the comparison operation to determine
whether we found the correct symbol in the export table is now an
integer compare, instead of a string compare
* binary size is reduced as symbol names can be dropped from the binary
* confidentiality is improved as a side-effect, as symbol names are no
longer present in the binary
Signed-off-by: Mathieu Choplain <mathieu.choplain@st.com>
Namespaced the generated headers with `zephyr` to prevent
potential conflict with other headers.
Introduce a temporary Kconfig `LEGACY_GENERATED_INCLUDE_PATH`
that is enabled by default. This allows the developers to
continue the use of the old include paths for the time being
until it is deprecated and eventually removed. The Kconfig will
generate a build-time warning message, similar to the
`CONFIG_TIMER_RANDOM_GENERATOR`.
Updated the includes path of in-tree sources accordingly.
Most of the changes here are scripted, check the PR for more
info.
Signed-off-by: Yong Cong Sin <ycsin@meta.com>
Use pyelftools to extract the symbol table from the
link stage executable. Then, filter out the function names
and sort them based on their offsets before writing into the
`symtab.c`, this is similar to how the `isr_tables` works.
To access the structure, simply include the new header:
```c
#include <zephyr/debug/symtab.h>
```
Signed-off-by: Yong Cong Sin <ycsin@meta.com>
Some flags are common between in tree extensions and out of tree
supported by the EDK. Instead of duplicating those flags, the EDK reuses
the llext ones.
However, as the EDK has its own needs, two new lists,
`LLEXT_EDK_APPEND_FLAGS` and `LLEXT_EDK_REMOVE_FLAGS` are defined to
allow EDK to append or remove flags as needed.
Signed-off-by: Ederson de Souza <ederson.desouza@intel.com>
A new Kconfig option which generates syscall stubs assuming that
extensions will always run on userspace, thus simplifying linking
them, as there's no need for z_impl_ stubs (used for direct syscalls),
CONFIG_LLEXT_EDK_USERSPACE_ONLY.
While defining __ZEPHYR_USER__ could have the same effect for optmised
builds, people building extensions on debug environments - thus
non-optimised - would suffer, as they'd need to somehow make the stubs
available (by either exporting the symbol or implementing dummy stubs).
Signed-off-by: Ederson de Souza <ederson.desouza@intel.com>
Loadable extensions need access to Zephyr (and Zephyr application)
includes and some CFLAGS to be properly built. This patch adds a new
target, `llext-edk`, which generates a tar file with those includes and
flags that can be loaded from cmake and make files.
A Zephyr application willing to expose some API to extensions it loads
only need to add the include directories describing such APIs to the
Zephyr ones via zephyr_include_directories() CMake call.
A new Kconfig option, CONFIG_LLEXT_EDK_NAME allows one to control some
aspects of the generated file, which enables some customization - think
of an application called ACME, willing to have a ACME_EXTENSION_KIT or
something.
All EDK Kconfig options are behind CONFIG_LLEXT_EDK, which doesn't
depend on LLEXT directly - so that EDK features can be leveraged by
downstream variations of loadable extensions.
Also, each arch may need different compiler flags for extensions: those
are handled by the `LLEXT_CFLAGS` cmake flag. An example is set for GCC
ARM.
Finally, EDK throughout this patch means Extension Development Kit,
which is a bad name, but at least doesn't conflict with SDK.
Signed-off-by: Ederson de Souza <ederson.desouza@intel.com>
Dynamic code execution applications not using LLEXT for "extension"
loading are subject to the same linker optimization symbol resolution
issue described in commit 321e395 (in summary, libkernel.a syscalls
not used directly by the application result in weak symbol resolution
of their z_mrsh_ wrapper).
To support usecases where an application is using alternative methods
to load and execute code calling syscalls (likely from userspace) or
is using a mechanism where the linker may not be aware, the configuration
option has been decoupled from CONFIG_LLEXT (who is now a selector) to
KERNEL_WHOLE_ARCHIVE.
Signed-off-by: Daniel Apperloo <daniel.apperloo@intel.com>
If modules require C compiler features, these need to be set before
calling add_subdirectory.
Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
Add a symbol to enable GNU C Extensions. And a hidden option for
toolchains to signal GNU Extensions support.
Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
Add symbols to select a C standard. Next to an option, hidden symbols
are available to select the minimum.
This allows subsystems or modules to select the least compliant C
standard supported.
Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
By default, the generated disassembly file (i.e: the .lst
file) also contains inline source code. This has the
potential to become problematic when attempting to compare
the generated .lst files accross platforms since they may
differ for various reasons. As such, add the option to
control whether the disassembly file should contain inline
source code or not.
The need for this patch was sparked by the differences
observed in the generated .lst file for Linux and Windows
in one of SOF's CI jobs (details in thesofproject/sof/issues/9034),
which were caused by the addition of the inline source code.
With this, we can keep testing for reproducible builds while
not having to deal with differences in the .lst files caused
by things such as having ".." include paths.
Signed-off-by: Laurentiu Mihalcea <laurentiu.mihalcea@nxp.com>
Add a new CMake helper to add new include directories to be parsed by
the syscall machinery. This helper complements the existing
zephyr_syscall_header, which works at a header-level.
Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
Instead of INTERFACE_INCLUDE_DIRECTORIES, because header files are used,
not directories. Headers were added to both, target sources and include
directories.
Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
commit 67bb6db3f8 ("syscall: Export all emitted syscalls, enabling
them for extensions") exports all emitted syscalls, however, it does
that only for the `z_mrsh` symbols, effectively only available for
userspace. If an extension running at kernel level tries to use a
syscall, it will fail to load.
This patch fixes that by exposing the `z_impl` symbols instead. However,
this is not as straightforward as the `z_mrsh` ones. As, in their
signatures, they can basically contain any type, it's not just a matter
of emitting `EXPORT_SYMBOL(z_impl_<syscall>)`, as the compiler will
complain about the undefined types. Here, there are a few approaches.
One of them is to have the `EXPORT_SYMBOL` being generated on the same
files where the syscall is implemented - injecting it there would allow
it to access all known symbols. But changing a lot of files is
undesirable, and it was one of the nice points of first patch.
Another one would be to reconstruct - or simply use the absolute path -
for the includes where the syscalls are defined. Reconstruct the paths
seems fragile and I'm not sure using absolute paths is portable.
Finally, the approach used in this patch is to declare, on a different
generated file, all `z_impl_` symbols as `void *` - after all, only the
address (and the name) to the function is relevant to EXPORT_SYMBOL. By
living in an compilation unit that doesn't include any header which
would expose any of the syscalls, there shouldn't be any conflicts. And
to account for the possibility that a syscall is not compiled - due
being configured out via Kconfig - all those symbols are also weak
aliases to a pointer to NULL. This file is then included in
`llext_export.c` (which should naturally not include any conflicting
header).
Signed-off-by: Ederson de Souza <ederson.desouza@intel.com>
Differently from other libraries, which are included whole in the final
Zephyr ELF, libkernel.a itself isn't. Assuming this is intended to
enable optimisations (if it isn't, this patch will break things) - linker
can remove parts of the kernel that are not used by the application.
However, when considering Linkable Loadable Extensions (llext), this
optimisations can be counterproductive: for instance, syscalls that are
not used by the application won't be available for extensions. It won't
matter if someone "EXPORT_SYMBOL" for them, or even try to keep them
using LINKER_KEEP, they'll be gone.
To avoid that, this patches includes, when CONFIG_LLEXT=y, libkernel.a
inside the linker "whole-archive" block. This ends up making it consider
libkernel.a as a library whose all symbols should be kept. Note this
doesn't mean that all symbols will be there - things compiled out via
Kconfig will naturally still be out.
Signed-off-by: Ederson de Souza <ederson.desouza@intel.com>
Fixes: #70359
Remove check_init_priorities target and instead create a post build
command and place the post build command on native_runner_executable, if
that target is the final target, else use the normal post build list for
Zephyr build target.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
Add option to not generate the logging dictionary database when the
zephyr finale image is created. Instead this database can be created
by its own build target.
This reduces the build time during debugging as the database file is not
required as part of the debugging.
Fix build byproducts not listing the output file.
Add comment so users know which command is executing as this command
can take a long time.
Signed-off-by: Joakim Andersson <joakim.andersson@heimdallpower.com>
It turns out that currently LTO is enabled only for the kernel.
This commit updates it to enable it for the whole application
and adds additional LTO exclusions required for the standard
C libraries to build and link properly.
Signed-off-by: Radosław Koppel <radoslaw.koppel@nordicsemi.no>
This commit moves all the functionality related to the current
interrupt parser into gen_isr_tables_parser_carrays.py file.
The new parser file gen_isr_tables_parser_local.py file is
implemented with the new parser that.
Additional information added to the generated interrupt header
that contains data required by the new parser.
Signed-off-by: Radosław Koppel <radoslaw.koppel@nordicsemi.no>
Allows a sysbuild project to specify a signing script file to
use instead of the default zephyr one
Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
8cc716792a renamed this variable to lower
case to indicate it's only used locally however WEST_ARG is used as a
parameter of zephyr_module.py in CMakeLists.txt when
CONFIG_BUILD_OUTPUT_META is enabled.
This variable was used when west had some limitation. It does not
really make sense now, so it has been removed and content of west_arg
variable has been added by default.
Signed-off-by: Thomas Gagneret <tgagneret@witekio.com>
The current zephyr.spdx does not contain the modules included in the build.
This commit split the zephyr-sources package into multiple packages, one
for each modules found by zephyr_module.py.
Signed-off-by: Thomas Gagneret <tgagneret@witekio.com>
Firstly, COMMENT does not work for ninja.
Therefore, change COMMENT to echo.
With the addition of sysbuild, several memory reports can be printed
for one build.
Because of this, it is useful to know which executable each memory
report is printed for, so adding full path to elf file.
Signed-off-by: Sigurd Hellesvik <sigurd.hellesvik@nordicsemi.no>
Fix the init_prioties related cmake targets so they also
work with native_simulator based build targets.
Mostly this consists of pointing to the right file
(final build result instead of intermediate elf library)
and setting the dependency to that final build result.
Note that for the native_simulator based targets
the init priorities check can only be run on build
if we are building the final image (not just a partial
prelinked library),
and we are not assembling several images together
into one executable.
Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
In some cases, the APPLICATION_BINARY_DIR does not match
the CMAKE_BINARY_DIR, in those cases the native simulator
build would not find the zephyr elf file.
Fix it by using the correct variable.
Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
Several paths are checked for existence before added as global Zephyr
include path.
The existence check was needed because some tooling emit warnings on
non-existing paths.
Only few SoCs are using those pre-defined paths, yet this code runs
for all SoCs. The principle originates back from Kbuild days, and with
CMake it's more common and generally more visible to let the CMake code
defining libraries to specify include paths.
Furthermore it appears that several SoC implementation following the
<soc-path>/include was unaware that the path would be automatically
added as include path, cause they contain lines like:
zephyr_library_include_directories(include)
Remove pre-defineds path except the `<SOC_PATH>` path, which is
guaranteed to exists.
This simplifies the CMake logic in the top-level Zephyr CMakeLists.txt
file.
This cleanup further prepares for future work where SoCs need not to
be organised under architectures which is important for multi-arch SoCs.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
Since bb590b5b6e introduced ordinals in the priority sequence, the "same
priority" case cannot happen anymore, furthermore the priority value in
the script is now the position of the function in the init sequence, so
if two devices have the same priority there's something real bad going
on.
Drop all the "same priority" handling code and tests, convert the case
into ane exception instead. Drop the init stubs as well from the test,
they are not required anymore.
Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
This commit updates the handling of board and SoC linker scripts.
Several SoCs creates a linker.ld file which sole purpose is to include
another arch common linker script, often with content like this:
#include <arch>/linker.ld
instead of 100+ SoC specific linker.ld files containing just a single
include line of above structure, then this commit introduces two now
CMake variables, BOARD_LINKER_SCRIPT and SOC_LINKER_SCRIPT.
This allows the board and SoC CMake code to point directly to a common
linker script instead of creating a dummy linker.ld file doing this.
This removes the need for several dummy linker.ld file.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
This commit removes the needs or generating isrList.bin temporary file.
Now gen_isr_tables.py script access the required section directly in
elf file, that was accessed by the script anyway.
It simplifies the building removing one step.
Signed-off-by: Radosław Koppel <radoslaw.koppel@nordicsemi.no>
Change the creation of version.h and app_version.h to apply the
KERNEL_VERSION_CUSTOMIZATION APP_VERSION_CUSTOMIZATION values as target
properties instead of CMake variables.
This allows more freedom for users / Zephyr modules to adjust the value
of KERNEL_VERSION_CUSTOMIZATION and APP_VERSION_CUSTOMIZATION values and
thereby make use of the functionality introduced with #61635.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
Fixes: #63610
Fix a variable spelling mistake which caused a required dependency to
not be set.
Together with this fix, then remove an unneeded CMake cache update.
The `ZEPHYR_GIT_INDEX-NOTFOUND` value is not really useful in this
case as a not set var will also ensure that Zephyr is checked to be
a git repo or not.
And when detected as a git repo, then `ZEPHYR_GIT_INDEX` is set
to correct value.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
The script does not play well with armclang binariest at the moment.
Disable the automatic invocation when running with armclang, at least
until this is investigated and fixed.
Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
Add a new "initlevels" target that can be used to print a human readable
version of the init sequence by running: west build -t initlevels.
Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
Rework check_init_priorities to use the main executable file instead of
the individual object files for discovering the devices.
This should make the script more robust in case of stale files in the
build directory, and also makes it work with LTO object files.
Additionally, keep track of the detected init calls, and add a handy
"-i" option to produce a human readable print of the initcalls in the
call sequence, which can be useful for debugging initialization problems
due to odd SYS_INIT and DEVICE interactions.
Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
Export Zephyr image byproducts through `BYPRODUCT_<VAR>` cache
variables.
This allow external tools, such as sysbuild, to read information on
products produced by a Zephyr build from the image CMake cache.
For sysbuild, this means that all byproducts will be added to a phony
build target, which again allow sysbuild itself to depends on target
output and properly describe dependencies between byproducts and their
producing targets.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
Remove commented out code which are no longer needed.
Code was made obsolete here and should have been removed at the time:
https://github.com/zephyrproject-rtos/zephyr/pull/24851
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>