Commit graph

91 commits

Author SHA1 Message Date
Stephanos Ioannidis fb35591f1e cmake: Correct PATHS usage
`PATH` is not a valid option for `find_program`; correct all such
usages to `PATHS`.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2020-05-20 12:10:20 +02:00
Torsten Rasmussen 32f351a7a2 cmake: raise a fatal error when C compiler is not found
This commit introduces an early error in case a valid C compiler is not
found in the system.

This will help to early identify misconfigured systems with the error:
  C compiler <compiler> not found - Please check your toolchain
  installation

instead of an obscure error, such as:
No such file or directory: LIBGCC_FILE_NAME: ''

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2020-05-19 14:45:36 +02:00
Stephanos Ioannidis 0e6ede8929 kconfig: Rename CONFIG_FLOAT to CONFIG_FPU
This commit renames the Kconfig `FLOAT` symbol to `FPU`, since this
symbol only indicates that the hardware Floating Point Unit (FPU) is
used and does not imply and/or indicate the general availability of
toolchain-level floating point support (i.e. this symbol is not
selected when building for an FPU-less platform that supports floating
point operations through the toolchain-provided software floating point
library).

Moreover, given that the symbol that indicates the availability of FPU
is named `CPU_HAS_FPU`, it only makes sense to use "FPU" in the name of
the symbol that enables the FPU.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2020-04-27 19:03:44 +02:00
Corey Wharton c8f7cd5462 kconfig: Make the CPU_HAS_FPU_DOUBLE_PRECISION option global.
This option now applies to the RISC-V architecture and is no longer
a ARM only configuration.

Signed-off-by: Corey Wharton <coreyw7@fb.com>
2020-04-22 16:39:48 -07:00
Corey Wharton 22c52846a5 riscv: Set mabi and march flags for floating point
Adds handling of the FLOAT_64BIT option when determining the ISA
flags as well as introduces a new Kconfig option to enable/disable
the hard-float calling convention.

Signed-off-by: Corey Wharton <coreyw7@fb.com>
2020-04-22 16:39:48 -07:00
Stephanos Ioannidis 1d9b08aef5 arch: arm: Remove -march compiler flag
The ARM GCC `-march` compiler flag is completely redundant when the
`-mcpu` flag is specified, since the `-mcpu` selects the target ARM
architecture as well as CPU-specific optimisations.

In fact, it is disadvantageous to specify both `-march` and `-mcpu`
flags because the `-march` flag overrides and disables any CPU-specific
optimisations enabled by the `-mcpu` flag.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2020-04-22 09:43:24 +02:00
Stephanos Ioannidis df4fdeed97 arch: arm: aarch64: Force LP64 ABI
This commit adds the GCC `-mabi=lp64` flag to force the LP64 (64-bit
long and pointer) ABI, which is mandatory for running the Zephyr
AArch64 architecture port.

Note that this flag is, strictly speaking, not necessary in most cases
because the AArch64 GCC defaults to using the LP64 ABI. This flag is
required, however, if compiling Zephyr with a GCC that is configured
with `--with-abi=ilp32`, which makes ILP32 the default ABI.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2020-04-21 18:26:52 +02:00
Stephanos Ioannidis a1e838872c arch: arm: Remove extraneous root cmake files
The ARM architecture root directory contains `aarch32.cmake` and
`aarch64.cmake` files whose contents are better suited to go into other
more purpose-specific files.

This commit removes the aforementioned files and moves their contents
to other files following the convention used by other architectures.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2020-04-15 11:23:56 +02:00
Jaron Kelleher bd4f721a59 RISCV compiler: Set mabi and march via Kconfig options
The mabi and march options of the compiler and linker commands
were previously hardcoded and depended only on the 64BIT config
option. This update allows these flags to be set by the config
options currently available, plus an additional option to
specify the compressed ISA.

Signed-off-by: Jaron Kelleher <jkelleher@fb.com>
2020-04-06 21:54:07 -04:00
Daniel Leung f72e4fc723 cmake: gcc: no need to force add system include
There is no need to force add system include by adding
${SYSROOT_DIR}/include. Let GCC tell us what include paths
are needed with --print-file-name and feed them via -isystem.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2020-03-27 09:06:03 -04:00
Stephanos Ioannidis 0bd86f3604 arch: arm: aarch32: Allow selecting compiler instruction set
This commit introduces the `COMPILER_ISA_THUMB2` symbol to allow
choosing either the ARM or Thumb instruction set for C code
compilation.

In addition, this commit introduces the `ASSEMBLER_ISA_THUMB2` helper
symbol to specify the default target instruction set for the assembler.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2020-03-10 17:51:32 +01:00
Stephanos Ioannidis e89881f532 cmake: compiler: arm: Whitespace-align flags
This commit whitespace-aligns the toolchain flags.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2020-03-10 17:51:32 +01:00
Carlo Caione 87d8a035dd arch: arm64: Support aarch64-gcc compiler
To be able to successfully compile the kernel for the ARM64 architecture
we have to tweak the compiler-related files to be able to use the
AArch64 GCC compiler.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2020-02-01 08:08:43 -05:00
Sebastian Bøe d385d86f74 cmake: toolchain: Fix 'host' toolchain variant
Fix an issue with 'ZEPHYR_TOOLCHAIN_VARIANT=host' where CMAKE_C_FLAGS
was incorrectly assumed to be set.

This fixes #21614

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2020-01-07 13:25:47 -05:00
Daniel Leung e73231f7f0 toolchain: xcc: use Clang if exists
The XCC toolchain may come with Clang front-end depending on
how it's built. Currently, the only SoC/board using XCC is
the intel_s1000_crb and its XCC toolchain comes with Clang
3.9.0 which has a lot better support for C99 and C++11 than
the portion based on GCC 4.2 (which does not even support
C++11). So this change attempts to use the Clang portion
instead of GCC if the Clang executable exists.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2020-01-07 17:09:38 +01:00
Peter A. Bigot 60ca2333dc cmake: toolchain: generalize exclusion of CXX options
-Wold-style-definition is not a supported option for C++ builds.  To
prevent it being passed:
* the list of compiler flags to be excluded from C++ builds is moved
  to be toolchain-specific;
* -Wold-style-definition is added to that list for gcc and clang;
* -Wold-style-definition is moved from zephyr_compiler_options to
  zephyr_cc_option so the option checking code is executed for it.

Signed-off-by: Peter A. Bigot <pab@pabigot.com>
2019-12-18 21:45:00 +01:00
Stephanos Ioannidis cff94bf7a0 cmake: Add GCC -Og flag fallback to -O0.
The -Og (optimise for debugging) flag is only available for GCC 4.8.0
and above, and specifying it for a GCC version lower than 4.8.0 will
result in a compilation error.

This commit adds a check for compiler -Og optimisation flag support and
a fallback to -O0 (disable optimisation) when -Og flag is unsupported.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2019-12-09 16:17:12 +01:00
Daniel Leung 7308fdc3c7 cmake: add --divide to GNU assembler options for x86
GNU Assembler, by default on non-Linux targets, treats slashes as
start of comments on i386.
(https://sourceware.org/binutils/docs-2.33.1/as/i386_002dChars.html#i386_002dChars)
In order to use division, `--divide` needs to be passed to
the assembler.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2019-10-31 09:09:22 +01:00
Daniel Leung 7aca9af7ed cmake: need to specify m32/m64 for x86_64 toolchain
Since x86_64-zephyr-elf is a multi-lib toolchain, m32/m64
need to be specified for the compiler to return the correct
library path when queried (e.g. --print-libgcc-file-name).
This affects the compile check done by CMake. Without these
flags, the compiler returns incorrect toolchain path (e.g.
requiring 64-bit libraries but returning 32-bit library path).
This also affects compiler flag checks for "-lstdc++". Incorrect
library path results in error when checking for "-lstdc++", and
this flag will not be used for the build. This results in
undefined references when compiling C++ code.

This creates target_x86.cmake to add the necessary flags for
CMake to use. The target_x86_64.cmake is also created to
mirror the same change.

Also removing the -m32 flags for host-gcc since we are not
building x86 targets with the host-gcc compiler.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2019-10-29 06:19:33 +01:00
Jan Van Winkel 23a866b828 cmake: toolchain abstraction for undefined behaviour sanitizer
Added toolchain abstraction for undefined behaviour sanitizer

Signed-off-by: Jan Van Winkel <jan.van_winkel@dxplore.eu>
2019-10-07 15:00:20 +02:00
Jan Van Winkel 89e97d13ec cmake: toolchain abstraction for address sanitizer
Added toolchain abstraction for address sanitizer

Signed-off-by: Jan Van Winkel <jan.van_winkel@dxplore.eu>
2019-10-04 13:39:52 -04:00
Sebastian Bøe c05a931bce cmake: Explicitly set the entry point when testing toolchain flags
We are observing warnings when test-compiling toolchain flags that
look like:

cannot find entry symbol _start; defaulting to 00000000000010d4

To fix this warning we explicitly set an entry point to an arbitrary
address. The files are only compiled, not run, so the entry point does
not need to be correct.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2019-09-19 09:29:57 -05:00
Kumar Gala 25066e7875 compiler: clang: Add setting of ARM related flags
Mimic what we have in cmake/compiler/gcc/target.cmake for clang
targetting ARM.  Match gcc behavior by setting -fshort-enums

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-09-19 08:55:01 -05:00
Kumar Gala e5c03925e5 cmake: compiler: introduce target_arm.cmake
Pull ARM flags into cmake/compiler/gcc/target.cmake to be reused between
gcc and clang.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-09-19 08:55:01 -05:00
Kumar Gala 8fb15826ff cmake: compiler: arm: Fold fpu-for-gcc-m-cpu.cmake into target.cmake
We only use fpu-for-gcc-m-cpu.cmake once, so just fold it into where it
used.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-09-19 08:55:01 -05:00
Jan Van Winkel f3eec6cba3 cmake: toolchain abstraction for coverage
Added toolchain abstraction for coverage for both gcc and clang.

Signed-off-by: Jan Van Winkel <jan.van_winkel@dxplore.eu>
2019-09-17 11:25:29 +02:00
Charles E. Youse 6767563f94 arch/x86: remove support for IAMCU ABI
This ABI is no longer required by any targets and is deprecated.

Signed-off-by: Charles E. Youse <charles.youse@intel.com>
2019-09-07 10:07:42 -04:00
Nicolas Pitre c351492bc7 riscv: toolchain arguments for a 64-bit build
For now we enforce the medany code model for 64-bit builds as we get
reloc issues otherwise. The instruction set and ABI are also set to
soft-float usage.

The ilp32 ABI is explicitly specified on 32-bit build to make sure
it is not using a wrong default if the same toolchain is used for both
32- and 64-bit builds. The archittecture options are the same as the
SDK's riscv32 toolchain default in that case.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2019-08-09 09:11:45 -05:00
Yasushi SHOJI 209a9104be cmake: compiler: gcc: Explicitly spell out stddef.h and limits.h
Depending on how compiler is built, it prints a different include
directory with `--print-file-name=include`.  What we want, instead, is
directories with `stddef.h` and `include-fixed/limits.h`.

This commit explicitly specify the header files we want to use, then
take the directory from the returned path.

Signed-off-by: Yasushi SHOJI <y-shoji@ispace-inc.com>
2019-08-02 14:58:02 +02:00
Danny Oerndrup aed9ea79b5 cmake: Toolchain abstraction: Abstraction of binary tools, foundation.
This forms the foundation for the abstraction of the binary tools,
where the following steps are taken:
- Move binary tool resolving, such as objcopy, objdump, readelf and
so forth, out of compiler definitions and place in a dedicated binary
tools folder with the binary tools supplier as subfolder, similar to
the compiler and linker directories.
- Create binary tool sets, gnu, host-gnu and llvm.
- Each toolchain selects the required set of binary tools by setting
BINTOOLS via its generic.cmake as it also does for compiler and linker.

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
Nicolas Pitre 1f783d9256 arch/posix: 64-bit build flags
We need to pass -m64 instead of -m32 when CONFIG_64BIT is set.
This is pretty x86 centric. Many platforms don't have the ability
to select between 32-bits or 64-bits builds and either of those should
be dropped in that case with restriction on the available configuration
done elsewhere. But for the time being this allows for testing both.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2019-07-16 10:41:11 -07:00
Nicolas Pitre e53c0d0ec7 cmake: toolchain_cc_imacros: don't use the long argument form
Commit f57ba2d30c ("cmake: toolchain_cc_imacros: don't use space
separated arguments") moved toolchain_cc_imacros() to using the long
argument format in order to avoid spaces that CMake uses to delimitate
and deduplicate arguments.

It seems that xcc doesn't support the --imacros=foo form. However
it does support the short "combined" -imacrosfoo form (without space).
So let's use that instead and document the caviat.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2019-07-03 06:09:16 -04:00
Nicolas Pitre f57ba2d30c cmake: toolchain_cc_imacros: don't use space separated arguments
Because CMake explicitly deduplicates arguments, it is not possible
to use toolchain_cc_imacros() multiple times as the later "-imacros"
are stripped away, leaving the associated file arguments dangling.
The documented workaround in the CMake manual involves some "SHELL:..."
construct but that doesn't get through zephyr_compile_options()
undammaged.

Let's simply remove this issue altogether by replacing "-imacros x.h"
with the joined form "--imacros=x.h" instead. Both gcc and clang
support this syntax.

FYI, this joined form is also available for other arguments such as:

	-include x.h   -->   --include=x.h
	-A foo         -->   --assert=foo
	-D foo         -->   --define-macro=foo
	-U foo         -->   --undefine-macro=foo

Etc.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2019-06-25 23:29:22 -04: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
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
Anas Nashif deb7ff524a cmake: no-address-of-packed-member is not supported in older compilers
Add a version check to allow building with older GCC versions that did
not support this option.

Fixes #16607

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-06-04 13:08:05 -04:00
Anas Nashif e82a9e9a55 compiler: no warnings on address-of-packed-member
With gcc 9.1.x on fedora 30 we are getting new warnings that turn into
errors when running sanitycheck. Disable those while the issues are
being addressed.

Relates to #16587

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-06-03 21:09:07 -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 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
Benjamin Valentin c2419fc006 cmake: gdb: use gdb-multiarch if ${CROSS_COMPILE}gdb is not availiable
Modern versions of GDB support multiple architectures
with the same binary.
In fact, Ubuntu stopped shipping a gdb-arm-none-eabi
package, gdb-multiarch should be used instead.

This fixes a failure on those systems where otherwise CMAKE_GDB will be
assigned to CMAKE_GDB-NOTFOUND.

Signed-off-by: Benjamin Valentin <benjamin.valentin@ml-pa.com>
2019-05-01 10:40:59 -04:00
Oleg Zhurakivskyy bee7d1ec8b compiler: clang: Don't link libgcc for native_posix
libgcc isn't used by native_posix.

Signed-off-by: Oleg Zhurakivskyy <oleg.zhurakivskyy@intel.com>
2019-04-30 09:33:54 -04:00
Oleg Zhurakivskyy f616aa3736 posix: cmake: Abstract freestanding options
clang has problems compiling the native_posix with -fno-freestanding.

Signed-off-by: Oleg Zhurakivskyy <oleg.zhurakivskyy@intel.com>
2019-04-30 09:33:54 -04:00
Oleg Zhurakivskyy ab2f00e9f1 cmake: clang: Fix comment
Fix comment, llvm -> clang.

Signed-off-by: Oleg Zhurakivskyy <oleg.zhurakivskyy@intel.com>
2019-04-30 09:33:54 -04:00
Oleg Zhurakivskyy f2c4779b84 cmake: clang: Provide toolchain_cc_nostdinc() macro
native_posix should build with standard includes.

Signed-off-by: Oleg Zhurakivskyy <oleg.zhurakivskyy@intel.com>
2019-04-30 09:33:54 -04:00