Commit graph

266 commits

Author SHA1 Message Date
Danny Oerndrup 51634cd661 cmake: Toolchain abstraction: Abstraction of binary tool, objcopy.
This abstracts the interface for generation of the objcopy command
line, by naming the desired actions instead of directly setting the
command parameters, which then opens up for other binary tool sets
which may require different arguments to achieve the desired result.

The intent here is to abstract Zephyr's dependence on toolchains,
thus allowing for easier porting to other, perhaps commercial,
toolchains and/or usecases.

No functional change expected.

Signed-off-by: Danny Oerndrup <daor@demant.com>
2019-08-02 13:05:59 +02:00
Danny Oerndrup c41e712c6f cmake: Toolchain abstraction: Abstraction of print memory usage.
The method for getting a memory usage report printed during build, is
based on a GNU linker (ld) option flag, and thus is not necessarily
supported by other toolchain binary tools.
The introduced cmake macro allows for a given toolchain to specify how
the memory usage report is to be generated, and whether the command for
generation, if any, is to be added to the post_build_commands and the
post_build_byproducts lists of the top level CMakeLists.txt

The intent here is to abstract Zephyr's dependence on toolchains,
thus allowing for easier porting to other, perhaps commercial,
toolchains and/or usecases.

No functional change expected.

Signed-off-by: Danny Oerndrup <daor@demant.com>
2019-07-31 11:09:35 +02:00
Danny Oerndrup e0569ac2dc cmake: Toolchain abstraction: Abstract compiler flag for add debug info
The macro, toolchain_cc_produce_debug_info, adds the compiler specific
flag for enabling the production of debugging information in the
toolchain native format.

The intent here is to abstract Zephyr's dependence on toolchains,
thus allowing for easier porting to other, perhaps commercial,
toolchains and/or usecases.

No functional change expected.

Signed-off-by: Danny Oerndrup <daor@demant.com>
2019-07-29 16:59:09 +02:00
Carles Cufi 3ad1f27efc cmake: Encode and decode in UTF-8 in build system
In order to make sure that the build works in folders that require a UTF
encoding, make sure that both CMake and the various Python scripts that
interact with each other on files use the same encoding, in this case
UTF-8.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2019-07-18 16:50:08 +02:00
Andy Ross 50b78f08ea cmake: Remove check_link_map.py
This script is looking for a hyperspecific error (mismatched padding
when linking into two simultaneous output sections) that bit us once,
in an era where the linker scripts were less unified.  We haven't seen
it crop up since, and multiple platforms have changed the way they do
this anyway.

It's needless complexity.  Junk it.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2019-07-14 04:54:29 -07:00
Nicolas Pitre b86aa65723 CMakeLists.txt: parse zephyr_stdint.h after compiler specific flags
The zephyr_stdint.h file enforces Zephyr specific policies on the
compilation environment. Let's give compilers a chance to provide
definitions of their own via TOOLCHAIN_C_FLAGS prior the inclusion
of zephyr_stdint.h.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2019-07-03 06:09:16 -04:00
Nicolas Pitre f32330b22c stdint.h: streamline type definitions
Compilers (at least gcc and clang) already provide definitions to
create standard types and their range. For example, __INT16_TYPE__ is
normally defined as a short to be used with the int16_t typedef, and
__INT16_MAX__ is defined as 32767. So it makes sense to rely on them
rather than hardcoding our own, especially for the fast types where
the compiler itself knows what basic type is best.

Using compiler provided definitions makes even more sense when dealing
with 64-bit targets where some types such as intptr_t and size_t must
have a different size and range. Those definitions are then adjusted
by the compiler directly.

However there are two cases for which we should override those
definitions:

* The __INT32_TYPE__ definition on 32-bit targets vary between an int
  and a long int depending on the architecture and configuration.
  Notably, all compilers shipped with the Zephyr SDK, except for the
  i586-zephyr-elfiamcu variant, define __INT32_TYPE__ to a long int.
  Whereas, all Linux configurations for gcc, both 32-bit and 64-bit,
  always define __INT32_TYPE__ as an int. Having variability here is
  not welcome as pointers to a long int and to an int are not deemed
  compatible by the compiler, and printing an int32_t defined with a
  long using %d makes the compiler to complain, even if they're the
  same size on 32-bit targets. Given that an int is always 32 bits
  on all targets we might care about, and given that Zephyr hardcoded
  int32_t to an int before, then we just redefine __INT32_TYPE__ and
  derrivatives to an int to keep the peace in the code.

* The confusion also exists with __INTPTR_TYPE__. Looking again at the
  Zephyr SDK, it is defined as an int, even even when __INT32_TYPE__ is
  initially a long int. One notable exception is i586-zephyr-elf where
  __INTPTR_TYPE__ is a long int even when using -m32. On 64-bit targets
  this is always a long int. So let's redefine __INTPTR_TYPE__ to always
  be a long int on Zephyr which simplifies the code, works for both
  32-bit and 64-bit targets, and mimics what the Linux kernel does.
  Only a few print format strings needed adjustment.

In those two cases, there is a safeguard to ensure the type we're
enforcing has the right size and fail the build otherwise.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2019-06-25 23:29:22 -04:00
Anas Nashif f2cb20c772 docs: fix misspelling across the tree
Found a few annoying typos and figured I better run script and
fix anything it can find, here are the results...

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-06-19 15:34:13 -05:00
Marc Herbert 83723109be cmake: silence "WARNING: ASSERTs enabled" when CONFIG_TEST is true
TEST configurations don't need to be warned that they're using test
techniques with some side-effects.

On a typical sanitycheck invocation, this warning is one of the only two
that appears in most test runs. In other words this commit gets rid of
half of the entire grep -ri '[[:blank:]]warn' noise that obscures any
work-in-progress warnings or platform specific warnings in the
logs (typically: device tree warnings).

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2019-06-17 22:47:05 -04:00
Marc Herbert f67dcdbdf8 CMakeLists.txt: -fmacro-prefix-map=${CMAKE_SOURCE_DIR}=CMAKE_SOURCE_DIR
In commit 28a5657f1f we stopped ZEPHYR_BASE from leaking into
__FILE__ and other macros.  This works great for apps inside ZEPHYR_BASE
but does nothing for apps outside ZEPHYR_BASE.
-fmacro-prefix-map=${CMAKE_SOURCE_DIR}=CMAKE_SOURCE_DIR does it.

To avoid collisions and for consistency change:
  -fmacro-prefix-map=${ZEPHYR_BASE}=.
to:
  -fmacro-prefix-map=${ZEPHYR_BASE}=ZEPHYR_BASE

Quickest test/demo:

 - Copy samples/hello_word/ to ~/home_world/
 - Add "%s", __FILE__  to printf in ~/home_world/src/main.c

 cmake -B build  -S ~/home_world/  -DBOARD=qemu_x86
 make  -C build  run

Before:
     ~/home_world/src/main.c says Hello World! qemu_x86

After:
 CMAKE_SOURCE_DIR/src/main.c says Hello World! qemu_x86

objdump -h $(find build -name *.c.obj) | grep noinit

  9 .noinit."ZEPHYR_BASE/kernel/system_work_q.c".0 0000
 17 .noinit."ZEPHYR_BASE/kernel/init.c".2 00000100  000
 18 .noinit."ZEPHYR_BASE/kernel/init.c".1 00000400  000
 19 .noinit."ZEPHYR_BASE/kernel/init.c".3 00000800  000
 16 .noinit."ZEPHYR_BASE/kernel/mailbox.c".2 00000348
 18 .noinit."ZEPHYR_BASE/kernel/mailbox.c".1 00000028
 20 .noinit."ZEPHYR_BASE/kernel/pipes.c".2 00000280  00
 22 .noinit."ZEPHYR_BASE/kernel/pipes.c".1 00000028  00

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2019-06-17 16:21:51 -04:00
Marc Herbert 0370c9b76c cmake: stop destroying intermediate link maps like zephyr_prebuilt.map
The different linker steps are all hardcoded to the output filename
"zephyr.map" and only the last one survives.

Un-harcode.

This removes some confusion when trying to follow who builds
what/when/how and it stops destroying intermediate linking information
useful when tracing/debugging new features or issues in the build.

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2019-06-17 12:02:12 -07:00
Danny Oerndrup 6331dae623 cmake: Toolchain abstraction: Introducing macro toolchain_cc_cstd_flag
The macro obtains the toolchain specific flag and value for
setting of the requested c standard.

The intent here is to abstract Zephyr's dependence on toolchains,
thus allowing for easier porting to other, perhaps commercial,
toolchains and/or usecases.

No functional change expected.

Signed-off-by: Danny Oerndrup <daor@demant.com>
2019-06-14 10:25:28 +02:00
Mark Ruvald Pedersen 4052bac93f cmake: Introduce toolchain_ld_link_elf to abstract linker invocation
Final step of linker abstraction:
 * Abstract zephyr_lnk by including it in toolchain_ld_link_elf.
 * Abstract relevant uses of target_link_libraries.
 * Introduce toolchain_ld_force_undefined_symbols.

No functional change expected.

This is motivated by the wish to abstract Zephyr's usage of toolchains,
permitting non-intrusive porting to other (commercial) toolchains.

Signed-off-by: Mark Ruvald Pedersen <mped@oticon.com>
2019-06-13 14:06:24 +02:00
Danny Oerndrup e34ed7c8e2 cmake: Toolchain abstraction: Introducing macro toolchain_cc_nocommon
The macro is intended to abstract the -fno-common compiler option
which controls the placement of uninitialized global variables. The
macro leaves it up to the toolchain to define the option.

The intent here is to abstract Zephyr's dependence on toolchains,
thus allowing for easier porting to other, perhaps commercial,
toolchains and/or usecases.

No functional change expected.

Signed-off-by: Danny Oerndrup <daor@demant.com>
2019-06-13 13:08:11 +02:00
Danny Oerndrup 4ddbc0096a cmake: Toolchain abstraction: Introducing macro toolchain_cc_imacros
The macro is intended to abstract the -imacros compiler option for
inclusion of the autoconf.h header file. The abstraction allows for a
given toolchain to decide how the inclusion of the header file is to
be done.

The intent here is to abstract Zephyr's dependence on toolchains,
thus allowing for easier porting to other, perhaps commercial,
toolchains and/or usecases.

No functional change expected.

Signed-off-by: Danny Oerndrup <daor@demant.com>
2019-06-12 13:05:40 +02:00
Danny Oerndrup faa72b7015 cmake: Toolchain abstraction: Introducing toolchain_cc_freestanding
The macro is intended to abstract the -ffreestanding compiler option
which tells the compiler that this is a bare metal env. The option is
compiler and thus toolchain specific, but this macro leaves it up to
the toolchain to decide the value of the option.

The intent here is to abstract Zephyr's dependence on toolchains,
thus allowing for easier porting to other, perhaps commercial,
toolchains and/or usecases.

No functional change expected.

Signed-off-by: Danny Oerndrup <daor@demant.com>
2019-06-12 10:16:17 +02:00
Marc Herbert d3d3394893 cmake: warn if inconsistency between CMAKE_SOURCE_DIR and ZEPHYR_BASE
cmake has a number of issues dealing with symbolic links:

  https://gitlab.kitware.com/cmake/cmake/issues/16228

One of them can cause cmake to rewrite the -S input from the user and
CMAKE_SOURCE_DIR to unexpectedly include symbolic links:

  https://cmake.org/pipermail/cmake/2019-May/thread.html#69496

Catch this corner case and warn about subtle issues like breaking
-fmacro-prefix-map=${ZEPHYR_BASE}=

Sample warning message:

CMake Warning at ../../CMakeLists.txt:30 (message):
  ZEPHYR_BASE doesn't match CMAKE_CURRENT_SOURCE_DIR

    ZEPHYR_BASE              = ~/zephyrproject/zephyr
    PWD                      = ~/westsymlink/zephyr/samples/hello_world
    CMAKE_CURRENT_SOURCE_DIR = ~/westsymlink/zephyr

  You may be using a mix of symbolic links and real paths which causes
  subtle and hard to debug CMake issues.

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2019-06-11 12:57:18 -04:00
Anas Nashif 6e27d6d3d1 mbedtls: move to external module
Use external module from https://github.com/zephyrproject-rtos/mbedtls

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-06-11 08:33:53 -04:00
Anas Nashif 3c2e43a19f cmake: build modules under /modules
As we start adding more modules, all of them end up in
${CMAKE_BINARY_DIR}/ and this is getting too busy. We have a module
directory created for each module and the interesting build data is
getting lost in the crowd.

Move all module into ${CMAKE_BINARY_DIR}/modules to and keep them under
one directory.

Future enhancement: maintain the same structure of the modules as
checked out by west.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-05-29 07:27:32 -04:00
Danny Oerndrup 025ffa2492 cmake: Toolchain abstraction: Abstraction of implicit-int error flag
Introducing the macro toolchain_cc_warning_error_implicit_int which,
abstracts the implicit_int error flag thus leaving it to the toolchain
to decide whether this flag is needed or not.

The intent here is to abstract Zephyr's dependence on toolchains,
thus allowing for easier porting to other, perhaps commercial,
toolchains and/or usecases.

No functional change expected.

Signed-off-by: Danny Oerndrup <daor@demant.com>
2019-05-22 15:28:07 +02:00
Danny Oerndrup 8e5a95e4df cmake: Toolchain abstraction: Introduce macros for MISRA SANE flags
The macros are named toolchain_cc_warning_error_misra_sane and
toolchain_cc_cpp_warning_error_misra_sane

These macros provide toolchain specific flag(s) relating to the MISRA
SANE configuration option.
The macros will place the flag(s) in a variable provided by caller,
which can then add to zephyr compile options.

The intent here is to abstract Zephyr's dependence on toolchains,
thus allowing for easier porting to other, perhaps commercial,
toolchains and/or usecases.

No functional change expected.

Signed-off-by: Danny Oerndrup <daor@demant.com>
2019-05-22 15:28:07 +02:00
Danny Oerndrup 8eaa906836 cmake: Toolchain abstraction: Added missing colon to some <at>Intent's
No functional change expected.

Signed-off-by: Danny Oerndrup <daor@demant.com>
2019-05-22 15:28:07 +02:00
Ulf Magnusson 9b6c2f4bf3 c++: kconfig: Fix choice dependencies and use 'menuconfig' symbol
- Make the 'C++ Standard' choice depend on CPLUSPLUS, so that it only
   shows up when C++ support is enabled.

   Also check that CPLUSPLUS is enabled before checking the standard in
   the top-level CMakeLists.txt, to avoid triggering an assert.

 - The 'C++ Options' menu now contains just CPLUSPLUS and its indented
   children. Remove one menu level by removing the menu and turning
   CPLUSPLUS into a 'menuconfig' symbol. Also change the prompt from
   "Enable C++ support for the application" to just "C++ support for the
   application", to make it consistent with e.g. "Logging".

 - Factor out the common CPLUSPLUS dependency with an 'if CPLUSPLUS'.

 - Order symbol properties more consistently with other Kconfig files,
   with the prompt at the top, etc.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-05-16 07:08:21 -05:00
Danny Oerndrup cbbbdeaae5 cmake: Toolchain abstraction: Introduce toolchain_cc_warning_extended
This is placeholder for extended warning flags, likely to change between
toolchains.

The intent here is to abstract Zephyr's dependence on toolchains,
thus allowing for easier porting to other, perhaps commercial,
toolchains and/or usecases.

No functional change expected.

Signed-off-by: Danny Oerndrup <daor@demant.com>
2019-05-14 18:19:18 +02:00
Danny Oerndrup bdb229faff cmake: Toolchain abstraction: Introduce toolchain_cc_warning_base
This is placeholder for base warning flags, common to most toolchains.

The intent here is to abstract Zephyr's dependence on toolchains,
thus allowing for easier porting to other, perhaps commercial,
toolchains and/or usecases.

No functional change expected.

Signed-off-by: Danny Oerndrup <daor@demant.com>
2019-05-14 18:19:18 +02:00
Danny Oerndrup 8650b150b9 cmake: Toolchain abstraction: Introduce toolchain_cc_warning_dw_[1-3]
The introduced macros are placeholders for the cmake parameter warning
level.

The intent here is to abstract Zephyr's dependence on toolchains,
thus allowing for easier porting to other, perhaps commercial,
toolchains and/or usecases.

No functional change expected.

Signed-off-by: Danny Oerndrup <daor@demant.com>
2019-05-14 18:19:18 +02:00
Mark Ruvald Pedersen 197197a579 cmake: Toolchain abstraction: Introduce toolchain_ld_configure_files
No functional change expected.

This is motivated by the wish to abstract Zephyr's usage of toolchains,
permitting non-intrusive porting to other (commercial) toolchains.

Signed-off-by: Mark Ruvald Pedersen <mped@oticon.com>
2019-05-12 12:50:57 -04:00
Sebastian Bøe f483e5b527 cmake: Mark post_build files as BYPRODUCTS
Mark post_build files as BYPRODUCTS to allow custom commands to depend
on them.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2019-05-12 12:49:24 -04:00
Mark Ruvald Pedersen 37d494778e cmake: Rename kernel_elf to zephyr_final
* KERNEL_ELF was easily confused with KERNEL_ELF_NAME and KERNEL_NAME.
 * kernel_elf as the name of the binary indicates it somehow only
   contains the kernel, which is not correct.

Rename to zephyr_final as this is the reality: Zephyr elf has been
linked again (a number of times) due to generated kernel files.

Signed-off-by: Mark Ruvald Pedersen <mped@oticon.com>
2019-05-08 10:40:39 -04:00
Mark Ruvald Pedersen d7ee114106 cmake: Toolchain abstraction: move PROPERTY_LINKER_SCRIPT_DEFINES
Move PROPERTY_LINKER_SCRIPT_DEFINES to toolchain_ld_base.

No functional change expected.

This is motivated by the wish to abstract Zephyr's usage of toolchains,
permitting non-intrusive porting to other (commercial) toolchains.

Signed-off-by: Mark Ruvald Pedersen <mped@oticon.com>
2019-05-07 22:17:29 -04:00
Mark Ruvald Pedersen 86a3e8ff40 cmake: Toolchain abstraction: Introduce toolchain_ld_relocation macro
No functional change expected.

This is motivated by the wish to abstract Zephyr's usage of toolchains,
permitting non-intrusive porting to other (commercial) toolchains.

Signed-off-by: Mark Ruvald Pedersen <mped@oticon.com>
2019-05-04 08:59:53 -04:00
Mark Ruvald Pedersen 5f347eefe6 cmake: move configure_linker_script to ld/target.cmake
While configure_linker_script() may be useful for other linkers, it
currently only aimed at GNU ld. To really be useful among different
linkers, we would need to abstract its usage of the C preprocessor.
We can do this later, if needed.

No functional change expected.

Signed-off-by: Mark Ruvald Pedersen <mped@oticon.com>
2019-05-02 21:54:27 +02:00
Mark Ruvald Pedersen fbcea17c86 cmake: simplify configure_linker_script: avoid deriving define from name
Rather than associating defines within the function, let the call sites
themselves pick the appropriate define. Add new argument for this.
This also permits us to remove regex matching.

No functional change expected.

Signed-off-by: Mark Ruvald Pedersen <mped@oticon.com>
2019-05-02 21:54:27 +02:00
Mark Ruvald Pedersen 1073fbaa00 cmake: configure_linker_script: accept argument with file extension
Reduce the amount of {pre,post}fixing magic: I.e. let it be clearer at
call sites that "linker.cmd" is a file, rather than having to know that
"linker" will be postfixed with ".cmd" internally.

Change argument name to linker_script_gen, to better indicate that we
are producing a generated file.

No functional change expected.

Signed-off-by: Mark Ruvald Pedersen <mped@oticon.com>
2019-05-02 21:54:27 +02:00
Mark Ruvald Pedersen 4c811971f5 cmake: rename construct_add_custom_command_for_linker_pass macro
Now that we avoid the two-step procedure, we can simplify the name of
the construct_add_custom_command_for_linker_pass macro.

Move description comment up to head of definition, making the purpose
clearer.

No functional change expected.

Signed-off-by: Mark Ruvald Pedersen <mped@oticon.com>
2019-05-02 21:54:27 +02:00
Mark Ruvald Pedersen 11d6baea8c cmake: change construct_add_custom_command_for_linker_pass into macro
Change construct_add_custom_command_for_linker_pass from function into
macro. The purpose of the function was to set the output variable to a
string that would be fed to add_custom_command. This meant all use
required a two-step procedure and an intermediate
variable (custom_command).

The environmental leakage from a macro in this case is small, so let's
just simplify to a macro and avoid the two-step.

No functional change expected.

Signed-off-by: Mark Ruvald Pedersen <mped@oticon.com>
2019-05-02 21:54:27 +02:00
Mark Ruvald Pedersen 8c7c2d21e8 cmake: whitespace alignment of syscall_macros_h
No functional change expected.

Signed-off-by: Mark Ruvald Pedersen <mped@oticon.com>
2019-05-02 21:54:27 +02:00
Mark Ruvald Pedersen 85af28050e cmake: remove unused ALIGN_SIZING_DEP
Full grep reveal ALIGN_SIZING_DEP is only mentioned in cmake, where
it is never assigned a value.

No functional change expected.

Signed-off-by: Mark Ruvald Pedersen <mped@oticon.com>
2019-05-02 21:54:27 +02:00
Mark Ruvald Pedersen 3db09aa610 cmake: Toolchain abstraction: introduce toolchain_ld_cpp
No functional change expected.

This is motivated by the wish to abstract Zephyr's usage of toolchains,
permitting non-intrusive porting to other (commercial) toolchains.

Signed-off-by: Mark Ruvald Pedersen <mped@oticon.com>
2019-05-02 15:19:02 +02:00
Mark Ruvald Pedersen b14b59c9e4 cmake: Toolchain abstraction: move symbol sorting into toolchain_ld_base
No functional change expected.

This is motivated by the wish to abstract Zephyr's usage of toolchains,
permitting non-intrusive porting to other (commercial) toolchains.

Signed-off-by: Mark Ruvald Pedersen <mped@oticon.com>
2019-05-02 07:47:14 -04:00
Mark Ruvald Pedersen 173c953e9c cmake: Toolchain abstraction: orphan handling in toolchain_ld_baremetal
Move GNU ld linker specific flags related to orphan handling into
toolchain_ld_baremetal().

No functional change expected.

This is motivated by the wish to abstract Zephyr's usage of toolchains,
permitting non-intrusive porting to other (commercial) toolchains.

Signed-off-by: Mark Ruvald Pedersen <mped@oticon.com>
2019-05-02 07:47:14 -04:00
Mark Ruvald Pedersen 69928beb36 cmake: Toolchain abstraction: build-id,gc-sections to toolchain_ld_base
Move --gc-sections flag to toolchain_ld_base()
Move --build-id=none flag to toolchain_ld_base()

No functional change expected.

This is motivated by the wish to abstract Zephyr's usage of toolchains,
permitting non-intrusive porting to other (commercial) toolchains.

Signed-off-by: Mark Ruvald Pedersen <mped@oticon.com>
2019-05-02 07:47:14 -04:00
Mark Ruvald Pedersen 65f02c04d5 cmake: Toolchain abstraction: introduce toolchain_ld_baremetal()
The intent of toolchain_ld_baremetal() is to collect the flags belonging
to non-hosted (i.e. POSIX-based) targets.

No functional change expected.

This is motivated by the wish to abstract Zephyr's usage of toolchains,
permitting non-intrusive porting to other (commercial) toolchains.

Signed-off-by: Mark Ruvald Pedersen <mped@oticon.com>
2019-04-30 10:13:41 -04:00
Mark Ruvald Pedersen 4080818300 cmake: Toolchain abstraction: move LINKERFLAGPREFIX under GNU ld
* LINKERFLAGPREFIX's value is GNU ld specific, and
* LINKERFLAGPREFIX is not a convention always honored by all linkers.

Thus we shall not set it from the common root CMakeList.txt.
So we move to linker/ld/target.cmake.

No functional change expected.

This is motivated by the wish to abstract Zephyr's usage of toolchains,
permitting non-intrusive porting to other (commercial) toolchains.

Signed-off-by: Mark Ruvald Pedersen <mped@oticon.com>
2019-04-30 10:13:41 -04:00
Oleg Zhurakivskyy 2211935ed6 cmake: clang: Make clang pick -T option on linking
When linking, clang doesn't pick -T for some reason and complains,
while -Wl,-T works for both, gcc and clang.

Signed-off-by: Oleg Zhurakivskyy <oleg.zhurakivskyy@intel.com>
2019-04-30 09:33:54 -04:00
Mark Ruvald Pedersen 1f01325ee5 cmake: Toolchain abstraction: use LINKER, introduce toolchain_ld_base
toolchain_ld_base() represents flags that are fundamental to linking or
otherwise does not belong in any further specified linker flag category.

No functional change expected.

This is motivated by the wish to abstract Zephyr's usage of toolchains,
permitting non-intrusive porting to other (commercial) toolchains.

Signed-off-by: Mark Ruvald Pedersen <mped@oticon.com>
2019-04-28 12:52:18 -04:00
Mark Ruvald Pedersen 3419efd552 cmake: fix intent description of toolchain_cc_nostdinc macro
toolchain_cc_nostdinc does not only obtain flags (to be placed in a
variable), it obtains and applies them.

No functional change expected.

Signed-off-by: Mark Ruvald Pedersen <mped@oticon.com>
2019-04-28 12:52:18 -04:00
Marc Herbert 4a10eea0eb gen_kobject_list.py: better comments and --help. Zero code change.
- The script can but does not always generate five files, in fact the
  current build invokes it at least three times requesting different
  outputs every time.

- --kobj-types-output produces a code fragment; not a standalone/usable
  header file. It outputs enum constants for a single enum type and not
  several enum types.

- Some outputs include driver instances and others not: clarify which.

- There's an entire and great section in the documentation that took
  me ages to find because it's not referenced anywhere in the --help
  or code. Fixed.

- Highlight the massive duplication in the CMakeLists.txt to save
  déjà vu confusion and minimize future divergence.

- Other minor tweaks.

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2019-04-26 03:21:59 -07:00
Sebastian Bøe 3a0597f099 cmake: LD: Allow input sections to remain unsorted
We have users that have problems in their linker scripts where the
order of input sections matters.

To allow users to use the latest Zephyr while working on a fix to
their linker scripts we add an option to allow leaving the sections
unsorted.

See discussion here for more details
https://github.com/zephyrproject-rtos/zephyr/pull/14183

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2019-04-24 13:58:00 -07:00
Marc Herbert 498b49469a CMakeLists.txt: fix misleading logical_target_for_zephyr_elf comment
The comment for:

  set_target_properties(${logical_target_for_zephyr_elf} PROPERTIES
     OUTPUT_NAME ${KERNEL_NAME})

was completely off-topic and making something relatively simple
incredibly puzzling and time-consuming to understand.

Re-order the if(GKSF OR GKOF) clauses so the two initializations of
logical_target_for_zephyr_elf are close to each other and so the very
short clause is not buried at the bottom of the long one.

Other minor logical_target_for_zephyr_elf comment fixes.

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2019-04-19 09:26:23 -05:00
Marc Herbert 28a5657f1f cmake: zephyr_cc_option(-fmacro-prefix-map=${ZEPHYR_BASE}=.)
If the compiler supports it, strip the ${ZEPHYR_BASE} prefix from the
__FILE__ macro used in __ASSERT* macros, in the
.noinit."/home/joe/zephyr/fu/bar.c" section names and in any application
code. This saves some memory, stops leaking user locations in binaries,
makes failure logs more deterministic and most importantly makes builds
more deterministic.

- .noinit section names now look like this in objdump -h:

 17 .noinit."./kernel/init.c".2 00001100  00000000  ...

 18 .noinit."./kernel/init.c".1 00001200  00000000  ...

 19 .noinit."./kernel/init.c".3 00001800  00000000  ...

- The output of __ASSERT* macros now looks like this:

  ASSERTION FAIL [0] @ ./samples/hello_world/src/main.c:13
    The world comes crashing down
  ***** Kernel Panic! *****
  Current thread ID = 0x00400040

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2019-04-17 08:08:14 -04:00
Bradley Bolen 4198ba71f2 cmake: Fix missing dependency
DRV_VALIDATION should depend on any changes to the tool that generates
it, gen_kobject_list.py.

Signed-off-by: Bradley Bolen <bbolen@lexmark.com>
2019-04-16 22:53:49 -04:00
Anas Nashif 3ae52624ff license: cleanup: add SPDX Apache-2.0 license identifier
Update the files which contain no license information with the
'Apache-2.0' SPDX license identifier.  Many source files in the tree are
missing licensing information, which makes it harder for compliance
tools to determine the correct license.

By default all files without license information are under the default
license of Zephyr, which is Apache version 2.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-04-07 08:45:22 -04:00
Daniel Leung 84b1bba8ee codecov: keep "inline" for ALWAYS_INLINE
Previous commit c31e659165 changed
the ALWAYS_INLINE macros to avoid functions being inlined for
the purpose of code coverage. This has a side effect of causing
the text sections of kobject_hash.c and priv_stacks_hash.c
to ballon more than 10 times in size. This is caused by
attaching the unused attribute, which results in all those
functions being in the text sections though they are never
used. So just keep the "inline" there.

This also removes -fno-inline from NO_COVERAGE_FLAGS so these
two files are not compiled with flags related to code coverage.

Fixes #15009

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2019-04-02 09:39:44 -04:00
Carles Cufi 766edd449d cmake: modules: Enclose name and path in quotes
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>
2019-04-01 07:27:23 +08:00
Torsten Rasmussen bd7569f272 cmake: Extracted Zephyr module processing into python script
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>
2019-03-29 23:10:59 -04:00
Kumar Gala 3713ea4761 cmake: Fix how we set include dirs for userspace
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>
2019-03-15 06:42:41 -05:00
Andrew Boie a514898ee7 userspace: don't modify optimization options
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>
2019-03-14 22:22:31 -05:00
Daniel Leung af10d16a08 linker: sort sections by alignment
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>
2019-03-13 15:54:29 -05:00
Daniel Leung 212ec9a29a linker: sort app shared mem partition by alignment
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>
2019-03-13 18:26:51 +01:00
Daniel Leung e8a2348fac linker: move app_smem.ld into include/linker
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>
2019-03-13 18:26:51 +01:00
Kumar Gala 7aa8e43add libc: newlib: Cleanup/fix setting of system include paths
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>
2019-03-13 06:50:23 -05:00
Andrew Boie e686aefe09 mbedtls: provide user mode access
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>
2019-03-05 08:27:20 -05:00
Sebastian Bøe 8730854206 cmake: Don't assert when empty libraries are detected
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>
2019-03-03 23:54:00 -05:00
Sebastian Bøe 244451b64f cmake: Rename CMake variable out of the reserved CONFIG_ namespace
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>
2019-03-03 23:52:29 -05:00
Torsten Rasmussen 605ae101eb cmake: remove debug message if no modules are included in build.
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>
2019-03-03 17:43:47 -05:00
Andy Ross fe04adf99b lib/os: Conditionally eliminate alloca/VLA usage
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>
2019-02-28 10:06:35 -08:00
Anas Nashif 29f04767e9 arch: move common app_data_alignment.ld file
This file is being used by different architectures and is not ARC
specific.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-02-28 08:53:16 -08:00
Anas Nashif aa049e5d8f toolchain: abstract setting -nostdinc
- 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>
2019-02-24 17:48:10 -05:00
Andrew Boie 4ce652e4b2 userspace: remove APP_SHARED_MEM Kconfig
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>
2019-02-23 07:43:55 -05:00
Mark Ruvald Pedersen cb0fd451c2 cmake: Toolchain abstraction: Assembly
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>
2019-02-23 07:41:46 -05:00
Andrew Boie 17ce822ed9 app_shmem: create generic libc partition
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>
2019-02-22 18:50:43 -05:00
Anas Nashif ccad9d0d09 tests: move testsuite and configs into subsys/
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>
2019-02-22 08:58:40 -05:00
Kumar Gala 9c2ac77861 cmake: Fix setting of -nostdinc
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>
2019-02-20 12:13:45 -06:00
Mark Ruvald Pedersen 63df409906 cmake: Toolchain abstraction: C++
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>
2019-02-19 12:33:19 -05:00
Mark Ruvald Pedersen efb50e7af2 cmake: remove redundant compiler flags for C++
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>
2019-02-19 12:33:19 -05:00
Mark Ruvald Pedersen 0b3c65feea cmake: Toolchain abstraction: optimizations
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>
2019-02-18 08:22:42 -05:00
Andrew Boie 9af5089dee build: remove meltdown warning
Now addressed by KPTI.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-02-14 12:46:36 -05:00
Kumar Gala b16509f168 cmake: Remove dead Kconfig CONFIG_READABLE_ASM
CONFIG_READABLE_ASM hasn't existed as Kconfig option, so remove dead
references to it

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-02-11 22:29:58 -05:00
Torsten Rasmussen 7e9d1bdda4 CMake/Kconfig: CMake and Kconfig build integration
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>
2019-02-08 22:47:02 -05:00
Sebastian Bøe 2a96312749 cmake: Fix dependencies for LD script generation
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>
2019-02-08 16:39:43 -06:00
Sebastian Bøe b43c6120ab cmake: Allow deps to be added to the preprocessing of LD scripts
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>
2019-02-08 16:39:43 -06:00
Sebastian Bøe 7a6afcdc04 cmake: Various refactorings and whitespace fixes
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>
2019-02-08 16:39:43 -06:00
Andrew Boie 41f6011c36 userspace: remove APPLICATION_MEMORY feature
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>
2019-02-08 07:04:30 -05:00
Andrew Boie 4b4f773484 libc: set up memory partitions
* 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>
2019-02-08 07:04:30 -05:00
Adithya Baglody c12381793a CMakeLists: fix app_shmem dependency
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>
2019-02-08 07:04:30 -05:00
Adithya Baglody 50950eb2c9 app_shmem: use script for all arches
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>
2019-02-08 07:04:30 -05:00
Klaus Petersen c66cb76fed Build: Added support for out-of-tree Arch
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>
2019-02-07 17:00:43 -05:00
Klaus Petersen 62e55e5e4b Build: Offsets lib as OBJECT not STATIC
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>
2019-02-04 13:14:09 -05:00
Rajavardhan Gundi ecdea1c30c CMakeLists: Introduce extra post build commands
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>
2019-01-30 21:30:49 -05:00
Sebastian Bøe 40363399c9 cmake: Don't use non-existing include paths
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>
2019-01-30 10:47:08 -05:00
Mark Ruvald Pedersen 01592071f1 cmake: Toolchain abstraction: security
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>
2019-01-30 08:42:11 -05:00
Benoit Leforestier 04dad5954c C++: Suppress warning
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>
2019-01-29 17:50:20 +01:00
Sebastian Bøe 5bd5e4e440 cmake: userspce: Always compile priv_stacks_hash.c as -Os
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>
2019-01-28 14:16:50 -08:00
Sebastian Bøe 361fdaac1a cmake: Fix the generation of fixup files
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>
2019-01-28 12:18:38 -05:00
Sebastian Bøe c23cc26c73 DeviceTree: Convert 'generated_dts_board.h' into a source file
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>
2019-01-25 03:02:33 -06:00
Sebastian Bøe fb3d201cae cmake: STACK_CANARIES: Re-write how compatibility is checked
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>
2019-01-23 09:44:09 +01:00
Anas Nashif b832a1e264 printk: move into lib/os
Last file under misc/. Put it alongside other support functions in
lib/os.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-01-22 07:45:22 -05:00
Anas Nashif 885aaf2734 cmake: fix assert message about misc/Kconfig
We have no Kconfig in misc/. Most options were moved to Kconfig.zephyr.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-01-22 07:45:22 -05:00
Sebastian Bøe 1b86fb9da3 cmake: Use variables for target names
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>
2019-01-19 07:21:55 -05:00