Commit graph

36 commits

Author SHA1 Message Date
Nikolay Agishev 2d75d7b2d3 ARCMWDT: Remove workaround with stripping DWARF info
Remove obsolete workaround with conditional turning off "-g"
flag when Thread Local Storage used.

Recent versions of MetaWare have no issue with linking files with
TSL-related data.

Moreover, pointed workaround breaks userspace for recently added
ARC-V platforms, as they use both TLS and DWARF info while compilation
process.

Fixes https://github.com/zephyrproject-rtos/zephyr/issues/29920

Signed-off-by: Nikolay Agishev <agishev@synopsys.com>
2024-06-21 10:10:24 +02:00
Nikolay Agishev efedf1cff3 ARCMWDT: Add compiler support for nSIM RMX platform
Add MetaWare compiller support for nSIM RMX platform

Signed-off-by: Nikolay Agishev <agishev@synopsys.com>
2024-06-14 19:01:06 -04:00
Pieter De Gendt cb459f12ba arcmwdt: Enable GNU C Extensions
Replace the global CSTD property with a Kconfig symbol selection.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2024-04-25 09:54:39 +00:00
Ryan McClelland 018dbcfd66 cmake: compiler: add double promotion warning
Too many times, code is pushed that includes floats that really
becomes doubles and C implicit promotion rules will want to make
floats into doubles very easily. As zephyr primarily targets
low-end process that may not have a double precision floating
point unit, enable this flag globally for now.

Signed-off-by: Ryan McClelland <ryanmcclelland@meta.com>
2024-01-26 21:37:24 -05:00
Marc Herbert 837698b935 cmake/compiler/: drop ERROR_QUIET when looking for compiler --version
Commit 40c2e08e82 ("xcc/cmake: don't discard stderr; don't (ever!) use
ERROR_QUIET") fixed xcc but the corresponding code is duplicated. Fix
the duplicates too.

See that commit for the issue description, longer commit message and
rationale.

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2023-12-04 16:38:08 +00:00
Grant Ramsay a3ff19a39e cmake: compiler: Add compiler property for no-builtin
Abstracts these flags for multiple toolchain support

Signed-off-by: Grant Ramsay <gramsay@enphaseenergy.com>
2023-11-13 10:21:41 +01:00
Daniel Leung e38fc6de8a cmake: enable -Wshadow partially for in-tree code
This enables -Wshadow to warn about shadow variables on
in tree code under arch/, boards/, drivers/, kernel/,
lib/, soc/, and subsys/.

Note that this does not enable it globally because
out-of-tree modules will probably take some time to fix
(or not at all depending on the project), and it would be
great to avoid introduction of any new shadow variables
in the meantime.

Also note that this tries to be done in a minimally
invasive way so it is easy to revert when we enable
-Wshadow globally. Source files under modules/, samples/
and tests/ are currently excluded because there does not
seem to be a trivial way to add -Wshadow there without
going through all CMakeLists.txt to add the option
(as there are 1000+ files to change).

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2023-08-22 11:39:58 +02:00
Evgeniy Paltsev b64cfe9832 ARC: MWDT: rework GNU helper tools usage
As of today MWDT toolchain in case of Zephyr may use few
tools from GNU toolchain - GNU compiler for DTS preprocessing
and objcopy for section renaming.

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

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

Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
Signed-off-by: Evgeniy Paltsev <PaltsevEvgeniy@gmail.com>
2023-06-17 07:44:31 -04:00
Keith Packard 70fdd9e4e1 compilers: Remove -Wno-main and -Wno-main-return-type compiler flags
These flags were added to avoid warnings when main was declared to return
void. Now that main returns int, those warnings will flag errors.

Signed-off-by: Keith Packard <keithp@keithp.com>
2023-04-14 07:49:41 +09:00
Nikolay Agishev 0dec4cf927 toolchain: Move extra warning options to toolchain abstraction
Move extra warning option from generic twister script into
compiler-dependent config files.
ARCMWDT compiler doesn't support extra warning options ex.
"-Wl,--fatal-warnings". To avoid build fails flag
"disable_warnings_as_errors" should be passed to twister.
This allows all warning messages and make atomatic test useles.

Signed-off-by: Nikolay Agishev <agishev@synopsys.com>
2023-02-19 20:34:13 -05:00
Flavio Ceolin ac5d45a080 build: userspace: No merge globals
Add a compiler option to not merge globals. gen_kobject_list.py
is not capable of distinguish addresses of merged objects. The script
itself does not look wrong. The dward specification says that the
attribute DW_AT_location with opcode DW_OP_addr encodes a machine
address and whose size is the size of an address on the target machine
but for merged objects the address is longer, not clear why.

Disable global merge when userspace is enabled to avoid this problem.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2023-01-26 14:56:10 -05:00
Evgeniy Paltsev ae79de1930 ARC: MWDT add TLS support
Add thread local storage support for ARC MWDT toolchain.

Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
Signed-off-by: Evgeniy Paltsev <PaltsevEvgeniy@gmail.com>
2022-11-29 09:48:23 +01:00
Evgeniy Paltsev 619c21ecfe ARC: MWDT: bump toolchain version
Bump minimal ARC MWDT version to 2022.09

Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
Signed-off-by: Evgeniy Paltsev <PaltsevEvgeniy@gmail.com>
2022-11-29 09:48:16 +01:00
Evgeniy Paltsev 94b87c6422 ARC: arcmwdt: fix & rework inclusion of C/C++ headers
Currently we try to manually specify C/C++ headers locations
with -isystem flag which lead to issues with "include_next"
directive which is used in C/C++ headers. As advised by MWDT
R&D team let's rely on the default C/C++ include locations
which are provided by MWDT if we do build with MW C / C++
libraries. For that case we still need to manually specify
header directory to ASM builds which bay use 'stdbool.h'

In case of building with minimal libc (provided by Zephyr)
we rely on minimal libc headers and manually specify
toolchain's C header directory (as minimal libc still uses some
toolchain's C headers.

Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
Signed-off-by: Evgeniy Paltsev <PaltsevEvgeniy@gmail.com>
2022-11-29 09:48:08 +01:00
Nikolay Agishev 9f33342602 compiler: arcmwdt: Remove unsupported compile flags (-fno-pic, -fno-pie)
Clang version used by ARCMWDT does not support -fno-pic and -fno-pie
flags.
Flags were added into arcmwdt branch by
commit 8259931fce ("xcc-clang: Do not used unavailable options").
Initially they were set in common CMakeLists.txt via
zephyr_cc_option() function, which filtered them out, and they
did not used in builing process.

Signed-off-by: Nikolay Agishev <agishev@synopsys.com>
2022-11-17 19:21:23 +09:00
Keith Packard 62bc9bf3e5 cmake: Allow selection of libc API overflow detection mode
This adds a choice of three different libc API buffer overflow detection
modes:

 * None
 * Compile-time
 * Compile-time and Run-time

These correspond with the clang/gcc _FORTIFY_SOURCE modes (0/1/2).
_FORTIFY_SOURCE depends on compiler optimizations and require libc support
which the minimal C library doesn't include, so _FORTIFY_SOURCE is disabled
by default in those cases. Native tooling might also enable
_FORTIFY_SOURCE, so don't enable it by default in that case either.

Signed-off-by: Keith Packard <keithp@keithp.com>
2022-10-31 23:23:27 +09:00
Nikolay Agishev 75bb8ce382 compiler: arcmwdt: Fix ccac version checking
Regexp suggested in #50173 PR is too strictly and
needs to be corrected. Previous regexp declines
engineering MWDT versions
(pattern ENG-2022.12-D1039-C39098348").

Signed-off-by: Nikolay Agishev <agishev@synopsys.com>
2022-10-28 22:06:49 +09:00
Nikolay Agishev df7beca2eb compiler: arcmwdt: Add ccac version checking
After recent changes Zephyr became incompatible with old
MWDT versions (older than 2022.06).
Version checking may help to avoid build errors
related this incompatibility.

Signed-off-by: Nikolay Agishev <agishev@synopsys.com>
2022-09-20 09:02:38 +00:00
Flavio Ceolin 8259931fce xcc-clang: Do not used unavailable options
xcc-clang in based on clan-10 and does not support -fno-pic and
-fno-pie.

clang-10: warning: argument unused during compilation: '-fno-pic'
[-Wunused-command-line-argument]
[147/148] Linking C executable zephyr/zephyr.elf
clang-10: warning: argument unused during compilation: '-no-pie'
[-Wunused-command-line-argument]

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2022-08-23 10:13:43 +02:00
Andy Ross 74cc534758 cmake: Update CONFIG_ASAN support
This had bitrotten a bit, and didn't build as shipped.  Current
libasan implementations want -fsanitize=address passed as a linker
argument too.  We have grown a "lld" linker variant that needs the
same cmake treatment as the "ld" binutils one, but never got it.  But
the various flags had been cut/pasted around to different places, with
slightly different forms.  That's really sort of a mess, as sanitizer
support was only ever support with host toolchains for native_posix
(and AFAICT no one anywhere has made this work on cross compilers in
an embedded environment).  And the separate "gcc" vs. "llvm" layers
were silly, as there has only ever been one API for this feature (from
LLVM, then picked up compatibly by gcc).

Pull this stuff out and just do it in one place in the posix arch for
simplicity.

Also recent sanitizers are trying to add instrumentation padding
around data that we use linker trickery to pack tightly
(c.f. SYS_INIT, STRUCT_SECTION_ITERABLE) and we need a way
("__noasan") to turn that off.  Actually for gcc, it was enough to
just make the records const (already true for most of them, except a
native_posix init struct), but clang apparently isn't smart enough.

Finally, add an ASAN_RECOVER kconfig that enables the use of
"halt_on_error=0" in $ASAN_OPTIONS, which continues execution past the
first error.

Signed-off-by: Andy Ross <andyross@google.com>
2022-08-19 08:30:01 +02:00
Stephanos Ioannidis 4d36e8f693 cmake: compiler: arcmwdt: Add no_strict_aliasing flag
This commit adds the `no_strict_aliasing` flag, which disables
the strict aliasing rule, for the ARC MetaWare compiler.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2022-08-11 17:45:58 +02:00
Stephanos Ioannidis e6629abcb0 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>
2022-04-29 08:57:21 +02:00
Nazar Kazakov f483b1bc4c everywhere: fix typos
Fix a lot of typos

Signed-off-by: Nazar Kazakov <nazar.kazakov.work@gmail.com>
2022-03-18 13:24:08 -04:00
Nazar Kazakov 9713f0d47c everywhere: fix typos
Fix a lot of typos

Signed-off-by: Nazar Kazakov <nazar.kazakov.work@gmail.com>
2022-03-14 20:22:24 -04:00
Jeremy Bettis 1fee4849bc cmake: Populate var CMAKE_GCOV
For each compiler, also set a CMAKE_GCOV var referencing the appropriate
gcov tool.

Tested with gcc and host-gcc on the ChromeOS codebase.

Signed-off-by: Jeremy Bettis <jbettis@chromium.org>
2021-09-02 19:44:00 -04:00
Evgeniy Paltsev d8590d7e2b ARC: MWDT: fix include path for the case of C/C++ lib usage
Fix include path of headers provided by MWDT toolchain for the
case of MWDT C/C++ lib usage.

Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
Signed-off-by: Evgeniy Paltsev <PaltsevEvgeniy@gmail.com>
2021-08-21 21:33:18 -04:00
Evgeniy Paltsev b82ffbd860 ARC: MWDT: add C++14, C++17 standards support
Add missing properties for C++14, C++17 standards support

Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
Signed-off-by: Evgeniy Paltsev <PaltsevEvgeniy@gmail.com>
2021-08-21 21:33:18 -04:00
Evgeniy Paltsev 33d5be8656 ARC: MWDT: generate access to builtin funcs only if ARCMWDT_LIBC is used
The MWDT compiler can replace some code with call to builtin
functions. We can't rely on these functions presence if we
don't use MWDT libc.

Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
Signed-off-by: Evgeniy Paltsev <PaltsevEvgeniy@gmail.com>
2021-08-13 13:43:19 -05:00
Alexander Wachter ad130f2661 cpp: Restore C++2A Kconfig
Restore the legacy C++2a Kconfig for compilers that
do not support C++20.

Signed-off-by: Alexander Wachter <alexander.wachter@leica-geosystems.com>
2021-07-14 07:19:43 -04:00
Lauren Murphy e6b8c50599 samples: tensorflow: add no-threadsafe-statics to compiler flags
Adds no-threadsafe-statics to compiler flags for gcc and arcmwdt.

The flag is required to compile the samples - the module can compile
without it.

Signed-off-by: Lauren Murphy <lauren.murphy@intel.com>
2021-05-20 20:59:45 -04:00
Watson Zeng 2354f055ec toolchain: arcmwdt: add compile options: -Wno-typedef-redefinition
Without the -Wno-typedef-redefinition option, arcmwdt (clang based)
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. As this warning is not fatal, so simply shut it off for good.

Signed-off-by: Watson Zeng <zhiwei@synopsys.com>
2020-10-19 14:06:07 -05:00
Eugeniy Paltsev 9b0ef4f19a ARC: MWDT: drop redundant stack checking
MWDT toolchain has Stackcheck_alloca option enabled by default.
So it adds stack checking in addition to Zephyr's stack checking.

As it is completely redundant let's drop it.

Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
2020-10-02 11:32:12 +02:00
Torsten Rasmussen 27e1fd69f9 cmake: c++ compiler flag exclusion, -Werror=implicit-int
Fixes: #28097

The compiler warning flag `-Werror=implicit-int` was added using
`set_compiler_property()` which will always add the compiler flag if the
compiler flag supports it.

This has been changed to `check_set_compiler_property()` which will
check if the flag is among the list of `CXX_EXCLUDED_OPTIONS`, and only
adds the flag if both the compiler supports it, and it is not an
excluded option.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2020-09-07 17:22:37 +02:00
Torsten Rasmussen 93e063ffc8 cmake: mwdt compiler adopted to new toolchain abstraction
This commit converts the MWDT compiler implementation from the old
macro based approach and into the new toolchain property scheme.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2020-09-05 10:22:56 -05:00
Eugeniy Paltsev 6dfaac0c95 cmake: allow to specify compliler for DTS preprocessing
MWDT CCAC compiler can't handle the dts file as gcc does, so
allow to specify compliler for DTS preprocessing which is differ
from ${CMAKE_C_COMPILER}.

Use ARC GNU compiler for DTS preprocessing in case of MWDT
toolchain.

Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
2020-09-05 10:22:56 -05:00
Wayne Ren b868018b51 cmake: add metaware toolchain support in build system
* add metaware toolchain support in build system:
   * compiler
   * linker
   * binutils
     * gcc objcopy is used because it can't be replaced
       with mwdt's binutils currently
* To use ARC metaware toolchain, you'd better:
   * in Linux/Unix environment
   * install arc gcc/zephyr toolchain to use gnu's objcopy
     tool
   * set ZEPHYR_TOOLCHAIN_VARIANT=arcmwdt

Signed-off-by: Wayne Ren <wei.ren@synopsys.com>
Signed-off-by: Watson Zeng <zhiwei@synopsys.com>
Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
2020-09-05 10:22:56 -05:00