Commit graph

435 commits

Author SHA1 Message Date
Radoslaw Koppel 48b93ee0aa scripts: build: gen_isr_tables: Cleanup access to ".intList"
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>
2023-10-20 14:58:55 +02:00
Torsten Rasmussen f9f0748c96 cmake: Zephyr kernel version.h and app_version.h creation
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>
2023-10-20 14:54:36 +02:00
Torsten Rasmussen 12c1fe4d83 cmake: fix git dependency for version.h creation
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>
2023-10-06 16:19:43 +03:00
Fabio Baltieri 4a556a925c cmake: skip build time priority checking with armclang
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>
2023-09-20 20:24:46 +01:00
Fabio Baltieri 79ed6da8fd cmake: add a new "initlevels" target to print the init sequence
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>
2023-09-20 20:24:46 +01:00
Fabio Baltieri 5212a4c619 scripts: check_init_priorities: use the Zephyr executable file
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>
2023-09-20 20:24:46 +01:00
Torsten Rasmussen b6095a878c cmake: add Zephyr image output files as byproducts
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>
2023-08-22 12:31:43 +02:00
Torsten Rasmussen 2c1f0792ee cmake: remove commented out code
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>
2023-08-22 12:31:43 +02:00
Daniel Leung e38fc6de8a cmake: enable -Wshadow partially for in-tree code
This enables -Wshadow to warn about shadow variables on
in tree code under arch/, boards/, drivers/, kernel/,
lib/, soc/, and subsys/.

Note that this does not enable it globally because
out-of-tree modules will probably take some time to fix
(or not at all depending on the project), and it would be
great to avoid introduction of any new shadow variables
in the meantime.

Also note that this tries to be done in a minimally
invasive way so it is easy to revert when we enable
-Wshadow globally. Source files under modules/, samples/
and tests/ are currently excluded because there does not
seem to be a trivial way to add -Wshadow there without
going through all CMakeLists.txt to add the option
(as there are 1000+ files to change).

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2023-08-22 11:39:58 +02:00
Jamie McCrae 77a00f1352 kernel: banner: Allow for customising version
This allows for further (out of tree) customisation of the boot
banner version string when devices boot.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-08-21 10:09:46 +02:00
Keith Packard 424590f7d8 cmake/compiler: Add linker_script compiler property
This property specifies the flag used to pass the linker script filename
through the compiler front end tot he linker.

For clang, we use the general purpose linker-pass through -Wl flag with -T:
-Wl,-T as clang doesn't support -T.

For gcc, we use -T directly as this keeps the picolibc specs file from
inserting the picolibc linker script as well.

If the compiler doesn't specify a value, we continue to use -Wl,-T as
before.

Signed-off-by: Keith Packard <keithp@keithp.com>
2023-07-06 11:43:09 +02:00
Alberto Escolar Piedras ece74b7b7f native_sim: Add new native_sim board
Add the new native_sim board, based on the native simulator.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-07-05 07:01:19 -04:00
Alberto Escolar Piedras feaf0ff576 cmake: Treat native libraries differently where needed
When building a native library there is a few options
we cannot pass to the compiler and linker,
including instructing them to genrate non PIE code
(as it is still to early to say that),
or garbage collect unused sections (as we are not yet doing
the final linking).

We also need to provide different
link options when building the elf for the DTS gen_handles
parsing (as that script requires a "final" executable elf)
than when we build the native library itself.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-07-05 07:01:19 -04:00
Alberto Escolar Piedras 56dc20eb1d Kconfig: Tidy up dependants of NATIVE_APPLICATION
So they depend or select on the right NATIVE_BUILD
instead of NATIVE_APPLICATION.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-07-05 07:01:19 -04:00
Gerard Marull-Paretas 48b201cc53 device: make device dependencies optional
Device dependencies are not always required, so make them optional via
CONFIG_DEVICE_DEPS. When enabled, the gen_device_deps script will run so
that dependencies are collected and part of the final image. Related
APIs will be also made available. Since device dependencies are used in
just a few places (power domains), disable the feature by default. When
not enabled, a second linking pass will not be required.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-06-21 09:32:05 +02:00
Gerard Marull-Paretas b6d5d246b7 scripts: build: gen_device_deps: s/--dynamic-handles/--dynamic-deps
Align naming of the CLI option with recent changes in handles naming.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-06-21 09:32:05 +02:00
Gerard Marull-Paretas 319fbe57e1 device: s/HAS_DYNAMIC_DEVICE_HANDLES/DEVICE_DEPS_DYMAMIC
Rename the Kconfig option to be in line with recent renamings in device
handles/dependencies.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-06-21 09:32:05 +02:00
Gerard Marull-Paretas 8bee39edff device: s/device_handles/device_deps/ in linker scripts
Use the "device_deps" naming scheme to emphasize we are storing device
dependencies. The fact we are using device handles to store them is an
implementation detail.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-06-21 09:32:05 +02:00
Gerard Marull-Paretas 92707866d1 device: s/gen_handles/gen_device_deps
Rename the gen_handles script and all of its references/associated files
to gen_device_deps. The new new makes things more clear, because the
script just take care of generating, for each device, an array of device
dependencies. While device handles are used internally to store this
information, it is in reality an implementation detail.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-06-21 09:32:05 +02:00
Daniel Leung 80e78208e6 kernel: syscalls: no need to include all syscalls in binary
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>
2023-06-17 07:57:45 -04:00
Gerard Marull-Paretas e5335f345a device: dynamic device handles were declared as const
When CONFIG_HAS_DYNAMIC_DEVICE_HANDLES is selected, devices handles are
placed in RAM region so that they can be modified at runtime. However,
the gen_handles.py script added the `const` attribute to the device
handle arrays regardless of this setting, leading to faults when running
the application. This may be an indicator that this feature is not
actively used.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-06-14 13:48:02 -04:00
Gerard Marull-Paretas 9f25fa20ce device: set number_of_dynamic_devices only if needed
This variable is only needed when gen_handles.py is called, so define it
under the if() above.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-06-14 13:48:02 -04:00
Fabio Baltieri 2264c14fdf Kconfig.zephyr: add an option for checking build time init priority
Add an option for running the build time initialization priority check
as part of the build.

By default the build is going to fail if any error is reported
(dependent devices, inverted priority), optionally it can also be failed
on warnings (dependent devices, same priority).

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-05-25 15:40:07 +02:00
Fabio Baltieri b9ea2c2705 build: downgrade the no optimization ztest error to warning
The current approach of failing the build on ztest with no optimization
broke coverage builds, and generally raised some concerns about being
too aggressive.

Downgrade the error to a warning and rework the option to inhibit the
warning, while also dropping it automatically for POSIX (that are not
really affected by stack size) and coverage run (that always runs with
no optimization).

Will reconsider this down the road if we still see issues filed for the
tests broken with no optimization and no further tuning.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-05-23 14:51:24 +00:00
Torsten Rasmussen a88502783b cmake: align Zephyr module variable to EXTRA_ZEPHYR_MODULES
Align Zephyr modules with other user facing variables where settings
can be defined or extended, meaning Zephyr modules now supports:
ZEPHYR_MODULES and EXTRA_ZEPHYR_MODULES.

Support for ZEPHYR_EXTRA_MODULES is kept foir backward compatibility.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2023-05-23 16:40:21 +02:00
Fabio Baltieri f5830f3c3f ztest: error out when building tests with no compiler optimizations
Many tests are known to fail when built and no compiler optimizations.
Add a CMake check to error out when building a ztest based test with no
optimization, ask not file issues about it but also adds an opt-out
option to bypass the error for tests are actually designed to work in
this setup.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-05-22 12:25:43 -04:00
Torsten Rasmussen 99064c2646 cmake: generated application version header when VERSION file is present
Allow applications to create a VERSION file in their application folder.

The presence of a VERSION file will create a app_version_h target which
generates an app_version.h file using same infrastructure as the Zephyr
kernel version.h generation.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2023-05-17 13:56:58 +02:00
Torsten Rasmussen 2c757f9e7a cmake: generalize VERSION infrastructure for better reuse
Generalize the VERSION and version.h generation so that the same
infrastructure can be reused for generating other version related
header files, such as an application version header.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2023-05-17 13:56:58 +02:00
Gerard Marull-Paretas 99ebe39289 compiler: add CONFIG_COMPILER_TRACK_MACRO_EXPANSION
Add a new compiler option to control tracking locations of tokens across
macro expansions. It may be useful to disable it when debugging long
macro expansion chains.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-05-05 12:08:48 +02:00
Alberto Escolar Piedras 01348d38ca cmake: Also build C++ files as no-pic
Seems it may have been lost during refactoring
that C++ code should also be built as not
position independent code to save space.
Let's enable it just like for plain C.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-05-05 09:47:44 +02:00
Keith Packard 87a30609da cmake: Add zephyr_libc_link_libraries function
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>
2023-04-17 11:13:17 +02:00
Keith Packard 6c5d806bcb toolchain: Add COMPILER_FREESTANDING to control use of -ffreestanding
Add an explicit compiler configuration, COMPILER_FREESTANDING, which
controls whether the compiler should operate in freestanding or hosted mode
(according to the C and C++ language specifications.

This depends on having a C library which conforms with the language
specification, and the minimal C library does not. Have the minimal C
library select COMPILER_FREESTANDING to continue using freestanding mode
with that library.

For other C libraries, leave this disabled by default while allowing users
to enable it if they want to go back to the previous configuration.

Signed-off-by: Keith Packard <keithp@keithp.com>
2023-04-14 21:36:31 +09:00
Martin Jäger a0ffaa763c cmake: strip paths in build output based on Kconfig option
Add CONFIG_BUILD_OUTPUT_STRIP_PATHS to allow keeping absolute paths
in the build output.

This can be helpful for IDEs to detect links in a console output and
jump to the code location (e.g. when running tests in native_posix
locally).

Debuggers usually have a path mapping feature to ensure the files are
still found.

Signed-off-by: Martin Jäger <martin@libre.solar>
2023-04-04 18:02:05 +02:00
Fabio Baltieri 3f8f7130e7 kconfig,toolchain: add an option for compiler save-temps
Add a Kconfig option to set the compiler save-temps flag and set the GCC
implementation. This is very useful for troubleshooting macro expansion
issues, having an option allows a user to set it like any other config
option.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-04-02 22:07:22 -04:00
Daniel Leung 81c3b3152c cmake: linker: make passing -no-pie configurable
This adds a new linker property specifically for passing
"-no-pie" to linker. Older binutils' LD (<= 2.36) do not
support this flag and will behave erratically if set. It
would parse "-no-pie" separately as "-n" and "-o-pie",
which would result in the output file being "-pie"
instead of "zephyr*.elf". Moreover, LLVM lld does not
support -no-pie but --no-pie (note the extra hyphen).
By having no-pie as a linker property, we can pass
correct no-pie flag to these linkers (or none at all).

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2023-03-29 19:48:47 -04:00
Jamie McCrae 176c805f9e cmake: Allow extending/replacing signing functionality
Allows extended or replacing the default MCUboot signing
functionality by using a cmake property which can be set by modules
if alternate or modified signing functionality is required.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-03-29 15:53:50 +00:00
Kumar Gala 9f8913c4e0 toolchain: Add ARMClang to gcc related toolchain flags check
Add ARMClang similar to LLVM to check to skip GCC specific flags

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2023-03-20 10:42:46 +01:00
Daniel Leung 751de22ca4 syscalls: skip generating mrsh.c if not userspace
There is no need to generate all the *_mrsh.c files for
marshalling syscall arguments when userspace is not enabled.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2023-03-11 19:45:23 +01:00
Kumar Gala 2d12766e78 toolchain: oneApi: Fix support and update for 2023.0.0 release
The oneApi support has bit rotten since it was first introduced.  Update
the support to function with the latest 2023.0.0 release and add a
check to only support that version or newer for now.  Versions before
2021.2.0 have linker script failures.

Various fixes made:
* In the 2023.0.0 release, various binaries are in a llvm-bin path so
  add support to search in that path.  This replaces the python search
  path that much older versions needed.
* newlib isn't supported with oneApi so set TOOLCHAIN_HAS_NEWLIB to
  OFF to match that.
* 2023.0.0 doesn't back llvm-nm, so use binutils version.  This
  is expected to be fixed in 2023.1.0 release so add a check to
  handle either case.
* Update compiler flag check based on clang to also support
  CMAKE_C_COMPILER_ID of "IntelLLVM" as that is how the oneApi toolchain
  reports itself.

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2023-02-23 14:30:03 -05:00
Fabio Baltieri 9b30667c77 build: drop LEGACY_INCLUDE_PATH support
LEGACY_INCLUDE_PATH has been defaulting to "n" and marked as deprecated
in both v3.2 and v3.3. Drop the option entirely for v3.4.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-02-21 15:06:48 +01:00
Nikolay Agishev 0dec4cf927 toolchain: Move extra warning options to toolchain abstraction
Move extra warning option from generic twister script into
compiler-dependent config files.
ARCMWDT compiler doesn't support extra warning options ex.
"-Wl,--fatal-warnings". To avoid build fails flag
"disable_warnings_as_errors" should be passed to twister.
This allows all warning messages and make atomatic test useles.

Signed-off-by: Nikolay Agishev <agishev@synopsys.com>
2023-02-19 20:34:13 -05:00
Torsten Rasmussen 60196ca112 cmake: sparse: deprecate old sparse support
Deprecate old sparse support as Zephyr now provides a proper
infrastructure for SCA tools. Set ZEPHYR_SCA_VARIANT to sparse if user
is using deprecated way.

This allows to cleanup sparse code in various places and thus have a
cleaner build system.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2023-01-27 20:28:58 +09:00
Flavio Ceolin ac5d45a080 build: userspace: No merge globals
Add a compiler option to not merge globals. gen_kobject_list.py
is not capable of distinguish addresses of merged objects. The script
itself does not look wrong. The dward specification says that the
attribute DW_AT_location with opcode DW_OP_addr encodes a machine
address and whose size is the size of an address on the target machine
but for merged objects the address is longer, not clear why.

Disable global merge when userspace is enabled to avoid this problem.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2023-01-26 14:56:10 -05:00
Jamie McCrae ec7044437e treewide: Disable automatic argparse argument shortening
Disables allowing the python argparse library from automatically
shortening command line arguments, this prevents issues whereby
a new command is added and code that wrongly uses the shortened
command of an existing argument which is the same as the new
command being added will silently change script behaviour.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-01-26 20:12:36 +09:00
Stephanos Ioannidis a9b35f0c41 cpp: Fix toolchain C++ standard library linkage
The build system currently links the toolchain-provided C++ standard
library even when the C++ support (`CONFIG_CPP`) is not enabled.

This commit updates the build system to link the toolchain-provided C++
standard library when the C++ support is enabled and a C++ library
implementation other than the Zephyr minimal C++ library is selected.

Signed-off-by: Stephanos Ioannidis <stephanos.ioannidis@nordicsemi.no>
2023-01-17 09:21:09 +01:00
Stephanos Ioannidis cf211aa7af treewide: Update deprecated CONFIG_LIB_CPLUSPLUS usages
This commit updates all deprecated `CONFIG_LIB_CPLUSPLUS` usages to:

* check if the Zephyr minimal C++ library is enabled using
  `CONFIG_MINIMAL_LIBCPP` instead of relying on the
  `CONFIG_LIB_CPLUSPLUS`-based inference.

* select `CONFIG_REQUIRES_FULL_LIBCPP` when there exists a component-
  level C++ standard library dependency. This allows a component to
  declare C++ standard library dependency without designating a
  specific libray implementation.

* select the correct type of C++ standard library implementation to use
  through one of the `CONFIG_LIBCPP_IMPLEMENTATION` choices.

Signed-off-by: Stephanos Ioannidis <stephanos.ioannidis@nordicsemi.no>
2023-01-13 17:42:55 -05:00
Stephanos Ioannidis a3b28ff0eb treewide: Use CONFIG_CPP_RTTI instead of CONFIG_RTTI
This commit updates all in-tree code to use `CONFIG_CPP_RTTI` instead
of `CONFIG_RTTI`, which is now deprecated.

Signed-off-by: Stephanos Ioannidis <stephanos.ioannidis@nordicsemi.no>
2023-01-13 17:42:55 -05:00
Stephanos Ioannidis 404e7a9bf7 treewide: Use CONFIG_CPP_EXCEPTIONS instead of CONFIG_EXCEPTIONS
This commit updates all in-tree code to use `CONFIG_CPP_EXCEPTIONS`
instead of `CONFIG_EXCEPTIONS`, which is now deprecated.

Signed-off-by: Stephanos Ioannidis <stephanos.ioannidis@nordicsemi.no>
2023-01-13 17:42:55 -05:00
Stephanos Ioannidis 4a64bfe351 treewide: Use CONFIG_CPP instead of CONFIG_CPLUSPLUS
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>
2023-01-13 17:42:55 -05:00
Flavio Ceolin 02d5290e07 linker: kobject: Handle literal section
Add kobject_data prefix to kobject literals and group it close to
text area to avoid changing .text addresses in the final linkage.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2023-01-02 11:05:06 +01:00