cmake: Add xcc-clang toolchain

Instead of setting XCC_USE_CLANG=1, this patch adds xcc-clang toolchain
that is basically xcc using the clang compiler.

Initially, the new toolchain simply includes files from current xcc
toolchain and (re)sets some variables. This should be a more scalable
approach to diverge the toolchains in the future than placing
"if($ENV{XCC_USE_CLANG})" at several places.

It should also help to filter tests that run (or not) exclusively with
the clang variant of XCC on twister.

The XCC_USE_CLANG flag is documented as deprecated, and a message is
emitted during build if still in use. Its new behaviour is to instruct
Zephyr to use `xcc-clang` toolchain.

Signed-off-by: Ederson de Souza <ederson.desouza@intel.com>
This commit is contained in:
Ederson de Souza 2022-02-17 15:32:27 -08:00 committed by Anas Nashif
commit 41d05fccd6
10 changed files with 94 additions and 76 deletions

View file

@ -37,6 +37,13 @@ if("${ARCH}" STREQUAL "posix")
return()
endif()
# Keep XCC_USE_CLANG behaviour for a while.
if ("${ZEPHYR_TOOLCHAIN_VARIANT}" STREQUAL "xcc"
AND "$ENV{XCC_USE_CLANG}" STREQUAL "1")
set(ZEPHYR_TOOLCHAIN_VARIANT xcc-clang)
message(STATUS "XCC_USE_CLANG is deprecated. Please set ZEPHYR_TOOLCHAIN_VARIANT to 'xcc-clang'")
endif()
if(NOT ZEPHYR_TOOLCHAIN_VARIANT AND
(CROSS_COMPILE OR (DEFINED ENV{CROSS_COMPILE})))
set(ZEPHYR_TOOLCHAIN_VARIANT cross-compile)