We do not need libgcc always, some environments do not have libgcc and
do not require it, so keep it more flexible.
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Without the -Wno-typedef-redefinition option, clang complains if a
typedef gets redefined in gnu99 mode (since this is officially a C11
feature).
While new versions of GCC do not seem to issue this warning in gnu99
mode anymore. So some existing code with typedef redefined which works
well with GCC will issue this warning.
Similar to what was done in 2354f055ec.
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Generate errors for implicit conversions that may alter a value, that
covers conversions implicit conversions to narrower types, different
signal, different essential types (float -> int), ... From GCC
documentation
(https://gcc.gnu.org/onlinedocs/gcc-9.3.0/gcc/Warning-Options.html)
"""
Warn for implicit conversions that may alter a value. This includes
conversions between real and integer, like abs (x) when x is double;
conversions between signed and unsigned, like unsigned ui = -1; and
conversions to smaller types, like sqrtf (M_PI). Do not warn for
explicit casts like abs ((int) x) and ui = (unsigned) -1, or if the
value is not changed by the conversion like in abs (2.0). Warnings
about conversions between signed and unsigned integers can be disabled
by using -Wno-sign-conversion.
For C++, also warn for confusing overload resolution for user-defined
conversions; and conversions that never use a type conversion
operator: conversions to void, the same type, a base class or a
reference to them. Warnings about conversions between signed and
unsigned integers are disabled by default in C++ unless
-Wsign-conversion is explicitly enabled.
"""
This partially cover rules: 10.4, 10.5, 10.6, 10.7 and 10.8
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
Add implicit-fallthrough flag when CONFIG_MISRA_SANE is set.
It will require __fallthrough macro or a proper comment tells the
compiler that this happens intentionally.
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
Add a Kconfig option to enable compiler flags that help to enforce
some code guideline rules.
Note: As the current code base is not in compliance with the adopted
code guideline, some rules will generate warnings during the
build. This is intended to help to spot violations.
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
-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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
clang doesn't understand fortify at all, provide no op macro,
in order to handle the request to fortify in a generic way.
Signed-off-by: Oleg Zhurakivskyy <oleg.zhurakivskyy@intel.com>
In case TOOLCHAIN_HOME isn't explicitly reuqested,
(or indirectly forced with CLANG_ROOT_DIR), detect
any host installed clang in the path.
Signed-off-by: Oleg Zhurakivskyy <oleg.zhurakivskyy@intel.com>
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>
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>
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>
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>
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>
Add missing -lgcc when compiling with ZEPHYR_TOOLCHAIN_VARIANT=host
merely copying some existing code from
'compiler/{clang,gcc}/target.cmake'.
This fixes compilation for the following boards with an x86
microprocessor:
galileo, minnowboard, qemu_x86, qemu_x86_nommu, up_squared,
up_squared_sbl
Compilation of the following boards with an X86_IAMCU microcontroller
still fail with a "cannot find -lgcc" error:
arduino_101, qemu_x86_iamcu, quark_d2000_crb, quark_se_c1000_devboard,
tinytile
This is _not_ a regression because these boards _already_ failed with
"undefined reference to __udivdi3" and other libgcc symbols.
Signed-off-by: Marc Herbert <marc.herbert@intel.com>
Split up the toolchain configuration into two phases, generic and
target. The 'generic' phase configures the toolchain just enough to be
able to preprocess DT files. The 'target' phase completes the
configuration with target-specific configuration.
Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>