Commit graph

30 commits

Author SHA1 Message Date
Jonathon Penix 97a734aa01 cmake: llvm: arm64: Set arm64 flags when building with clang
Ensure --target and -mcpu/-mfpu/-mtune are set appropriately when building
with clang targeting arm64/aarch64.

Signed-off-by: Jonathon Penix <jpenix@quicinc.com>
2024-06-13 17:58:04 +02:00
Jonathon Penix fb98adc323 kconfig: llvm: arm64: Advertise TLS support when using llvm for arm64
clang and lld both support TLS for arm64/aarch64, so advertise this
support in Kconfig.

Signed-off-by: Jonathon Penix <jpenix@quicinc.com>
2024-06-13 17:58:04 +02:00
Jonathon Penix 99adbadad5 toolchain: llvm: Allow TLS when using llvm targeting arm
TLS for Arm targets seems to be well supported in clang/lld, so mark it as
supported by the toolchain.

Signed-off-by: Jonathon Penix <jpenix@quicinc.com>
2024-05-14 09:43:37 +02:00
Jonathon Penix 7d5ccc083c cmake: llvm: arm: Remove '--specs' when building with clang for arm
Currently, clang produces a warning that the '--specs=nosys.specs' argument
is unused. Remove this flag to fix the warning as clang will generally not
honor '--specs' when targeting arm baremetal.

While this flag has been present for some time, I think this should be safe
to do. For background, clang does not seem to handle '--specs' [1] besides
possibly passing it through to GCC if GCC is used as the driver for
linking. However, whether GCC will be used for linking as a fallback
depends on the "Toolchain" [1] clang uses internally, which in turn depends
on the triple. For arm/thumb baremetal triples, the Toolchain clang uses
will not fall back to GCC to drive linking, so '--specs' will never be used
here.

I believe this behavior in clang is fairly longstanding as well (since
~2017/LLVM 5 [2]). While there isn't a minimum required clang version for
Zephyr, Zephyr currently requires lld >= 14.0.0. So, I don't think removing
this flag should impact current users (besides preventing the warning).

[1] https://clang.llvm.org/docs/DriverInternals.html
[2] https://reviews.llvm.org/D33259

Signed-off-by: Jonathon Penix <jpenix@quicinc.com>
2024-05-07 09:33:16 +02:00
Pieter De Gendt a599ed13a1 kconfig: Add symbols for GNU C Extensions
Add a symbol to enable GNU C Extensions. And a hidden option for
toolchains to signal GNU Extensions support.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2024-04-25 09:54:39 +00:00
Jonathon Penix 82a47cc06d kconfig: llvm: riscv: Advertise TLS support when using llvm for RISC-V
clang and lld support TLS for RISC-V, so advertise this support in
Kconfig. I believe other non-RISC-V targets also have TLS support in LLVM,
but I'm not sure on the exact subset. As TLS support in LLVM wasn't
automatically advertised previously, gate this on RISC-V for now as it
a) shouldn't break other targets and b) prevents us from improperly
claiming support for unsupported targets.

Signed-off-by: Jonathon Penix <jpenix@quicinc.com>
2024-03-18 13:16:06 +01:00
Jonathon Penix ba871733e0 cmake: llvm: riscv: Set RISC-V flags when building with clang
Ensure --target and -march/-mabi/-mcmodel are set appropriately when
building with clang targeting RISC-V.

Signed-off-by: Jonathon Penix <jpenix@quicinc.com>
2024-03-18 13:16:06 +01:00
Fabio Baltieri fd9a464495 toolchain: llvm: use the "none" vendor triplet
This was submitted with "cros" in 77dde5dc9f, it was meant to be "none".

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-11-15 13:05:01 +01:00
Marc Herbert 0fead68e2b Revert "llvm: use proper syntax for --config option"
This reverts commit 577d47f3f1.

The --config= syntax with the equal sign does not work with clang 15
which is less than one year old (https://releases.llvm.org/). It does
not work with clang 14 either.

```
clang --verbose
clang version 15.0.7

clang --help | grep config

  -cl-std=<value>         OpenCL language standard to compile for.
  --config   <value>      Specifies configuration file
  --cuda-feature=<value>  Manually specify the CUDA feature to use

clang: error: unsupported option '--config=/home/runner/work/...
```

The reverted commit mentioned "issues in some situations" without
providing any example or other information.
This revert fixes the SOF fuzzer build, see more details in #61778.

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2023-08-31 10:24:29 +02:00
Benjamin Cabé 577d47f3f1 llvm: use proper syntax for --config option
Use proper --config= syntax instead of --config as the latter can cause
issues in some situations.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2023-08-23 16:07:54 +01:00
Patryk Duda 4b94fc3da2 llvm: Add support for selecting runtime library
This patch adds Kconfig options to select either GNU libgcc or LLVM
compiler-rt. The 'rtlib' flag is provided in a config file, so this
patch introduces 'clang_libgcc.cfg' and 'clang_compiler_rt.cfg' which
enable appropriate library. The file is selected by concatenating
the 'clang_' prefix with library name.

Signed-off-by: Patryk Duda <pdk@semihalf.com>
2023-08-03 19:35:11 +02:00
Patryk Duda 77dde5dc9f llvm: Add ARMv6-M, ARMv7-M, ARMv8-M Mainline and Baseline targets
Introduce more specific ARM targets basing on enabled options in
Kconfig.

Signed-off-by: Patryk Duda <pdk@semihalf.com>
2023-08-01 11:08:36 +02:00
Daniel Leung fb350bca10 toolchain: llvm: defer setting target triple to target.cmake
Since kconfigs are not available when generic.cmake is parsed.
Setting the target triple for x86 needs to be deferred to
target.cmake as it needs to know whether CONFIG_64BIT is
enabled. This also moves the ARM triple to target.cmake as
triple is needed for target tools.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2023-03-29 19:48:47 -04:00
Daniel Leung a5cc22b2a9 toolchain: defer setting variable LINKER till target tools
The variable LINKER is dependent on CONFIG_LLVM_USE_LLD
or CONFIG_LLVM_USE_LD, and these kconfigs are not
available when toolchain/llvm/generic.cmake is parsed.
So setting LINKER needs to be deferred to target.cmake
where kconfigs are available.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2023-03-29 19:48:47 -04:00
Daniel Leung 4d914f4f89 toolchain: move CONFIG_LLVM_USE_LD into cmake/toolchain/llvm
This moves CONFIG_LLVM_USE_LD into cmake/toolchain/llvm as this
is a toolchain kconfig. Also make it a choice to allow the use
of LLVM's lld as linker.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2023-03-29 19:48:47 -04:00
Daniel Leung 7864caba1b linker: llvm: provide a default config file for clang
Some distros may provide config files for clang to change its
default behavior. We need to override that, or else developers
may be using different defaults and we will have confusing
bug reports in the future.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2023-03-29 19:48:47 -04:00
Torsten Rasmussen 56c827ac2c cmake: use zephyr_get in toolchains to ensure identical behavior.
Fixes: #40389

Update toolchain handling to use zephyr_get() to ensure consistent
handling of CMake cache variables, environment variable, and CMake
local variables.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2022-09-02 15:16:50 +02:00
Chen Peng1 d8fa857b19 LLVM: add built-in lld linker support for x86.
add support to use LLVM built-in lld linker to build
zephyr applications for x86 platforms.

Signed-off-by: Chen Peng1 <peng1.chen@intel.com>
2022-06-05 14:10:25 +02:00
Anas Nashif 29d35ced53 cmake: llvm: llvm has no newlib
llvm does not have newlib integrated for all architectures.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2021-04-22 07:42:58 -04:00
Anas Nashif 1d949ee20f cmake: llvm: use lld
Use lld linker instead of ld.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2021-03-25 08:54:10 -04:00
Anas Nashif 03de10091a clang: use LLVM_TOOLCHAIN_PATH instead of CLANG_ROOT_DIR
Be consistent with other toolchains.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-11-02 14:30:37 -05:00
Anas Nashif 7fe8198102 llvm: add support for building x86_64-pc
set triplet for 64bit x86.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-11-02 14:30:37 -05:00
Anas Nashif 39bd354389 clang: remove cache handling
This is taking too long for every run and does not seem to work as
expected and wastes time instead of saving it. Remove for now..

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-11-02 14:30:37 -05:00
Martí Bolívar c5f8e9a84b cmake: toolchain: print what we find
Print the name of the discovered toolchain as well as the variable
used to initialize it.

This is nice to know when doing remote support, since users will
sometimes misconfigure their toolchain and not know what that means.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-03-10 14:53:28 +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
Oleg Zhurakivskyy cbe74d46e0 cmake: llvm: Invalidate toolchain capability cache
Invalidate toolchain capability cache on toolchain configuration.

Signed-off-by: Oleg Zhurakivskyy <oleg.zhurakivskyy@intel.com>
2019-04-30 09:33:54 -04:00
Oleg Zhurakivskyy 129ae378c0 cmake: llvm: Make the setup for host installed clang easier
The logic is practically intact and is the following:

1. Use any host installed llvm/clang in the path in case
   ZEPHYR_TOOLCHAIN_VARIANT=llvm is requested alone.
2. This can be further restricted with TOOLCHAIN_HOME.
3. And can be further overridden with CLANG_ROOT_DIR,
   like previously.

So, only the unconditional restriction to /usr is lifted.

Together with fixing the unconditional set of TOOLCHAIN_HOME
by host tools for non-toolchain needs, this makes the logic
more flexible.

Now, after the logic is controllable by TOOLCHAIN_HOME, 3)
might be an extra, but is left intact for backward compatibility.

Signed-off-by: Oleg Zhurakivskyy <oleg.zhurakivskyy@intel.com>
2019-04-30 09:33:54 -04:00
Mark Ruvald Pedersen 0cad53b5ce cmake: Toolchain abstraction: introduce LINKER variable
The LINKER variable is introduced to follow the same logic and flow as
the existing COMPILER variable: That is, each TOOLCHAIN is responsible
for choosing COMPILER and LINKER.

Currently, Zephyr's build system is hardcoded for GNU ld.
Reflect this in LINKER by letting all existing toolchains use GNU ld.

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
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
Sebastian Bøe a0a63ac344 cmake: Split toolchain configuration into pre-and post-DT
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>
2018-12-14 13:16:28 +01:00