Due to the fact that CMake only supports greedy regexes,
the ':' in a Windows path ('C:\...') was being matched leading
to an invalid split of the line. Quote both the name and the path
to avoid this issue.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Fixes: #14513
This commit move the functionality of extracting zephyr modules into
generated CMake and Kconfig include files from CMake into python.
This allows other tools, especially CI to re-use the zephyr module
functionality.
Signed-off-by: Torsten Rasmussen <torsten.rasmussen@nordicsemi.no>
To ensure the proper flags are specified to the toolchain, we need to
keep system headers and non-system headers seperate and set the SYSTEM
flag to target_include_directories for system headers.
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
The gperf hashtables and support functions are created
after the initial zephyr_prebuilt.elf is created, using
data found within it.
A fixed-sized amount of memory is reserved for the
program text of these support functions, as their true
size isn't possible to predict in advance and we don't
want memory addresses after them to shift. To minimize
the amount of space reserved, it seemed reasonable to
hard-code -Os.
However, on ARC, building with -Os can cause various
millicode functions from libgcc to be included in the
binary which would not be present in zephyr_prebuilt.elf
unless zephyr_prebuilt.elf was also built with -Os,
causing anything after them to be shifted, wreaking all
kinds of havoc.
Just build without hardcoding any optimization parameters.
We have checks in the linker scripts to let us know if
we have overflowed the region for the gperf support
functions anyway, so there is no danger of this failing
silently.
Fixes: #14139
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
This turns on the linker flag to sort sections by alignment
in decreasing size of symbols. This helps to minimize
padding between symbols.
This also adds the linker options to sort common symbols by
alignment in descending to minimize the need for padding.
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
If CONFIG_MPU_REQUIRES_POWER_OF_TWO_ALIGNMENT is enabled,
the app shared memory partition may cause waste of memory
due to the need for padding.
For example, tests/subsys/jwt and board mps2_an385:
z_test_mem_partition: addr 0x20000000, size 52
z_libc_partition : addr 0x20000040, size 4
k_mbedtls_partition : addr 0x20008000, size 32736
ending at 0x2000ffff, taking up 65536 bytes
With power-of-two size and alignment requirement,
k_mbedtls_partition takes up 32KB memory and needs to be
aligned on 32KB boundary. If the above partitions are
ordered as shown, there needs to be a lot of padding
after z_libc_partition before k_mbedtls_partition can
start. In order to minimize padding, these partitions
need to be sort by size in descending order.
After the changes here, the partitions are:
k_mbedtls_partition : addr 0x20000000, size 32736
z_test_mem_partition: addr 0x20008000, size 52
z_libc_partition : addr 0x20008040, size 4
ending at 0x2000805f, taking up 32864 bytes
With the above example, sorting results in a saving
of 32672 bytes of saving.
Fixes#14121
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
The app_smem.ld is also being used by architectures other than ARM.
So move the linker script out of include/arch/arm and into
include/linker.
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
When we build with newlib we don't set -nostdinc. In that case make
sure that we leave it to the toolchain to set the system include paths.
The one exception to leaving to the toolchain to set the system include
paths is the path to the newlib headers. Since we build
with -ffreestanding we need to make sure the newlib header path is the
before the toolchain headers. Otherwise the toolchain's 'freestanding'
headers get picked up and that causes issues (for example getting PRI*64
defined properly from inttypes.h due to __STDC_HOSTED__ being '0').
For newlib we accomplish this by having the only system header specified
by zephyr_system_include_directories() being just the newlib headers.
Note: for minlibc we leave things alone as things just happen to work as
the -I include of the libc headers takes precedence over -isystem so we
get the libc headers over the toolchain ones. For the newlib case it
appears that setting both -I and -isystem for the same dir causes the
-I to be ignored.
Fixes#14310
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
The mbedtls library has some globals which results in faults
when user mode tries to access them.
Instantiate a memory partition for mbedtls's globals.
The linker will place all globals found by building this
library into this partition.
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
The empty-library check was introduced because in earlier versions of
CMake the error message for empty libraries was very cryptic. But in
3.13.2 CMake now reports:
-- Configuring done
CMake Error at ../../cmake/extensions.cmake:357 (add_library):
No SOURCES given to target: drivers__entropy
Call Stack (most recent call first):
../../cmake/extensions.cmake:334 (zephyr_library_named)
../../drivers/entropy/CMakeLists.txt:1 (zephyr_library)
which should be clear enough.
In addition to being redundant, our empty library check is run earlier
than CMake's check, so it will falsely report libraries to be empty,
when in fact, in an out-of-tree driver use-case, they will not
actually be empty at Generation time.
CMake runs it's check at generation time and is not affected by this
problem, so we remove the check.
This is a step, but not a complete solution, to resolving #8379.
Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
Rename the poorly named CMake variable 'CONFIG_COMPILER_OPT_AS_LIST'
to 'COMPILER_OPT_AS_LIST' to take it out of the Kconfig-reserved
namespace 'CONFIG_*'.
This is a small step towards resolving #12144
Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
Fixes: #13245
Remove the printing of: 'Including module(s)' when no modules are
included into the CMake build.
Signed-off-by: Torsten Rasmussen <torsten.rasmussen@nordicsemi.no>
MISRA rules (see #9892) forbid alloca() and family, even though those
features can be valuable performance and memory size optimizations
useful to Zephyr.
Introduce a MISRA_SANE kconfig, which when true enables a gcc error
condition whenever a variable length array is used.
When enabled, the mempool code will use a theoretical-maximum array
size on the stack instead of one tailored to the current pool
configuration.
The rbtree code will do similarly, but because the theoretical maximum
is quite a bit larger (236 bytes on 32 bit platforms) the array is
placed into struct rbtree instead so it can live in static data (and
also so I don't have to go and retune all the test stack sizes!).
Current code only uses at most two of these (one in the scheduler when
SCHED_SCALABLE is selected, and one for dynamic kernel objects when
USERSPACE and DYNAMIC_OBJECTS are set).
This tunable is false by default, but is selected in a single test (a
subcase of tests/kernel/common) for coverage. Note that the I2C and
SPI subsystems contain uncorrected VLAs, so a few platforms need to be
blacklisted with a filter.
Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
- newlib needs c standard includes (so no -nostdinc)
- xcc needs toolchain headers (so no -nostdinc)
- with host gcc:
- x86_64 should not build with standard includes (-nostdinc needed)
- native_posix should build with standard include (no -nostdinc)
..
..
To simplify, abstract this and move it to compilers/toolchains and still
depend on what the application wants.
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
This is an integral part of userspace and cannot be used
on its own. Fold into the main userspace configuration.
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
Introduce toolchain_cc_asm macro to capture toolchain specific flags
related to assembly.
-D_ASMLANGUAGE is kept common for all, assuming -D as define flag is
supported by all compilers (which is almost the case).
No functional change expected.
Clang's flags are compatible with gcc, and are thus inherited.
This is motivated by the wish to abstract Zephyr's usage of toolchains,
permitting easier porting to other (commercial) toolchains.
Signed-off-by: Mark Ruvald Pedersen <mped@oticon.com>
We need a generic name for the partition containing
essential C library globals. We're going to need to
add the stack canary guard to this area so user mode
can read it.
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
Move test related code and the testsuite away from tests/ and make it a
proper subsystem.
The way tests were integrate in the tree was not obvious and actual
tests were intermixed with the testsuite code.
This will allow us to have trees with the testcode and without the
samples by just remove the folders tests/ and samples, needed for
isolating actual code from test/sample code.
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
We where defining the variable NOSTDINC_F after we tried to use it.
Move the definition before the first reference fixes things. When
-nostdinc now enabled we need to explicitly add the compiler include
path for x86_64 based builds (x86_64 and ARCH_POSIX).
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
Introduce toolchain_cc_cpp_*-family of macros.
Move the following into the toolchain_cc_cpp_* macros:
* Common base set of flags
* C++ standard version
* RTTI
* Exceptions
These macros must be implemented by every compiler port.
These macros set the respective flags, but leaves logic and control to
the root CMakeLists.txt file.
No functional change expected.
Clang's C++ flags are compatible with gcc, and are thus
inherited.
This is motivated by the wish to abstract Zephyr's usage of toolchains,
permitting easier porting to other (commercial) toolchains.
Signed-off-by: Mark Ruvald Pedersen <mped@oticon.com>
The compiler flags -ffunction-sections and -fdata-sections are already
universally set from arch/common/CMakeLists.txt, so we shall not set
them again for C++ only.
Signed-off-by: Mark Ruvald Pedersen <mped@oticon.com>
Introduce toolchain_cc_optimize_for_* family of macros.
Each macro represents a general optimization class.
Each macro is then responsible for setting an output variable to that
class-of-optimization's flag.
The names of these output variables are decided from the root
CMakeLists.txt.
No functional change expected.
Clang's optimization flags are compatible with gcc, and are thus
inherited.
This is motivated by the wish to abstract Zephyr's usage of toolchains,
permitting easier porting to other (commercial) toolchains.
Signed-off-by: Mark Ruvald Pedersen <mped@oticon.com>
This commit allows for Zephyr modules to be natively integrated into
the build system with CMakeLists.txt and Kconfig files.
The sourcing of module files are done in following order:
- If <module>/zephyr/module.yml exists, use cmake and kconfig settings
for sourcing of additional file
- Else if <module>/zephyr/CMakeLists.txt exists, source this file into
CMake build tree and add <module>/zephyr/Kconfig as osource
If none of the above files are present, the project is considered to
not be a Zephyr module
Signed-off-by: Torsten Rasmussen <torsten.rasmussen@nordicsemi.no>
The dependencies relating to generating LD scripts are declared
incorrectly. This manifests itself as broken incremental builds as
shown in #13001.
This commit aligns the LD script generation with the Zephyr standard
for declaring custom commands.
For instance, custom commands should generate files that are wrapped
by targets. The custom commands should declare the dependencies, not
the targets.
Also, when using custom commands, the OUTPUT signature should be used,
not the TARGET signature, as app_smem was doing.
For details about how Zephyr uses custom commands see
https://samthursfield.wordpress.com/2015/11/21/cmake-dependencies-between-targets-and-files-and-custom-commands/
This fixes#13001.
Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
To be able to correctly express that preprocessing a file will depend
on targets and files we enhance the LD script preprocessing function
by adding all trailing arguments to the DEPENDS section of the custom
command.
Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
This commit applies various refactorings and whitespace fixes in
preparation for the patch that fixes#13001.
It includes changing indentation from tabs to spaces and splitting
tokens across more lines to increase readability and minimize patch
sizes.
Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
This was never a long-term solution, more of a gross hack
to get test cases working until we could figure out a good
end-to-end solution for memory domains that generated
appropriate linker sections. Now that we have this with
the app shared memory feature, and have converted all tests
to remove it, delete this feature.
To date all userspace APIs have been tagged as 'experimental'
which sidesteps deprecation policies.
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
* Newlib now defines a special z_newlib_partition containing
all globals relevant to newlib. Most of these are in libc.a
with a heap tracking variable in newlib's hooks.
* Both C libraries now expose a k_mem_partition containing the
bounds of the malloc heap arena. Threads that want to use
libc malloc() will need to add this to their memory domain.
* z_newlib_get_heap_bounds has been removed, in favor of the
memory partition for the heap arena
* ztest now includes the C library partitions in its memory
domain.
* The mem_alloc test now runs in user mode to prove that this
all works for both C libraries.
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
This particular rule of cmake was causing problems when run in
multi-threaded environment. This change in the dependency will
resolve all such issues and ensures that this script is executed
correctly.
Signed-off-by: Adithya Baglody <adithya.nagaraj.baglody@intel.com>
This patch will run the python scripts for all architectures
to determine the partitions available. This is needed for correct
operation of the app_shared_mem feature.
Signed-off-by: Adithya Baglody <adithya.nagaraj.baglody@intel.com>
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
Introduces the ARCH_ROOT argument, similar to BOARD_ROOT and SOC_ROOT.
This enables support for out-of-tree architectures.
The ARCH_ROOT out-of-tree layout is expected to be the following:
* ${ARCH_ROOT}/arch/${ARCH}/
* ${ARCH_ROOT}/include/arch/${ARCH}/ (Optional)
Signed-off-by: Klaus Petersen <kape@oticon.com>
With the new cmake version, we are able to simplify the generation of
the offset object library without using absolute hardcoded paths.
Instead of the hardcoded paths, we now use the generator:
$<TARGET_OBJECTS:${OFFSETS_LIB}>
This is needed to eventually be able to have an arch-out-of-tree build
Signed-off-by: Klaus Petersen <kape@oticon.com>
This patchset introduces support for building board specific custom
images. Any board which needs to build a custom image (a post-processed
zephyr.bin) should inject the post_build_command from a script in the
corresponding board directory.
Signed-off-by: Rajavardhan Gundi <rajavardhan.gundi@intel.com>
Don't add non-existing include directories, it creates noise and even
warnings in some tooling, like Eclipse.
This fixes#12696
Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
Introduce the first of the toolchain_cc-family of macros:
toolchain_cc_security_fortify and toolchain_cc_security_canaries.
No functional change expected.
Fortify source is not supported by Clang, but this commit retains
current behavior.
This is motivated by the wish to abstract Zephyr's usage of toolchains,
permitting easier porting to other (commercial) toolchains.
Signed-off-by: Mark Ruvald Pedersen <mped@oticon.com>
The "register" keyword was deprecated since C++11.
Add -Wno-register flag for avoid warning, with recent version of C++.
Signed-off-by: Benoit Leforestier <benoit.leforestier@gmail.com>
The gperf hash table 'kobject_hash.c' is always compiled as -Os to
resolve bug #5226, the same bug also affects the gperf hash table
'priv_stacks_hash.c'.
In this patch we copy over the fix from 'kobject_hash.c' to also fix
'priv_stacks_hash.c'.
See #5672 for more discussion on the original fix.
Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
A recent change in how the fixup mechanism works caused several
regressions. See
https://github.com/zephyrproject-rtos/zephyr/pull/12680 for more
details about the regressions.
The core of the matter is that using defines to pass on include paths
causes interopability issues when integrating with external build
systems.
To resolve this we re-write the fixup mechanism to instead generate an
aggregated fixup file that is ready to be included at build time. Then
no paths are passed through defines and we resolve the regressions
reported.
Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
extract_dts_includes.py has been generating DT output and then
concatenating it with fixup header files to create
'generated_dts_board.h'.
In this patch we instead introduce a source file named
'generated_dts_board.h' and have it \#include the appropriate DT
output and fixup files.
This results in a simpler system because users can now read
'generated_dts_board.h' as C source code to see how fixup files and
generated DT output relate to each other. Whereas before they would
have to either read documentation or python code to gain the same
understanding.
Also, it reduces the scope and complexity of one of our most bloated
python scripts, extract_dts_includes.py.
Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
This re-write fixes several issues with how we were checking for
compatibility with the canary flags:
If a compiler did not support any stack canaries, but a user had still
enabled them, this would silently result in no canaries being added
instead of error-ing out as it should have.
Compatiblity for '-mstack-protector-guard=global' was unnecessarily
being tested twice, once in 'check_c_compiler_flag' and once in
'zephyr_cc_option'.
Compatibility was being tested with 'check_c_compiler_flag' which is
slower than 'zephyr_check_compiler_flag' because it does not cache
it's results.
Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
There is an effort underway to make most of the Zephyr build script's
reentrant. Meaning, the build scripts can be executed multiple times
during the same CMake invocation.
Reentrancy enables several use-cases, the motivating one is the
ability to build several Zephyr executables, or images, for instance a
bootloader and an application.
For build scripts to be reentrant they cannot be directly referencing
global variables, like target names, but must instead reference
variables, which can vary from entry to entry.
Therefore, in this patch, we replace global targets with variables.
Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
There is an effort underway to make most of the Zephyr build script's
reentrant. Meaning, the build scripts can be executed multiple times
during the same CMake invocation.
Reentrancy enables several use-cases, the motivating one is the
ability to build several Zephyr executables, or images, for instance a
bootloader and an application.
For build scripts to be reentrant they cannot be directly referencing
global variables, like target names, but must instead reference
variables, which can vary from entry to entry.
Therefore, in this patch, we replace global targets with variables.
Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
When coverage option is enabled, all C files will have
coverage option enabled. When we enable it for generated files
it adds extra .bss info and other related information.
Since the bss has now increased the perfect hash that was
calculated by gperf is now incorrect. Which is a problem
for userspace enabled systems.
This patch will make sure that the generated C files will be
compiled without the coverage flags. The remaining functionality
remains unchanged.
Signed-off-by: Adithya Baglody <adithya.nagaraj.baglody@intel.com>
Cosmetics, no functional change expected.
Fixed leading space alignment.
Replaced tabs with spaces.
Emulation error message output is now aligned.
To locate tabs in cmake, the following bash is useful:
grep -PRil "\t" * | grep -i cmake | grep -v ^sanity
Signed-off-by: Mark Ruvald Pedersen <mped@oticon.com>