Commit Graph

157 Commits

Author SHA1 Message Date
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
Daniel Leung 9eec3fc6eb cmake: add zephyr_syscall_header stub
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>
2023-06-17 07:57:45 -04:00
Evgeniy Paltsev b64cfe9832 ARC: MWDT: rework GNU helper tools usage
As of today MWDT toolchain in case of Zephyr may use few
tools from GNU toolchain - GNU compiler for DTS preprocessing
and objcopy for section renaming.

Currently we were trying to find any GNU compiler & objcopy
which start to cause compatibility issues for new targets -
i.e. not every objcopy knows new ARC targets.

Let's use ARC GNU tools from Zephyr SDK as we still usually
require it when building with MWDT for other tools like DTC
(device tree compiler)

Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
Signed-off-by: Evgeniy Paltsev <PaltsevEvgeniy@gmail.com>
2023-06-17 07:44:31 -04:00
Jamie McCrae 9642c48a29 cmake: boards: Fix issue with relative paths
Fixes an issue with relative paths both with and without using
sysbuild where they would not be updated properly or a warning
would previously be emitted.

Signed-off-by: Torsten Rasmussen <torsten.rasmussen@nordicsemi.no>
Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-06-15 05:10:42 -04:00
Torsten Rasmussen ba48dd8763 cmake: support snippets scope for `zephyr_get()`
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>
2023-05-25 13:31:53 +00:00
Torsten Rasmussen a6d9105d51 cmake: create Zephyr scope functions for variables
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>
2023-05-25 13:31:53 +00:00
Torsten Rasmussen fd526cc4b2 cmake: add reverse option to `zephyr_get(... MERGE)`
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>
2023-05-25 13:31:53 +00:00
Torsten Rasmussen 5c71e68607 kconfig: provide an option for enforcing Kconfig settings
This commit introduces an internal FORCE_CONF_FILE CMake setting which
allows higher order build systems to generate a configuration file
which will always take precedence.

This means that in case a user tries to change any setting to be
different than the defined value in the FORCE_CONF_FILE provide file(s),
then a warning will be printed and the setting will be reset to the
value given in the FORCE_CONF_FILE file.

Example of such warning:
   <path>/.config.sysbuild:1: warning: BOOTLOADER_MCUBOOT
   (defined at Kconfig.zephyr:766) set more than once.
   Old value "n", new value "y".

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2023-05-25 14:57:41 +02: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
Torsten Rasmussen 384fb1e478 cmake: introduce EXTRA_DTC_OVERLAY_FILE for devicetree
This commit introduces EXTRA_DTC_OVERLAY_FILE.

This allows users to specify additional devicetree overlays in addition
to a sample / board specific default devicetree overlay files.

It also allows snippets to provide extra devicetree overlays on addition
to sample / board specific overlays.

The name EXTRA_DTC_OVERLAY_FILE clearly indicates the purpose and
follows the naming scheme of EXTRA_ in front of variable name.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2023-05-23 16:40:21 +02:00
Torsten Rasmussen 3a345682ba cmake: introduce EXTRA_CONF_FILE and deprecate OVERLAY_CONFIG
This commit introduces EXTRA_CONF_FILE and deprecates OVERLAY_CONFIG.

It has often caused confusion that OVERLAY_CONFIG adds extra
configuration fragments to the value of CONF_FILE (default: prj.conf),
but the similar named variable DTC_OVERLAY_FILE replaces the default
dtc overlay file used by the build system.

To remove such confusion, this commit introduces the EXTRA_ prefix in
front of CONF_FILE to clearly indicate it's purpose.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2023-05-23 16:40:21 +02:00
Torsten Rasmussen 8460d91e32 cmake: extend zephyr_get() to support fetching of multiple variables
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>
2023-05-23 16:40:21 +02:00
Marc Herbert 4975c94845 west.cmake: make MIN_WEST_VERSION catch up with requirements-base.txt
Also add a comment in each file reminding to keep them the same.

Fixes 251f269e23 ("west: v0.14.0 is required now (and soon, v1.1")

Confusing error message before this commit:

```
-- Found west (found suitable version 0.13.1, minimum required is 0.7.1)
CMake Error at SOF/zephyr/cmake/modules/zephyr_module.cmake:77 (message):
  Traceback (most recent call last):

    File "SOF/zephyr/scripts/zephyr_module.py", line 733, in <module>
      main()
    File "SOF/zephyr/scripts/zephyr_module.py", line 678, in main
      west_projs = west_projects()
                   ^^^^^^^^^^^^^^^
    File "SOF/zephyr/scripts/zephyr_module.py", line 536, in west_projects
      from west.configuration import MalformedConfig

  ImportError: cannot import name 'MalformedConfig'
                      from 'west.configuration'
  (west/src/west/configuration.py)
```

Clearer error message after this commit:

```
CMake Error at SOF/zephyr/cmake/modules/west.cmake:68 (message):
  The detected west version, 0.13.1, is unsupported.

    The minimum supported version is 0.14.0.
    Please upgrade with:
        /usr/bin/python3.11 -m pip install --upgrade west
```

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2023-05-22 10:17:11 +02:00
Jamie McCrae 0972cb9d87 cmake: kconfig: Configure KCONFIG_ROOT variable
This configures the KCONFIG_ROOT variable to perform variable
substitution, this allows external applications/modules to supply
variables for this when will then be correctly used.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-05-17 16:14:49 +02:00
Torsten Rasmussen 49389b546a west: sign: Add Kconfig with application version
Adds a Kconfig option which controls the version of the application
to use when the image is signed using imgtool.

When an application VERSION file is present, the default value will be
identical to the application version, else it will be 0.0.0+0, but a
project may still decide another value, if it so prefers.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
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
Jamie McCrae a41f44b8db cmake: extensions: Fix missing quotes for zephyr_get function
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>
2023-05-15 09:17:01 +02:00
Gerard Marull-Paretas a7e8b3afcb cmake: extensions: add NUMERIC support to zephyr_iterable_section
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>
2023-05-12 12:01:10 +02:00
Evgeniy Paltsev 4e81b0e081 linker: restore CREATE_OBJ_LEVEL wildcard pattern
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>
2023-05-11 19:44:37 +02:00
Manoel Brunnen 3953de793f cmake: Fix USER_CACHE_DIR path generation
When the optional env_suffix_${env_var} was not set, USER_CACHE_DIR was
slightly malformed and had double slashes,
e.g. /home/user/.cache//zephyr.

To fix it string(JOIN ...) is used, which only sets slashes when
necessary.

Signed-off-by: Manoel Brunnen <mb@lee-brunnen.de>
2023-05-10 15:27:54 +02:00
Jamie McCrae 87f50bb72b cmake: extensions: Do not clear variable in zephyr_get MERGE mode
Fixes a regression whereby the variable would be cleared prior to
being used in MERGE mode.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-05-10 12:05:51 +02:00
Grzegorz Swiderski af23628e43 sysbuild: Add SB_OVERLAY_CONFIG
This fixes a minor issue in sysbuild, where `-DOVERLAY_CONFIG=...` would
be applied not only to the main application, but also sysbuild itself.
This was incorrect, because sysbuild imports a different Kconfig tree
than normal Zephyr builds, so the same Kconfig fragment file would not
necessarily be valid for both.

This adds a new variable SB_OVERLAY_CONFIG to resolve this ambiguity.
It functions along the lines of SB_CONF_FILE, with both being sysbuild-
specific versions of existing variables.

To ensure that OVERLAY_CONFIG is still passed on to the main application
verbatim, its value is now loaded in `configuration_files.cmake`, rather
than `kconfig.cmake`. This is because the former file is not imported by
sysbuild, and it is where the related variables, such as CONF_FILE and
DTC_OVERLAY_FILE, are loaded as well.

Signed-off-by: Grzegorz Swiderski <grzegorz.swiderski@nordicsemi.no>
2023-05-05 09:42:10 +02:00
Jamie McCrae cd9465ac94 sysbuild: Fix issue with *_ROOT values not propagating
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>
2023-05-03 14:25:33 +02:00
Kumar Gala f5eada5553 cmake: linker: arm: put RAM sections in RAM region
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>
2023-05-03 17:07:47 +09:00
Alberto Escolar Piedras 6758156c09 nrf52_bsim: Find simulator thru west as fallback
For developers ease, let's try to find the simulator
thru west if the environment variables that tell where
the simulator is are not set.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-04-28 13:57:21 +02:00
Keith Packard 638842c598 cmake: Compute TOOLCHAIN_HAS_NEWLIB at cmake time
Switch from using a generator expression to computing the value with a
conditional so that it is available during the execution of kconfig instead
of only being available while generating the build script.

Signed-off-by: Keith Packard <keithp@keithp.com>
2023-04-27 20:18:11 +09:00
Marc Herbert acb7f71ae5 cmake: sparse: fix handling of (deprecated) -DSPARSE=garbage
Due to many layers of indirections (Github Actions, Docker scripts, SOF
build scripts, etc.), thesofproject/sof/pull/7452's first attempt to
turn off VLAs ended up setting `-DSPARSE=gar bage`:

  west build ...  -- '-DSPARSE=y -DCONFIG_LOG_USE_VLA=n'

Quoting issues are typical when trying to pass parameters through too
many layers of indirections. In this case, the mistake set the $SPARSE
variable to the 'y -DCONFIG_LOG_USE_VLA=n' garbage which printed this
confusing and time-consuming error message:

    Setting SPARSE=y -DCONFIG_LOG_USE_VLA=n is deprecated.

Worse: this enabled sparse (!) while silently ignoring the garbage
trailing after "y".

1. Enable sparse only when $SPARSE is equal to "y" and nothing
   else. This stops enabling sparse when `-DSPARSE=gar bage` which draws
   more attention to the warning and gives a little more incentive to
   leave the deprecated option behind. Don't make any difference between
   the "n" and "gar bage" values because $SPARSE is deprecated so not
   worth that much CMake code.

2. Add quotes in the deprecation message to make garbage values more
   obvious, now:

    Setting SPARSE='y -DCONFIG_LOG_USE_VLA=n' is deprecated.

Fixes: 60196ca112 ("cmake: sparse: deprecate old sparse support")

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2023-04-20 10:49:23 +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
Martí Bolívar dc4eac4198 cmake: follow-up zephyr_dt_preprocess() fixes
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>
2023-04-14 11:19:47 -07:00
Martí Bolívar 64c7f50229 cmake: extensions: fix zephyr_dt_preprocess() CPP handling
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>
2023-04-13 13:05:37 +09:00
Daniel Leung 2a76637963 cmake: toolchain: cache property GNULD_LINKER_IS_BFD
Cache the property GNULD_LINKER_IS_BFD between cmake invocations.
It is observed that, in repeated builds (2nd time and later),
this property becomes true even for non-bfd compatible linker.
So cache it to avoid any surprises.

Fixes #56501

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2023-04-12 10:25:41 -04:00
Martí Bolívar d395719adc cmake: modules: dts: extract preprocessing helper extension
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>
2023-04-12 13:04:31 +02:00
Martí Bolívar c3004a10f9 cmake: modules: dts: extract overlay helper function
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>
2023-04-12 13:04:31 +02:00
Martí Bolívar f680c9db8d cmake: modules: dts: document outcome
When the build system was being split up into modules under
cmake/modules, most of the resulting cmake modules had their inputs
and outputs documented in top-of-file comments. The dts module is an
exception, which makes it harder to use since its contracts aren't
defined. Fix this by adding a contract.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2023-04-12 13:04:31 +02:00
Martí Bolívar a619f9e36e cmake: modules: add pre_dt
Create a separate module that sets up all our devicetree handling, by
setting up common variables that would apply to any and all DT
processing. This is then included in the regular dts module that we
include in zephyr_default.cmake.

The separation of this code from dts.cmake is groundwork for enabling
system devicetree in Zephyr, which will need the same definitions
included into its scope.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2023-04-12 13:04:31 +02:00
Martí Bolívar 53ab5fcf1c cmake: modules: add generated_file_directories
Due to Hyrum's Law, there are users out in the wild depending on this
directory existing to place their own generated files, so it'd break
things unnecessarily to not do this if we don't have a DTS, as
explained in a source code comment.

However, this doesn't really have anything to do with DTS processing,
so split it into its own module to separate concerns. This isn't
really a CMake module in the usual sense of something that defines
functions you can use, and is therefore a form of technical debt. The
decision was made to accept this because fixing this is a larger task
for the files in cmake/modules/, since there are multiple other
examples of this in here.

This also paves the way for inserting another module in between the
generated_file_directories and dts modules that itself depends on
these directories existing.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2023-04-12 13:04:31 +02:00
Martí Bolívar 977a915c25 cmake: extensions: fix comment
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>
2023-04-12 13:04:31 +02:00
Gerard Marull-Paretas c2a51fd336 cmake: dts: remove generation of legacy device_extern.h
device_extern.h was still generated with an #error directive, not really
useful was it was never designed to be included directly, but via
device.h.

Fixes #56425

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-04-05 19:32:43 +02:00
Torsten Rasmussen d6dfacc9c6 cmake: add CMake configure dependency for VERSION file
Fixes: #56235

Changes to the Zephyr VERSION file is not picked up by CMake and thus
not picked up by Kconfig which may rely on the KERNELVERSION setting.

Fix this by setting CMAKE_CONFIGURE_DEPENDS on the Zephyr VERSION file.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2023-04-04 17:27:38 +02:00
Daniel Leung 04fd862f68 linker: ld: GNULD_LINKER_IS_BFD to indicate if ld.bfd is used
This adds a new output variable to FindGnuLd.cmake to indicate
if ld.bfd is found. Since we now ask the compilers for their
preferred ld.bfd linker, it may not match using the existing
string equal test to ${CROSS_COMPILE}ld.bfd. So set the new
variable GNULD_LINKER_IS_BFD to true if ld.bfd, and use it to
pass an extra argument to compiler to make it use ld.bfd.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2023-03-29 19:48:47 -04:00
Daniel Leung aa8f812118 linker: lld: see if clang has a preferred linker
This asks the clang if it has its own preference for ld.lld.
This is to mirror what we are doing to find GNU ld, and to
make sure we are using the linker clang is using.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2023-03-29 19:48:47 -04:00
Daniel Leung 0e00c3da5c linker: ld: see if compiler has a preferred linker
This asks the compiler if it has its own preference for ld.bfd.
This is useful for LLVM (when CONFIG_LLVM_USE_LD=y) so we know
which linker clang is using.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2023-03-29 19:48:47 -04:00
Daniel Leung 41f015b39b linker: use find_package() to find LLVM lld
This introduces a new cmake module FindLlvmLld.cmake to do
the work to discover LLVM lld linker.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2023-03-29 19:48:47 -04:00
Daniel Leung 29a67d1f2e linker: use find_package() to find GNU ld
This introduces a new cmake module FindGnuLd.cmake to do
the work to discover GNU ld (of binutils).

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2023-03-29 19:48:47 -04:00
Pete Dietl fd94ca7e78 cmake: modules: Make modules.cmake check more precise
When checking that modules contain a file `modules/modules.cmake`,
the CMake file only actually checked for the existence of the module
root, not the `modules/modules.cmake` file inside of it.

Signed-off-by: Pete Dietl <pete.dietl@worldcoin.org>
2023-03-27 22:15:59 +00:00
Marti Bolivar 06c9bf47b3 snippets: initial snippet.yml support
Add a new script, snippets.py, which is responsible for searching
SNIPPET_ROOT for snippet definitions, validating them, and informing
the build system about what needs doing as a result.

Use this script in snippets.cmake to:

- validate any discovered snippet.yml files
- error out on undefined snippets
- add a 'snippets' build system target that prints all snippet
  names (analogous to 'boards' and 'shields' targets)
- handle any specific build system settings properly,
  by include()-ing a file it generates

With this patch, you can define or extend a snippet in a snippet.yml
file anywhere underneath a directory in SNIPPET_ROOT. The snippet.yml
file format has a schema whose initial definition is in a new file,
snippet-schema.yml.

This initial snippet.yml file format supports adding .overlay and
.conf files, like this:

  name: foo
  append:
    DTC_OVERLAY_FILE: foo.overlay
    OVERLAY_CONFIG: foo.conf
  boards:
    myboard:
      append:
        DTC_OVERLAY_FILE: myboard.overlay
        OVERLAY_CONFIG: myboard.conf
    /my-regular-expression-over-board-names/:
      append:
        DTC_OVERLAY_FILE: myregexp.overlay
        OVERLAY_CONFIG: myregexp.conf

(Note that since the snippet feature is intended to be extensible, the
same snippet name may appear in multiple files throughout any
directory in SNIPPET_ROOT, with each addition augmenting prior ones.)

This initial syntax aligns with the following snippet design goals:

- extensible: you can add board-specific support for an existing
  snippet in another module

- able to combine multiple types of configuration: we can now apply a
  .overlay and .conf at the same time

- specializable: this allows you to define settings that only apply
  to a selectable set of boards (including with regular expression
  support for matching against multiple similar boards that follow
  a naming convention)

- DRY: you can use regular expressions to apply the same snippet
  settings to multiple boards like this: /(board1|board2|...)/

This patch is not trying to design and implement everything up front.
Additional features can and will be added to the snippet.yml format
over time; using YAML as a format allows us to make
backwards-compatible extensions as needed.

Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
2023-03-26 16:12:41 +02:00
Marti Bolivar 80ca540522 snippets: basic build system boilerplate
Basic things needed to integrate the new 'snippets' feature into the
build system. The main CMake variable which controls snippets is
SNIPPET. It is a whitespace-or-semicolon-separated list of snippet
names.

- Add minimal new cmake module for processing snippets. This just has
  basic infrastructure for processing a SNIPPET variable into
  SNIPPET_AS_LIST, and warning the user if they try to change it too
  late.

- Integrate the new module into the build system, via
  zephyr_default.cmake

This is anologous to the shields and boards modules' boilerplate and
input variables.

Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
2023-03-26 16:12:41 +02:00
Jamie McCrae 20ab0578d2 cmake: Change prj_<board>.conf deprecation location
Moves the deprecation notice for prj_<board>.conf files to the
proper location where other deprecation notices are located.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-03-22 08:58:14 +00:00
Jamie McCrae fbdd4ee379 cmake: Add warning when using prj_<board>.conf file
Adds a warning that this method of configuration is deprecated.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-03-20 10:18:32 +01:00
Jamie McCrae f9d0e38376 cmake: Throw error if no prj.conf file is in the app config dir
This now throws an error if there is no prj.conf file located in a
user-specified APPLICATION_CONFIG_DIR, which otherwise would have
used an empty configuration and not included board-specific files.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-03-17 11:49:27 +01:00